fix(analytics.gblib): Fixes in database storage.

This commit is contained in:
Rodrigo Rodriguez 2020-01-27 16:19:09 -03:00
parent 5d6dacc910
commit 22f4250831
12 changed files with 177 additions and 128 deletions

11
.vscode/tasks.json vendored
View file

@ -14,6 +14,17 @@
"kind": "build", "kind": "build",
"isDefault": true "isDefault": true
} }
},
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": {
"kind": "build",
"isDefault": true
}
} }
] ]
} }

View file

@ -6,15 +6,9 @@ const { exec } = require('child_process');
// Displays version of Node JS being used at runtime and others attributes. // Displays version of Node JS being used at runtime and others attributes.
console.log(`[GB Runtime] version = ${process.version}`); console.log(`[GB Runtime] NodeJS = ${process.version}`);
console.log(`[GB Runtime] env = ${process.env}`);
console.log(`[GB Runtime] platform = ${process.platform}`); console.log(`[GB Runtime] platform = ${process.platform}`);
console.log(`[GB Runtime] release = ${process.release}`);
console.log(`[GB Runtime] argv = ${process.argv}`); console.log(`[GB Runtime] argv = ${process.argv}`);
console.log(`[GB Runtime] env.USER = ${process.env.USER}`);
console.log(`[GB Runtime] env.PATH = ${process.env.PATH.split(':').join('\n')}`);
console.log(`[GB Runtime] env.PWD = ${process.env.PWD}`);
console.log(`[GB Runtime] env.HOME = ${process.env.HOME}`);
console.log(`[GB Runtime] debugPort = ${process.debugPort}`); console.log(`[GB Runtime] debugPort = ${process.debugPort}`);
var now = () => { var now = () => {

View file

@ -38,6 +38,7 @@
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib'; import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
import { Sequelize } from 'sequelize-typescript'; import { Sequelize } from 'sequelize-typescript';
import { GuaribasConversation, GuaribasConversationMessage } from './models';
/** /**
* .gblib Package handler. * .gblib Package handler.
@ -49,6 +50,8 @@ export class GBAnalyticsPackage implements IGBPackage {
} }
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void { public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
GBLog.verbose(`loadPackage called.`); GBLog.verbose(`loadPackage called.`);
core.sequelize.addModels([GuaribasConversation, GuaribasConversationMessage]);
} }
public unloadPackage(core: IGBCoreService): void { public unloadPackage(core: IGBCoreService): void {
GBLog.verbose(`unloadPackage called.`); GBLog.verbose(`unloadPackage called.`);

View file

@ -58,6 +58,50 @@ import { GuaribasChannel, GuaribasInstance } from '../../core.gbapp/models/GBMod
import { GuaribasSubject } from '../../kb.gbapp/models'; import { GuaribasSubject } from '../../kb.gbapp/models';
import { GuaribasUser } from '../../security.gblib/models'; import { GuaribasUser } from '../../security.gblib/models';
/**
* A conversation that groups many messages.
*/
@Table
export class GuaribasConversation extends Model<GuaribasConversation> {
@PrimaryKey
@AutoIncrement
@Column
public conversationId: number;
@ForeignKey(() => GuaribasSubject)
@Column
public startSubjectId: number;
@BelongsTo(() => GuaribasSubject)
public startSubject: GuaribasSubject;
@ForeignKey(() => GuaribasChannel)
@Column
public channelId: string;
@Column public rateDate: Date;
@Column(DataType.FLOAT)
@Column
public rate: number;
@Column
@CreatedAt
public createdAt: Date;
@Column public text: string;
@ForeignKey(() => GuaribasUser)
@Column
public startedByUserId: number;
@BelongsTo(() => GuaribasUser)
public startedBy: GuaribasUser;
}
/** /**
* A single message in a conversation. * A single message in a conversation.
*/ */
@ -104,48 +148,3 @@ export class GuaribasConversationMessage extends Model<GuaribasConversationMessa
@BelongsTo(() => GuaribasUser) @BelongsTo(() => GuaribasUser)
public user: GuaribasUser; public user: GuaribasUser;
} }
/**
* A conversation that groups many messages.
*/
@Table
export class GuaribasConversation extends Model<GuaribasConversation> {
@PrimaryKey
@AutoIncrement
@Column
public conversationId: number;
@ForeignKey(() => GuaribasSubject)
@Column
public startSubjectId: number;
@BelongsTo(() => GuaribasSubject)
public startSubject: GuaribasSubject;
@ForeignKey(() => GuaribasChannel)
@Column
public channelId: string;
@Column public rateDate: Date;
@Column(DataType.FLOAT)
@Column
public rate: number;
@Column
@CreatedAt
public createdAt: Date;
@Column public text: string;
@HasMany(() => GuaribasConversationMessage)
public conversationMessage: GuaribasConversationMessage[];
@ForeignKey(() => GuaribasUser)
@Column
public startedByUserId: number;
@BelongsTo(() => GuaribasUser)
public startedBy: GuaribasUser;
}

View file

@ -45,22 +45,41 @@ export class AnalyticsService {
public async createConversation( public async createConversation(
user: GuaribasUser user: GuaribasUser
): Promise<GuaribasConversation> { ): Promise<GuaribasConversation> {
const conversation = new GuaribasConversation(); const conversation = new GuaribasConversation();
conversation.startedBy = user; conversation.startedBy = user;
conversation.startedByUserId = user.userId; conversation.startedByUserId = user.userId;
return await conversation.save(); return await conversation.save();
} }
public async updateConversationRate(
instanceId: number,
conversationId: number,
rate: number
): Promise<GuaribasConversation> {
const options = { where: {} };
// TODO: Filter by instanceId: instanceId
options.where = { conversationId: conversationId };
const item = await GuaribasConversation.findOne(options);
item.rate = rate;
item.rateDate = new Date();
return item.save();
}
public async createMessage( public async createMessage(
instanceId: number,
conversation: GuaribasConversation, conversation: GuaribasConversation,
user: GuaribasUser, user: GuaribasUser,
content: string content: string
): Promise<GuaribasConversationMessage> { ): Promise<GuaribasConversationMessage> {
const message = GuaribasConversationMessage.build();
message.conversation = conversation; const message = GuaribasConversationMessage.build();
message.user = user; message.content = content;
message.content = content; message.instanceId = instanceId;
return await message.save(); message.userId = user.userId;
message.conversationId = conversation.conversationId;
return await message.save();
} }
} }

View file

@ -382,11 +382,11 @@ STORAGE_SYNC=true
const sysPackages: IGBPackage[] = []; const sysPackages: IGBPackage[] = [];
[ [
GBAdminPackage, GBAdminPackage,
GBAnalyticsPackage,
GBCorePackage, GBCorePackage,
GBSecurityPackage, GBSecurityPackage,
GBKBPackage, GBKBPackage,
GBCustomerSatisfactionPackage, GBCustomerSatisfactionPackage,
GBAnalyticsPackage,
GBWhatsappPackage, GBWhatsappPackage,
GBAzureDeployerPackage, GBAzureDeployerPackage,
GBSharePointPackage, GBSharePointPackage,

View file

@ -58,19 +58,12 @@ import {
import { MicrosoftAppCredentials } from 'botframework-connector'; import { MicrosoftAppCredentials } from 'botframework-connector';
import { GBServer } from '../../../src/app'; import { GBServer } from '../../../src/app';
import { GBAnalyticsPackage } from '../../analytics.gblib';
import { GBCorePackage } from '../../core.gbapp';
import { GBCustomerSatisfactionPackage } from '../../customer-satisfaction.gbapp';
import { GBKBPackage } from '../../kb.gbapp';
import { AskDialogArgs } from '../../kb.gbapp/dialogs/AskDialog'; import { AskDialogArgs } from '../../kb.gbapp/dialogs/AskDialog';
import { GBSecurityPackage } from '../../security.gblib';
import { GBWhatsappPackage } from '../../whatsapp.gblib';
import { Messages } from '../strings'; import { Messages } from '../strings';
import { GBAdminPackage } from './../../admin.gbapp/index';
import { GBConfigService } from './GBConfigService'; import { GBConfigService } from './GBConfigService';
import { GBDeployer } from './GBDeployer'; import { GBDeployer } from './GBDeployer';
import { SecService } from '../../security.gblib/services/SecService'; import { SecService } from '../../security.gblib/services/SecService';
import { isBreakOrContinueStatement } from 'typescript'; import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService';
/** /**
* Minimal service layer for a bot. * Minimal service layer for a bot.
@ -124,7 +117,7 @@ export class GBMinService {
if (process.env.DISABLE_WEB !== 'true') { if (process.env.DISABLE_WEB !== 'true') {
GBServer.globals.server.get('/instances/:botId', (req, res) => { GBServer.globals.server.get('/instances/:botId', (req, res) => {
(async () => { (async () => {
await this.handleGetInstanceFroClient(req, res); await this.handleGetInstanceForClient(req, res);
})(); })();
}); });
} }
@ -189,7 +182,7 @@ export class GBMinService {
public async mountBot(instance: IGBInstance) { public async mountBot(instance: IGBInstance) {
// Build bot adapter. // Build bot adapter.
const { min, adapter, conversationState } = await this.buildBotAdapter(instance, GBServer.globals.publicAddress, GBServer.globals.sysPackages); const { min, adapter, conversationState } = await this.buildBotAdapter(instance, GBServer.globals.sysPackages);
if (GBServer.globals.minInstances.length === 0) { if (GBServer.globals.minInstances.length === 0) {
GBServer.globals.minBoot = min; GBServer.globals.minBoot = min;
@ -201,7 +194,7 @@ export class GBMinService {
// this.deployer.deployPackage(min, 'packages/default.gbdialog'); // this.deployer.deployPackage(min, 'packages/default.gbdialog');
// Call the loadBot context.activity for all packages. // Call the loadBot context.activity for all packages.
this.invokeLoadBot(GBServer.globals.appPackages, GBServer.globals.sysPackages, min, GBServer.globals.server); this.invokeLoadBot(GBServer.globals.appPackages, GBServer.globals.sysPackages, min);
// Serves individual URL for each bot conversational interface... // Serves individual URL for each bot conversational interface...
const url = `/api/messages/${instance.botId}`; const url = `/api/messages/${instance.botId}`;
@ -280,7 +273,7 @@ export class GBMinService {
/** /**
* Returns the instance object to clients requesting bot info. * Returns the instance object to clients requesting bot info.
*/ */
private async handleGetInstanceFroClient(req: any, res: any) { private async handleGetInstanceForClient(req: any, res: any) {
let botId = req.params.botId; let botId = req.params.botId;
if (botId === '[default]' || botId === undefined) { if (botId === '[default]' || botId === undefined) {
botId = GBConfigService.get('BOT_ID'); botId = GBConfigService.get('BOT_ID');
@ -365,7 +358,7 @@ export class GBMinService {
} }
} }
private async buildBotAdapter(instance: any, proxyAddress: string, sysPackages: IGBPackage[]) { private async buildBotAdapter(instance: any, sysPackages: IGBPackage[]) {
const adapter = new BotFrameworkAdapter({ const adapter = new BotFrameworkAdapter({
appId: instance.marketplaceId, appId: instance.marketplaceId,
appPassword: instance.marketplacePassword appPassword: instance.marketplacePassword
@ -404,11 +397,9 @@ export class GBMinService {
return { min, adapter, conversationState }; return { min, adapter, conversationState };
} }
private invokeLoadBot(appPackages: IGBPackage[], sysPackages: IGBPackage[], min: GBMinInstance, server: any) { private invokeLoadBot(appPackages: IGBPackage[], sysPackages: IGBPackage[], min: GBMinInstance) {
let index = 0;
sysPackages.forEach(e => { sysPackages.forEach(e => {
e.loadBot(min); e.loadBot(min);
index++;
}, this); }, this);
appPackages.forEach(p => { appPackages.forEach(p => {
@ -456,15 +447,24 @@ export class GBMinService {
user.loaded = true; user.loaded = true;
user.subjects = []; user.subjects = [];
user.cb = undefined; user.cb = undefined;
await min.userProfile.set(step.context, user);
if (context.activity.membersAdded !== undefined) { if (context.activity.membersAdded !== undefined) {
let sec = new SecService(); let sec = new SecService();
const member = context.activity.membersAdded[0]; const member = context.activity.membersAdded[0];
await sec.ensureUser(instance.instanceId, member.id, const persistedUser = await sec.ensureUser(instance.instanceId, member.id,
min.botId, member.id, "", "web", member.name, member.id); min.botId, member.id, "", "web", member.name, member.id);
const analytics = new AnalyticsService();
user.systemUser = persistedUser;
user.conversation = await analytics.createConversation(persistedUser);
} }
await min.userProfile.set(step.context, user);
} }
GBLog.info( GBLog.info(
@ -534,7 +534,17 @@ export class GBMinService {
} }
private async processMessageActivity(context, min: GBMinInstance, step: GBDialogStep) { private async processMessageActivity(context, min: GBMinInstance, step: GBDialogStep) {
// Direct script invoking by itent name.
// Adds message to the analytics layer.
const analytics = new AnalyticsService();
const user = await min.userProfile.get(context, {});
analytics.createMessage(min.instance.instanceId,
user.conversation, user.systemUser,
context.activity.text);
// Checks for global exit kewywords cancelling any active dialogs.
const globalQuit = (locale, utterance) => { const globalQuit = (locale, utterance) => {
return utterance.match(Messages[locale].global_quit); return utterance.match(Messages[locale].global_quit);
} }
@ -546,7 +556,7 @@ export class GBMinService {
if (hasBadWord) { if (hasBadWord) {
await step.beginDialog('/pleaseNoBadWords'); await step.beginDialog('/pleaseNoBadWords');
}else if (isVMCall) { } else if (isVMCall) {
await GBMinService.callVM(context.activity.text, min, step); await GBMinService.callVM(context.activity.text, min, step);
} else if (context.activity.text.charAt(0) === '/') { } else if (context.activity.text.charAt(0) === '/') {
await step.beginDialog(context.activity.text); await step.beginDialog(context.activity.text);
@ -562,7 +572,6 @@ export class GBMinService {
await step.beginDialog('/menu', JSON.parse(context.activity.text)); await step.beginDialog('/menu', JSON.parse(context.activity.text));
// Otherwise, continue to the active dialog in the stack. // Otherwise, continue to the active dialog in the stack.
} else { } else {
const user = await min.userProfile.get(context, {});
if (step.activeDialog !== undefined) { if (step.activeDialog !== undefined) {
await step.continueDialog(); await step.continueDialog();
} else { } else {

View file

@ -42,6 +42,7 @@ import { BotAdapter } from 'botbuilder';
import { WaterfallDialog } from 'botbuilder-dialogs'; import { WaterfallDialog } from 'botbuilder-dialogs';
import { CSService } from '../services/CSService'; import { CSService } from '../services/CSService';
import { Messages } from '../strings'; import { Messages } from '../strings';
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService';
/** /**
* Dialog for collecting quality of answer. * Dialog for collecting quality of answer.
@ -78,6 +79,14 @@ export class QualityDialog extends IGBDialog {
user.lastQuestion, user.lastQuestion,
user.lastQuestionId user.lastQuestionId
); );
// Updates values to perform Bot Analytics.
const analytics = new AnalyticsService();
analytics.updateConversationRate(min.instance.instanceId, user.conversation, score);
// Goes to the ask loop.
await step.replaceDialog('/ask', { isReturning: true }); await step.replaceDialog('/ask', { isReturning: true });
} }

View file

@ -2818,6 +2818,15 @@
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=" "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8="
}, },
"browser-id": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/browser-id/-/browser-id-1.1.0.tgz",
"integrity": "sha512-MuvthhJ8pDjIYpJzHwYOrlFtTPhEOF3wk9AVvy19pLQwmS/OdGWptuhzjkgLnDJS3WgV2m7bLDvlCwufg1jWBA==",
"requires": {
"uuid": "^3.3.3",
"versioned-storage": "^1.1.0"
}
},
"browser-process-hrtime": { "browser-process-hrtime": {
"version": "0.1.3", "version": "0.1.3",
"resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz", "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz",
@ -6058,6 +6067,11 @@
"locate-path": "^3.0.0" "locate-path": "^3.0.0"
} }
}, },
"fingerprintjs2": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fingerprintjs2/-/fingerprintjs2-2.1.0.tgz",
"integrity": "sha512-H1k/ESTD2rJ3liupyqWBPjZC+LKfCGixQzz/NDN4dkgbmG1bVFyMOh7luKSkVDoyfhgvRm62pviNMPI+eJTZcQ=="
},
"flat-cache": { "flat-cache": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz",
@ -7639,8 +7653,7 @@
}, },
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"bundled": true, "bundled": true
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
@ -7677,8 +7690,7 @@
}, },
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
@ -7687,8 +7699,7 @@
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -7791,8 +7802,7 @@
}, },
"inherits": { "inherits": {
"version": "2.0.4", "version": "2.0.4",
"bundled": true, "bundled": true
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -7802,7 +7812,6 @@
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -7822,13 +7831,11 @@
}, },
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.9.0", "version": "2.9.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.2", "safe-buffer": "^5.1.2",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -7845,7 +7852,6 @@
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -7926,8 +7932,7 @@
}, },
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -7937,7 +7942,6 @@
"once": { "once": {
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -8013,8 +8017,7 @@
}, },
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"bundled": true, "bundled": true
"optional": true
}, },
"safer-buffer": { "safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
@ -8044,7 +8047,6 @@
"string-width": { "string-width": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -8062,7 +8064,6 @@
"strip-ansi": { "strip-ansi": {
"version": "3.0.1", "version": "3.0.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
@ -8101,13 +8102,11 @@
}, },
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true
"optional": true
}, },
"yallist": { "yallist": {
"version": "3.1.1", "version": "3.1.1",
"bundled": true, "bundled": true
"optional": true
} }
} }
} }
@ -14283,6 +14282,11 @@
"extsprintf": "^1.2.0" "extsprintf": "^1.2.0"
} }
}, },
"versioned-storage": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/versioned-storage/-/versioned-storage-1.1.0.tgz",
"integrity": "sha512-oS+unMiWJjaVAFCkNJvmHiu6LDb8KrzT8YmfrQpAmn8/yKnW4Roq3lcVMxQofT9Oidqg8oWChbGYl4FGQJyPPg=="
},
"vfile": { "vfile": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/vfile/-/vfile-3.0.1.tgz", "resolved": "https://registry.npmjs.org/vfile/-/vfile-3.0.1.tgz",

View file

@ -1,6 +1,6 @@
{ {
"name": "default.gbui", "name": "default.gbui",
"version": "0.0.12", "version": "0.0.13",
"private": false, "private": false,
"repository": "https://github.com/pragmatismo-io/BotServer", "repository": "https://github.com/pragmatismo-io/BotServer",
"description": "Default web interface for General Bots open-core", "description": "Default web interface for General Bots open-core",
@ -12,6 +12,7 @@
"botframework-webchat": "^4.7.1", "botframework-webchat": "^4.7.1",
"deep-extend": "0.6.0", "deep-extend": "0.6.0",
"fetch": "1.1.0", "fetch": "1.1.0",
"fingerprintjs2": "^2.1.0",
"msal": "^1.2.0", "msal": "^1.2.0",
"powerbi-client": "2.10.2", "powerbi-client": "2.10.2",
"react": "^16.12.0", "react": "^16.12.0",

View file

@ -41,8 +41,8 @@ import GBCss from './components/GBCss.js';
import { DirectLine } from 'botframework-directlinejs'; import { DirectLine } from 'botframework-directlinejs';
import { ConnectionStatus } from 'botframework-directlinejs'; import { ConnectionStatus } from 'botframework-directlinejs';
import ReactWebChat from 'botframework-webchat'; import ReactWebChat from 'botframework-webchat';
// import GBPowerBIPlayer from './players/GBPowerBIPlayer.js';
import { UserAgentApplication } from 'msal'; import { UserAgentApplication } from 'msal';
import Fingerprint2 from 'fingerprintjs2';
class GBUIApp extends React.Component { class GBUIApp extends React.Component {
constructor() { constructor() {
@ -90,7 +90,8 @@ class GBUIApp extends React.Component {
} }
getUser() { getUser() {
return { id: 'webUser@gb', name: 'You' };
return { id: 'web@gb', name: 'You' };
} }
postEvent(name, value) { postEvent(name, value) {
@ -145,7 +146,7 @@ class GBUIApp extends React.Component {
let userAgentApplication = new UserAgentApplication( let userAgentApplication = new UserAgentApplication(
this.state.instanceClient.authenticatorClientId, this.state.instanceClient.authenticatorClientId,
authority, authority,
function(errorDesc, token, error, tokenType) { function (errorDesc, token, error, tokenType) {
if (error) { if (error) {
console.log(error); console.log(error);
} }
@ -157,10 +158,10 @@ class GBUIApp extends React.Component {
var user = userAgentApplication.getUser(); var user = userAgentApplication.getUser();
if (user) { if (user) {
userAgentApplication.acquireTokenSilent(graphScopes).then( userAgentApplication.acquireTokenSilent(graphScopes).then(
function(accessToken) { function (accessToken) {
_this_.sendToken(accessToken); _this_.sendToken(accessToken);
}, },
function(error) { function (error) {
console.log(error); console.log(error);
} }
); );
@ -264,16 +265,16 @@ class GBUIApp extends React.Component {
/> />
); );
break; break;
/* case 'pbi': /* case 'pbi':
playerComponent = ( playerComponent = (
<GBPowerBIPlayer <GBPowerBIPlayer
app={this} app={this}
ref={player => { ref={player => {
this.player = player; this.player = player;
}} }}
/> />
); );
break; */ break; */
case 'login': case 'login':
playerComponent = ( playerComponent = (
<GBLoginPlayer <GBLoginPlayer
@ -342,7 +343,7 @@ class GBUIApp extends React.Component {
{sideBar} {sideBar}
<div className="player">{playerComponent}</div> <div className="player">{playerComponent}</div>
<div className="webchat"> <div className="webchat">
{chat} {chat}
</div> </div>
</div> </div>
); );

View file

@ -65,8 +65,7 @@ export class SecService extends GBService {
user.email = userName; user.email = userName;
user.phone = phone; user.phone = phone;
user.defaultChannel = channelName; user.defaultChannel = channelName;
user.save(); return await user.save();
return user;
} }
/** /**