fix(default.gbui): Removing warnings.
This commit is contained in:
parent
dcafb7acf9
commit
02ed08508d
4 changed files with 59 additions and 67 deletions
|
@ -43,7 +43,7 @@ import { GBMinInstance } from 'botlib';
|
||||||
import { IGBDialog } from 'botlib';
|
import { IGBDialog } from 'botlib';
|
||||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||||
import { GBImporter } from '../../core.gbapp/services/GBImporter';
|
import { GBImporter } from '../../core.gbapp/services/GBImporterService';
|
||||||
import { GBAdminService } from '../services/GBAdminService';
|
import { GBAdminService } from '../services/GBAdminService';
|
||||||
import { Messages } from '../strings';
|
import { Messages } from '../strings';
|
||||||
|
|
||||||
|
@ -57,19 +57,27 @@ export class AdminDialog extends IGBDialog {
|
||||||
const packageName = text.split(' ')[1];
|
const packageName = text.split(' ')[1];
|
||||||
const importer = new GBImporter(min.core);
|
const importer = new GBImporter(min.core);
|
||||||
const deployer = new GBDeployer(min.core, importer);
|
const deployer = new GBDeployer(min.core, importer);
|
||||||
await deployer.undeployPackageFromLocalPath(
|
await deployer.undeployPackageFromLocalPath(min.instance, UrlJoin('packages', packageName));
|
||||||
min.instance,
|
|
||||||
UrlJoin('packages', packageName)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async deployPackageCommand(text: string, deployer: GBDeployer) {
|
public static async deployPackageCommand(min: GBMinInstance, text: string, deployer: GBDeployer) {
|
||||||
const packageName = text.split(' ')[1];
|
const packageName = text.split(' ')[1];
|
||||||
const additionalPath = GBConfigService.get('ADDITIONAL_DEPLOY_PATH');
|
const additionalPath = GBConfigService.get('ADDITIONAL_DEPLOY_PATH');
|
||||||
await deployer.deployPackageFromLocalPath(
|
await deployer.deployPackageFromLocalPath(min, UrlJoin(additionalPath, packageName));
|
||||||
UrlJoin(additionalPath, packageName)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async rebuildIndexPackageCommand(min: GBMinInstance, text: string, deployer: GBDeployer) {
|
||||||
|
await deployer.rebuildIndex(min.instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async addConnectionCommand(min: GBMinInstance, text: any) {
|
||||||
|
const packageName = text.split(' ')[1];
|
||||||
|
const importer = new GBImporter(min.core);
|
||||||
|
const admin = new GBAdminService(min.core);
|
||||||
|
// TODO: await admin.addConnection
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup dialogs flows and define services call.
|
* Setup dialogs flows and define services call.
|
||||||
*
|
*
|
||||||
|
@ -87,23 +95,22 @@ export class AdminDialog extends IGBDialog {
|
||||||
async step => {
|
async step => {
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
const prompt = Messages[locale].authenticate;
|
const prompt = Messages[locale].authenticate;
|
||||||
await step.prompt('textPrompt', prompt);
|
|
||||||
return await step.next();
|
return await step.prompt('textPrompt', prompt);
|
||||||
},
|
},
|
||||||
async step => {
|
async step => {
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
const password = step.result;
|
const password = step.result;
|
||||||
if (
|
|
||||||
password === GBConfigService.get('ADMIN_PASS') &&
|
if (password === GBConfigService.get('ADMIN_PASS')) {
|
||||||
GBAdminService.StrongRegex.test(password)
|
|
||||||
) {
|
|
||||||
await step.context.sendActivity(Messages[locale].welcome);
|
await step.context.sendActivity(Messages[locale].welcome);
|
||||||
await step.prompt('textPrompt', Messages[locale].which_task);
|
|
||||||
|
return await step.prompt('textPrompt', Messages[locale].which_task);
|
||||||
} else {
|
} else {
|
||||||
await step.prompt('textPrompt', Messages[locale].wrong_password);
|
await step.context.sendActivity(Messages[locale].wrong_password);
|
||||||
await step.endDialog();
|
|
||||||
|
return await step.endDialog();
|
||||||
}
|
}
|
||||||
return await step.next();
|
|
||||||
},
|
},
|
||||||
async step => {
|
async step => {
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
|
@ -114,20 +121,32 @@ export class AdminDialog extends IGBDialog {
|
||||||
let unknownCommand = false;
|
let unknownCommand = false;
|
||||||
|
|
||||||
if (text === 'quit') {
|
if (text === 'quit') {
|
||||||
await step.replaceDialog('/');
|
return await step.replaceDialog('/');
|
||||||
} else if (cmdName === 'createFarm') {
|
} else if (cmdName === 'createFarm') {
|
||||||
await AdminDialog.createFarmCommand(text, deployer);
|
await AdminDialog.createFarmCommand(text, deployer);
|
||||||
await step.replaceDialog('/admin', { firstRun: false });
|
|
||||||
|
return await step.replaceDialog('/admin', { firstRun: false });
|
||||||
} else if (cmdName === 'deployPackage') {
|
} else if (cmdName === 'deployPackage') {
|
||||||
await AdminDialog.deployPackageCommand(text, deployer);
|
await AdminDialog.deployPackageCommand(min, text, deployer);
|
||||||
await step.replaceDialog('/admin', { firstRun: false });
|
|
||||||
|
return await step.replaceDialog('/admin', { firstRun: false });
|
||||||
} else if (cmdName === 'redeployPackage') {
|
} else if (cmdName === 'redeployPackage') {
|
||||||
await AdminDialog.undeployPackageCommand(text, min);
|
await AdminDialog.undeployPackageCommand(text, min);
|
||||||
await AdminDialog.deployPackageCommand(text, deployer);
|
await AdminDialog.deployPackageCommand(min, text, deployer);
|
||||||
await step.replaceDialog('/admin', { firstRun: false });
|
|
||||||
|
return await step.replaceDialog('/admin', { firstRun: false });
|
||||||
|
} else if (cmdName === 'rebuildIndex') {
|
||||||
|
await AdminDialog.rebuildIndexPackageCommand(min, text, deployer);
|
||||||
|
|
||||||
|
return await step.replaceDialog('/admin', { firstRun: false });
|
||||||
|
} else if (cmdName === 'addConnection') {
|
||||||
|
await AdminDialog.addConnectionCommand(min, text);
|
||||||
|
|
||||||
|
return await step.replaceDialog('/admin', { firstRun: false });
|
||||||
} else if (cmdName === 'undeployPackage') {
|
} else if (cmdName === 'undeployPackage') {
|
||||||
await AdminDialog.undeployPackageCommand(text, min);
|
await AdminDialog.undeployPackageCommand(text, min);
|
||||||
await step.replaceDialog('/admin', { firstRun: false });
|
|
||||||
|
return await step.replaceDialog('/admin', { firstRun: false });
|
||||||
} else if (cmdName === 'setupSecurity') {
|
} else if (cmdName === 'setupSecurity') {
|
||||||
await AdminDialog.setupSecurity(min, step);
|
await AdminDialog.setupSecurity(min, step);
|
||||||
} else {
|
} else {
|
||||||
|
@ -137,13 +156,11 @@ export class AdminDialog extends IGBDialog {
|
||||||
if (unknownCommand) {
|
if (unknownCommand) {
|
||||||
await step.context.sendActivity(Messages[locale].unknown_command);
|
await step.context.sendActivity(Messages[locale].unknown_command);
|
||||||
} else {
|
} else {
|
||||||
await step.context.sendActivity(
|
await step.context.sendActivity(Messages[locale].finshed_working(cmdName));
|
||||||
Messages[locale].finshed_working(cmdName)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
await step.endDialog();
|
await step.endDialog();
|
||||||
await step.replaceDialog('/answer', { query: text });
|
|
||||||
return await step.next();
|
return await step.replaceDialog('/answer', { query: text });
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
@ -151,17 +168,9 @@ export class AdminDialog extends IGBDialog {
|
||||||
|
|
||||||
private static async setupSecurity(min: any, step: any) {
|
private static async setupSecurity(min: any, step: any) {
|
||||||
const locale = step.activity.locale;
|
const locale = step.activity.locale;
|
||||||
const state = `${min.instance.instanceId}${Math.floor(
|
const state = `${min.instance.instanceId}${Math.floor(Math.random() * 1000000000)}`;
|
||||||
Math.random() * 1000000000
|
await min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state);
|
||||||
)}`;
|
const url = `https://login.microsoftonline.com/${min.instance.authenticatorTenant}/oauth2/authorize?client_id=${
|
||||||
await min.adminService.setValue(
|
|
||||||
min.instance.instanceId,
|
|
||||||
'AntiCSRFAttackState',
|
|
||||||
state
|
|
||||||
);
|
|
||||||
const url = `https://login.microsoftonline.com/${
|
|
||||||
min.instance.authenticatorTenant
|
|
||||||
}/oauth2/authorize?client_id=${
|
|
||||||
min.instance.authenticatorClientId
|
min.instance.authenticatorClientId
|
||||||
}&response_type=code&redirect_uri=${min.instance.botEndpoint}/${
|
}&response_type=code&redirect_uri=${min.instance.botEndpoint}/${
|
||||||
min.instance.botId
|
min.instance.botId
|
||||||
|
|
|
@ -40,13 +40,9 @@ import SidebarMenu from "./components/SidebarMenu.js";
|
||||||
import GBCss from "./components/GBCss.js";
|
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 { SpeechRecognizer } from "botframework-webchat";
|
|
||||||
import { SpeechSynthesizer } from "botframework-webchat";
|
|
||||||
import { SynthesisGender } from "botframework-webchat";
|
|
||||||
import { Chat } from "botframework-webchat";
|
import { Chat } from "botframework-webchat";
|
||||||
import GBPowerBIPlayer from "./players/GBPowerBIPlayer.js";
|
import GBPowerBIPlayer from "./players/GBPowerBIPlayer.js";
|
||||||
import { UserAgentApplication } from "msal";
|
|
||||||
import { Observable } from 'rxjs'
|
|
||||||
|
|
||||||
class GBUIApp extends React.Component {
|
class GBUIApp extends React.Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -117,11 +113,11 @@ class GBUIApp extends React.Component {
|
||||||
|
|
||||||
configureChat() {
|
configureChat() {
|
||||||
var botId = window.location.href.split("/")[3];
|
var botId = window.location.href.split("/")[3];
|
||||||
if (botId.indexOf('#') != -1) {
|
if (botId.indexOf('#') !== -1) {
|
||||||
botId = botId.split("#")[0];
|
botId = botId.split("#")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!botId || botId == "") {
|
if (!botId || botId === "") {
|
||||||
botId = "[default]";
|
botId = "[default]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +298,7 @@ class GBUIApp extends React.Component {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let speechOptions;
|
|
||||||
let chat = <div />;
|
let chat = <div />;
|
||||||
let gbCss = <div />;
|
let gbCss = <div />;
|
||||||
|
|
||||||
|
@ -314,15 +310,10 @@ class GBUIApp extends React.Component {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.state.line && this.state.instance) {
|
if (this.state.line && this.state.instance) {
|
||||||
let token = this.state.instanceClient.speechToken;
|
|
||||||
gbCss = <GBCss instance={this.state.instance} />;
|
gbCss = <GBCss instance={this.state.instance} />;
|
||||||
|
|
||||||
function getToken() {
|
// let speechOptions;
|
||||||
return new Promise((resolve: any, reject: any): any => {
|
// let token = this.state.instanceClient.speechToken;
|
||||||
resolve(token);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// speechOptions = {
|
// speechOptions = {
|
||||||
// speechRecognizer: new SpeechRecognizer({
|
// speechRecognizer: new SpeechRecognizer({
|
||||||
// locale: "pt-br",
|
// locale: "pt-br",
|
||||||
|
|
|
@ -43,14 +43,6 @@ class GBLoginPlayer extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
doLogin(info) {
|
doLogin(info) {
|
||||||
let logger = new Logger(
|
|
||||||
(logLevel, message, piiEnabled) => {
|
|
||||||
console.log(message);
|
|
||||||
},
|
|
||||||
{ level: LogLevel.Verbose }
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
let authority =
|
let authority =
|
||||||
"https://login.microsoftonline.com/" +
|
"https://login.microsoftonline.com/" +
|
||||||
this.state.login.authenticatorTenant;
|
this.state.login.authenticatorTenant;
|
||||||
|
|
|
@ -119,13 +119,13 @@ class GBMarkdownPlayer extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.prevId) {
|
if (this.state.prevId) {
|
||||||
prev = <a style={{ color: 'blue', cursor: 'pointer' }}
|
prev = <a style={{ color: 'blue', cursor: 'pointer' }} href={"#"}
|
||||||
onClick={() => this.sendAnswer(this.state.prevId)}>
|
onClick={() => this.sendAnswer(this.state.prevId)}>
|
||||||
Back
|
Back
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
if (this.state.nextId) {
|
if (this.state.nextId) {
|
||||||
next = <a style={{ color: 'blue', cursor: 'pointer' }}
|
next = <a style={{ color: 'blue', cursor: 'pointer' }} href={"#"}
|
||||||
onClick={() => this.sendAnswer(this.state.nextId)}>
|
onClick={() => this.sendAnswer(this.state.nextId)}>
|
||||||
Next
|
Next
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Add table
Reference in a new issue