Skip to content

Commit 30e8b2d

Browse files
author
Gabriele Panico
committed
integrated undo/redo logic and bug-fixing
1 parent 2ffa4a9 commit 30e8b2d

File tree

76 files changed

+2508
-2416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2508
-2416
lines changed

src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-askgpt/cds-action-askgpt.component.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@
7777
// gap: 10px;
7878
}
7979

80-
.title-label {
81-
color: white;
82-
font-size: 14px;
83-
margin-bottom: 6px;
84-
}
85-
8680
.select-box {
8781
margin-bottom: 24px;
8882
}

src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-askgpt/cds-action-askgpt.component.ts

Lines changed: 30 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { KnowledgeBaseService } from 'src/app/services/knowledge-base.service';
88
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
99
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
1010
import { AppConfigService } from 'src/app/services/app-config';
11+
import { Subscription } from 'rxjs/internal/Subscription';
1112

1213
@Component({
1314
selector: 'cds-action-askgpt',
@@ -32,7 +33,8 @@ export class CdsActionAskgptComponent implements OnInit {
3233
isConnectedTrue: boolean = false;
3334
isConnectedFalse: boolean = false;
3435
connector: any;
35-
36+
private subscriptionChangedConnector: Subscription;
37+
3638
kbs_list = [];
3739
kb_selected_id: string = null;
3840
status_code: number;
@@ -60,11 +62,8 @@ export class CdsActionAskgptComponent implements OnInit {
6062

6163
ngOnInit(): void {
6264
this.logger.debug("[ACTION-ASKGPT] action detail: ", this.action);
63-
console.log("[ACTION-ASKGPT] action detail: ", this.action);
64-
console.log("[ACTION-ASKGPT] action kbid: ", this.action.kbid);
65-
console.log("[ACTION-ASKGPT] action kbname: ", this.action.kbName);
6665

67-
this.intentService.isChangedConnector$.subscribe((connector: any) => {
66+
this.subscriptionChangedConnector = this.intentService.isChangedConnector$.subscribe((connector: any) => {
6867
this.logger.debug('[ACTION-ASKGPT] isChangedConnector -->', connector);
6968
this.connector = connector;
7069
this.updateConnector();
@@ -92,6 +91,13 @@ export class CdsActionAskgptComponent implements OnInit {
9291
}
9392

9493

94+
/** */
95+
ngOnDestroy() {
96+
if (this.subscriptionChangedConnector) {
97+
this.subscriptionChangedConnector.unsubscribe();
98+
}
99+
}
100+
95101
initializeConnector() {
96102
this.idIntentSelected = this.intentSelected.intent_id;
97103
this.idConnectorTrue = this.idIntentSelected+'/'+this.action._tdActionId + '/true';
@@ -114,7 +120,9 @@ export class CdsActionAskgptComponent implements OnInit {
114120
this.action.falseIntent = null
115121
this.isConnectedFalse = false;
116122
}
117-
this.updateAndSaveAction.emit();
123+
// if(this.connector.notify)
124+
if(this.connector.save)this.updateAndSaveAction.emit(this.connector);
125+
// this.updateAndSaveAction.emit();
118126
} else {
119127
// TODO: verificare quale dei due connettori è stato aggiunto (controllare il valore della action corrispondente al true/false intent)
120128
// ADD / EDIT
@@ -124,15 +132,19 @@ export class CdsActionAskgptComponent implements OnInit {
124132
this.isConnectedTrue = true;
125133
if(this.action.trueIntent !== '#'+this.connector.toId){
126134
this.action.trueIntent = '#'+this.connector.toId;
127-
this.updateAndSaveAction.emit();
135+
// if(this.connector.notify)
136+
if(this.connector.save)this.updateAndSaveAction.emit(this.connector);
137+
// this.updateAndSaveAction.emit();
128138
}
129139
}
130140
if(array[array.length -1] === 'false'){
131141
// this.action.falseIntent = '#'+this.connector.toId;
132142
this.isConnectedFalse = true;
133143
if(this.action.falseIntent !== '#'+this.connector.toId){
134144
this.action.falseIntent = '#'+this.connector.toId;
135-
this.updateAndSaveAction.emit();
145+
// if(this.connector.notify)
146+
if(this.connector.save)this.updateAndSaveAction.emit(this.connector);
147+
// this.updateAndSaveAction.emit();
136148
}
137149
}
138150
}
@@ -213,17 +225,17 @@ export class CdsActionAskgptComponent implements OnInit {
213225
onChangeBlockSelect(event:{name: string, value: string}, type: 'trueIntent' | 'falseIntent') {
214226
if(event){
215227
this.action[type]=event.value
216-
}
217228

218-
switch(type){
219-
case 'trueIntent':
220-
this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorTrue, toId: this.action.trueIntent})
221-
break;
222-
case 'falseIntent':
223-
this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorFalse, toId: this.action.falseIntent})
224-
break;
229+
switch(type){
230+
case 'trueIntent':
231+
this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorTrue, toId: this.action.trueIntent})
232+
break;
233+
case 'falseIntent':
234+
this.onConnectorChange.emit({ type: 'create', fromId: this.idConnectorFalse, toId: this.action.falseIntent})
235+
break;
236+
}
237+
this.updateAndSaveAction.emit();
225238
}
226-
this.updateAndSaveAction.emit();
227239
}
228240

229241
onResetBlockSelect(event:{name: string, value: string}, type: 'trueIntent' | 'falseIntent') {
@@ -260,7 +272,7 @@ export class CdsActionAskgptComponent implements OnInit {
260272
// }
261273

262274
goToKNB(){
263-
let url = this.appConfigService.getConfig().dashboardBaseUrl + 'dashboard/#/project/' + this.project_id +'/knowledge-bases'
275+
let url = this.appConfigService.getConfig().DASHBOARD_BASE_URL + 'dashboard/#/project/' + this.project_id +'/knowledge-bases'
264276
window.open(url, '_blank')
265277
}
266278

@@ -271,139 +283,4 @@ export class CdsActionAskgptComponent implements OnInit {
271283
}
272284
}
273285

274-
275-
// -----------------
276-
// TO CHECK / DELETE
277-
// -----------------
278-
279-
280-
// getAllOpenaiKbs() {
281-
// this.openaikbService.getAllOpenaikbs().subscribe((kbs: any[]) => {
282-
// this.kbs_list = kbs.map(t => {
283-
// t.icon = "language"
284-
// return t;
285-
// })
286-
// if (this.action.kbid) {
287-
// this.kb_selected_id = this.kbs_list.find(k => k.url === this.action.kbid)._id;
288-
// this.kb_selected_name = this.kbs_list.find(k => k.url === this.action.kbid).name;
289-
// //this.checkKbStatus(this.action.kbid);
290-
// }
291-
// //this.checkLimit();
292-
// }, (error) => {
293-
// this.logger.error("[ACTION ASKGPT] ERROR get openai kbs: ", error);
294-
// }, () => {
295-
// this.logger.info("[ACTION ASKGPT] get openai kbs *COMPLETED*");
296-
// })
297-
// }
298-
299-
// openAddKbDialog() {
300-
// const dialogRef = this.dialog.open(AddkbDialogComponent, {
301-
// panelClass: 'custom-dialog-container',
302-
// data: { name: '', url: '' }
303-
// });
304-
// dialogRef.afterClosed().subscribe(result => {
305-
// this.logger.info("[ACTION ASKGPT] Dialog result - new openai kb: ", result);
306-
// if (result && result.name && result.url) {
307-
// this.saveOpenaiKb(result);
308-
// }
309-
// });
310-
// }
311-
312-
// saveOpenaiKb(new_kb) {
313-
// this.openaikbService.addOpenaiKb(new_kb).subscribe((savedKb) => {
314-
// this.getAllOpenaiKbs();
315-
// }, (error) => {
316-
// this.logger.error("[ACTION ASKGPT] ERROR add new kb: ", error);
317-
// }, () => {
318-
// this.logger.info("[ACTION ASKGPT] add new kb *COMPLETED*");
319-
// })
320-
// }
321-
322-
// onDeleteSelect(id) {
323-
// this.openDeleteDialog(id);
324-
// }
325-
326-
// openDeleteDialog(id) {
327-
// const dialogRef = this.dialog.open(DialogYesNoComponent, {
328-
// panelClass: 'custom-dialog-container',
329-
// data: { title: 'Delete Knowledge base', text: 'Are you sure you want to delete permanently this Knwoledge base?', yes: 'Delete', no: 'Cancel' }
330-
// })
331-
// dialogRef.afterClosed().subscribe(result => {
332-
// if (result && result !== undefined && result !== false) {
333-
// this.deleteKb(id);
334-
// }
335-
// })
336-
// }
337-
338-
// deleteKb(id: string) {
339-
// if (this.kb_selected_id === id) {
340-
// this.action.kbid = null;
341-
// this.kb_selected_id = null;
342-
// this.status_code = null;
343-
// }
344-
// this.openaikbService.deleteOpenaiKb(id).subscribe((deletedKb) => {
345-
// this.logger.info("deletedKb response ", deletedKb);
346-
// this.logger.log("deletedKb response ", deletedKb);
347-
// this.getAllOpenaiKbs();
348-
// }, (error) => {
349-
// this.logger.error("[ACTION ASKGPT] ERROR delete kb: ", error);
350-
// }, () => {
351-
// this.logger.info("[ACTION ASKGPT] delete kb *COMPLETE*");
352-
// })
353-
// }
354-
355-
// checkKbStatus(kbid) {
356-
// let data = {
357-
// full_url: kbid
358-
// }
359-
// this.gptService.checkScrapingStatus(data).subscribe((status: any) => {
360-
// this.spinner = false;
361-
// this.logger.log("[ACTION ASKGPT] Scraping status: ", status);
362-
// this.status_code = status.status_code;;
363-
// }, (error) => {
364-
// this.logger.error("[ACTION ASKGPT] error getting scraping status: ", error);
365-
// }, () => {
366-
// this.logger.log("[ACTION ASKGPT] get scraping status *COMPLETE*")
367-
// })
368-
// }
369-
370-
// startKbIndexing() {
371-
372-
// this.spinner = true;
373-
// if (!this.action.gptkey) {
374-
// this.indexing_hint = "Missing GPT Key"
375-
// this.spinner = false;
376-
// } else {
377-
// let data = {
378-
// full_url: this.action.kbid,
379-
// gptkey: this.action.gptkey
380-
// }
381-
382-
// this.gptService.startScraping(data).subscribe((response: any) => {
383-
// if (response.message === 'Invalid Openai API key') {
384-
// this.indexing_hint = response.message;
385-
// }
386-
// this.checkKbStatus(this.action.kbid);
387-
// }, (error) => {
388-
// this.logger.error("[ACTION ASKGPT] error start indexing: ", error);
389-
// this.indexing_hint = error.message;
390-
// this.spinner = false;
391-
// }, () => {
392-
// this.logger.log("[ACTION ASKGPT] start indexing *COMPLETE*");
393-
// })
394-
// }
395-
// }
396-
397-
// checkLimit() {
398-
// if (this.kbs_list.length >= 3) {
399-
// this.buttonDisabled = true;
400-
// this.buttonIcon = null;
401-
// this.buttonText = "Maximum number of Knwoledge Bases reached"
402-
// } else {
403-
// this.buttonDisabled = false;
404-
// this.buttonIcon = "add";
405-
// this.buttonText = "Add Knowledge Bases"
406-
// }
407-
// }
408-
409286
}

src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-function/cds-action-assign-function.component.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
gap: 10px;
3131
}
3232

33-
.title-label {
34-
color: white;
35-
font-size: 18px;
36-
margin-bottom: 0px;
37-
38-
}
3933

4034
.material-icons{
4135
color: $icon-color;

src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/cds-action-assign-variable.component.scss

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
@import "./src/assets/sass/cds/_variables.scss";
22

3-
.content-action {
4-
margin-top: 10px;
5-
height: 50px;
6-
// float: left;
7-
width: calc(100% - 250px);
8-
}
9-
10-
.content {
11-
padding: 20px 0 30px 0;
12-
margin-left: 30px;
13-
margin-right: 30px;
14-
}
153

164
.text-editor-wrapper {
175
font-size: $font-size-base;
@@ -28,19 +16,12 @@
2816
flex-direction: column;
2917
// width: 70%;
3018
min-width: 90px;
31-
gap: 10px;
32-
}
33-
34-
.title-label {
35-
color: white;
36-
font-size: 18px;
37-
margin-bottom: 0px;
38-
19+
gap: 5px;
3920
}
4021

4122
.material-icons {
42-
color: $icon-color;
43-
font-size: 18px;
23+
color: $blu;
24+
font-size: 16px;
4425
}
4526

4627
div.value-wrp {

src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/cds-action-assign-variable.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export class CdsActionAssignVariableComponent implements OnInit, OnChanges {
2222
TYPE_MATH_OPERATOR_LIST = TYPE_MATH_OPERATOR_LIST
2323

2424
private logger: LoggerService = LoggerInstance.getInstance();
25-
2625
constructor() { }
2726

2827
ngOnInit(): void {

src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-assign-variable/operand/operand.component.scss

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
@import "./src/assets/sass/cds/_variables.scss";
22

3+
:host{
4+
--icon-color: #{$blu};
5+
--textColor: #{$blu};
6+
--backGroundColor: #{$blu-light-04};
7+
--hoverBackgroundColor: #{$blu-light-03};
8+
9+
--content-background: rgb(244, 246, 251, 0.4);
10+
--border-radius-base: 8px
11+
12+
}
13+
314
div.operand-wrp {
415
display: grid;
516
align-items: center;
617
grid-template-columns: 11fr 1fr;
718
grid-column-gap: 0px;
819
grid-row-gap: 10px;
9-
background: rgb(66,85,117);
20+
background-color: var(--content-background);
21+
border: 1px solid $gray-light-02;
1022
padding: 10px 10px 20px;
11-
border-radius: 5px;
23+
border-radius: 4px;
1224
&.opened {
1325
.select-function{
1426
display:block;
@@ -20,7 +32,7 @@ div.operand-wrp {
2032

2133
.material-icons {
2234
font-size: 25px;
23-
color: #8ab4f8;
35+
color: var(--icon-color);
2436
display: flex;
2537
justify-content: center;
2638
align-items: center;

0 commit comments

Comments
 (0)