diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-askgpt/cds-action-askgpt.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-askgpt/cds-action-askgpt.component.scss index 5fe0a89c..f651c619 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-askgpt/cds-action-askgpt.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-askgpt/cds-action-askgpt.component.scss @@ -77,12 +77,6 @@ // gap: 10px; } -.title-label { - color: white; - font-size: 14px; - margin-bottom: 6px; -} - .select-box { margin-bottom: 24px; } diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-askgpt/cds-action-askgpt.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-askgpt/cds-action-askgpt.component.ts index 01e9a7ac..2877755b 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-askgpt/cds-action-askgpt.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-askgpt/cds-action-askgpt.component.ts @@ -8,6 +8,7 @@ import { KnowledgeBaseService } from 'src/app/services/knowledge-base.service'; import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'; import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'; import { AppConfigService } from 'src/app/services/app-config'; +import { Subscription } from 'rxjs/internal/Subscription'; @Component({ selector: 'cds-action-askgpt', @@ -32,7 +33,8 @@ export class CdsActionAskgptComponent implements OnInit { isConnectedTrue: boolean = false; isConnectedFalse: boolean = false; connector: any; - + private subscriptionChangedConnector: Subscription; + kbs_list = []; kb_selected_id: string = null; status_code: number; @@ -60,11 +62,8 @@ export class CdsActionAskgptComponent implements OnInit { ngOnInit(): void { this.logger.debug("[ACTION-ASKGPT] action detail: ", this.action); - console.log("[ACTION-ASKGPT] action detail: ", this.action); - console.log("[ACTION-ASKGPT] action kbid: ", this.action.kbid); - console.log("[ACTION-ASKGPT] action kbname: ", this.action.kbName); - this.intentService.isChangedConnector$.subscribe((connector: any) => { + this.subscriptionChangedConnector = this.intentService.isChangedConnector$.subscribe((connector: any) => { this.logger.debug('[ACTION-ASKGPT] isChangedConnector -->', connector); this.connector = connector; this.updateConnector(); @@ -92,6 +91,13 @@ export class CdsActionAskgptComponent implements OnInit { } + /** */ + ngOnDestroy() { + if (this.subscriptionChangedConnector) { + this.subscriptionChangedConnector.unsubscribe(); + } + } + initializeConnector() { this.idIntentSelected = this.intentSelected.intent_id; this.idConnectorTrue = this.idIntentSelected+'/'+this.action._tdActionId + '/true'; @@ -114,7 +120,9 @@ export class CdsActionAskgptComponent implements OnInit { this.action.falseIntent = null this.isConnectedFalse = false; } - this.updateAndSaveAction.emit(); + // if(this.connector.notify) + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); + // this.updateAndSaveAction.emit(); } else { // TODO: verificare quale dei due connettori è stato aggiunto (controllare il valore della action corrispondente al true/false intent) // ADD / EDIT @@ -124,7 +132,9 @@ export class CdsActionAskgptComponent implements OnInit { this.isConnectedTrue = true; if(this.action.trueIntent !== '#'+this.connector.toId){ this.action.trueIntent = '#'+this.connector.toId; - this.updateAndSaveAction.emit(); + // if(this.connector.notify) + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); + // this.updateAndSaveAction.emit(); } } if(array[array.length -1] === 'false'){ @@ -132,7 +142,9 @@ export class CdsActionAskgptComponent implements OnInit { this.isConnectedFalse = true; if(this.action.falseIntent !== '#'+this.connector.toId){ this.action.falseIntent = '#'+this.connector.toId; - this.updateAndSaveAction.emit(); + // if(this.connector.notify) + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); + // this.updateAndSaveAction.emit(); } } } @@ -213,17 +225,17 @@ export class CdsActionAskgptComponent implements OnInit { onChangeBlockSelect(event:{name: string, value: string}, type: 'trueIntent' | 'falseIntent') { if(event){ this.action[type]=event.value - } - switch(type){ - case 'trueIntent': - this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorTrue, toId: this.action.trueIntent}) - break; - case 'falseIntent': - this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorFalse, toId: this.action.falseIntent}) - break; + switch(type){ + case 'trueIntent': + this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorTrue, toId: this.action.trueIntent}) + break; + case 'falseIntent': + this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorFalse, toId: this.action.falseIntent}) + break; + } + this.updateAndSaveAction.emit(); } - this.updateAndSaveAction.emit(); } onResetBlockSelect(event:{name: string, value: string}, type: 'trueIntent' | 'falseIntent') { @@ -260,7 +272,7 @@ export class CdsActionAskgptComponent implements OnInit { // } goToKNB(){ - let url = this.appConfigService.getConfig().dashboardBaseUrl + 'dashboard/#/project/' + this.project_id +'/knowledge-bases' + let url = this.appConfigService.getConfig().DASHBOARD_BASE_URL + 'dashboard/#/project/' + this.project_id +'/knowledge-bases' window.open(url, '_blank') } @@ -271,139 +283,4 @@ export class CdsActionAskgptComponent implements OnInit { } } - - // ----------------- - // TO CHECK / DELETE - // ----------------- - - - // getAllOpenaiKbs() { - // this.openaikbService.getAllOpenaikbs().subscribe((kbs: any[]) => { - // this.kbs_list = kbs.map(t => { - // t.icon = "language" - // return t; - // }) - // if (this.action.kbid) { - // this.kb_selected_id = this.kbs_list.find(k => k.url === this.action.kbid)._id; - // this.kb_selected_name = this.kbs_list.find(k => k.url === this.action.kbid).name; - // //this.checkKbStatus(this.action.kbid); - // } - // //this.checkLimit(); - // }, (error) => { - // this.logger.error("[ACTION ASKGPT] ERROR get openai kbs: ", error); - // }, () => { - // this.logger.info("[ACTION ASKGPT] get openai kbs *COMPLETED*"); - // }) - // } - - // openAddKbDialog() { - // const dialogRef = this.dialog.open(AddkbDialogComponent, { - // panelClass: 'custom-dialog-container', - // data: { name: '', url: '' } - // }); - // dialogRef.afterClosed().subscribe(result => { - // this.logger.info("[ACTION ASKGPT] Dialog result - new openai kb: ", result); - // if (result && result.name && result.url) { - // this.saveOpenaiKb(result); - // } - // }); - // } - - // saveOpenaiKb(new_kb) { - // this.openaikbService.addOpenaiKb(new_kb).subscribe((savedKb) => { - // this.getAllOpenaiKbs(); - // }, (error) => { - // this.logger.error("[ACTION ASKGPT] ERROR add new kb: ", error); - // }, () => { - // this.logger.info("[ACTION ASKGPT] add new kb *COMPLETED*"); - // }) - // } - - // onDeleteSelect(id) { - // this.openDeleteDialog(id); - // } - - // openDeleteDialog(id) { - // const dialogRef = this.dialog.open(DialogYesNoComponent, { - // panelClass: 'custom-dialog-container', - // data: { title: 'Delete Knowledge base', text: 'Are you sure you want to delete permanently this Knwoledge base?', yes: 'Delete', no: 'Cancel' } - // }) - // dialogRef.afterClosed().subscribe(result => { - // if (result && result !== undefined && result !== false) { - // this.deleteKb(id); - // } - // }) - // } - - // deleteKb(id: string) { - // if (this.kb_selected_id === id) { - // this.action.kbid = null; - // this.kb_selected_id = null; - // this.status_code = null; - // } - // this.openaikbService.deleteOpenaiKb(id).subscribe((deletedKb) => { - // this.logger.info("deletedKb response ", deletedKb); - // this.logger.log("deletedKb response ", deletedKb); - // this.getAllOpenaiKbs(); - // }, (error) => { - // this.logger.error("[ACTION ASKGPT] ERROR delete kb: ", error); - // }, () => { - // this.logger.info("[ACTION ASKGPT] delete kb *COMPLETE*"); - // }) - // } - - // checkKbStatus(kbid) { - // let data = { - // full_url: kbid - // } - // this.gptService.checkScrapingStatus(data).subscribe((status: any) => { - // this.spinner = false; - // this.logger.log("[ACTION ASKGPT] Scraping status: ", status); - // this.status_code = status.status_code;; - // }, (error) => { - // this.logger.error("[ACTION ASKGPT] error getting scraping status: ", error); - // }, () => { - // this.logger.log("[ACTION ASKGPT] get scraping status *COMPLETE*") - // }) - // } - - // startKbIndexing() { - - // this.spinner = true; - // if (!this.action.gptkey) { - // this.indexing_hint = "Missing GPT Key" - // this.spinner = false; - // } else { - // let data = { - // full_url: this.action.kbid, - // gptkey: this.action.gptkey - // } - - // this.gptService.startScraping(data).subscribe((response: any) => { - // if (response.message === 'Invalid Openai API key') { - // this.indexing_hint = response.message; - // } - // this.checkKbStatus(this.action.kbid); - // }, (error) => { - // this.logger.error("[ACTION ASKGPT] error start indexing: ", error); - // this.indexing_hint = error.message; - // this.spinner = false; - // }, () => { - // this.logger.log("[ACTION ASKGPT] start indexing *COMPLETE*"); - // }) - // } - // } - - // checkLimit() { - // if (this.kbs_list.length >= 3) { - // this.buttonDisabled = true; - // this.buttonIcon = null; - // this.buttonText = "Maximum number of Knwoledge Bases reached" - // } else { - // this.buttonDisabled = false; - // this.buttonIcon = "add"; - // this.buttonText = "Add Knowledge Bases" - // } - // } - } diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-function/cds-action-assign-function.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-function/cds-action-assign-function.component.scss index d431417e..4e8e7f74 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-function/cds-action-assign-function.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-function/cds-action-assign-function.component.scss @@ -30,12 +30,6 @@ gap: 10px; } -.title-label { - color: white; - font-size: 18px; - margin-bottom: 0px; - -} .material-icons{ color: $icon-color; diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/cds-action-assign-variable.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/cds-action-assign-variable.component.scss index 5b8797e4..f1a7858a 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/cds-action-assign-variable.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/cds-action-assign-variable.component.scss @@ -1,17 +1,5 @@ @import "./src/assets/sass/cds/_variables.scss"; -.content-action { - margin-top: 10px; - height: 50px; - // float: left; - width: calc(100% - 250px); -} - -.content { - padding: 20px 0 30px 0; - margin-left: 30px; - margin-right: 30px; -} .text-editor-wrapper { font-size: $font-size-base; @@ -28,19 +16,12 @@ flex-direction: column; // width: 70%; min-width: 90px; - gap: 10px; -} - -.title-label { - color: white; - font-size: 18px; - margin-bottom: 0px; - + gap: 5px; } .material-icons { - color: $icon-color; - font-size: 18px; + color: $blu; + font-size: 16px; } div.value-wrp { diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/cds-action-assign-variable.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/cds-action-assign-variable.component.ts index 31abe956..48858205 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/cds-action-assign-variable.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/cds-action-assign-variable.component.ts @@ -22,7 +22,6 @@ export class CdsActionAssignVariableComponent implements OnInit, OnChanges { TYPE_MATH_OPERATOR_LIST = TYPE_MATH_OPERATOR_LIST private logger: LoggerService = LoggerInstance.getInstance(); - constructor() { } ngOnInit(): void { diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/operand/operand.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/operand/operand.component.scss index 1c11650b..42933ee6 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/operand/operand.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/operand/operand.component.scss @@ -1,14 +1,26 @@ @import "./src/assets/sass/cds/_variables.scss"; +:host{ + --icon-color: #{$blu}; + --textColor: #{$blu}; + --backGroundColor: #{$blu-light-04}; + --hoverBackgroundColor: #{$blu-light-03}; + + --content-background: rgb(244, 246, 251, 0.4); + --border-radius-base: 8px + +} + div.operand-wrp { display: grid; align-items: center; grid-template-columns: 11fr 1fr; grid-column-gap: 0px; grid-row-gap: 10px; - background: rgb(66,85,117); + background-color: var(--content-background); + border: 1px solid $gray-light-02; padding: 10px 10px 20px; - border-radius: 5px; + border-radius: 4px; &.opened { .select-function{ display:block; @@ -20,7 +32,7 @@ div.operand-wrp { .material-icons { font-size: 25px; - color: #8ab4f8; + color: var(--icon-color); display: flex; justify-content: center; align-items: center; diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/operation/operation.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/operation/operation.component.scss index c0449f26..3b5fddde 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/operation/operation.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/operation/operation.component.scss @@ -1,9 +1,14 @@ @import "./src/assets/sass/cds/_variables.scss"; -.title-label { - color: white; - font-size: 18px; - margin-bottom: 10px; +:host{ + --icon-color: #{$blu}; + --textColor: #{$blu}; + --backGroundColor: #{$blu-light-04}; + --hoverBackgroundColor: #{$blu-light-03}; + + --content-background: rgb(244, 246, 251, 0.4); + --border-radius-base: 8px + } .block-wrp { @@ -19,17 +24,30 @@ align-items: center; justify-content: center; width: 100%; - font-weight: 600; - padding: 8px 15px; - border: 1px solid #c6cdd4; - border-radius: 4px; - color: #c6cdd4; + margin: auto; + + user-select: none; + box-sizing: border-box; + outline: none; + border: 1px dashed $blu-light-02; + border-radius: $button-border-radius-base; + color: $blu-light-02; cursor: pointer; - margin-top: 15px; + font-size: 0.7em; + font-weight: 400; + line-height: $button-height-base; + // margin: 0px 5px 0; + order: 1; + padding: 0 10px; + transition: all .3s; + min-width: 100px; + text-align: center; + width: fit-content; + &:hover{ - border-color: white; - color: white + border-color: var(--textColor); + color: var(--textColor); } } @@ -60,12 +78,10 @@ position: absolute; right: -8px; top: -14px; - + transition: opacity 0.3s ease 0s; opacity: 0; - height: 28px; width: 28px; - -webkit-box-align: center; -webkit-box-pack: center; align-items: center; @@ -73,21 +89,16 @@ cursor: pointer; display: flex; justify-content: center; - background: rgb(255, 255, 255); + background:white; border-radius: 100%; transition: background-color 0.3s ease 0s; font-size: 12px; - - span.material-icons{ + span.material-icons { font-size: 20px; - color: $icon-color; + color: var(--textColor); } - - &:hover{ - background-color: $icon-color; - span.material-icons{ - color: white; - } + &:hover { + background-color: var(--hoverBackgroundColor); } } } diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-capture-user-reply/cds-action-capture-user-reply.component.html b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-capture-user-reply/cds-action-capture-user-reply.component.html index 8bbb0491..4b9f1ea2 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-capture-user-reply/cds-action-capture-user-reply.component.html +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-capture-user-reply/cds-action-capture-user-reply.component.html @@ -64,9 +64,9 @@
- +
- Then go to block + Then go to block
diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-capture-user-reply/cds-action-capture-user-reply.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-capture-user-reply/cds-action-capture-user-reply.component.scss index b713f2ed..2ecc3b14 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-capture-user-reply/cds-action-capture-user-reply.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-capture-user-reply/cds-action-capture-user-reply.component.scss @@ -65,11 +65,6 @@ flex-direction: column; } -.title-label { - color: white; - font-size: 14px; - margin-bottom: 6px; -} div.value-wrp { position: relative; @@ -127,9 +122,3 @@ div.value-wrp { gap: 5px; padding: 3px 0px; } - -.condition-text { - font-size: 14px; - font-weight: 600; - color: white; -} \ No newline at end of file diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-capture-user-reply/cds-action-capture-user-reply.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-capture-user-reply/cds-action-capture-user-reply.component.ts index 5d26d167..a3da9a63 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-capture-user-reply/cds-action-capture-user-reply.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-capture-user-reply/cds-action-capture-user-reply.component.ts @@ -4,6 +4,7 @@ import { Intent } from 'src/app/models/intent-model'; import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'; import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'; import { ActionCaptureUserReply } from 'src/app/models/action-model'; +import { Subscription } from 'rxjs/internal/Subscription'; @Component({ selector: 'cds-action-capture-user-reply', @@ -26,9 +27,9 @@ export class CdsActionCaptureUserReplyComponent implements OnInit { idConnector: string; isConnected: boolean = false; connector: any; + private subscriptionChangedConnector: Subscription; private logger: LoggerService = LoggerInstance.getInstance(); - constructor( private intentService: IntentService ) { } @@ -36,7 +37,7 @@ export class CdsActionCaptureUserReplyComponent implements OnInit { ngOnInit(): void { this.logger.debug("[ACTION-CAPTURE-USER-REPLY] action detail: ", this.action); - this.intentService.isChangedConnector$.subscribe((connector: any) => { + this.subscriptionChangedConnector = this.intentService.isChangedConnector$.subscribe((connector: any) => { this.logger.debug('[ACTION-CAPTURE-USER-REPLY] isChangedConnector -->', connector); this.connector = connector; this.updateConnector(); @@ -44,6 +45,13 @@ export class CdsActionCaptureUserReplyComponent implements OnInit { this.initializeConnector(); } + /** */ + ngOnDestroy() { + if (this.subscriptionChangedConnector) { + this.subscriptionChangedConnector.unsubscribe(); + } + } + initializeConnector() { this.logger.debug("Intent Selected: ", this.intentSelected); this.idIntentSelected = this.intentSelected.intent_id; @@ -60,15 +68,14 @@ export class CdsActionCaptureUserReplyComponent implements OnInit { // DELETE this.action.goToIntent = null this.isConnected = false - this.updateAndSaveAction.emit(); } else { // ADD / EDIT this.isConnected = true; if(this.action.goToIntent !== "#"+this.connector.toId){ this.action.goToIntent = "#"+this.connector.toId; - this.updateAndSaveAction.emit(); } }; + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); } } catch (error) { this.logger.error('[ACTION-CAPTURE-USER-REPLY] updateConnector error: ', error); @@ -85,9 +92,9 @@ export class CdsActionCaptureUserReplyComponent implements OnInit { onChangeBlockSelect(event:{name: string, value: string}, type: string) { if(event){ this.action[type] = event.value; + this.onConnectorChange.emit({ type: 'create', fromId: this.idConnector, toId: this.action.goToIntent }); + this.updateAndSaveAction.emit(); } - this.onConnectorChange.emit({ type: 'create', fromId: this.idConnector, toId: this.action.goToIntent }); - this.updateAndSaveAction.emit(); } onResetBlockSelect(event:{name: string, value: string}, type: string) { diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-change-department/cds-action-change-department.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-change-department/cds-action-change-department.component.scss index 481168da..b1368e5b 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-change-department/cds-action-change-department.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-change-department/cds-action-change-department.component.scss @@ -24,12 +24,6 @@ min-width: 90px; } -.title-label { - color: white; - font-size: 18px; - margin-bottom: 0px; - -} // .select-bot-box { // width: 100%; diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-change-department/cds-action-change-department.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-change-department/cds-action-change-department.component.ts index 8773b4f6..6a659e45 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-change-department/cds-action-change-department.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-change-department/cds-action-change-department.component.ts @@ -20,7 +20,6 @@ export class CdsActionChangeDepartmentComponent implements OnInit { dep_selected: Department; private logger: LoggerService = LoggerInstance.getInstance(); - constructor( private departmentService: DepartmentService, ) { } @@ -31,14 +30,14 @@ export class CdsActionChangeDepartmentComponent implements OnInit { } getAllDepartments() { - this.departmentService.getDeptsByProjectId().subscribe((deps) => { + this.departmentService.getDeptsByProjectId().subscribe({ next: (deps) => { this.logger.log("[ACTION CHANGE DEPARTMENT] deps: ", deps); this.deps_name_list = deps.map(a => ({ name: a.name, value: a.name })); - }, (error) => { + }, error: (error) => { this.logger.error("[ACTION CHANGE DEPARTMENT] error get deps: ", error); - }, () => { + }, complete: () => { this.logger.log("[ACTION CHANGE DEPARTMENT] get all deps completed."); - }) + }}) } onChangeSelect(event: {name: string, value: string}) { diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-delete-variable/cds-action-delete-variable.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-delete-variable/cds-action-delete-variable.component.scss index e13c6d84..52592149 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-delete-variable/cds-action-delete-variable.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-delete-variable/cds-action-delete-variable.component.scss @@ -30,9 +30,3 @@ min-width: 90px; gap: 10px; } - -.title-label { - color: white; - font-size: 18px; - margin-bottom: 0px; -} \ No newline at end of file diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-delete-variable/cds-action-delete-variable.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-delete-variable/cds-action-delete-variable.component.ts index ce748662..848113c4 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-delete-variable/cds-action-delete-variable.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-delete-variable/cds-action-delete-variable.component.ts @@ -18,7 +18,6 @@ export class CdsActionDeleteVariableComponent implements OnInit { variableListUserDefined: Array<{name: string, value: string}>; private logger: LoggerService = LoggerInstance.getInstance(); - constructor() { } ngOnInit(): void { diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-email/cds-action-email.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-email/cds-action-email.component.scss index 872c0831..f0f06e42 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-email/cds-action-email.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-email/cds-action-email.component.scss @@ -1,13 +1,6 @@ @import "./src/assets/sass/cds/_variables.scss"; -#scrollMe { - scroll-behavior: smooth; - overflow-y: scroll; - // max-height: calc(100vh - 200px); -} - - .text-editor-wrapper { font-size: $font-size-base; position: relative; @@ -46,14 +39,6 @@ // max-width: 1400px; } -.title-label { - color: $blu; - font-size: 14px; - margin-bottom: 3px; - // margin-left: 30px; - // margin-left: 13px; -} - cds-textarea.subject-text-area ::ng-deep { textarea { diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-gpt-task/cds-action-gpt-task.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-gpt-task/cds-action-gpt-task.component.scss index efc92463..8c7d01a2 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-gpt-task/cds-action-gpt-task.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-gpt-task/cds-action-gpt-task.component.scss @@ -79,11 +79,6 @@ // gap: 10px; } -.title-label { - color: white; - font-size: 14px; - margin-bottom: 6px; -} .select-box { margin-bottom: 24px; diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-gpt-task/cds-action-gpt-task.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-gpt-task/cds-action-gpt-task.component.ts index d211ed09..a96a5613 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-gpt-task/cds-action-gpt-task.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-gpt-task/cds-action-gpt-task.component.ts @@ -5,6 +5,9 @@ import { variableList } from '../../../../../utils'; import { OpenaiService } from 'src/app/services/openai.service'; import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'; import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'; +import { MatDialog } from '@angular/material/dialog'; +import { AppConfigService } from 'src/app/services/app-config'; +import { AttributesDialogComponent } from './attributes-dialog/attributes-dialog.component'; @Component({ selector: 'cds-action-gpt-task', @@ -15,13 +18,19 @@ export class CdsActionGPTTaskComponent implements OnInit { @Input() intentSelected: Intent; @Input() action: ActionGPTTask; + @Input() project_id: string; @Input() previewMode: boolean = true; @Output() updateAndSaveAction = new EventEmitter; panelOpenState = false; - models_list = [{ name: "GPT-3 (DaVinci)", value: "text-davinci-003" }, { name: "GPT-3.5 Turbo (ChatGPT)", value: "gpt-3.5-turbo" }, { name: "GPT-4 (ChatGPT)", value: "gpt-4" }]; + models_list = [ + { name: "GPT-3 (DaVinci)", value: "text-davinci-003" }, + { name: "GPT-3.5 Turbo (ChatGPT)", value: "gpt-3.5-turbo" }, + { name: "GPT-4 (ChatGPT)", value: "gpt-4" } + ]; ai_response: string = ""; - ai_error: string = "Oops! Something went wrong. Please wait some minutes and retry." + ai_error: string = "Oops! Something went wrong. Check your GPT Key or retry in a few moment." + // ai_error: string = "Oops! Something went wrong." showPreview: boolean = false; missingVariables: boolean = true; @@ -32,14 +41,19 @@ export class CdsActionGPTTaskComponent implements OnInit { temp_variables = []; private logger: LoggerService = LoggerInstance.getInstance(); - constructor( - private openaiService: OpenaiService + private dialog: MatDialog, + private openaiService: OpenaiService, + private appConfigService: AppConfigService, ) { } ngOnInit(): void { this.logger.debug("[ACTION GPT-TASK] ngOnInit action: ", this.action); this.initializeAttributes(); + + if (!this.action.preview) { + this.action.preview = []; // per retrocompatibilità + } } ngOnChanges(changes: SimpleChanges) { @@ -59,7 +73,7 @@ export class CdsActionGPTTaskComponent implements OnInit { this.logger.debug("[ACTION GPT-TASK] changeTextarea event: ", $event); this.logger.debug("[ACTION GPT-TASK] changeTextarea propery: ", property); this.action[property] = $event; - this.checkVariables(); + // this.checkVariables(); this.updateAndSaveAction.emit(); } @@ -80,108 +94,21 @@ export class CdsActionGPTTaskComponent implements OnInit { updateSliderValue(event, target) { this.logger.debug("[ACTION GPT-TASK] updateSliderValue event: ", event) this.logger.debug("[ACTION GPT-TASK] updateSliderValue target: ", target) - - console.log("[ACTION GPT-TASK] updateSliderValue event: ", event) - console.log("[ACTION GPT-TASK] updateSliderValue target: ", target) - this.action[target] = event; - // if (event.value) { - // this.action[target] = Number(event.value); - // } else if (event) { - // this.action[target] = Number(event); - // } else { - // if (target === 'temperature') { - // this.action[target] = 0.7 - // } else { - // this.action[target] = 128 - // } - // } - - // if (target === 'max_tokens') { - // if (event) { - // if (event < 1) { - // this.action[target] = 1 - // } else if (event > 512) { - // this.action[target] = 512 - // } else { - // this.action[target] = Number(event); - // } - // } else { - // this.action[target] = 128 - // } - // } - - // if (target === 'temperature') { - // if (event) { - // if (event < 0) { - // this.action[target] = 0 - // } else if (event > 1) { - // this.action[target] = 1 - // } else { - // this.action[target] = Number(event); - // } - // } else { - // this.action[target] = 0.7 - // } - // } - this.updateAndSaveAction.emit(); } - getResponsePreview() { - - this.showPreview = true; - this.showAiError = false; - + execPreview() { this.checkVariables().then((resp) => { - if (resp === false) { - this.missingVariables = true; + if (resp === true) { + this.getResponse(this.action.question); } else { - let temp_question = this.action.question; - this.temp_variables.forEach((tv) => { - let old_value = "{{" + tv.name + "}}"; - temp_question = temp_question.replace(old_value, tv.value); - }) - - this.searching = true; - this.missingVariables = false; - - setTimeout(() => { - let element = document.getElementById("preview-container"); - element.classList.remove('preview-container-extended') - }, 200) - - let data = { - question: temp_question, - context: this.action.context, - model: this.action.model, - max_tokens: this.action.max_tokens, - temperature: this.action.temperature - } - - this.openaiService.previewPrompt(data).subscribe((ai_response: any) => { - this.searching = false; - setTimeout(() => { - let element = document.getElementById("preview-container"); - element.classList.add('preview-container-extended') - }, 200) - this.ai_response = ai_response; - }, (error) => { - this.logger.error("[ACTION GPT-TASK] previewPrompt error: ", error); - setTimeout(() => { - let element = document.getElementById("preview-container"); - element.classList.add('preview-container-extended') - }, 200) - this.showAiError = true; - this.searching = false; - }, () => { - this.logger.error("[ACTION GPT-TASK] preview prompt *COMPLETE*: "); - this.searching = false; - }) + this.openAttributesDialog(); } + }) } @@ -193,58 +120,224 @@ export class CdsActionGPTTaskComponent implements OnInit { let response: boolean = true; if (!matches || matches.length == 0) { - this.showVariablesBtn = false; - resolve(response); - } + resolve(true); - if (matches.length > 0) { - if (!this.action.preview) { - this.action.preview = []; - } - this.showVariablesBtn = true; - this.temp_variables = []; + } else { + this.temp_variables = []; matches.forEach((m) => { let name = m.slice(2, m.length - 2); let attr = this.action.preview.find(v => v.name === name); + if (attr && attr.value) { this.temp_variables.push({ name: name, value: attr.value }); + } else if (attr && !attr.value) { - response = false; this.temp_variables.push({ name: name, value: null }); + } else { - response = false; this.temp_variables.push({ name: name, value: null }); this.action.preview.push({ name: name, value: null }); } }) - resolve(response); + resolve(false); } - }) } - showHideVariablesSection() { - this.showVariablesSection = !this.showVariablesSection; - if (this.showVariablesSection == false) { - this.getResponsePreview(); + getResponse(question) { + this.logger.log("getResponse called...") + + let data = { + question: question, + context: this.action.context, + model: this.action.model, + max_tokens: this.action.max_tokens, + temperature: this.action.temperature } + + this.showAiError = false; + this.searching = true; + this.showPreview = true; + + setTimeout(() => { + let element = document.getElementById("preview-container"); + element.classList.remove('preview-container-extended') + }, 200) + + this.openaiService.previewPrompt(data).subscribe((ai_response: any) => { + this.searching = false; + setTimeout(() => { + let element = document.getElementById("preview-container"); + element.classList.add('preview-container-extended') + }, 200) + this.ai_response = ai_response; + }, (error) => { + this.searching = false; + this.logger.error("[ACTION GPT-TASK] previewPrompt error: ", error); + setTimeout(() => { + let element = document.getElementById("preview-container"); + element.classList.add('preview-container-extended') + }, 200) + this.showAiError = true; + }, () => { + this.logger.debug("[ACTION GPT-TASK] preview prompt *COMPLETE*: "); + this.searching = false; + }) + } - onChangeVar(event, name) { - let index = this.action.preview.findIndex(v => v.name === name); - if (index != -1) { - this.action.preview[index].value = event; - } - this.updateAndSaveAction.emit(); + + // getResponsePreview() { + + // this.showPreview = true; + // this.showAiError = false; + + // this.checkVariables().then((resp) => { + + // if (resp === false) { + // this.missingVariables = true; + + // } else { + // let temp_question = this.action.question; + // this.temp_variables.forEach((tv) => { + // let old_value = "{{" + tv.name + "}}"; + // temp_question = temp_question.replace(old_value, tv.value); + // }) + + // this.searching = true; + // this.missingVariables = false; + + // setTimeout(() => { + // let element = document.getElementById("preview-container"); + // element.classList.remove('preview-container-extended') + // }, 200) + + // let data = { + // question: temp_question, + // context: this.action.context, + // model: this.action.model, + // max_tokens: this.action.max_tokens, + // temperature: this.action.temperature + // } + + // this.openaiService.previewPrompt(data).subscribe((ai_response: any) => { + // this.searching = false; + // setTimeout(() => { + // let element = document.getElementById("preview-container"); + // element.classList.add('preview-container-extended') + // }, 200) + // this.ai_response = ai_response; + // }, (error) => { + // this.logger.error("[ACTION GPT-TASK] previewPrompt error: ", error); + // setTimeout(() => { + // let element = document.getElementById("preview-container"); + // element.classList.add('preview-container-extended') + // }, 200) + // this.showAiError = true; + // this.searching = false; + // }, () => { + // this.logger.error("[ACTION GPT-TASK] preview prompt *COMPLETE*: "); + // this.searching = false; + // }) + // } + // }) + // } + + // _checkVariables() { + // return new Promise((resolve, reject) => { + // let regex: RegExp = /{{[^{}]*}}/g; + // let string = this.action.question; + // let matches = string.match(regex); + // let response: boolean = true; + + // if (!matches || matches.length == 0) { + // this.showVariablesBtn = false; + // resolve(response); + // } + + // if (matches.length > 0) { + // if (!this.action.preview) { + // this.action.preview = []; + // } + // this.showVariablesBtn = true; + // this.temp_variables = []; + + // matches.forEach((m) => { + // let name = m.slice(2, m.length - 2); + // let attr = this.action.preview.find(v => v.name === name); + // if (attr && attr.value) { + // this.temp_variables.push({ name: name, value: attr.value }); + // } else if (attr && !attr.value) { + // response = false; + // this.temp_variables.push({ name: name, value: null }); + // } else { + // response = false; + // this.temp_variables.push({ name: name, value: null }); + // this.action.preview.push({ name: name, value: null }); + // } + // }) + // this.logger.log("temp_variables: ", this.temp_variables) + // resolve(response); + // } + + // }) + // } + + // showHideVariablesSection() { + // this.showVariablesSection = !this.showVariablesSection; + // if (this.showVariablesSection == false) { + // this.getResponsePreview(); + // } + // } + + // onChangeVar(event, name) { + // let index = this.action.preview.findIndex(v => v.name === name); + // if (index != -1) { + // this.action.preview[index].value = event; + // } + // this.updateAndSaveAction.emit(); + // } + + // closePreview() { + // let element = document.getElementById("preview-container"); + // element.classList.remove('preview-container-extended') + + // this.showPreview = false; + // this.searching = false; + // } + + openAttributesDialog() { + this.logger.log("temp_variables: ", this.temp_variables); + const dialogRef = this.dialog.open(AttributesDialogComponent, { + panelClass: 'custom-dialog-container', + data: { attributes: this.temp_variables, question: this.action.question } + }); + dialogRef.afterClosed().subscribe(result => { + this.logger.log("AttributesDialogComponent result: ", result); + if (result !== false) { + this.getResponse(result.question); + this.saveAttributes(result.attributes); + } + }); } - closePreview() { - let element = document.getElementById("preview-container"); - element.classList.remove('preview-container-extended') + saveAttributes(attributes) { + this.logger.log("attributes: ", attributes); + attributes.forEach(a => { + let index = this.action.preview.findIndex(v => v.name === a.name) + if (index != -1) { + this.action.preview[index].value = a.value; + } else { + this.action.preview.push({ name: a.name, value: a.value }) + } + this.updateAndSaveAction.emit(); + }) + } - this.showPreview = false; - this.searching = false; + goToKNB(){ + let url = this.appConfigService.getConfig().DASHBOARD_BASE_URL + 'dashboard/#/project/' + this.project_id +'/knowledge-bases' + window.open(url, '_blank') } diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-hide-message/cds-action-hide-message.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-hide-message/cds-action-hide-message.component.scss index 67e9e0da..e9b926e1 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-hide-message/cds-action-hide-message.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-hide-message/cds-action-hide-message.component.scss @@ -30,8 +30,3 @@ min-width: 90px; } -.title-label { - color: white; - font-size: 18px; - margin-bottom: 0px; -} diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-intent/cds-action-intent.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-intent/cds-action-intent.component.scss index e92edeba..348f6c69 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-intent/cds-action-intent.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-intent/cds-action-intent.component.scss @@ -103,11 +103,6 @@ // gap: 10px; } -.title-label { - color: $blu; - font-size: 16px; - margin-bottom: 0px; -} /** NG-SELECT **/ diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-intent/cds-action-intent.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-intent/cds-action-intent.component.ts index 04662746..1689e220 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-intent/cds-action-intent.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-intent/cds-action-intent.component.ts @@ -4,6 +4,7 @@ import { ActionIntentConnected } from 'src/app/models/action-model'; import { IntentService } from '../../../../../services/intent.service'; import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'; import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'; +import { Subscription } from 'rxjs/internal/Subscription'; @Component({ selector: 'cds-action-intent', @@ -24,9 +25,9 @@ export class CdsActionIntentComponent implements OnInit { idConnector: string; isConnected: boolean = false; connector: any; + private subscriptionChangedConnector: Subscription; private logger: LoggerService = LoggerInstance.getInstance(); - constructor( private intentService: IntentService ) { @@ -36,50 +37,66 @@ export class CdsActionIntentComponent implements OnInit { ngOnInit(): void { this.logger.log("[CDS-ACTION-INTENT] elementSelected: ", this.action, this.intentSelected) - this.intentService.isChangedConnector$.subscribe((connector: any) => { - this.logger.log('[CDS-ACTION-INTENT] - subcribe to isChangedConnector$ >>', connector); + this.subscriptionChangedConnector = this.intentService.isChangedConnector$.subscribe((connector: any) => { + // this.logger.log('[CDS-ACTION-INTENT] - subcribe to isChangedConnector$ >>', connector); this.connector = connector; this.updateConnector(); }); this.initialize(); } + /** */ + ngOnDestroy() { + if (this.subscriptionChangedConnector) { + this.subscriptionChangedConnector.unsubscribe(); + } + } + ngOnChanges(changes: SimpleChanges): void { - + console.log('[CDS-ACTION-INTENT] >> ngOnChanges', changes); + // this.checkConnectionStatus(); + } + + private checkConnectionStatus(){ + if(this.action.intentName){ + this.isConnected = true; + } else { + this.isConnected = false; + } } private initialize() { - // this.isConnected = false; + this.checkConnectionStatus(); this.idIntentSelected = this.intentSelected.intent_id; this.idConnector = this.idIntentSelected+'/'+this.action._tdActionId; this.intents = this.intentService.getListOfIntents(); this.logger.log('[CDS-ACTION-INTENT] - initialize - idIntentSelected ', this.idIntentSelected); this.logger.log('[CDS-ACTION-INTENT] - initialize - idConnector ', this.idConnector); - this.logger.log('[CDS-ACTION-INTENT] - initialize - intents ', this.intents); + // console.log('[CDS-ACTION-INTENT] - initialize - intents ', this.intents); } private updateConnector(){ - this.logger.log('[CDS-ACTION-INTENT] 1- updateConnector :: '); + this.logger.log('[CDS-ACTION-INTENT] 1- updateConnector :: ',this.action.intentName); + this.isConnected = this.action.intentName?true:false; try { const array = this.connector.fromId.split("/"); const idAction= array[1]; - this.logger.log('[CDS-ACTION-INTENT] 2 - updateConnector :: ', idAction, this.action._tdActionId); + this.logger.log('[CDS-ACTION-INTENT] 2 - updateConnector :: ', idAction, this.action._tdActionId, this.connector); if(idAction === this.action._tdActionId){ if(this.connector.deleted){ + this.logger.log('[CDS-ACTION-INTENT] 3 - PALLINO VUOTO :: '); // DELETE - this.logger.log('[CDS-ACTION-INTENT] deleteConnector :: ', this.connector.id); this.action.intentName = null; this.isConnected = false; - this.updateAndSaveAction.emit(); } else { // ADD / EDIT - console.log('[CDS-ACTION-INTENT] updateConnector :: ', this.connector.toId, this.action.intentName); + this.logger.log('[CDS-ACTION-INTENT] 4 - PALLINO PIENO :: '); this.isConnected = true; - if(this.action.intentName !== "#"+this.connector.toId){ - this.action.intentName = "#"+this.connector.toId; - this.updateAndSaveAction.emit(); - } + //if(this.action.intentName !== "#"+this.connector.toId){ + this.action.intentName = "#"+this.connector.toId; + //} } + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); } } catch (error) { this.logger.log('error: ', error); @@ -89,18 +106,18 @@ export class CdsActionIntentComponent implements OnInit { onChangeSelect(event: {name: string, value: string}){ this.logger.log('CDS-ACTION-INTENT onChangeSelect-->', event) - this.action.intentName = event.value + this.action.intentName = event.value; if(!this.action._tdActionTitle){ - this.action._tdActionTitle = this.intents.find(intent => intent.value === event.value).name + this.action._tdActionTitle = this.intents.find(intent => intent.value === event.value).name; } - this.onConnectorChange.emit({ type: 'create', fromId: this.idConnector, toId: this.action.intentName}) - this.updateAndSaveAction.emit(); + this.onConnectorChange.emit({ type: 'create', fromId: this.idConnector, toId: this.action.intentName }); + this.updateAndSaveAction.emit(this.intentSelected); } onResetSelect(event:{name: string, value: string}) { - this.onConnectorChange.emit({ type: 'delete', fromId: this.idConnector, toId: this.action.intentName}) - this.action.intentName=null - this.updateAndSaveAction.emit(); + this.onConnectorChange.emit({ type: 'delete', fromId: this.idConnector, toId: this.action.intentName }); + this.action.intentName = null; + this.updateAndSaveAction.emit(this.intentSelected); } } diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/base-filter/base-filter.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/base-filter/base-filter.component.scss index a92b544d..52755fcb 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/base-filter/base-filter.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/base-filter/base-filter.component.scss @@ -9,7 +9,6 @@ --content-background: rgb(244, 246, 251, 0.4); --border-radius-base: 8px - } .base-filter{ diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/cds-action-json-condition.component.html b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/cds-action-json-condition.component.html index c37d4c39..21f53d80 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/cds-action-json-condition.component.html +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/cds-action-json-condition.component.html @@ -29,8 +29,8 @@
-
-
+
+
diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/cds-action-json-condition.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/cds-action-json-condition.component.scss index 5857c009..27fe7cd2 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/cds-action-json-condition.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/cds-action-json-condition.component.scss @@ -8,6 +8,11 @@ --border-radius-base: 8px } +/* customize scrollbar */ +::-webkit-scrollbar { + width: 0px; +} + .previewContent{ position: relative; display: flex; diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/cds-action-json-condition.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/cds-action-json-condition.component.ts index 99530b31..a70681ca 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/cds-action-json-condition.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-json-condition/cds-action-json-condition.component.ts @@ -7,6 +7,8 @@ import { SatPopover } from '@ncstate/sat-popover'; import { IntentService } from '../../../../../services/intent.service'; import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'; import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'; +import { Subscription } from 'rxjs/internal/Subscription'; +import { ConnectorService } from 'src/app/chatbot-design-studio/services/connector.service'; @Component({ selector: 'cds-action-json-condition', @@ -35,6 +37,7 @@ export class CdsActionJsonConditionComponent implements OnInit { isConnectedTrue: boolean = false; isConnectedFalse: boolean = false; connector: any; + private subscriptionChangedConnector: Subscription; listOfIntents: Array<{name: string, value: string, icon?:string}>; @@ -42,17 +45,25 @@ export class CdsActionJsonConditionComponent implements OnInit { constructor( private formBuilder: FormBuilder, - private intentService: IntentService + private intentService: IntentService, + private connectorService: ConnectorService ) { } ngOnInit(): void { - this.intentService.isChangedConnector$.subscribe((connector: any) => { + this.subscriptionChangedConnector = this.intentService.isChangedConnector$.subscribe((connector: any) => { this.logger.log('CdsActionJsonConditionComponent isChangedConnector-->', connector); this.connector = connector; this.updateConnector(); }); } + /** */ + ngOnDestroy() { + if (this.subscriptionChangedConnector) { + this.subscriptionChangedConnector.unsubscribe(); + } + } + ngOnChanges() { this.initialize(); if(this.intentSelected){ @@ -90,16 +101,20 @@ export class CdsActionJsonConditionComponent implements OnInit { this.action.falseIntent = null this.isConnectedFalse = false; } - this.updateAndSaveAction.emit(); + // if(this.connector.notify) + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); + // this.updateAndSaveAction.emit(); } else { //TODO: verificare quale dei due connettori è stato aggiunto (controllare il valore della action corrispondente al true/false intent) // ADD / EDIT - this.logger.log(' updateConnector :: json-condition', this.connector.toId, this.connector.fromId ,this.action, array[array.length-1]); + console.log(' updateConnector :: json-condition', this.connector, this.connector.toId, this.connector.fromId ,this.action, array[array.length-1]); if(array[array.length -1] === 'true'){ // this.action.trueIntent = '#'+this.connector.toId; this.isConnectedTrue = true if(this.action.trueIntent !== '#'+this.connector.toId){ this.action.trueIntent = '#'+this.connector.toId; - this.updateAndSaveAction.emit(); + // if(this.connector.notify) + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); + // this.updateAndSaveAction.emit(); } } if(array[array.length -1] === 'false'){ @@ -107,7 +122,9 @@ export class CdsActionJsonConditionComponent implements OnInit { this.isConnectedFalse = true; if(this.action.falseIntent !== '#'+this.connector.toId){ this.action.falseIntent = '#'+this.connector.toId; - this.updateAndSaveAction.emit(); + // if(this.connector.notify) + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); + // this.updateAndSaveAction.emit(); } } } @@ -215,20 +232,21 @@ export class CdsActionJsonConditionComponent implements OnInit { onChangeForm(event:{name: string, value: string}, type : 'trueIntent' | 'falseIntent'){ if(event){ this.action[type]=event.value - } - switch(type){ - case 'trueIntent': - this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorTrue, toId: this.action.trueIntent}) - break; - case 'falseIntent': - this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorFalse, toId: this.action.falseIntent}) - break; + switch(type){ + case 'trueIntent': + this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorTrue, toId: this.action.trueIntent}) + break; + case 'falseIntent': + this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorFalse, toId: this.action.falseIntent}) + break; + } + this.updateAndSaveAction.emit(); } - this.updateAndSaveAction.emit(); } onResetBlockSelect(event:{name: string, value: string}, type: 'trueIntent' | 'falseIntent') { + console.log('onResetBlockSelect', event ) switch(type){ case 'trueIntent': this.onConnectorChange.emit({ type: 'delete', fromId: this.idConnectorTrue, toId: this.action.trueIntent}) @@ -242,7 +260,7 @@ export class CdsActionJsonConditionComponent implements OnInit { } onChangeExpression(event){ - console.log('eventtttttttt', event) + this.connectorService.updateConnector(this.intentSelected.intent_id); this.updateAndSaveAction.emit(); } diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-online-agents/cds-action-online-agents.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-online-agents/cds-action-online-agents.component.ts index 53dd84f3..70e12633 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-online-agents/cds-action-online-agents.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-online-agents/cds-action-online-agents.component.ts @@ -5,6 +5,7 @@ import { Intent } from 'src/app/models/intent-model'; import { ActionOnlineAgent } from 'src/app/models/action-model'; import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'; import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'; +import { Subscription } from 'rxjs/internal/Subscription'; @Component({ selector: 'cds-action-online-agents', @@ -30,24 +31,31 @@ export class CdsActionOnlineAgentsComponent implements OnInit { isConnectedTrue: boolean = false; isConnectedFalse: boolean = false; connector: any; + private subscriptionChangedConnector: Subscription; listOfIntents: Array<{name: string, value: string, icon?:string}>; private logger: LoggerService = LoggerInstance.getInstance(); - constructor( private formBuilder: FormBuilder, private intentService: IntentService, ) { } ngOnInit(): void { - this.intentService.isChangedConnector$.subscribe((connector: any) => { + this.subscriptionChangedConnector = this.intentService.isChangedConnector$.subscribe((connector: any) => { // console.log('CdsActionIntentComponent isChangedConnector-->', connector); this.connector = connector; this.updateConnector(); }); } + /** */ + ngOnDestroy() { + if (this.subscriptionChangedConnector) { + this.subscriptionChangedConnector.unsubscribe(); + } + } + ngOnChanges() { this.initialize(); if(this.intentSelected){ @@ -72,7 +80,7 @@ export class CdsActionOnlineAgentsComponent implements OnInit { const array = this.connector.fromId.split("/"); const idAction= array[1]; if(idAction === this.action._tdActionId){ - if(this.connector.deleted){ //TODO: verificare quale dei due connettori è stato eliminato e impostare isConnected a false + if(this.connector.deleted){ // DELETE // this.logger.log(' deleteConnector :: ', this.connector.id); // this.action.intentName = null; @@ -84,7 +92,9 @@ export class CdsActionOnlineAgentsComponent implements OnInit { this.action.falseIntent = null this.isConnectedFalse = false; } - this.updateAndSaveAction.emit(); + // if(this.connector.notify) + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); + // this.updateAndSaveAction.emit(); } else { //TODO: verificare quale dei due connettori è stato aggiunto (controllare il valore della action corrispondente al true/false intent) // ADD / EDIT this.logger.log(' updateConnector :: onlineagents', this.connector.toId, this.connector.fromId ,this.action, array[array.length-1]); @@ -92,15 +102,19 @@ export class CdsActionOnlineAgentsComponent implements OnInit { this.isConnectedTrue = true; if(this.action.trueIntent !== '#'+this.connector.toId){ this.action.trueIntent = '#'+this.connector.toId; - this.updateAndSaveAction.emit(); + // if(this.connector.notify) + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); + // this.updateAndSaveAction.emit(); } } if(array[array.length -1] === 'false'){ this.isConnectedFalse = true; if(this.action.falseIntent !== '#'+this.connector.toId){ - this.action.falseIntent = '#'+this.connector.toId - this.updateAndSaveAction.emit(); + this.action.falseIntent = '#'+this.connector.toId; + // if(this.connector.notify) + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); + // this.updateAndSaveAction.emit(); } } } @@ -143,16 +157,17 @@ export class CdsActionOnlineAgentsComponent implements OnInit { onChangeSelect(event:{name: string, value: string}, type: 'trueIntent' | 'falseIntent'){ if(event){ this.action[type]=event.value + + switch(type){ + case 'trueIntent': + this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorTrue, toId: this.action.trueIntent}) + break; + case 'falseIntent': + this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorFalse, toId: this.action.falseIntent}) + break; + } + this.updateAndSaveAction.emit(); } - switch(type){ - case 'trueIntent': - this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorTrue, toId: this.action.trueIntent}) - break; - case 'falseIntent': - this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorFalse, toId: this.action.falseIntent}) - break; - } - this.updateAndSaveAction.emit(); } onResetBlockSelect(event:{name: string, value: string}, type: 'trueIntent' | 'falseIntent') { diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-open-hours/cds-action-open-hours.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-open-hours/cds-action-open-hours.component.ts index d851834f..ace26efc 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-open-hours/cds-action-open-hours.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-open-hours/cds-action-open-hours.component.ts @@ -5,6 +5,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { IntentService } from '../../../../../services/intent.service'; import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'; import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'; +import { Subscription } from 'rxjs/internal/Subscription'; @Component({ selector: 'cds-action-open-hours', @@ -30,7 +31,8 @@ export class CdsActionOpenHoursComponent implements OnInit { isConnectedTrue: boolean = false; isConnectedFalse: boolean = false; connector: any; - + private subscriptionChangedConnector: Subscription; + listOfIntents: Array<{name: string, value: string, icon?:string}>; private logger: LoggerService = LoggerInstance.getInstance(); @@ -41,13 +43,20 @@ export class CdsActionOpenHoursComponent implements OnInit { ) { } ngOnInit(): void { - this.intentService.isChangedConnector$.subscribe((connector: any) => { + this.subscriptionChangedConnector = this.intentService.isChangedConnector$.subscribe((connector: any) => { // this.logger.log('CdsActionIntentComponent isChangedConnector-->', connector); this.connector = connector; this.updateConnector(); }); } + /** */ + ngOnDestroy() { + if (this.subscriptionChangedConnector) { + this.subscriptionChangedConnector.unsubscribe(); + } + } + ngOnChanges() { this.initialize() if(this.intentSelected){ @@ -72,35 +81,50 @@ export class CdsActionOpenHoursComponent implements OnInit { const array = this.connector.fromId.split("/"); const idAction= array[1]; if(idAction === this.action._tdActionId){ + console.log('[ACTION-OPEN-HOURS] updateConnector :: onlineagents', idAction, array[array.length -1], this.connector); if(this.connector.deleted){ //TODO: verificare quale dei due connettori è stato eliminato e impostare isConnected a false // DELETE // this.logger.log(' deleteConnector :: ', this.connector.id); // this.action.intentName = null; if(array[array.length -1] === 'true'){ - this.action.trueIntent = null - this.isConnectedTrue = false + this.action.trueIntent = null; + this.isConnectedTrue = false; + console.log('[ACTION-OPEN-HOURS] -----> DELETE TRUE :', this.connector); + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); + return; } if(array[array.length -1] === 'false'){ - this.action.falseIntent = null + this.action.falseIntent = null; this.isConnectedFalse = false; + console.log('[ACTION-OPEN-HOURS] -----> DELETE FALSE :', this.connector); + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); + return; } - this.updateAndSaveAction.emit(); + // if(this.connector.notify) + + // this.updateAndSaveAction.emit(); } else { //TODO: verificare quale dei due connettori è stato aggiunto (controllare il valore della action corrispondente al true/false intent) // ADD / EDIT - this.logger.log(' updateConnector :: onlineagents', this.connector.toId, this.connector.fromId ,this.action, array[array.length-1]); + // console.log(' -----> updateConnector :: onlineagents', this.connector.toId, this.connector.fromId ,this.action, array[array.length-1]); if(array[array.length -1] === 'true'){ this.isConnectedTrue = true; - if(this.action.trueIntent !== '#'+this.connector.toId){ + // if(this.action.trueIntent !== '#'+this.connector.toId){ this.action.trueIntent = '#'+this.connector.toId; - this.updateAndSaveAction.emit(); - } + // if(this.connector.notify) + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); + // this.updateAndSaveAction.emit(); + // } + console.log('[ACTION-OPEN-HOURS] -----> CREATE TRUE :', array[array.length -1]); } - if(array[array.length -1] === 'false'){ + else if(array[array.length -1] === 'false'){ this.isConnectedFalse = true; - if(this.action.falseIntent !== '#'+this.connector.toId){ + // if(this.action.falseIntent !== '#'+this.connector.toId){ this.action.falseIntent = '#'+this.connector.toId; - this.updateAndSaveAction.emit(); - } + // if(this.connector.notify) + if(this.connector.save)this.updateAndSaveAction.emit(this.connector); + // this.updateAndSaveAction.emit(); + // } + console.log('[ACTION-OPEN-HOURS] -----> CREATE FALSE :', array[array.length -1]); } } @@ -111,6 +135,10 @@ export class CdsActionOpenHoursComponent implements OnInit { } private initialize() { + console.log("[ACTION-OPEN-HOURS] ngOnInit"); + this.isConnectedTrue = false; + this.isConnectedFalse = false; + this.actionOpenHoursFormGroup = this.buildForm(); this.actionOpenHoursFormGroup.valueChanges.subscribe(form => { this.logger.log('[ACTION-OPEN-HOURS] form valueChanges-->', form) @@ -139,17 +167,17 @@ export class CdsActionOpenHoursComponent implements OnInit { onChangeSelect(event:{name: string, value: string}, type : 'trueIntent' | 'falseIntent'){ if(event){ this.action[type]=event.value - } - switch(type){ - case 'trueIntent': - this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorTrue, toId: this.action.trueIntent}) - break; - case 'falseIntent': - this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorFalse, toId: this.action.falseIntent}) - break; + switch(type){ + case 'trueIntent': + this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorTrue, toId: this.action.trueIntent}) + break; + case 'falseIntent': + this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorFalse, toId: this.action.falseIntent}) + break; + } + this.updateAndSaveAction.emit(); } - this.updateAndSaveAction.emit(); } onResetBlockSelect(event:{name: string, value: string}, type: 'trueIntent' | 'falseIntent') { diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-replace-bot/cds-action-replace-bot.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-replace-bot/cds-action-replace-bot.component.scss index 8f797471..fc8d039d 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-replace-bot/cds-action-replace-bot.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-replace-bot/cds-action-replace-bot.component.scss @@ -5,9 +5,3 @@ margin-left: 30px; margin-right: 30px; } - -.title-label { - color: $blu; - font-size: 16px; - margin-bottom: 0px; -} \ No newline at end of file diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/cds-action-reply.component.html b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/cds-action-reply.component.html index 7a3e5fdc..c21a52cc 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/cds-action-reply.component.html +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/cds-action-reply.component.html @@ -63,6 +63,7 @@ (createNewButton) = onCreateNewButton($event) (deleteButton) = onDeleteButton($event) (deleteActionReply) = onDeleteActionReply($event) + (updateAndSaveAction) = onUpdateAndSaveAction($event) (changeActionReply) = onChangeActionReply($event)> @@ -100,6 +101,7 @@ (createNewButton) = onCreateNewButton($event) (deleteButton) = onDeleteButton($event) (deleteActionReply) = onDeleteActionReply($event) + (updateAndSaveAction) = onUpdateAndSaveAction($event) (changeActionReply) = onChangeActionReply($event)>
@@ -198,6 +200,7 @@ (moveDownResponse) = onMoveDownResponse($event) (openButtonPanel) = onOpenButtonPanel($event) (changeActionReply) = onChangeActionReply($event) + (updateAndSaveAction) = onUpdateAndSaveAction($event) (deleteActionReply) = onDeleteActionReply($event)>
diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/cds-action-reply.component.scss b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/cds-action-reply.component.scss index 8a280d8d..b23bd0a7 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/cds-action-reply.component.scss +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/cds-action-reply.component.scss @@ -133,6 +133,7 @@ $margin-bottom: 15px; margin: 0; display: flex; flex-direction: column; + overflow: unset; // gap: 5px; } .content{ @@ -158,11 +159,6 @@ $margin-bottom: 15px; } } -#scrollMe { - scroll-behavior: smooth; - margin-bottom: 30px; - padding-bottom: 40px; -} .content { position: relative; display: block; diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/cds-action-reply.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/cds-action-reply.component.ts index 5f3c24f8..0e93cd8f 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/cds-action-reply.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/cds-action-reply.component.ts @@ -24,6 +24,7 @@ export class CdsActionReplyComponent implements OnInit { @Input() action: ActionReply; @Input() intentSelected: Intent; @Input() previewMode: boolean = true + @Output() updateIntentFromConnectorModification = new EventEmitter(); @Output() updateAndSaveAction = new EventEmitter(); @@ -68,15 +69,15 @@ export class CdsActionReplyComponent implements OnInit { // SYSTEM FUNCTIONS // ngOnInit(): void { - console.log('ActionReplyComponent ngOnInit', this.action, this.intentSelected); - // // console.log('ngOnInit panel-response::: ', this.typeAction); + this.logger.log('ActionReplyComponent ngOnInit', this.action, this.intentSelected); + // // this.logger.log('ngOnInit panel-response::: ', this.typeAction); this.typeAction = (this.action._tdActionType === TYPE_ACTION.RANDOM_REPLY ? TYPE_ACTION.RANDOM_REPLY : TYPE_ACTION.REPLY); try { this.element = Object.values(ACTIONS_LIST).find(item => item.type === this.action._tdActionType); if(this.action._tdActionTitle && this.action._tdActionTitle != ""){ this.dataInput = this.action._tdActionTitle; } - console.log('ActionDescriptionComponent action:: ', this.element); + this.logger.log('ActionDescriptionComponent action:: ', this.element); } catch (error) { this.logger.log("error ", error); } @@ -100,7 +101,7 @@ export class CdsActionReplyComponent implements OnInit { // CUSTOM FUNCTIONS // /** */ private initialize() { - console.log('initialize:::: ', this.intentSelected); + this.logger.log('initialize:::: ', this.intentSelected); this.action._tdActionId = this.action._tdActionId?this.action._tdActionId:generateShortUID(); this.idAction =this.intentSelected.intent_id+'/'+this.action._tdActionId; @@ -150,7 +151,7 @@ export class CdsActionReplyComponent implements OnInit { /** */ drop(event: CdkDragDrop) { - console.log( 'DROP REPLY ---> ',event, this.arrayResponses); + // this.logger.log( 'DROP REPLY ---> ',event, this.arrayResponses); this.textGrabbing = false; try { let currentPos = event.currentIndex*2+1; @@ -163,8 +164,8 @@ export class CdsActionReplyComponent implements OnInit { this.arrayResponses[currentPos] = msgPre; this.arrayResponses[previousPos-1] = waitCur; this.arrayResponses[previousPos] = msgCur; - // console.log( 'DROP REPLY ---> ', this.arrayResponses); - this.connectorService.movedConnector(this.intentSelected.id); + // this.logger.log( 'DROP REPLY ---> ', this.arrayResponses); + this.connectorService.updateConnector(this.intentSelected.id); this.onUpdateAndSaveAction(); } catch (error) { this.logger.log('drop ERROR', error); @@ -175,6 +176,7 @@ export class CdsActionReplyComponent implements OnInit { // on action // /** */ onMoveUpResponse(index: number) { + if(index<2)return; try { let from = index - 1; let to = from - 2; @@ -182,8 +184,8 @@ export class CdsActionReplyComponent implements OnInit { from = index; to = from - 2; this.arrayResponses.splice(to, 0, this.arrayResponses.splice(from, 1)[0]); - // console.log( 'onMoveUpResponse ---> ', this.arrayResponses); - this.connectorService.movedConnector(this.intentSelected.id); + // this.logger.log( 'onMoveUpResponse ---> ', this.arrayResponses); + this.connectorService.updateConnector(this.intentSelected.id); this.onUpdateAndSaveAction(); } catch (error) { this.logger.log('onAddNewResponse ERROR', error); @@ -192,6 +194,7 @@ export class CdsActionReplyComponent implements OnInit { /** */ onMoveDownResponse(index: number) { + if(index === this.arrayResponses.length-1)return; try { let from = index; let to = from + 2; @@ -199,8 +202,8 @@ export class CdsActionReplyComponent implements OnInit { from = index - 1; to = from + 2; this.arrayResponses.splice(to, 0, this.arrayResponses.splice(from, 1)[0]); - // console.log( 'onMoveUpResponse ---> ', this.arrayResponses); - this.connectorService.movedConnector(this.intentSelected.id); + // this.logger.log( 'onMoveUpResponse ---> ', this.arrayResponses); + this.connectorService.updateConnector(this.intentSelected.id); this.onUpdateAndSaveAction(); } catch (error) { this.logger.log('onAddNewResponse ERROR', error); @@ -210,7 +213,7 @@ export class CdsActionReplyComponent implements OnInit { /** onAddNewActionReply */ onAddNewActionReply(element) { - console.log('onAddNewActionReply: ', element); + this.logger.log('onAddNewActionReply: ', element); try { let message = new Message(element.message.type, element.message.text); if (element.message.attributes) { @@ -234,13 +237,13 @@ export class CdsActionReplyComponent implements OnInit { /** onDeleteActionReply */ onDeleteActionReply(index: number) { - console.log('onDeleteActionReply: ', this.arrayResponses[index]); + this.logger.log('onDeleteActionReply: ', this.arrayResponses[index]); // !!! cancello tutti i connettori di una action var intentId = this.idAction.substring(0, this.idAction.indexOf('/')); try { let buttons = this.arrayResponses[index].message.attributes.attachment.buttons; buttons.forEach(button => { - console.log('button: ', button); + this.logger.log('button: ', button); if(button.__isConnected){ this.connectorService.deleteConnectorFromAction(intentId, button.__idConnector); // this.connectorService.deleteConnector(button.__idConnector); @@ -249,26 +252,29 @@ export class CdsActionReplyComponent implements OnInit { } catch (error) { this.logger.log('onAddNewResponse ERROR', error); } - // cancello l'elemento wait precedente - console.log('**** arrayResponses: ', this.arrayResponses, 'index-1: ', (index-1)); + this.logger.log('**** arrayResponses: ', this.arrayResponses, 'index-1: ', (index-1)); const wait = this.arrayResponses[index-1]; - console.log('wait: ', wait); + this.logger.log('wait: ', wait); if( wait && wait.type === this.typeCommand.WAIT){ - console.log('CANCELLO WAIT E MESSAGE'); + this.logger.log('CANCELLO WAIT E MESSAGE'); this.arrayResponses.splice(index-1, 2); } else { - console.log('CANCELLO SOLO MESSAGE'); + this.logger.log('CANCELLO SOLO MESSAGE'); this.arrayResponses.splice(index, 1); } - console.log('onDeleteActionReply', this.arrayResponses); + this.logger.log('onDeleteActionReply', this.arrayResponses); this.onUpdateAndSaveAction(); } + onUpdateIntentFromConnectorModification(connectorID){ + this.updateIntentFromConnectorModification.emit(connectorID); + } + /** onChangingReplyAction */ onChangeActionReply(event) { - // console.log('onChangeActionReply ************', event); + // this.logger.log('onChangeActionReply ************', event); this.onUpdateAndSaveAction(); } @@ -278,18 +284,18 @@ export class CdsActionReplyComponent implements OnInit { /** onCreateNewButton */ onCreateNewButton(index){ - console.log('[cds-action-reply] onCreateNewButton: ', index); + this.logger.log('[cds-action-reply] onCreateNewButton: ', index); try { if(!this.arrayResponses[index].message.attributes || !this.arrayResponses[index].message.attributes.attachment){ this.arrayResponses[index].message.attributes = new MessageAttributes(); } } catch (error) { - console.log('error: ', error); + this.logger.error('error: ', error); } let buttonSelected = this.createNewButton(); if(buttonSelected){ this.arrayResponses[index].message.attributes.attachment.buttons.push(buttonSelected); - console.log('[cds-action-reply] onCreateNewButton: ', this.action, this.arrayResponses); + this.logger.log('[cds-action-reply] onCreateNewButton: ', this.action, this.arrayResponses); // this.intentService.setIntentSelected(this.intentSelected.intent_id); this.intentService.selectAction(this.intentSelected.intent_id, this.action._tdActionId); this.onUpdateAndSaveAction(); @@ -313,7 +319,7 @@ export class CdsActionReplyComponent implements OnInit { '', true ); - console.log('[cds-action-reply] createNewButton: ', buttonSelected); + this.logger.log('[cds-action-reply] createNewButton: ', buttonSelected); return buttonSelected; } return null; @@ -325,7 +331,8 @@ export class CdsActionReplyComponent implements OnInit { event.buttons.splice(event.index, 1); var intentId = this.idAction.substring(0, this.idAction.indexOf('/')); this.connectorService.deleteConnectorFromAction(intentId, button.__idConnector); - this.updateAndSaveAction.emit(); + // this.updateAndSaveAction.emit(); + this.onUpdateAndSaveAction(); } @@ -334,10 +341,10 @@ export class CdsActionReplyComponent implements OnInit { * 1 - update connectors * 2 - update intent * */ - public async onUpdateAndSaveAction() { - console.log('[cds-action-reply] onUpdateAndSaveAction:::: ', this.intentSelected, this.action); - this.connectorService.movedConnector(this.intentSelected.intent_id); - this.updateAndSaveAction.emit(this.action); + public async onUpdateAndSaveAction(connector?) { + this.logger.log('[cds-action-reply] onUpdateAndSaveAction:::: ', this.intentSelected, this.action); + this.connectorService.updateConnector(this.intentSelected.intent_id); + this.updateAndSaveAction.emit(connector); } // on intent name // @@ -361,6 +368,7 @@ export class CdsActionReplyComponent implements OnInit { onDisableInputMessage() { try { this.action.attributes.disableInputMessage = !this.action.attributes.disableInputMessage; + this.updateAndSaveAction.emit(this.action); } catch (error) { this.logger.log("Error: ", error); } @@ -369,7 +377,7 @@ export class CdsActionReplyComponent implements OnInit { /** appdashboard-button-configuration-panel: onOpenButtonPanel */ onOpenButtonPanel(buttonSelected) { - console.log('onOpenButtonPanel 2 :: ', buttonSelected); + this.logger.log('onOpenButtonPanel 2 :: ', buttonSelected); // this.intentService.setIntentSelected(this.intentSelected.intent_id); this.intentService.selectAction(this.intentSelected.intent_id, this.action._tdActionId); this.controllerService.closeAllPanels(); @@ -377,7 +385,7 @@ export class CdsActionReplyComponent implements OnInit { } onOpenPanelActionDetail(event){ - console.log('onOpenPanelActionDetail :: ', this.action); + this.logger.log('onOpenPanelActionDetail :: ', this.action); this.intentService.setIntentSelected(this.intentSelected.intent_id); this.controllerService.openActionDetailPanel(TYPE_INTENT_ELEMENT.ACTION, this.action); } diff --git a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-gallery/cds-action-reply-gallery.component.ts b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-gallery/cds-action-reply-gallery.component.ts index 12a53011..a734fc7b 100644 --- a/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-gallery/cds-action-reply-gallery.component.ts +++ b/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-gallery/cds-action-reply-gallery.component.ts @@ -7,6 +7,7 @@ import { TYPE_ACTION, TYPE_BUTTON, TYPE_URL, generateShortUID } from '../../../. import { Button, Expression, GalleryElement, Message, Wait, Metadata, MessageAttributes } from 'src/app/models/action-model'; import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'; import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'; +import { Subscription } from 'rxjs/internal/Subscription'; @Component({ selector: 'cds-action-reply-gallery', @@ -16,6 +17,8 @@ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance' export class CdsActionReplyGalleryComponent implements OnInit { @ViewChild('scrollMe', { static: false }) scrollContainer: ElementRef; + // @Output() updateIntentFromConnectorModification = new EventEmitter(); + @Output() updateAndSaveAction = new EventEmitter(); @Output() changeActionReply = new EventEmitter(); @Output() deleteActionReply = new EventEmitter(); @Output() moveUpResponse = new EventEmitter(); @@ -31,6 +34,7 @@ export class CdsActionReplyGalleryComponent implements OnInit { // Connector // idIntent: string; connector: any; + private subscriptionChangedConnector: Subscription; // Delay // delayTime: number; // Filter // @@ -42,8 +46,9 @@ export class CdsActionReplyGalleryComponent implements OnInit { // Textarea // activateEL: { [key: number]: {title: boolean, description: boolean} } = {}; // Buttons // - TYPE_BUTTON = TYPE_BUTTON; buttons: Array
-->
-
- +
+
Test your Chatbot
Start trying your chatbot and interact with it
@@ -21,7 +21,7 @@ Test it
-