Skip to content

Commit 74b76b4

Browse files
author
Nicola Lanzilotto
committed
Merge branch 'chatbot-dashboard-2'
# Conflicts: # src/app/chatbot-design-studio/cds-dashboard/panel-actions/panel-actions.component.ts # src/app/chatbot-design-studio/cds-dashboard/panel-intent-detail/panel-intent-detail.component.html # src/app/chatbot-design-studio/chatbot-design-studio.module.ts # src/app/chatbot-design-studio/utils.ts
2 parents 18db344 + 0d23650 commit 74b76b4

28 files changed

+4960
-21989
lines changed

package-lock.json

Lines changed: 4186 additions & 21929 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/chatbot-design-studio/cds-base-element/text/text.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
[matAutocomplete]="auto"
2323
[maxlength]="limitCharsText"
2424
type="text"
25+
[placeholder]="placeholder"
2526
cdkTextareaAutosize
2627
cdkAutosizeMinRows="1"
2728
cdkAutosizeMaxRows="5"
@@ -32,7 +33,7 @@
3233
<mat-option *ngFor="let option of filteredOptions | async" [value]="option">
3334
{{option}}
3435
</mat-option>
35-
</mat-autocomplete>
36+
</mat-autocomplete>
3637
</mat-form-field>
3738

3839
</div>

src/app/chatbot-design-studio/cds-base-element/text/text.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class CDSTextComponent implements OnInit {
1313
// @Input() textMessage: string;
1414
@Input() control: FormControl<string> = new FormControl()
1515
@Input() text: string;
16+
@Input() placeholder: string;
1617
@Input() customPrefix: string;
1718
@Input() limitCharsText: number = 200;
1819
@Input() autocompleteOptions: string[] = [];

src/app/chatbot-design-studio/cds-base-element/textarea/textarea.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</textarea>
1212
</mat-form-field>
1313

14-
<div class="editor-utils">
14+
<div *ngIf="showUtils === true" class="editor-utils">
1515
<div class="num-chars" [ngClass]="{'error' : alertCharsText}">{{leftCharsText}}</div>
1616
<!-- <div class="text-editor-insert-attribute">
1717
<em class="material-icons">code</em>

src/app/chatbot-design-studio/cds-base-element/textarea/textarea.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export class CDSTextareaComponent implements OnInit {
1515

1616
@Input() text: string;
1717
@Input() limitCharsText: number;
18-
@Input() control: FormControl = new FormControl;
18+
@Input() textMessage: string;
19+
@Input() control: FormControl = new FormControl();
20+
@Input() showUtils: boolean = true;
1921
@Output() change = new EventEmitter();
2022

2123
// Textarea //
@@ -25,6 +27,9 @@ export class CDSTextareaComponent implements OnInit {
2527
constructor() { }
2628

2729
ngOnInit(): void {
30+
console.log("limitCharsText: ", this.limitCharsText)
31+
console.log("showUtils: ", this.showUtils)
32+
2833
this.leftCharsText = calculatingRemainingCharacters(this.text);
2934
if(this.leftCharsText<(this.limitCharsText/10)){
3035
this.alertCharsText = true;

src/app/chatbot-design-studio/cds-dashboard/panel-actions/panel-actions.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<div class="action-box-wpr">
6666
<div class="action-box">
6767
<div class="action-btn-icon">
68-
<button class="btn btn-tdblu-no-boxshadow action-btn" (click)="actionSelected('connectintent')" disabled>
68+
<button class="btn btn-tdblu-no-boxshadow action-btn" (click)="actionSelected('intent')">
6969
<svg aria-label="ConnectIntent" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
7070
width="24px" fill="#fff">
7171
<path d="M0 0h24v24H0z" fill="none" />
@@ -285,7 +285,7 @@
285285
<div class="action-box-wpr">
286286
<div class="action-box">
287287
<div class="action-btn-icon">
288-
<button class="btn btn-tdblu-no-boxshadow action-btn" disabled>
288+
<button class="btn btn-tdblu-no-boxshadow action-btn" (click)="actionSelected('email')">
289289
<svg aria-label="SendEmail" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
290290
width="24px" fill="#FFFFFF">
291291
<path d="M0 0h24v24H0z" fill="none" />

src/app/chatbot-design-studio/cds-dashboard/panel-actions/panel-actions.component.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core';
2-
import { ActionCondition, ActionAgent, ActionClose, ActionReply, Intent, Command, Message, ActionWait} from 'app/models/intent-model';
2+
3+
import { ActionCondition, ActionAgent, ActionClose, ActionReply, Intent, Command, Message, ActionIntentConnected, ActionEmail, ActionWait } from 'app/models/intent-model';
34
import { TYPE_ACTION } from '../../utils';
45

56
@Component({
@@ -56,7 +57,6 @@ export class PanelActionsComponent implements OnInit, OnChanges {
5657
console.log('2 command: ', command)
5758
action.attributes.commands.push(command);
5859
this.intentSelected.actions.push(action);
59-
console.log('2 ', action)
6060
}
6161
if(typeAction === TYPE_ACTION.AGENT){
6262
let action = new ActionAgent();
@@ -72,6 +72,16 @@ export class PanelActionsComponent implements OnInit, OnChanges {
7272
this.intentSelected.actions.push(action);
7373
}
7474

75+
if(typeAction === TYPE_ACTION.INTENT) {
76+
let action = new ActionIntentConnected()
77+
this.intentSelected.actions.push(action)
78+
}
79+
80+
if(typeAction === TYPE_ACTION.EMAIL) {
81+
let action = new ActionEmail()
82+
this.intentSelected.actions.push(action);
83+
}
84+
7585
if(typeAction === TYPE_ACTION.CONDITION){
7686
let action = new ActionCondition();
7787
this.intentSelected.actions.push(action);

src/app/chatbot-design-studio/cds-dashboard/panel-intent-detail/actions/action-condition/action-condition.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<div class="content-condition">
99
<cds-text id="text-condition"
10-
[control]="listOfActions">
10+
[control]="actionConditionFormGroup.controls['condition']">
1111
</cds-text>
1212
</div>
1313
</div>
@@ -20,7 +20,7 @@
2020

2121
<div class="content-condition">
2222
<cds-text id="text-true"
23-
[control]=""
23+
[control]="actionConditionFormGroup.controls['trueIntent']"
2424
[autocompleteOptions]="listOfActions">
2525
</cds-text>
2626
</div>
@@ -33,7 +33,7 @@
3333

3434
<div class="content-condition">
3535
<cds-text id="text-false"
36-
[control]=""
36+
[control]="actionConditionFormGroup.controls['falseIntent']"
3737
[autocompleteOptions]="listOfActions">
3838
</cds-text>
3939
</div>

src/app/chatbot-design-studio/cds-dashboard/panel-intent-detail/actions/action-condition/action-condition.component.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
import { ActionCondition } from './../../../../../models/intent-model';
2+
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
13
import { Component, OnInit, Input } from '@angular/core';
4+
import { Console } from 'console';
5+
import { LoggerService } from 'app/services/logger/logger.service';
6+
import { throwDialogContentAlreadyAttachedError } from '@angular/cdk/dialog';
27

38
@Component({
49
selector: 'appdashboard-action-condition',
@@ -8,10 +13,44 @@ import { Component, OnInit, Input } from '@angular/core';
813
export class ActionConditionComponent implements OnInit {
914

1015
@Input() listOfActions: Array<any>;
16+
@Input() action: ActionCondition;
1117

12-
constructor() { }
18+
actionConditionFormGroup: FormGroup;
19+
20+
constructor(private formBuilder: FormBuilder,
21+
private logger: LoggerService,) { }
1322

1423
ngOnInit(): void {
24+
this.actionConditionFormGroup.valueChanges.subscribe(form => {
25+
console.log('[ACTION-CONDITION] form valueChanges-->', form)
26+
if(form && (form.condition !== '' || form.trueIntent !=='' || form.falseIntent !== ''))
27+
this.action = Object.assign(this.action, this.actionConditionFormGroup.value);
28+
})
29+
}
30+
31+
ngOnChanges(){
32+
this.actionConditionFormGroup = this.buildForm();
33+
if(this.action && this.action.condition){
34+
this.setFormValue()
35+
}
36+
37+
}
38+
39+
40+
buildForm(): FormGroup{
41+
return this.formBuilder.group({
42+
condition: ['', Validators.required],
43+
trueIntent: ['', Validators.required],
44+
falseIntent: ['', Validators.required]
45+
})
46+
}
47+
48+
setFormValue(){
49+
this.actionConditionFormGroup.patchValue({
50+
condition: this.action.condition,
51+
trueIntent: this.action.trueIntent,
52+
falseIntent: this.action.falseIntent
53+
})
1554
}
1655

1756

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<div class="content">
2+
3+
4+
<div class="text-editor-wrapper">
5+
<div class="text-editor">
6+
<div class="email-field-box">
7+
<label class="title-label">To</label>
8+
<mat-form-field class="box-textarea" appearance="fill">
9+
<input matInput type="email" placeholder="Destinatary" [(ngModel)]="action.to">
10+
<mat-hint *ngIf="email_error">Email must be valid</mat-hint>
11+
</mat-form-field>
12+
<!-- <input class="cds-input" type="email" placeholder="Destinatary" [(ngModel)]="action.to"> -->
13+
</div>
14+
</div>
15+
</div>
16+
17+
<div class="text-editor-wrapper">
18+
<div class="text-editor">
19+
<div class="email-field-box">
20+
<label class="title-label">Subject</label>
21+
<mat-form-field class="box-textarea" appearance="fill">
22+
<input matInput type="text" placeholder="Destinatary" [(ngModel)]="action.subject">
23+
</mat-form-field>
24+
<!-- <input class="cds-input" type="email" placeholder="Destinatary" [(ngModel)]="action.to"> -->
25+
</div>
26+
</div>
27+
</div>
28+
29+
<div class="email-field-box">
30+
<label class="title-label">Email body</label>
31+
<mat-form-field class="box-textarea" appearance="fill">
32+
<textarea matInput type="text" placeholder="Destinatary" rows="10" [(ngModel)]="action.text"></textarea>
33+
</mat-form-field>
34+
<!-- <input class="cds-input" type="email" placeholder="Destinatary" [(ngModel)]="action.to"> -->
35+
</div>
36+
37+
38+
39+
40+
<!-- <div>
41+
<label class="title-label">
42+
To
43+
</label>
44+
<cds-text [placeholder]="'Destinatary'" [text]="'ciao'" (change)="onToChange($event)"></cds-text>
45+
</div>
46+
47+
48+
<div>
49+
<label class="title-label">
50+
Subject
51+
</label>
52+
<cds-text [placeholder]="'Destinatary'" [text]="'ciao'" (change)="onTextChange($event)"></cds-text>
53+
</div> -->
54+
55+
56+
<!-- <div style="margin-top: 30px;">
57+
<label class="title-label"></label>
58+
<input type="email" required>
59+
</div> -->
60+
61+
62+
<!-- <label class="title-label">
63+
Go to Intent
64+
</label>
65+
66+
<div class="">
67+
<ng-select
68+
class = "form-control-select"
69+
[items] = "intents"
70+
[searchable] = true
71+
[editableSearchTerm]= true
72+
[clearable] = false
73+
[(ngModel)] = "buttonAction"
74+
(change) = "onChangeActionButton($event)">
75+
</ng-select>
76+
</div> -->
77+
78+
79+
80+
<!-- <div class="form-group ng-select" style="width: 500px;">
81+
<label class="control-label">
82+
Go to Intent
83+
</label>
84+
<div class="selectFormModel">
85+
<ng-select
86+
class = "form-control-select"
87+
[items] = "intents"
88+
[searchable] = true
89+
[clearable] = false
90+
[(ngModel)] = "buttonAction"
91+
(change) = "onChangeActionButton($event)">
92+
</ng-select>
93+
</div>
94+
</div> -->
95+
96+
<!-- <div class="form-group json-payload-textaread">
97+
<label class="control-label">
98+
JSON Payload
99+
</label>
100+
<mat-form-field class="box-textarea" appearance="fill">
101+
<textarea matInput cdkTextareaAutosize #autosize="cdkTextareaAutosize" cdkAutosizeMinRows="1"
102+
cdkAutosizeMaxRows="5">
103+
</textarea>
104+
</mat-form-field>
105+
</div> -->
106+
107+
</div>

0 commit comments

Comments
 (0)