From 2b88befb359ce7f03ed338126a2d69987244febf Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 5 Jul 2021 12:29:27 +0200 Subject: [PATCH 01/56] [SAFE-411] init + get form object --- .../pages/forms/forms.component.html | 6 +++- .../dashboard/pages/forms/forms.component.ts | 12 ++++++- .../safe/src/lib/services/download.service.ts | 33 +++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/forms/forms.component.html b/projects/back-office/src/app/dashboard/pages/forms/forms.component.html index 52d4f1721b..cc79d522e5 100644 --- a/projects/back-office/src/app/dashboard/pages/forms/forms.component.html +++ b/projects/back-office/src/app/dashboard/pages/forms/forms.component.html @@ -179,6 +179,10 @@ delete Delete + @@ -188,4 +192,4 @@ [ngClass]="{'clickable': ( row.canCreate && (row.status === 'active') )}" [routerLink]="( row.canCreate && (row.status === 'active') ) ? ['/forms/answer', row.id] : []"> - \ No newline at end of file + diff --git a/projects/back-office/src/app/dashboard/pages/forms/forms.component.ts b/projects/back-office/src/app/dashboard/pages/forms/forms.component.ts index cefc9942ab..b49d2a2fcb 100644 --- a/projects/back-office/src/app/dashboard/pages/forms/forms.component.ts +++ b/projects/back-office/src/app/dashboard/pages/forms/forms.component.ts @@ -19,6 +19,7 @@ import { AddFormComponent } from '../../../components/add-form/add-form.componen import { MatTableDataSource } from '@angular/material/table'; import { MatSort } from '@angular/material/sort'; import { MatEndDate, MatStartDate } from '@angular/material/datepicker'; +import {SafeDownloadService} from '../../../../../../safe/src/lib/services/download.service'; @Component({ @@ -57,7 +58,8 @@ export class FormsComponent implements OnInit, OnDestroy, AfterViewInit { public dialog: MatDialog, private router: Router, private snackBar: SafeSnackBarService, - private authService: SafeAuthService + private authService: SafeAuthService, + private downloadService: SafeDownloadService ) {} /* Load the forms. @@ -191,4 +193,12 @@ export class FormsComponent implements OnInit, OnDestroy, AfterViewInit { this.coreFilter = ''; this.clearDateFilter(); } + + async onExportAssistant(element: any, $event: any): Promise { + console.log(element); + const path = `download/form/test/${element.id}`; + const dataReturn = await this.downloadService.getForm(path); + window.open('/test'); + // return dataReturn; + } } diff --git a/projects/safe/src/lib/services/download.service.ts b/projects/safe/src/lib/services/download.service.ts index ffaa257423..22ad01828c 100644 --- a/projects/safe/src/lib/services/download.service.ts +++ b/projects/safe/src/lib/services/download.service.ts @@ -43,4 +43,37 @@ export class SafeDownloadService { link.click(); setTimeout(() => link.remove(), 0); } + + async getForm(path: string): Promise { + // const url = `${this.baseUrl}/download/form/${id}`; + const url = path.startsWith('http') ? path : `${this.baseUrl}/${path}`; + const token = localStorage.getItem('msal.idtoken'); + const headers = new HttpHeaders({ + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + }); + // console.log(url); + // console.log(headers); + let response; + let reason; + await this.http.get(url, { headers }).toPromise().then((res) => { + response = res; + }).catch((reas => {console.log(reas); reason = reas; })); + // console.log(response); + // console.log(reason); + let dataReturn = null; + if (reason == null) { + dataReturn = { + status: true, + data: response + }; + } + else { + dataReturn = { + status: false, + data: reason + }; + } + return dataReturn; + } } From 6e473b2980c1a1491e01edc4c1389115956765e6 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 5 Jul 2021 12:37:44 +0200 Subject: [PATCH 02/56] [SAFE-411] code cleaning --- .../src/app/dashboard/pages/forms/forms.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/back-office/src/app/dashboard/pages/forms/forms.component.ts b/projects/back-office/src/app/dashboard/pages/forms/forms.component.ts index b49d2a2fcb..02798b2a38 100644 --- a/projects/back-office/src/app/dashboard/pages/forms/forms.component.ts +++ b/projects/back-office/src/app/dashboard/pages/forms/forms.component.ts @@ -196,7 +196,7 @@ export class FormsComponent implements OnInit, OnDestroy, AfterViewInit { async onExportAssistant(element: any, $event: any): Promise { console.log(element); - const path = `download/form/test/${element.id}`; + const path = `download/form/${element.id}`; const dataReturn = await this.downloadService.getForm(path); window.open('/test'); // return dataReturn; From 0167ceb00a242b1bc5460fcac687e6df39177e81 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 5 Jul 2021 16:17:13 +0200 Subject: [PATCH 03/56] [SAFE-411] new virtual-assistant component (opened in a new tab) --- .../back-office/src/app/app-routing.module.ts | 20 ++++++++++- .../dashboard/pages/forms/forms.component.ts | 7 ++-- .../virtual-assistant.component.html | 1 + .../virtual-assistant.component.scss | 0 .../virtual-assistant.component.spec.ts | 25 +++++++++++++ .../virtual-assistant.component.ts | 36 +++++++++++++++++++ .../virtual-assistant.module.ts | 12 +++++++ 7 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.spec.ts create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts diff --git a/projects/back-office/src/app/app-routing.module.ts b/projects/back-office/src/app/app-routing.module.ts index 5d4bf2dad1..17955a4c1b 100644 --- a/projects/back-office/src/app/app-routing.module.ts +++ b/projects/back-office/src/app/app-routing.module.ts @@ -2,6 +2,7 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { MsalGuard } from '@azure/msal-angular'; import { AccessGuard } from './guards/access.guard'; +import {VirtualAssistantComponent} from './dashboard/pages/virtual-assistant/virtual-assistant.component'; const routes: Routes = [ { @@ -31,7 +32,24 @@ const routes: Routes = [ .then(m => m.AppPreviewModule), } ] - } + }, + // { + // path: 'va', + // loadChildren: () => import('../../../safe/src/lib/components/virtual-assistant') + // .then(m => m.Virtual), + // }, + { + path: 'va', + // component: VaComponent + children: [ + { + path: ':id', + component: VirtualAssistantComponent + // loadChildren: () => import('./dashboard/pages/va/va.module') + // .then(m => m.VaModule), + } + ] + }, ], canActivate: [MsalGuard, AccessGuard] }, diff --git a/projects/back-office/src/app/dashboard/pages/forms/forms.component.ts b/projects/back-office/src/app/dashboard/pages/forms/forms.component.ts index 02798b2a38..de05b0b7b0 100644 --- a/projects/back-office/src/app/dashboard/pages/forms/forms.component.ts +++ b/projects/back-office/src/app/dashboard/pages/forms/forms.component.ts @@ -196,9 +196,10 @@ export class FormsComponent implements OnInit, OnDestroy, AfterViewInit { async onExportAssistant(element: any, $event: any): Promise { console.log(element); - const path = `download/form/${element.id}`; - const dataReturn = await this.downloadService.getForm(path); - window.open('/test'); + // const path = `download/form/${element.id}`; + // const dataReturn = await this.downloadService.getForm(path); + window.open(`/va/${element.id}`); + // this.router.navigate([`/va/${element.id}`]); // return dataReturn; } } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html new file mode 100644 index 0000000000..0fd65a8f71 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html @@ -0,0 +1 @@ +

virtual-assistant works!

diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.spec.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.spec.ts new file mode 100644 index 0000000000..344b3a0746 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { VirtualAssistantComponent } from './virtual-assistant.component'; + +describe('VirtualAssistantComponent', () => { + let component: VirtualAssistantComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ VirtualAssistantComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(VirtualAssistantComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts new file mode 100644 index 0000000000..26c2870e72 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts @@ -0,0 +1,36 @@ +import { Component, OnInit } from '@angular/core'; +import {Subscription} from 'rxjs'; +import {ActivatedRoute} from '@angular/router'; +import {SafeDownloadService} from '../../../../../../safe/src/lib/services/download.service'; + +@Component({ + selector: 'app-virtual-assistant', + templateUrl: './virtual-assistant.component.html', + styleUrls: ['./virtual-assistant.component.scss'] +}) +export class VirtualAssistantComponent implements OnInit { + + // === DATA === + public id = ''; + + // === ROUTE === + private routeSubscription?: Subscription; + + constructor(private route: ActivatedRoute, private downloadService: SafeDownloadService) { } + + ngOnInit(): void { + this.routeSubscription = this.route.params.subscribe((params) => { + this.id = params.id; + console.log('this.id'); + console.log(this.id); + this.getForm(); + }); + } + + async getForm(): Promise{ + const path = `download/form/${this.id}`; + const dataReturn = await this.downloadService.getForm(path); + console.log('dataReturn'); + console.log(dataReturn); + } +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts new file mode 100644 index 0000000000..cffc8db557 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts @@ -0,0 +1,12 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import {VirtualAssistantComponent} from './virtual-assistant.component'; + +@NgModule({ + declarations: [VirtualAssistantComponent], + imports: [ + CommonModule, + ], + exports: [VirtualAssistantComponent] +}) +export class VirtualAssistantModule { } From 8bce5c6606857805ed91d0b052d61e628ab889b3 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 5 Jul 2021 18:06:39 +0200 Subject: [PATCH 04/56] [SAFE-411] routing-module problems fixed + starting page design --- .../back-office/src/app/app-routing.module.ts | 11 +++-------- .../virtual-assistant-routing.module.ts | 16 ++++++++++++++++ .../virtual-assistant.component.html | 12 ++++++++++++ .../virtual-assistant.component.scss | 3 +++ .../virtual-assistant.module.ts | 8 ++++++++ 5 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant-routing.module.ts diff --git a/projects/back-office/src/app/app-routing.module.ts b/projects/back-office/src/app/app-routing.module.ts index 17955a4c1b..b1562376d2 100644 --- a/projects/back-office/src/app/app-routing.module.ts +++ b/projects/back-office/src/app/app-routing.module.ts @@ -33,20 +33,15 @@ const routes: Routes = [ } ] }, - // { - // path: 'va', - // loadChildren: () => import('../../../safe/src/lib/components/virtual-assistant') - // .then(m => m.Virtual), - // }, { path: 'va', // component: VaComponent children: [ { path: ':id', - component: VirtualAssistantComponent - // loadChildren: () => import('./dashboard/pages/va/va.module') - // .then(m => m.VaModule), + // component: VirtualAssistantComponent + loadChildren: () => import('./dashboard/pages/virtual-assistant/virtual-assistant.module') + .then(m => m.VirtualAssistantModule), } ] }, diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant-routing.module.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant-routing.module.ts new file mode 100644 index 0000000000..8914cf2e70 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant-routing.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import {VirtualAssistantComponent} from './virtual-assistant.component'; + +const routes: Routes = [ + { + path: '', + component: VirtualAssistantComponent + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class VirtualAssistantRoutingModule { } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html index 0fd65a8f71..abc480537c 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html @@ -1 +1,13 @@

virtual-assistant works!

+ + + + + + + + + + + + diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss index e69de29bb2..1b93a72f24 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss @@ -0,0 +1,3 @@ +#va-face { + height: 250px; +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts index cffc8db557..591113e99a 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts @@ -1,11 +1,19 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import {VirtualAssistantComponent} from './virtual-assistant.component'; +import {VirtualAssistantRoutingModule} from './virtual-assistant-routing.module'; +import {MatIconModule} from '@angular/material/icon'; +import {MatButtonModule} from '@angular/material/button'; +import {MatGridListModule} from '@angular/material/grid-list'; @NgModule({ declarations: [VirtualAssistantComponent], imports: [ CommonModule, + VirtualAssistantRoutingModule, + MatIconModule, + MatButtonModule, + MatGridListModule ], exports: [VirtualAssistantComponent] }) From a097ab05885edbbbc892c15025bcf08303190794 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Tue, 6 Jul 2021 17:37:36 +0200 Subject: [PATCH 05/56] [SAFE-411] interface --- .../virtual-assistant/models/message.model.ts | 25 ++++ .../virtual-assistant/models/user.model.ts | 9 ++ .../conversation-footer.component.html | 5 + .../conversation-footer.component.scss | 32 +++++ .../conversation-footer.component.spec.ts | 25 ++++ .../conversation-footer.component.ts | 55 ++++++++ .../conversation-header.component.html | 3 + .../conversation-header.component.scss | 14 +++ .../conversation-header.component.spec.ts | 25 ++++ .../conversation-header.component.ts | 15 +++ .../conversation-message.component.html | 30 +++++ .../conversation-message.component.scss | 31 +++++ .../conversation-message.component.spec.ts | 25 ++++ .../conversation-message.component.ts | 59 +++++++++ .../va-conversation.component.html | 9 ++ .../va-conversation.component.scss | 11 ++ .../va-conversation.component.spec.ts | 25 ++++ .../va-conversation.component.ts | 118 ++++++++++++++++++ .../virtual-assistant.component.html | 25 +++- .../virtual-assistant.component.ts | 45 ++++++- .../virtual-assistant.module.ts | 10 +- 21 files changed, 585 insertions(+), 11 deletions(-) create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/models/message.model.ts create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/models/user.model.ts create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.spec.ts create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.html create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.scss create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.spec.ts create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.ts create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.spec.ts create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.scss create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.spec.ts create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/message.model.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/message.model.ts new file mode 100644 index 0000000000..4b0f6d206d --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/message.model.ts @@ -0,0 +1,25 @@ +import { User } from './user.model'; + +export class Message { + type: string; + text: string; + reply: string; + user: User; + date: number; + choices: string[]; + + // tslint:disable-next-line:max-line-length + constructor(type: string, + text: string, + reply: string, + user: User, + date: number, + choices: string[]) { + this.type = type; + this.text = text; + this.reply = reply; + this.user = user; + this.date = date; + this.choices = choices; + } +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/user.model.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/user.model.ts new file mode 100644 index 0000000000..12aa02e5d7 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/user.model.ts @@ -0,0 +1,9 @@ +export class User { + name: string; + avatar: string; + + constructor(name: string, avatar: string) { + this.name = name; + this.avatar = avatar; + } +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html new file mode 100644 index 0000000000..5d04de2792 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html @@ -0,0 +1,5 @@ + diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss new file mode 100644 index 0000000000..372aecdb4a --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss @@ -0,0 +1,32 @@ +#footer { + background-color: #269ed1; + height: 50px; + border-top: 1px solid lightgray; + border-radius: 0 0 5px 5px; +} + +#inputMsg { + height: 30px; + margin-top: 7px; + margin-left: 5px; + width: 390px; + border: 1px solid lightgray; + border-radius: 5px; + padding-left: 5px; +} + +.btnFoot { + //height: 30px; + //width: 30px; + margin-left: 10px; +} + +#btnSend { + background-color: green; + color: white; +} + +#btnRec { + background-color: indianred; + color: white; +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.spec.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.spec.ts new file mode 100644 index 0000000000..815d8161c2 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ConversationFooterComponent } from './conversation-footer.component'; + +describe('ConversationFooterComponent', () => { + let component: ConversationFooterComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ConversationFooterComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ConversationFooterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts new file mode 100644 index 0000000000..b6763804a6 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts @@ -0,0 +1,55 @@ +import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges} from '@angular/core'; + +@Component({ + selector: 'app-conversation-footer', + templateUrl: './conversation-footer.component.html', + styleUrls: ['./conversation-footer.component.scss'] +}) + +export class ConversationFooterComponent implements OnInit, OnChanges { + + @Output() btnSendClick: EventEmitter = new EventEmitter(); + @Output() btnRecClick: EventEmitter = new EventEmitter(); + + @Output() inputChange: EventEmitter = new EventEmitter(); + + public input: any; + public btnSend: any; + public btnRec: any; + + @Input() inputValue = ''; + + ngOnChanges(changes: SimpleChanges): void { + // we skip that at the beginning when object are not yet set + if (this.input !== undefined){ + this.msgChange(changes.inputValue.currentValue); + this.input.focus(); + } + } + + constructor() { + } + + ngOnInit(): void { + this.input = document.getElementById('inputMsg'); + this.btnSend = document.getElementById('btnSend'); + this.btnRec = document.getElementById('btnRec'); + } + + msgChange(text: string): void { + this.inputChange.emit(text); + if (text === ''){ + this.btnSend.setAttribute('disabled', ''); + this.btnSend.setAttribute('style', 'display: none'); + + this.btnRec.removeAttribute('disabled'); + this.btnRec.setAttribute('style', 'display: inline'); + } else { + this.btnRec.setAttribute('disabled', ''); + this.btnRec.setAttribute('style', 'display: none'); + + this.btnSend.removeAttribute('disabled'); + this.btnSend.setAttribute('style', 'display: inline'); + } + } +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.html new file mode 100644 index 0000000000..b330f61b39 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.html @@ -0,0 +1,3 @@ + diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.scss new file mode 100644 index 0000000000..76b1b684d5 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.scss @@ -0,0 +1,14 @@ +#header { + height: 50px; + border-radius: 5px 5px 0 0; + background-color: #60d295; + display: flex; + align-items: center; + padding: 0px 0px 0px 0px; + color: white; +} + +#convName { + display: inline; + margin-left: 10px; +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.spec.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.spec.ts new file mode 100644 index 0000000000..0d1dc60a6f --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ConversationHeaderComponent } from './conversation-header.component'; + +describe('ConversationHeaderComponent', () => { + let component: ConversationHeaderComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ConversationHeaderComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ConversationHeaderComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.ts new file mode 100644 index 0000000000..b7d91b779c --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-conversation-header', + templateUrl: './conversation-header.component.html', + styleUrls: ['./conversation-header.component.scss'] +}) +export class ConversationHeaderComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html new file mode 100644 index 0000000000..0b8a6c5c3a --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+ +
+ profile_photo +

+
+
+ +
+ profile_photo +

+
+
+
+ +
+ + + + + diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss new file mode 100644 index 0000000000..864095d6d5 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss @@ -0,0 +1,31 @@ +#messageGlobal{ + display: flex; + align-items: center; + width: fit-content; + padding: 5px; + border-radius: 15px; + margin-left: 0; + margin-right: auto; + margin-bottom: 10px; +} + +img { + display: inline; + height: 40px; + width:40px; + border-radius: 100px; +} + +p { + display: inline; + margin-left: 10px; + color: white; +} + +.btnChoice { + margin-right: 5px; +} + +#btnsChoices { + +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.spec.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.spec.ts new file mode 100644 index 0000000000..35223bfbee --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ConversationMessageComponent } from './conversation-message.component'; + +describe('ConversationMessageComponent', () => { + let component: ConversationMessageComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ConversationMessageComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ConversationMessageComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts new file mode 100644 index 0000000000..00ad614af0 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -0,0 +1,59 @@ +import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; + +@Component({ + selector: 'app-conversation-message', + templateUrl: './conversation-message.component.html', + styleUrls: ['./conversation-message.component.scss'] +}) +export class ConversationMessageComponent implements OnInit { + + @Input() imgSrc = ''; + + @Input() backgroundColor = ''; + + @Input() backgroundColorReply = ''; + + @Input() text = ''; + + @Input() reply = ''; + + @Input() + choices: string[] = []; + + @Output() btnChoiceClick: EventEmitter = new EventEmitter(); + + public ml = ''; + public mr = ''; + + constructor() { + console.log(this.choices); + // this.imgSrc = environment.profilePhotoDefault; + } + + ngOnInit(): void { + const msg = document.getElementById('messageGlobal'); + if (msg !== null) { + console.log(this.reply); + if (this.reply === 'true'){ + console.log('REPLY 1'); + // document.getElementById('messageGlobal').style.backgroundColor = this.backgroundColorReply; + this.ml = 'auto'; + this.mr = '0'; + console.log('REPLY 2'); + + } else { + // document.getElementById('messageGlobal').style.backgroundColor = this.backgroundColor; + this.ml = '0'; + this.mr = 'auto'; + console.log('NOT REPLY'); + } + } + } + + btnChoiceClickFn($event: any , ch: string): void{ + this.btnChoiceClick.emit(ch); + console.log('$event.target'); + $event.target.parentElement.setAttribute('style', 'display: none'); + } + +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html new file mode 100644 index 0000000000..129928b085 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html @@ -0,0 +1,9 @@ +
+ +
+ + + +
+ +
diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.scss new file mode 100644 index 0000000000..b2cf24b46d --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.scss @@ -0,0 +1,11 @@ +#chat-global { + height: 400px; + border-radius: 5px; + box-shadow: 0 5px 5px 2px gray; + background-color: white; +} + +.example-viewport { + height: 300px; + width: 800px; +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.spec.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.spec.ts new file mode 100644 index 0000000000..192370ecec --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { VaConversationComponent } from './va-conversation.component'; + +describe('VaConversationComponent', () => { + let component: VaConversationComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ VaConversationComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(VaConversationComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts new file mode 100644 index 0000000000..2952390f8f --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts @@ -0,0 +1,118 @@ +import {Component, Input, OnInit, ViewChild} from '@angular/core'; +import {CdkVirtualScrollViewport} from '@angular/cdk/scrolling'; +import {Message} from '../models/message.model'; +import {User} from '../models/user.model'; + +@Component({ + selector: 'app-va-conversation', + templateUrl: './va-conversation.component.html', + styleUrls: ['./va-conversation.component.scss'] +}) +export class VaConversationComponent implements OnInit { + + @Input() form: any[] = []; + + items: string[] = []; + public currentText: string; + @ViewChild(CdkVirtualScrollViewport) viewport: any; + + public messages: Message[] = []; + + constructor() { + this.currentText = ''; + console.log(this.messages); + // this.viewport = new CdkVirtualScrollViewport(); + } + + + ngOnInit(): void { + console.log('this.form'); + console.log(this.form); + // this.speechToTextService.endSpeechEvent.subscribe( + // (text) => { + // this.currentText = text; + // } + // ); + // this.controllerService.botReplied.subscribe( + // () => { + // this.updateScrollViewPos(); + // } + // ); + + window.setTimeout(() => { + console.log('this.form'); + console.log(this.form); + this.sendQuestionMsg(this.form[0].name); + }, 5000); + } + + msgUpdated(msg: any): void{ + if (typeof msg === 'string'){ + this.currentText = msg; + } + } + + sendReplyMsg(msg: string): void { + this.currentText = msg; + if (this.currentText !== '') { + this.addMsg('', + this.currentText, + 'true', + new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), + Date.now(), + []); + console.log(this.messages); + } + this.currentText = ''; + this.updateScrollViewPos(); + } + + sendQuestionMsg(msg: string): void { + this.currentText = msg; + if (this.currentText !== '') { + this.addMsg('', + this.currentText, + 'false', + new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), + Date.now(), + []); + console.log(this.messages); + } + this.currentText = ''; + this.updateScrollViewPos(); + } + + addMsg(type: string, + text: string, + reply: string, + user: User, + date: number, + choices: string[]): void { + this.messages.push(new Message(type, text, reply, user, date, choices)); + } + + updateScrollViewPos(): void { + setTimeout(() => { + this.viewport.scrollTo({ + bottom: 0, + behavior: 'auto', + }); + }, 0); + setTimeout(() => { + this.viewport.scrollTo({ + bottom: 0, + behavior: 'auto', + }); + }, 50); + } + + startSpeech(): void { + // this.speechToTextService.start(); + } + + choiceClick(e: any): void{ + console.log(e); + this.sendReplyMsg(e); + } + +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html index abc480537c..0aabf3014f 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html @@ -1,13 +1,26 @@ -

virtual-assistant works!

- - + + - + + + + + + + + + + + + + + + - - + + diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts index 26c2870e72..af98b7677e 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts @@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core'; import {Subscription} from 'rxjs'; import {ActivatedRoute} from '@angular/router'; import {SafeDownloadService} from '../../../../../../safe/src/lib/services/download.service'; +import {User} from './models/user.model'; +import {Message} from './models/message.model'; @Component({ selector: 'app-virtual-assistant', @@ -12,11 +14,18 @@ export class VirtualAssistantComponent implements OnInit { // === DATA === public id = ''; + public form: any; + public iQuestion: any; + public messages: any; + public vaCols: number; // === ROUTE === private routeSubscription?: Subscription; - constructor(private route: ActivatedRoute, private downloadService: SafeDownloadService) { } + constructor(private route: ActivatedRoute, private downloadService: SafeDownloadService) { + this.vaCols = 6; + this.iQuestion = 0; + } ngOnInit(): void { this.routeSubscription = this.route.params.subscribe((params) => { @@ -30,7 +39,37 @@ export class VirtualAssistantComponent implements OnInit { async getForm(): Promise{ const path = `download/form/${this.id}`; const dataReturn = await this.downloadService.getForm(path); - console.log('dataReturn'); - console.log(dataReturn); + if (dataReturn.status === true) { + this.form = dataReturn.data; + + // this.addMsg(this.form[0].type, + // this.form[0].name, + // 'false', + // new User('assistant', 'https://www.pngarts.com/files/11/Avatar-PNG-Transparent-Image.png'), + // Date.now(), + // []); + + // for (const m of this.form){ + // this.addMsg(m.type, + // m.name, + // 'false', + // new User('assistant', 'https://www.pngarts.com/files/11/Avatar-PNG-Transparent-Image.png'), + // Date.now(), + // null); + // } + } + else { + // problem with the form + } + } + + onChatButton(event: any): void { + console.log('onChatButton'); + if (this.vaCols !== 6) { + this.vaCols = 6; + } + else { + this.vaCols = 12; + } } } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts index 591113e99a..d35470c2fc 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts @@ -5,15 +5,21 @@ import {VirtualAssistantRoutingModule} from './virtual-assistant-routing.module' import {MatIconModule} from '@angular/material/icon'; import {MatButtonModule} from '@angular/material/button'; import {MatGridListModule} from '@angular/material/grid-list'; +import {ScrollingModule} from '@angular/cdk/scrolling'; +import { VaConversationComponent } from './va-conversation/va-conversation.component'; +import {ConversationHeaderComponent} from './va-conversation/conversation-header/conversation-header.component'; +import {ConversationMessageComponent} from './va-conversation/conversation-message/conversation-message.component'; +import {ConversationFooterComponent} from './va-conversation/conversation-footer/conversation-footer.component'; @NgModule({ - declarations: [VirtualAssistantComponent], + declarations: [VirtualAssistantComponent, VaConversationComponent, ConversationHeaderComponent, ConversationMessageComponent, ConversationFooterComponent], imports: [ CommonModule, VirtualAssistantRoutingModule, MatIconModule, MatButtonModule, - MatGridListModule + MatGridListModule, + ScrollingModule ], exports: [VirtualAssistantComponent] }) From 76400dfb210dc058fdcd18d5c8d287b946073fc1 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Wed, 7 Jul 2021 11:37:44 +0200 Subject: [PATCH 06/56] [SAFE-411] conversation works (style: Bottom) --- .../conversation-message.component.html | 18 ++-------------- .../conversation-message.component.scss | 2 +- .../conversation-message.component.ts | 6 +++--- .../va-conversation.component.html | 2 +- .../va-conversation.component.scss | 13 +++++++++--- .../virtual-assistant.component.html | 21 +++++++++++-------- .../virtual-assistant.component.scss | 13 ++++++++++++ .../virtual-assistant.component.ts | 5 +++-- .../virtual-assistant.module.ts | 6 +++++- 9 files changed, 50 insertions(+), 36 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html index 0b8a6c5c3a..716dbded11 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html @@ -1,21 +1,12 @@ - - - - - - - - -
-
+
profile_photo

-
+
profile_photo

@@ -23,8 +14,3 @@
- - - - - diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss index 864095d6d5..4528ea007d 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss @@ -1,4 +1,4 @@ -#messageGlobal{ +.messageGlobal{ display: flex; align-items: center; width: fit-content; diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index 00ad614af0..4f77389c6d 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -31,18 +31,18 @@ export class ConversationMessageComponent implements OnInit { } ngOnInit(): void { - const msg = document.getElementById('messageGlobal'); + const msg = document.getElementsByClassName('messageGlobal'); if (msg !== null) { console.log(this.reply); if (this.reply === 'true'){ console.log('REPLY 1'); - // document.getElementById('messageGlobal').style.backgroundColor = this.backgroundColorReply; + // document.getElementsByClassName('messageGlobal').style.backgroundColor = this.backgroundColorReply; this.ml = 'auto'; this.mr = '0'; console.log('REPLY 2'); } else { - // document.getElementById('messageGlobal').style.backgroundColor = this.backgroundColor; + // document.getElementsByClassName('messageGlobal').style.backgroundColor = this.backgroundColor; this.ml = '0'; this.mr = 'auto'; console.log('NOT REPLY'); diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html index 129928b085..4423b4389c 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html @@ -2,7 +2,7 @@
- +
diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.scss index b2cf24b46d..259e2ab133 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.scss +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.scss @@ -1,11 +1,18 @@ #chat-global { - height: 400px; + height: 100%; + box-sizing: border-box; border-radius: 5px; box-shadow: 0 5px 5px 2px gray; background-color: white; } +#conversation { + //height: 100px; + height: calc(100% - 100px); +} + .example-viewport { - height: 300px; - width: 800px; + //height: 300px; + width: 100%; + height: 100%; } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html index 0aabf3014f..2133b7914f 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html @@ -1,25 +1,28 @@ - - + + + - + - + - - + + + + - + - + - + diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss index 1b93a72f24..5dc6907e30 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss @@ -1,3 +1,16 @@ #va-face { height: 250px; } +#conversation .mat-figure { + top: 0; + left: 0; + right: 0; + bottom: 0; + position: absolute; + display: block !important ; + align-items: flex-start; + justify-content: flex-start; + height: 100%; + padding: 0; + margin: 0; +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts index af98b7677e..27aa3dfaba 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, OnInit, ViewEncapsulation} from '@angular/core'; import {Subscription} from 'rxjs'; import {ActivatedRoute} from '@angular/router'; import {SafeDownloadService} from '../../../../../../safe/src/lib/services/download.service'; @@ -8,7 +8,8 @@ import {Message} from './models/message.model'; @Component({ selector: 'app-virtual-assistant', templateUrl: './virtual-assistant.component.html', - styleUrls: ['./virtual-assistant.component.scss'] + styleUrls: ['./virtual-assistant.component.scss'], + encapsulation: ViewEncapsulation.None }) export class VirtualAssistantComponent implements OnInit { diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts index d35470c2fc..9fef03a3f3 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts @@ -12,7 +12,11 @@ import {ConversationMessageComponent} from './va-conversation/conversation-messa import {ConversationFooterComponent} from './va-conversation/conversation-footer/conversation-footer.component'; @NgModule({ - declarations: [VirtualAssistantComponent, VaConversationComponent, ConversationHeaderComponent, ConversationMessageComponent, ConversationFooterComponent], + declarations: [VirtualAssistantComponent, + VaConversationComponent, + ConversationHeaderComponent, + ConversationMessageComponent, + ConversationFooterComponent], imports: [ CommonModule, VirtualAssistantRoutingModule, From 1da2200166aef6dcb5b40e9e5805bb9eb733102a Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Wed, 7 Jul 2021 11:40:35 +0200 Subject: [PATCH 07/56] [SAFE-411] conversation works (+ style top right) --- .../virtual-assistant.component.html | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html index 2133b7914f..e78eeeeb08 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html @@ -1,27 +1,18 @@ - + - + + - - - - - - - - - - - - + + From 9f5ddf6187f72120969bbb88c17c8aa2d17a4812 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Wed, 7 Jul 2021 13:15:13 +0200 Subject: [PATCH 08/56] [SAFE-411] showing questions --- .../conversation-footer.component.scss | 3 ++ .../conversation-header.component.scss | 1 - .../conversation-message.component.ts | 3 -- .../va-conversation.component.ts | 40 ++++++++++++++----- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss index 372aecdb4a..14a108cfb9 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss @@ -3,6 +3,9 @@ height: 50px; border-top: 1px solid lightgray; border-radius: 0 0 5px 5px; + //align-content: center; + text-align: center; + //align-items: center; } #inputMsg { diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.scss index 76b1b684d5..fda5d35839 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.scss +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.scss @@ -4,7 +4,6 @@ background-color: #60d295; display: flex; align-items: center; - padding: 0px 0px 0px 0px; color: white; } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index 4f77389c6d..6ab41be23a 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -35,17 +35,14 @@ export class ConversationMessageComponent implements OnInit { if (msg !== null) { console.log(this.reply); if (this.reply === 'true'){ - console.log('REPLY 1'); // document.getElementsByClassName('messageGlobal').style.backgroundColor = this.backgroundColorReply; this.ml = 'auto'; this.mr = '0'; - console.log('REPLY 2'); } else { // document.getElementsByClassName('messageGlobal').style.backgroundColor = this.backgroundColor; this.ml = '0'; this.mr = 'auto'; - console.log('NOT REPLY'); } } } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts index 2952390f8f..d5a1f4e46f 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts @@ -11,23 +11,25 @@ import {User} from '../models/user.model'; export class VaConversationComponent implements OnInit { @Input() form: any[] = []; + public records: any[] = []; - items: string[] = []; public currentText: string; @ViewChild(CdkVirtualScrollViewport) viewport: any; public messages: Message[] = []; + public iCurrentQuestion: number; constructor() { this.currentText = ''; console.log(this.messages); + this.iCurrentQuestion = 0; // this.viewport = new CdkVirtualScrollViewport(); } + + ngOnInit(): void { - console.log('this.form'); - console.log(this.form); // this.speechToTextService.endSpeechEvent.subscribe( // (text) => { // this.currentText = text; @@ -39,11 +41,20 @@ export class VaConversationComponent implements OnInit { // } // ); - window.setTimeout(() => { - console.log('this.form'); + // window.setTimeout(() => { + // console.log('this.form'); + // console.log(this.form); + // this.sendQuestionMsg(this.form[0].name); + // }, 5000); + } + + ngOnChanges(): void{ + console.log('ngAfterContentInit'); + if (this.form !== undefined) { + console.log('*this.form*'); console.log(this.form); - this.sendQuestionMsg(this.form[0].name); - }, 5000); + this.sendQuestionMsg(); + } } msgUpdated(msg: any): void{ @@ -65,10 +76,20 @@ export class VaConversationComponent implements OnInit { } this.currentText = ''; this.updateScrollViewPos(); + + this.sendQuestionMsg(); } - sendQuestionMsg(msg: string): void { - this.currentText = msg; + sendQuestionMsg(): void { + if (this.iCurrentQuestion < this.form.length){ + console.log('sendQuestionMsg'); + console.log(this.iCurrentQuestion); + console.log(this.form.length); + this.currentText = this.form[this.iCurrentQuestion].name; + } + else { + this.currentText = 'Form finished'; + } if (this.currentText !== '') { this.addMsg('', this.currentText, @@ -77,6 +98,7 @@ export class VaConversationComponent implements OnInit { Date.now(), []); console.log(this.messages); + this.iCurrentQuestion++; } this.currentText = ''; this.updateScrollViewPos(); From 0d4fec721b79baba3ee20da2f3491e56a488b7fb Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Wed, 7 Jul 2021 15:10:03 +0200 Subject: [PATCH 09/56] [SAFE-411] console log --- projects/safe/src/lib/services/download.service.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/safe/src/lib/services/download.service.ts b/projects/safe/src/lib/services/download.service.ts index 22ad01828c..b2dcfca730 100644 --- a/projects/safe/src/lib/services/download.service.ts +++ b/projects/safe/src/lib/services/download.service.ts @@ -58,6 +58,8 @@ export class SafeDownloadService { let reason; await this.http.get(url, { headers }).toPromise().then((res) => { response = res; + console.log('res'); + console.log(res); }).catch((reas => {console.log(reas); reason = reas; })); // console.log(response); // console.log(reason); From fdf9bf6c94d3e98604de2e7570629b9d62e99491 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Wed, 7 Jul 2021 15:13:51 +0200 Subject: [PATCH 10/56] [SAFE-411] test --- projects/safe/src/lib/services/download.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/safe/src/lib/services/download.service.ts b/projects/safe/src/lib/services/download.service.ts index b2dcfca730..e12b8e6400 100644 --- a/projects/safe/src/lib/services/download.service.ts +++ b/projects/safe/src/lib/services/download.service.ts @@ -52,7 +52,7 @@ export class SafeDownloadService { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` }); - // console.log(url); + console.log(url); // console.log(headers); let response; let reason; From 8cf4c3a0b46797777b96e20fc61064ad92c9913e Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Wed, 7 Jul 2021 18:10:46 +0200 Subject: [PATCH 11/56] [SAFE-411] form object + other issues fixed --- .../va-conversation/va-conversation.component.ts | 2 +- .../virtual-assistant/virtual-assistant.component.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts index d5a1f4e46f..5fa9f01482 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts @@ -85,7 +85,7 @@ export class VaConversationComponent implements OnInit { console.log('sendQuestionMsg'); console.log(this.iCurrentQuestion); console.log(this.form.length); - this.currentText = this.form[this.iCurrentQuestion].name; + this.currentText = this.form[this.iCurrentQuestion].title; } else { this.currentText = 'Form finished'; diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts index 27aa3dfaba..c6e98b635f 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts @@ -40,8 +40,16 @@ export class VirtualAssistantComponent implements OnInit { async getForm(): Promise{ const path = `download/form/${this.id}`; const dataReturn = await this.downloadService.getForm(path); + console.log('dataReturn'); + console.log(dataReturn); if (dataReturn.status === true) { - this.form = dataReturn.data; + console.log(JSON.parse(dataReturn.data.structure)); + this.form = JSON.parse(dataReturn.data.structure).pages[0].elements; + console.log('this.form'); + console.log(this.form); + // this.form = dataReturn.data; + + // JSON.parse(form.structure).pages[0].elements // this.addMsg(this.form[0].type, // this.form[0].name, From 05d67272c4cf6e22e1ee3a331643df34d4441a31 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Thu, 8 Jul 2021 10:50:13 +0200 Subject: [PATCH 12/56] [SAFE-411] message display + style --- .../conversation-footer.component.scss | 1 - .../conversation-message.component.html | 2 +- .../conversation-message.component.ts | 1 - .../va-conversation.component.ts | 56 ++++++++++--------- .../virtual-assistant.component.ts | 6 +- .../safe/src/lib/services/download.service.ts | 4 +- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss index 14a108cfb9..904724ff8a 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss @@ -1,5 +1,4 @@ #footer { - background-color: #269ed1; height: 50px; border-top: 1px solid lightgray; border-radius: 0 0 5px 5px; diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html index 716dbded11..120bdacdc8 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html @@ -12,5 +12,5 @@
- +
diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index 6ab41be23a..8db4ec1dfe 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -52,5 +52,4 @@ export class ConversationMessageComponent implements OnInit { console.log('$event.target'); $event.target.parentElement.setAttribute('style', 'display: none'); } - } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts index 5fa9f01482..3122924e81 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, OnInit, ViewChild} from '@angular/core'; +import {Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from '@angular/core'; import {CdkVirtualScrollViewport} from '@angular/cdk/scrolling'; import {Message} from '../models/message.model'; import {User} from '../models/user.model'; @@ -8,7 +8,7 @@ import {User} from '../models/user.model'; templateUrl: './va-conversation.component.html', styleUrls: ['./va-conversation.component.scss'] }) -export class VaConversationComponent implements OnInit { +export class VaConversationComponent implements OnInit, OnChanges { @Input() form: any[] = []; public records: any[] = []; @@ -23,12 +23,8 @@ export class VaConversationComponent implements OnInit { this.currentText = ''; console.log(this.messages); this.iCurrentQuestion = 0; - // this.viewport = new CdkVirtualScrollViewport(); } - - - ngOnInit(): void { // this.speechToTextService.endSpeechEvent.subscribe( // (text) => { @@ -48,7 +44,7 @@ export class VaConversationComponent implements OnInit { // }, 5000); } - ngOnChanges(): void{ + ngOnChanges(changes: SimpleChanges): void{ console.log('ngAfterContentInit'); if (this.form !== undefined) { console.log('*this.form*'); @@ -64,44 +60,54 @@ export class VaConversationComponent implements OnInit { } sendReplyMsg(msg: string): void { - this.currentText = msg; - if (this.currentText !== '') { + if (msg !== '') { this.addMsg('', - this.currentText, + msg, 'true', new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), Date.now(), []); console.log(this.messages); - } - this.currentText = ''; - this.updateScrollViewPos(); - this.sendQuestionMsg(); + // reset input text + this.currentText = ''; + + this.updateScrollViewPos(); + + this.sendQuestionMsg(); + } } sendQuestionMsg(): void { + console.log('this.currentText'); + console.log(this.currentText); + let nextQuest = ''; if (this.iCurrentQuestion < this.form.length){ - console.log('sendQuestionMsg'); console.log(this.iCurrentQuestion); console.log(this.form.length); - this.currentText = this.form[this.iCurrentQuestion].title; - } - else { - this.currentText = 'Form finished'; - } - if (this.currentText !== '') { + nextQuest = this.form[this.iCurrentQuestion].title; + this.addMsg('', - this.currentText, + nextQuest, 'false', new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), Date.now(), []); - console.log(this.messages); + } + else if (this.iCurrentQuestion === this.form.length) { + nextQuest = 'Thank you for your time, bye!'; + + this.addMsg('', + nextQuest, + 'false', + new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), + Date.now(), + ['restart']); + } + if (this.iCurrentQuestion <= this.form.length){ this.iCurrentQuestion++; + this.updateScrollViewPos(); } - this.currentText = ''; - this.updateScrollViewPos(); } addMsg(type: string, diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts index c6e98b635f..2a9b6c2a76 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts @@ -2,8 +2,6 @@ import {Component, OnInit, ViewEncapsulation} from '@angular/core'; import {Subscription} from 'rxjs'; import {ActivatedRoute} from '@angular/router'; import {SafeDownloadService} from '../../../../../../safe/src/lib/services/download.service'; -import {User} from './models/user.model'; -import {Message} from './models/message.model'; @Component({ selector: 'app-virtual-assistant', @@ -40,10 +38,8 @@ export class VirtualAssistantComponent implements OnInit { async getForm(): Promise{ const path = `download/form/${this.id}`; const dataReturn = await this.downloadService.getForm(path); - console.log('dataReturn'); - console.log(dataReturn); if (dataReturn.status === true) { - console.log(JSON.parse(dataReturn.data.structure)); + // console.log(JSON.parse(dataReturn.data.structure)); this.form = JSON.parse(dataReturn.data.structure).pages[0].elements; console.log('this.form'); console.log(this.form); diff --git a/projects/safe/src/lib/services/download.service.ts b/projects/safe/src/lib/services/download.service.ts index e12b8e6400..6676662d14 100644 --- a/projects/safe/src/lib/services/download.service.ts +++ b/projects/safe/src/lib/services/download.service.ts @@ -58,8 +58,8 @@ export class SafeDownloadService { let reason; await this.http.get(url, { headers }).toPromise().then((res) => { response = res; - console.log('res'); - console.log(res); + // console.log('res'); + // console.log(res); }).catch((reas => {console.log(reas); reason = reas; })); // console.log(response); // console.log(reason); From f153b004dc3762c53d856cb454e3ddcc9425a752 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Thu, 8 Jul 2021 12:20:59 +0200 Subject: [PATCH 13/56] [SAFE-411] conversation + records works --- .../conversation-message.component.ts | 9 +- .../va-conversation.component.html | 2 +- .../va-conversation.component.ts | 102 ++++++++++++------ 3 files changed, 75 insertions(+), 38 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index 8db4ec1dfe..83ee424220 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -26,21 +26,17 @@ export class ConversationMessageComponent implements OnInit { public mr = ''; constructor() { - console.log(this.choices); // this.imgSrc = environment.profilePhotoDefault; } ngOnInit(): void { const msg = document.getElementsByClassName('messageGlobal'); if (msg !== null) { - console.log(this.reply); if (this.reply === 'true'){ - // document.getElementsByClassName('messageGlobal').style.backgroundColor = this.backgroundColorReply; this.ml = 'auto'; this.mr = '0'; - - } else { - // document.getElementsByClassName('messageGlobal').style.backgroundColor = this.backgroundColor; + } + else { this.ml = '0'; this.mr = 'auto'; } @@ -49,7 +45,6 @@ export class ConversationMessageComponent implements OnInit { btnChoiceClickFn($event: any , ch: string): void{ this.btnChoiceClick.emit(ch); - console.log('$event.target'); $event.target.parentElement.setAttribute('style', 'display: none'); } } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html index 4423b4389c..96070c150e 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html @@ -2,7 +2,7 @@
- +
diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts index 3122924e81..ce3940d344 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts @@ -12,17 +12,26 @@ export class VaConversationComponent implements OnInit, OnChanges { @Input() form: any[] = []; public records: any[] = []; + public currentRecord: any; public currentText: string; @ViewChild(CdkVirtualScrollViewport) viewport: any; - public messages: Message[] = []; + public conv: Message[] = []; public iCurrentQuestion: number; + public endConv: boolean; + public endConvMsg: string; + constructor() { this.currentText = ''; - console.log(this.messages); + this.iCurrentQuestion = 0; + + this.endConvMsg = 'restart'; + this.endConv = false; + + this.currentRecord = {}; } ngOnInit(): void { @@ -45,10 +54,7 @@ export class VaConversationComponent implements OnInit, OnChanges { } ngOnChanges(changes: SimpleChanges): void{ - console.log('ngAfterContentInit'); if (this.form !== undefined) { - console.log('*this.form*'); - console.log(this.form); this.sendQuestionMsg(); } } @@ -60,33 +66,54 @@ export class VaConversationComponent implements OnInit, OnChanges { } sendReplyMsg(msg: string): void { - if (msg !== '') { - this.addMsg('', - msg, - 'true', - new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), - Date.now(), - []); - console.log(this.messages); - - // reset input text - this.currentText = ''; - - this.updateScrollViewPos(); - - this.sendQuestionMsg(); + if (!this.endConv){ + if (msg !== '') { + this.addMsg('', + msg, + 'true', + new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), + Date.now(), + []); + console.log(this.conv); + + // this.records.push(msg); + // complete current record + // -1 because the chat start with a message of the bot + this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = msg; + console.log(this.currentRecord); + console.log(this.iCurrentQuestion); + + console.log(this.records); + + // reset input text + this.currentText = ''; + + this.updateScrollViewPos(); + + this.sendQuestionMsg(); + } } } + sendReplyMsgEnd(): void { + if (this.endConvMsg !== '') { + this.addMsg('', + this.endConvMsg, + 'true', + new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), + Date.now(), + []); + // reset input text + this.currentText = ''; + this.updateScrollViewPos(); + this.sendQuestionMsg(); + } + } + sendQuestionMsg(): void { - console.log('this.currentText'); - console.log(this.currentText); let nextQuest = ''; if (this.iCurrentQuestion < this.form.length){ - console.log(this.iCurrentQuestion); - console.log(this.form.length); nextQuest = this.form[this.iCurrentQuestion].title; - this.addMsg('', nextQuest, 'false', @@ -96,13 +123,16 @@ export class VaConversationComponent implements OnInit, OnChanges { } else if (this.iCurrentQuestion === this.form.length) { nextQuest = 'Thank you for your time, bye!'; + this.endConv = true; + // add this record + this.records.push(this.currentRecord); this.addMsg('', nextQuest, 'false', new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), Date.now(), - ['restart']); + [this.endConvMsg]); } if (this.iCurrentQuestion <= this.form.length){ this.iCurrentQuestion++; @@ -116,7 +146,7 @@ export class VaConversationComponent implements OnInit, OnChanges { user: User, date: number, choices: string[]): void { - this.messages.push(new Message(type, text, reply, user, date, choices)); + this.conv.push(new Message(type, text, reply, user, date, choices)); } updateScrollViewPos(): void { @@ -138,9 +168,21 @@ export class VaConversationComponent implements OnInit, OnChanges { // this.speechToTextService.start(); } - choiceClick(e: any): void{ - console.log(e); - this.sendReplyMsg(e); + choiceClick(choice: any): void{ + console.log(choice); + if (choice === this.endConvMsg){ + this.endConv = false; + this.sendReplyMsgEnd(); + this.iCurrentQuestion = 0; + this.currentRecord = {}; + window.setTimeout(() => { + this.sendQuestionMsg(); + }, 500); + } + else { + this.sendReplyMsg(choice); + } + } } From 3119be7f1bd79b4d7019b1a02c39b5f1a77dd09d Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Thu, 8 Jul 2021 13:13:39 +0200 Subject: [PATCH 14/56] [SAFE-411] add question controller --- .../va-conversation.component.html | 2 +- .../va-conversation.component.ts | 99 ++++++++++--------- .../virtual-assistant.component.html | 37 ++++--- .../virtual-assistant.component.scss | 2 +- 4 files changed, 78 insertions(+), 62 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html index 96070c150e..cd921ad630 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html @@ -5,5 +5,5 @@
- + diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts index ce3940d344..b3576054cc 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts @@ -55,7 +55,7 @@ export class VaConversationComponent implements OnInit, OnChanges { ngOnChanges(changes: SimpleChanges): void{ if (this.form !== undefined) { - this.sendQuestionMsg(); + this.sendNextQuestion(); } } @@ -65,37 +65,34 @@ export class VaConversationComponent implements OnInit, OnChanges { } } - sendReplyMsg(msg: string): void { - if (!this.endConv){ - if (msg !== '') { - this.addMsg('', - msg, - 'true', - new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), - Date.now(), - []); - console.log(this.conv); - - // this.records.push(msg); - // complete current record - // -1 because the chat start with a message of the bot - this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = msg; - console.log(this.currentRecord); - console.log(this.iCurrentQuestion); + sendReplyMsgText(msg: string): void { + if (!this.endConv && msg !== ''){ + this.addMsg('', + msg, + 'true', + new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), + Date.now(), + []); + console.log(this.conv); - console.log(this.records); + // this.records.push(msg); + // complete current record + // -1 because the chat start with a message of the bot + this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = msg; - // reset input text - this.currentText = ''; + // reset input text + this.currentText = ''; - this.updateScrollViewPos(); + this.updateScrollViewPos(); - this.sendQuestionMsg(); - } + this.sendNextQuestion(); } + // else if (msg === this.endConvMsg){ + // this.restartForm(); + // } } - sendReplyMsgEnd(): void { + sendReplyMsgTextEnd(): void { if (this.endConvMsg !== '') { this.addMsg('', this.endConvMsg, @@ -106,40 +103,45 @@ export class VaConversationComponent implements OnInit, OnChanges { // reset input text this.currentText = ''; this.updateScrollViewPos(); - this.sendQuestionMsg(); + this.sendNextQuestion(); } } - sendQuestionMsg(): void { - let nextQuest = ''; + sendNextQuestion(): void { if (this.iCurrentQuestion < this.form.length){ - nextQuest = this.form[this.iCurrentQuestion].title; - this.addMsg('', - nextQuest, - 'false', - new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), - Date.now(), - []); + this.questionController(); + this.iCurrentQuestion++; + this.updateScrollViewPos(); } else if (this.iCurrentQuestion === this.form.length) { - nextQuest = 'Thank you for your time, bye!'; this.endConv = true; // add this record this.records.push(this.currentRecord); + console.log(this.records); this.addMsg('', - nextQuest, + 'Thank you for your time, bye!', 'false', new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), Date.now(), [this.endConvMsg]); - } - if (this.iCurrentQuestion <= this.form.length){ this.iCurrentQuestion++; this.updateScrollViewPos(); } } + questionController(): void { + switch (this.form[this.iCurrentQuestion].type){ + case 'text': + this.addMsg('', + this.form[this.iCurrentQuestion].title, + 'false', + new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), + Date.now(), + []); + } + } + addMsg(type: string, text: string, reply: string, @@ -171,18 +173,21 @@ export class VaConversationComponent implements OnInit, OnChanges { choiceClick(choice: any): void{ console.log(choice); if (choice === this.endConvMsg){ - this.endConv = false; - this.sendReplyMsgEnd(); - this.iCurrentQuestion = 0; - this.currentRecord = {}; - window.setTimeout(() => { - this.sendQuestionMsg(); - }, 500); + this.restartForm(); } else { - this.sendReplyMsg(choice); + this.sendReplyMsgText(choice); } + } + restartForm(): void { + this.endConv = false; + this.sendReplyMsgTextEnd(); + this.iCurrentQuestion = 0; + this.currentRecord = {}; + window.setTimeout(() => { + this.sendNextQuestion(); + }, 500); } } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html index e78eeeeb08..f0281e4a2e 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html @@ -1,20 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - + + diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss index 5dc6907e30..e6279cc3e5 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss @@ -1,7 +1,7 @@ #va-face { height: 250px; } -#conversation .mat-figure { +.conversation .mat-figure { top: 0; left: 0; right: 0; From 70b9451f3efc0b94b0cc9ce6fab89eddfeef5d0c Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Thu, 8 Jul 2021 16:07:37 +0200 Subject: [PATCH 15/56] [SAFE-411] add Choices Model --- .../virtual-assistant/models/choices.model.ts | 9 +++++++++ .../virtual-assistant/models/message.model.ts | 5 +++-- .../conversation-message.component.html | 2 +- .../conversation-message.component.ts | 5 +++-- .../va-conversation.component.ts | 14 +++++++++++-- .../virtual-assistant.component.html | 20 +++++++++++++------ 6 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 projects/back-office/src/app/dashboard/pages/virtual-assistant/models/choices.model.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/choices.model.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/choices.model.ts new file mode 100644 index 0000000000..42615b5045 --- /dev/null +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/choices.model.ts @@ -0,0 +1,9 @@ +export class Choices { + value: string; + text: string; + + constructor(value: string, text: string) { + this.value = value; + this.text = text; + } +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/message.model.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/message.model.ts index 4b0f6d206d..2949adfe10 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/message.model.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/message.model.ts @@ -1,4 +1,5 @@ import { User } from './user.model'; +import {Choices} from './choices.model'; export class Message { type: string; @@ -6,7 +7,7 @@ export class Message { reply: string; user: User; date: number; - choices: string[]; + choices: Choices[]; // tslint:disable-next-line:max-line-length constructor(type: string, @@ -14,7 +15,7 @@ export class Message { reply: string, user: User, date: number, - choices: string[]) { + choices: Choices[]) { this.type = type; this.text = text; this.reply = reply; diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html index 120bdacdc8..34e9538a5a 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html @@ -12,5 +12,5 @@
- +
diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index 83ee424220..ccdeab96f8 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -1,4 +1,5 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; +import {Choices} from '../../models/choices.model'; @Component({ selector: 'app-conversation-message', @@ -17,8 +18,7 @@ export class ConversationMessageComponent implements OnInit { @Input() reply = ''; - @Input() - choices: string[] = []; + @Input() choices: Choices[]; @Output() btnChoiceClick: EventEmitter = new EventEmitter(); @@ -27,6 +27,7 @@ export class ConversationMessageComponent implements OnInit { constructor() { // this.imgSrc = environment.profilePhotoDefault; + this.choices = [{value: '', text: ''}]; } ngOnInit(): void { diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts index b3576054cc..1a169efdae 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts @@ -2,6 +2,7 @@ import {Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from '@an import {CdkVirtualScrollViewport} from '@angular/cdk/scrolling'; import {Message} from '../models/message.model'; import {User} from '../models/user.model'; +import {Choices} from '../models/choices.model'; @Component({ selector: 'app-va-conversation', @@ -124,7 +125,7 @@ export class VaConversationComponent implements OnInit, OnChanges { 'false', new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), Date.now(), - [this.endConvMsg]); + [new Choices(this.endConvMsg, this.endConvMsg + '?')]); this.iCurrentQuestion++; this.updateScrollViewPos(); } @@ -139,6 +140,15 @@ export class VaConversationComponent implements OnInit, OnChanges { new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), Date.now(), []); + break; + case 'radiogroup': + this.addMsg('', + this.form[this.iCurrentQuestion].title, + 'false', + new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), + Date.now(), + []); + break; } } @@ -147,7 +157,7 @@ export class VaConversationComponent implements OnInit, OnChanges { reply: string, user: User, date: number, - choices: string[]): void { + choices: Choices[]): void { this.conv.push(new Message(type, text, reply, user, date, choices)); } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html index f0281e4a2e..9c5d0261a6 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html @@ -19,13 +19,21 @@ - - - - + + + + + + + + + + + + + va-face - + - From 5a6ad239a93ae4ee1a26a291189522bc4321524c Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Fri, 9 Jul 2021 10:02:04 +0200 Subject: [PATCH 16/56] [SAFE-411] restart button bug fixed --- .../conversation-message.component.html | 9 ++- .../conversation-message.component.scss | 5 +- .../conversation-message.component.ts | 8 +- .../va-conversation.component.html | 2 +- .../va-conversation.component.ts | 74 +++++++++++++++---- 5 files changed, 78 insertions(+), 20 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html index 34e9538a5a..ef270111f2 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html @@ -11,6 +11,9 @@

-
- -
+ + + + + + diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss index 4528ea007d..a5ddee9177 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss @@ -22,10 +22,11 @@ p { color: white; } -.btnChoice { +.btnChoices { margin-right: 5px; + margin-bottom: 5px; } -#btnsChoices { +.btnChoicesCont { } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index ccdeab96f8..c2262b56ae 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -8,6 +8,8 @@ import {Choices} from '../../models/choices.model'; }) export class ConversationMessageComponent implements OnInit { + @Input() type = ''; + @Input() imgSrc = ''; @Input() backgroundColor = ''; @@ -44,8 +46,12 @@ export class ConversationMessageComponent implements OnInit { } } - btnChoiceClickFn($event: any , ch: string): void{ + btnChoiceClickFn($event: any , ch: Choices): void{ this.btnChoiceClick.emit(ch); $event.target.parentElement.setAttribute('style', 'display: none'); } + + btnChoiceCheckClickFn($event: any, ch: Choices): void { + $event.target.parentElement.setAttribute('color', 'Accent'); + } } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html index cd921ad630..568fcd804d 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html @@ -2,7 +2,7 @@
- +
diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts index 1a169efdae..dbc766bb30 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts @@ -74,7 +74,6 @@ export class VaConversationComponent implements OnInit, OnChanges { new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), Date.now(), []); - console.log(this.conv); // this.records.push(msg); // complete current record @@ -93,6 +92,29 @@ export class VaConversationComponent implements OnInit, OnChanges { // } } + sendReplyMsgChoice(ch: Choices): void { + if (!this.endConv && ch.text !== ''){ + this.addMsg('', + ch.text, + 'true', + new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), + Date.now(), + []); + + // this.records.push(msg); + // complete current record + // -1 because the chat start with a message of the bot + this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = ch.value; + + // reset input text + this.currentText = ''; + + this.updateScrollViewPos(); + + this.sendNextQuestion(); + } + } + sendReplyMsgTextEnd(): void { if (this.endConvMsg !== '') { this.addMsg('', @@ -109,47 +131,74 @@ export class VaConversationComponent implements OnInit, OnChanges { } sendNextQuestion(): void { + console.log('this.iCurrentQuestion'); + console.log(this.iCurrentQuestion); if (this.iCurrentQuestion < this.form.length){ - this.questionController(); + console.log('BEF'); + const r = this.questionController(); + console.log('AFT'); + console.log('this.iCurrentQuestion++; 1'); this.iCurrentQuestion++; this.updateScrollViewPos(); + if (!r){ + this.sendNextQuestion(); + } } else if (this.iCurrentQuestion === this.form.length) { this.endConv = true; // add this record this.records.push(this.currentRecord); + console.log('FIN: records'); console.log(this.records); - this.addMsg('', + const cTab = []; + // cTab.push(new Choices(this.endConvMsg, this.endConvMsg + '?')); + cTab.push({value: this.endConvMsg, text: this.endConvMsg + '?'}); + console.log(cTab); + + this.addMsg('text', 'Thank you for your time, bye!', 'false', new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), Date.now(), - [new Choices(this.endConvMsg, this.endConvMsg + '?')]); + cTab); + console.log('this.iCurrentQuestion++; 2'); this.iCurrentQuestion++; this.updateScrollViewPos(); } } - questionController(): void { + questionController(): boolean { + let r = true; + console.log('*** questionController ***'); + console.log(this.form[this.iCurrentQuestion].type); + console.log(this.form[this.iCurrentQuestion].choices); switch (this.form[this.iCurrentQuestion].type){ case 'text': - this.addMsg('', + this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), Date.now(), []); break; - case 'radiogroup': - this.addMsg('', + case 'radiogroup' || 'checkbox': + this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), Date.now(), - []); + this.form[this.iCurrentQuestion].choices); + break; + default: + console.log('default'); + r = false; + // console.log('this.iCurrentQuestion++; 3'); + // this.iCurrentQuestion++; + break; } + return r; } addMsg(type: string, @@ -180,13 +229,12 @@ export class VaConversationComponent implements OnInit, OnChanges { // this.speechToTextService.start(); } - choiceClick(choice: any): void{ - console.log(choice); - if (choice === this.endConvMsg){ + choiceClick(choice: Choices): void{ + if (choice.value === this.endConvMsg){ this.restartForm(); } else { - this.sendReplyMsgText(choice); + this.sendReplyMsgChoice(choice); } } From 4eb0d46906863d467bc57b972979c3e2f2ff6419 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Fri, 9 Jul 2021 11:03:03 +0200 Subject: [PATCH 17/56] [SAFE-411] buttons disappearing fixed --- .../conversation-message.component.html | 8 ++++---- .../conversation-message.component.ts | 9 ++++++++- .../va-conversation/va-conversation.component.ts | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html index ef270111f2..96a23aa97a 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html @@ -11,9 +11,9 @@

- +
- - +
+
- +
diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index c2262b56ae..55ea4cf39c 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -48,7 +48,14 @@ export class ConversationMessageComponent implements OnInit { btnChoiceClickFn($event: any , ch: Choices): void{ this.btnChoiceClick.emit(ch); - $event.target.parentElement.setAttribute('style', 'display: none'); + // $event.target.parentElement.setAttribute('style', 'display: none'); + // console.log($event.target); + console.log('$event.currentTarget'); + console.log($event.currentTarget); + console.log($event.currentTarget.parentElement); + $event.currentTarget.parentElement.setAttribute('style', 'display: none'); + // console.log($event.target.parentElement); + // console.log($event.target.parentElement.parentElement); } btnChoiceCheckClickFn($event: any, ch: Choices): void { diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts index dbc766bb30..4af843a386 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts @@ -153,7 +153,7 @@ export class VaConversationComponent implements OnInit, OnChanges { const cTab = []; // cTab.push(new Choices(this.endConvMsg, this.endConvMsg + '?')); - cTab.push({value: this.endConvMsg, text: this.endConvMsg + '?'}); + cTab.push({value: this.endConvMsg, text: this.endConvMsg + '?'}, {value: 'value', text: 'text'}); console.log(cTab); this.addMsg('text', From b03895defae329546a6d3df88b1adfc2ee216cf0 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Fri, 9 Jul 2021 11:17:27 +0200 Subject: [PATCH 18/56] [SAFE-411] expression type added --- .../conversation-message.component.ts | 6 ------ .../va-conversation/va-conversation.component.ts | 13 ++++++++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index 55ea4cf39c..4af40afd14 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -48,14 +48,8 @@ export class ConversationMessageComponent implements OnInit { btnChoiceClickFn($event: any , ch: Choices): void{ this.btnChoiceClick.emit(ch); - // $event.target.parentElement.setAttribute('style', 'display: none'); // console.log($event.target); - console.log('$event.currentTarget'); - console.log($event.currentTarget); - console.log($event.currentTarget.parentElement); $event.currentTarget.parentElement.setAttribute('style', 'display: none'); - // console.log($event.target.parentElement); - // console.log($event.target.parentElement.parentElement); } btnChoiceCheckClickFn($event: any, ch: Choices): void { diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts index 4af843a386..d60eca8fd7 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts @@ -174,7 +174,7 @@ export class VaConversationComponent implements OnInit, OnChanges { console.log(this.form[this.iCurrentQuestion].type); console.log(this.form[this.iCurrentQuestion].choices); switch (this.form[this.iCurrentQuestion].type){ - case 'text': + case 'text' || 'expression': this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', @@ -190,6 +190,17 @@ export class VaConversationComponent implements OnInit, OnChanges { Date.now(), this.form[this.iCurrentQuestion].choices); break; + case 'expression': + if (this.form[this.iCurrentQuestion].description){ + this.addMsg(this.form[this.iCurrentQuestion].type, + this.form[this.iCurrentQuestion].description, + 'false', + new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), + Date.now(), + []); + } + r = false; + break; default: console.log('default'); r = false; From ce52a962fcdd36875ef3d7b62555a374c450fab5 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Fri, 9 Jul 2021 13:07:44 +0200 Subject: [PATCH 19/56] [SAFE-411] checkbox type added --- .../conversation-message.component.html | 5 ++- .../conversation-message.component.scss | 4 +++ .../conversation-message.component.ts | 19 +++++++++++- .../va-conversation.component.html | 2 +- .../va-conversation.component.ts | 31 +++++++++++++++++-- 5 files changed, 56 insertions(+), 5 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html index 96a23aa97a..dd8fe7573f 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html @@ -15,5 +15,8 @@
- + +
+
+
diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss index a5ddee9177..48eb71d98f 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss @@ -30,3 +30,7 @@ p { .btnChoicesCont { } + +#btnChoicesValidate { + background-color: #60d295; +} diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index 4af40afd14..0cde280cdc 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -23,13 +23,18 @@ export class ConversationMessageComponent implements OnInit { @Input() choices: Choices[]; @Output() btnChoiceClick: EventEmitter = new EventEmitter(); + @Output() btnChoiceCheckValidateClick: EventEmitter = new EventEmitter(); public ml = ''; public mr = ''; + public checkBoxChoices: Choices[]; + constructor() { // this.imgSrc = environment.profilePhotoDefault; this.choices = [{value: '', text: ''}]; + + this.checkBoxChoices = []; } ngOnInit(): void { @@ -53,6 +58,18 @@ export class ConversationMessageComponent implements OnInit { } btnChoiceCheckClickFn($event: any, ch: Choices): void { - $event.target.parentElement.setAttribute('color', 'Accent'); + console.log($event.currentTarget); + if (this.checkBoxChoices.includes(ch)){ + this.checkBoxChoices.splice(this.checkBoxChoices.indexOf(ch), 1); + // $event.currentTarget.setAttribute('style', 'background-color: #3a8dc4'); + } + else { + this.checkBoxChoices.push(ch); + // $event.currentTarget.setAttribute('style', 'background-color: green'); + } + } + + btnChoiceCheckValidateClickFn($event: MouseEvent): void { + this.btnChoiceCheckValidateClick.emit(this.checkBoxChoices); } } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html index 568fcd804d..dc3a0fe739 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html @@ -2,7 +2,7 @@
- +
diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts index d60eca8fd7..dfd116d7b7 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts @@ -174,7 +174,7 @@ export class VaConversationComponent implements OnInit, OnChanges { console.log(this.form[this.iCurrentQuestion].type); console.log(this.form[this.iCurrentQuestion].choices); switch (this.form[this.iCurrentQuestion].type){ - case 'text' || 'expression': + case 'text': this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', @@ -182,7 +182,8 @@ export class VaConversationComponent implements OnInit, OnChanges { Date.now(), []); break; - case 'radiogroup' || 'checkbox': + case 'radiogroup': + case 'checkbox': this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', @@ -259,4 +260,30 @@ export class VaConversationComponent implements OnInit, OnChanges { }, 500); } + choiceCheckValidateClick(choices: any[]): void { + console.log('# choiceCheckValidateClick #'); + console.log(choices); + let text = ''; + const choicesRecord: string[] = []; + choices.forEach((ch) => { + choicesRecord.push(ch.value); + console.log('ch'); + console.log(ch.text); + text = text + ' ' + ch.text; + }); + this.addMsg('', + text, + 'true', + new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), + Date.now(), + []); + + this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = choicesRecord; + + this.currentText = ''; + + this.updateScrollViewPos(); + + this.sendNextQuestion(); + } } From 6d7a33236a63e38238265256db20968fc31f69b3 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Fri, 9 Jul 2021 13:14:01 +0200 Subject: [PATCH 20/56] [SAFE-411] display of buttons (for checkbox type) fixed --- .../conversation-message.component.html | 13 ++++++++----- .../conversation-message.component.ts | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html index dd8fe7573f..383ecc9954 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html @@ -14,9 +14,12 @@
-
- -
-
- +
+
+ +
+
+ +
+ diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index 0cde280cdc..1efdfda1e1 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -69,7 +69,8 @@ export class ConversationMessageComponent implements OnInit { } } - btnChoiceCheckValidateClickFn($event: MouseEvent): void { + btnChoiceCheckValidateClickFn($event: any): void { this.btnChoiceCheckValidateClick.emit(this.checkBoxChoices); + $event.currentTarget.parentElement.parentElement.setAttribute('style', 'display: none'); } } From 2d53d1caf2010118b2dd704c8c569732028a0a61 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Fri, 9 Jul 2021 15:48:16 +0200 Subject: [PATCH 21/56] [SAFE-411] code refactoring --- .../conversation-message.component.html | 4 +- .../conversation-message.component.ts | 10 +- .../va-conversation.component.html | 2 +- .../va-conversation.component.ts | 208 +++++++----------- 4 files changed, 81 insertions(+), 143 deletions(-) diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html index 383ecc9954..67aa998cc9 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html @@ -16,10 +16,10 @@
- +
- +
diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index 1efdfda1e1..5d66d8284b 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -23,7 +23,7 @@ export class ConversationMessageComponent implements OnInit { @Input() choices: Choices[]; @Output() btnChoiceClick: EventEmitter = new EventEmitter(); - @Output() btnChoiceCheckValidateClick: EventEmitter = new EventEmitter(); + @Output() btnChoiceCheckBoxValidateClick: EventEmitter = new EventEmitter(); public ml = ''; public mr = ''; @@ -57,20 +57,18 @@ export class ConversationMessageComponent implements OnInit { $event.currentTarget.parentElement.setAttribute('style', 'display: none'); } - btnChoiceCheckClickFn($event: any, ch: Choices): void { + btnChoiceCheckBoxClickFn($event: any, ch: Choices): void { console.log($event.currentTarget); if (this.checkBoxChoices.includes(ch)){ this.checkBoxChoices.splice(this.checkBoxChoices.indexOf(ch), 1); - // $event.currentTarget.setAttribute('style', 'background-color: #3a8dc4'); } else { this.checkBoxChoices.push(ch); - // $event.currentTarget.setAttribute('style', 'background-color: green'); } } - btnChoiceCheckValidateClickFn($event: any): void { - this.btnChoiceCheckValidateClick.emit(this.checkBoxChoices); + btnChoiceCheckBoxValidateClickFn($event: any): void { + this.btnChoiceCheckBoxValidateClick.emit(this.checkBoxChoices); $event.currentTarget.parentElement.parentElement.setAttribute('style', 'display: none'); } } diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html index dc3a0fe739..e04457f2ae 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html @@ -2,7 +2,7 @@
- +
diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts index dfd116d7b7..32f869095a 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts @@ -22,17 +22,27 @@ export class VaConversationComponent implements OnInit, OnChanges { public iCurrentQuestion: number; public endConv: boolean; - public endConvMsg: string; + public endConvChoiceMsg: string; + + public userImgLink: string; + public vaImgLink: string; + + public endMessage: string; constructor() { this.currentText = ''; this.iCurrentQuestion = 0; - this.endConvMsg = 'restart'; + this.endConvChoiceMsg = 'restart'; this.endConv = false; this.currentRecord = {}; + + this.userImgLink = 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'; + this.vaImgLink = 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'; + + this.endMessage = 'Thank you for your time, bye!'; } ngOnInit(): void { @@ -66,78 +76,70 @@ export class VaConversationComponent implements OnInit, OnChanges { } } + // send simple reply message (TEXT) sendReplyMsgText(msg: string): void { if (!this.endConv && msg !== ''){ - this.addMsg('', - msg, - 'true', - new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), - Date.now(), - []); + this.addMsg('', msg, 'true', new User('Me', this.userImgLink), Date.now(), []); // this.records.push(msg); // complete current record // -1 because the chat start with a message of the bot this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = msg; - - // reset input text - this.currentText = ''; - - this.updateScrollViewPos(); - - this.sendNextQuestion(); + this.afterReply(); } - // else if (msg === this.endConvMsg){ - // this.restartForm(); - // } } + // send reply message after clicking on a choice (RADIOGROUP) sendReplyMsgChoice(ch: Choices): void { if (!this.endConv && ch.text !== ''){ - this.addMsg('', - ch.text, - 'true', - new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), - Date.now(), - []); - - // this.records.push(msg); - // complete current record - // -1 because the chat start with a message of the bot + this.addMsg('', ch.text, 'true', new User('Me', this.userImgLink), Date.now(), []); this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = ch.value; + this.afterReply(); + } + } - // reset input text - this.currentText = ''; + // click on a validate button (CHECKBOX) + choiceCheckBoxValidateClick(choices: any[]): void { + let text = ''; const choicesRecord: string[] = []; - this.updateScrollViewPos(); + choices.forEach((ch) => { + choicesRecord.push(ch.value); + text = text + ' ' + ch.text; + }); - this.sendNextQuestion(); - } + this.addMsg('', text, 'true', new User('Me', this.userImgLink), Date.now(), []); + this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = choicesRecord; + this.afterReply(); } + // send final conversation message sendReplyMsgTextEnd(): void { - if (this.endConvMsg !== '') { - this.addMsg('', - this.endConvMsg, - 'true', - new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), - Date.now(), - []); - // reset input text - this.currentText = ''; - this.updateScrollViewPos(); - this.sendNextQuestion(); - } + if (this.endConvChoiceMsg !== '') { + this.addMsg('', this.endConvChoiceMsg, 'true', new User('Me', this.userImgLink), Date.now(), []); + this.afterReply(); + } + } + + afterReply(): void { + // reset input text + this.currentText = ''; + this.updateScrollViewPos(); + this.sendNextQuestion(); + } + + restartForm(): void { + this.endConv = false; + this.sendReplyMsgTextEnd(); + this.iCurrentQuestion = 0; + this.currentRecord = {}; + window.setTimeout(() => { + this.sendNextQuestion(); + }, 500); } sendNextQuestion(): void { - console.log('this.iCurrentQuestion'); - console.log(this.iCurrentQuestion); if (this.iCurrentQuestion < this.form.length){ - console.log('BEF'); const r = this.questionController(); - console.log('AFT'); - console.log('this.iCurrentQuestion++; 1'); this.iCurrentQuestion++; this.updateScrollViewPos(); if (!r){ @@ -146,73 +148,57 @@ export class VaConversationComponent implements OnInit, OnChanges { } else if (this.iCurrentQuestion === this.form.length) { this.endConv = true; + // add this record this.records.push(this.currentRecord); - console.log('FIN: records'); console.log(this.records); - const cTab = []; - // cTab.push(new Choices(this.endConvMsg, this.endConvMsg + '?')); - cTab.push({value: this.endConvMsg, text: this.endConvMsg + '?'}, {value: 'value', text: 'text'}); - console.log(cTab); - - this.addMsg('text', - 'Thank you for your time, bye!', - 'false', - new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), - Date.now(), - cTab); - console.log('this.iCurrentQuestion++; 2'); + this.addMsg('text', this.endMessage, 'false', new User('Assistant', this.vaImgLink), Date.now(), + [new Choices(this.endConvChoiceMsg, this.endConvChoiceMsg + '?')]); + this.iCurrentQuestion++; this.updateScrollViewPos(); } } + // control the bot format message depending on the type questionController(): boolean { let r = true; - console.log('*** questionController ***'); - console.log(this.form[this.iCurrentQuestion].type); - console.log(this.form[this.iCurrentQuestion].choices); switch (this.form[this.iCurrentQuestion].type){ case 'text': - this.addMsg(this.form[this.iCurrentQuestion].type, - this.form[this.iCurrentQuestion].title, - 'false', - new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), - Date.now(), - []); + this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', + new User('Assistant', this.vaImgLink), Date.now(), []); break; case 'radiogroup': case 'checkbox': - this.addMsg(this.form[this.iCurrentQuestion].type, - this.form[this.iCurrentQuestion].title, - 'false', - new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), - Date.now(), - this.form[this.iCurrentQuestion].choices); + this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', + new User('Assistant', this.vaImgLink), Date.now(), this.form[this.iCurrentQuestion].choices); break; case 'expression': if (this.form[this.iCurrentQuestion].description){ - this.addMsg(this.form[this.iCurrentQuestion].type, - this.form[this.iCurrentQuestion].description, - 'false', - new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'), - Date.now(), - []); + this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].description, 'false', + new User('Assistant', this.vaImgLink), Date.now(), []); } r = false; break; default: - console.log('default'); r = false; - // console.log('this.iCurrentQuestion++; 3'); - // this.iCurrentQuestion++; - break; } return r; } + // click on a choice (radio) + choiceClick(choice: Choices): void{ + if (choice.value === this.endConvChoiceMsg){ + this.restartForm(); + } + else { + this.sendReplyMsgChoice(choice); + } + } + + // add a message to the conversation addMsg(type: string, text: string, reply: string, @@ -240,50 +226,4 @@ export class VaConversationComponent implements OnInit, OnChanges { startSpeech(): void { // this.speechToTextService.start(); } - - choiceClick(choice: Choices): void{ - if (choice.value === this.endConvMsg){ - this.restartForm(); - } - else { - this.sendReplyMsgChoice(choice); - } - } - - restartForm(): void { - this.endConv = false; - this.sendReplyMsgTextEnd(); - this.iCurrentQuestion = 0; - this.currentRecord = {}; - window.setTimeout(() => { - this.sendNextQuestion(); - }, 500); - } - - choiceCheckValidateClick(choices: any[]): void { - console.log('# choiceCheckValidateClick #'); - console.log(choices); - let text = ''; - const choicesRecord: string[] = []; - choices.forEach((ch) => { - choicesRecord.push(ch.value); - console.log('ch'); - console.log(ch.text); - text = text + ' ' + ch.text; - }); - this.addMsg('', - text, - 'true', - new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'), - Date.now(), - []); - - this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = choicesRecord; - - this.currentText = ''; - - this.updateScrollViewPos(); - - this.sendNextQuestion(); - } } From eedfc0fdcca94d967315a779fbfc496a29468121 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Fri, 9 Jul 2021 18:07:11 +0200 Subject: [PATCH 22/56] [SAFE-411] virtual-assistant directory moved + text messages sending managed --- projects/back-office/src/app/app-routing.module.ts | 6 ++---- .../pages => }/virtual-assistant/models/choices.model.ts | 0 .../pages => }/virtual-assistant/models/message.model.ts | 0 .../pages => }/virtual-assistant/models/user.model.ts | 0 .../conversation-footer/conversation-footer.component.html | 0 .../conversation-footer/conversation-footer.component.scss | 0 .../conversation-footer.component.spec.ts | 0 .../conversation-footer/conversation-footer.component.ts | 0 .../conversation-header/conversation-header.component.html | 0 .../conversation-header/conversation-header.component.scss | 0 .../conversation-header.component.spec.ts | 0 .../conversation-header/conversation-header.component.ts | 0 .../conversation-message.component.html | 0 .../conversation-message.component.scss | 0 .../conversation-message.component.spec.ts | 0 .../conversation-message/conversation-message.component.ts | 0 .../va-conversation/va-conversation.component.html | 0 .../va-conversation/va-conversation.component.scss | 0 .../va-conversation/va-conversation.component.spec.ts | 0 .../va-conversation/va-conversation.component.ts | 3 ++- .../virtual-assistant/virtual-assistant-routing.module.ts | 0 .../virtual-assistant/virtual-assistant.component.html | 0 .../virtual-assistant/virtual-assistant.component.scss | 0 .../virtual-assistant/virtual-assistant.component.spec.ts | 0 .../virtual-assistant/virtual-assistant.component.ts | 2 +- .../virtual-assistant/virtual-assistant.module.ts | 0 26 files changed, 5 insertions(+), 6 deletions(-) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/models/choices.model.ts (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/models/message.model.ts (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/models/user.model.ts (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.spec.ts (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/conversation-header/conversation-header.component.html (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/conversation-header/conversation-header.component.scss (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/conversation-header/conversation-header.component.spec.ts (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/conversation-header/conversation-header.component.ts (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/conversation-message/conversation-message.component.spec.ts (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/va-conversation.component.html (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/va-conversation.component.scss (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/va-conversation.component.spec.ts (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/va-conversation/va-conversation.component.ts (97%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/virtual-assistant-routing.module.ts (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/virtual-assistant.component.html (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/virtual-assistant.component.scss (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/virtual-assistant.component.spec.ts (100%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/virtual-assistant.component.ts (95%) rename projects/back-office/src/app/{dashboard/pages => }/virtual-assistant/virtual-assistant.module.ts (100%) diff --git a/projects/back-office/src/app/app-routing.module.ts b/projects/back-office/src/app/app-routing.module.ts index b1562376d2..2ece9de3a3 100644 --- a/projects/back-office/src/app/app-routing.module.ts +++ b/projects/back-office/src/app/app-routing.module.ts @@ -2,7 +2,7 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { MsalGuard } from '@azure/msal-angular'; import { AccessGuard } from './guards/access.guard'; -import {VirtualAssistantComponent} from './dashboard/pages/virtual-assistant/virtual-assistant.component'; +import {VirtualAssistantComponent} from './virtual-assistant/virtual-assistant.component'; const routes: Routes = [ { @@ -35,12 +35,10 @@ const routes: Routes = [ }, { path: 'va', - // component: VaComponent children: [ { path: ':id', - // component: VirtualAssistantComponent - loadChildren: () => import('./dashboard/pages/virtual-assistant/virtual-assistant.module') + loadChildren: () => import('./virtual-assistant/virtual-assistant.module') .then(m => m.VirtualAssistantModule), } ] diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/choices.model.ts b/projects/back-office/src/app/virtual-assistant/models/choices.model.ts similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/models/choices.model.ts rename to projects/back-office/src/app/virtual-assistant/models/choices.model.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/message.model.ts b/projects/back-office/src/app/virtual-assistant/models/message.model.ts similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/models/message.model.ts rename to projects/back-office/src/app/virtual-assistant/models/message.model.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/models/user.model.ts b/projects/back-office/src/app/virtual-assistant/models/user.model.ts similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/models/user.model.ts rename to projects/back-office/src/app/virtual-assistant/models/user.model.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html rename to projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss rename to projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.spec.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.spec.ts similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.spec.ts rename to projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.spec.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts rename to projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-header/conversation-header.component.html similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.html rename to projects/back-office/src/app/virtual-assistant/va-conversation/conversation-header/conversation-header.component.html diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.scss b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-header/conversation-header.component.scss similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.scss rename to projects/back-office/src/app/virtual-assistant/va-conversation/conversation-header/conversation-header.component.scss diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.spec.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-header/conversation-header.component.spec.ts similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.spec.ts rename to projects/back-office/src/app/virtual-assistant/va-conversation/conversation-header/conversation-header.component.spec.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-header/conversation-header.component.ts similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-header/conversation-header.component.ts rename to projects/back-office/src/app/virtual-assistant/va-conversation/conversation-header/conversation-header.component.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html rename to projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss rename to projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.scss diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.spec.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.spec.ts similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.spec.ts rename to projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.spec.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts rename to projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.html rename to projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.scss b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.scss similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.scss rename to projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.scss diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.spec.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.spec.ts similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.spec.ts rename to projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.spec.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts similarity index 97% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts rename to projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 32f869095a..c68ed3bf32 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -78,7 +78,8 @@ export class VaConversationComponent implements OnInit, OnChanges { // send simple reply message (TEXT) sendReplyMsgText(msg: string): void { - if (!this.endConv && msg !== ''){ + console.log(this.iCurrentQuestion); + if (!this.endConv && msg !== '' && this.form[this.iCurrentQuestion - 1].type === 'text'){ this.addMsg('', msg, 'true', new User('Me', this.userImgLink), Date.now(), []); // this.records.push(msg); diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant-routing.module.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant-routing.module.ts similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant-routing.module.ts rename to projects/back-office/src/app/virtual-assistant/virtual-assistant-routing.module.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.html rename to projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.scss rename to projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.spec.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.spec.ts similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.spec.ts rename to projects/back-office/src/app/virtual-assistant/virtual-assistant.component.spec.ts diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts similarity index 95% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts rename to projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts index 2a9b6c2a76..f1a582598f 100644 --- a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts @@ -1,7 +1,7 @@ import {Component, OnInit, ViewEncapsulation} from '@angular/core'; import {Subscription} from 'rxjs'; import {ActivatedRoute} from '@angular/router'; -import {SafeDownloadService} from '../../../../../../safe/src/lib/services/download.service'; +import {SafeDownloadService} from '../../../../safe/src/lib/services/download.service'; @Component({ selector: 'app-virtual-assistant', diff --git a/projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts similarity index 100% rename from projects/back-office/src/app/dashboard/pages/virtual-assistant/virtual-assistant.module.ts rename to projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts From d4e69b90ea48a08543e3f1fdc2dfe39dad0e9818 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 12 Jul 2021 10:33:38 +0200 Subject: [PATCH 23/56] [SAFE-411] get form by id request (from REST request to GraphQL request) --- .../virtual-assistant.component.ts | 62 ++++++++++--------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts index f1a582598f..bdce6611eb 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts @@ -2,6 +2,9 @@ import {Component, OnInit, ViewEncapsulation} from '@angular/core'; import {Subscription} from 'rxjs'; import {ActivatedRoute} from '@angular/router'; import {SafeDownloadService} from '../../../../safe/src/lib/services/download.service'; +import {Apollo} from 'apollo-angular'; +// import {GET_FORM_BY_ID, GetFormByIdQueryResponse} from '../../../../../dist/safe/lib/graphql/queries'; +import {GET_FORM_BY_ID, GET_SHORT_FORMS, GetFormByIdQueryResponse, GetFormsQueryResponse} from '../graphql/queries'; @Component({ selector: 'app-virtual-assistant', @@ -21,7 +24,9 @@ export class VirtualAssistantComponent implements OnInit { // === ROUTE === private routeSubscription?: Subscription; - constructor(private route: ActivatedRoute, private downloadService: SafeDownloadService) { + constructor(private route: ActivatedRoute, + private downloadService: SafeDownloadService, + private apollo: Apollo) { this.vaCols = 6; this.iQuestion = 0; } @@ -36,36 +41,35 @@ export class VirtualAssistantComponent implements OnInit { } async getForm(): Promise{ - const path = `download/form/${this.id}`; - const dataReturn = await this.downloadService.getForm(path); - if (dataReturn.status === true) { - // console.log(JSON.parse(dataReturn.data.structure)); - this.form = JSON.parse(dataReturn.data.structure).pages[0].elements; - console.log('this.form'); - console.log(this.form); - // this.form = dataReturn.data; + // const path = `download/form/${this.id}`; + // const dataReturn = await this.downloadService.getForm(path); + // if (dataReturn.status === true) { + // // console.log(JSON.parse(dataReturn.data.structure)); + // this.form = JSON.parse(dataReturn.data.structure).pages[0].elements; + // console.log('this.form'); + // console.log(this.form); + // } + // else { + // // problem with the form + // } - // JSON.parse(form.structure).pages[0].elements + // this.apollo.watchQuery({ + // query: GET_SHORT_FORMS, + // }).valueChanges.subscribe((res: any) => { + // console.log('Apollo: res.data.forms'); + // console.log(res.data.forms); + // }); - // this.addMsg(this.form[0].type, - // this.form[0].name, - // 'false', - // new User('assistant', 'https://www.pngarts.com/files/11/Avatar-PNG-Transparent-Image.png'), - // Date.now(), - // []); - - // for (const m of this.form){ - // this.addMsg(m.type, - // m.name, - // 'false', - // new User('assistant', 'https://www.pngarts.com/files/11/Avatar-PNG-Transparent-Image.png'), - // Date.now(), - // null); - // } - } - else { - // problem with the form - } + this.apollo.watchQuery({ + query: GET_FORM_BY_ID, + variables: { + id: this.id + } + }).valueChanges.subscribe((res: any) => { + console.log('APOLLO: res.data.form'); + console.log(res); + this.form = JSON.parse(res.data.form.structure).pages[0].elements; + }); } onChatButton(event: any): void { From ebfa38668a13544ff01197618f0b3b4f55644298 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 12 Jul 2021 12:20:23 +0200 Subject: [PATCH 24/56] [SAFE-411] modules problems fixed + endConv boolean removed --- package-lock.json | 125 +++++++++++++----- .../va-conversation.component.ts | 21 ++- 2 files changed, 103 insertions(+), 43 deletions(-) diff --git a/package-lock.json b/package-lock.json index 11d8457b76..3670ca05bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -481,6 +481,7 @@ "resolved": "https://registry.npmjs.org/@angular/cdk/-/cdk-11.2.13.tgz", "integrity": "sha512-FkE4iCwoLbQxLDUOjV1I7M/6hmpyb7erAjEdWgch7nGRNxF1hqX5Bqf1lvLFKPNCbx5NRI5K7YVAdIUQUR8vug==", "dependencies": { + "parse5": "^5.0.0", "tslib": "^2.0.0" }, "optionalDependencies": { @@ -2936,6 +2937,7 @@ "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", "dev": true, "dependencies": { + "graceful-fs": "^4.1.6", "universalify": "^2.0.0" }, "optionalDependencies": { @@ -4713,7 +4715,8 @@ "esprima": "^4.0.1", "estraverse": "^5.2.0", "esutils": "^2.0.2", - "optionator": "^0.8.1" + "optionator": "^0.8.1", + "source-map": "~0.6.1" }, "bin": { "escodegen": "bin/escodegen.js", @@ -5387,6 +5390,7 @@ "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", "dev": true, "dependencies": { + "graceful-fs": "^4.1.6", "universalify": "^2.0.0" }, "optionalDependencies": { @@ -6099,6 +6103,7 @@ "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", "dev": true, "dependencies": { + "graceful-fs": "^4.1.6", "universalify": "^2.0.0" }, "optionalDependencies": { @@ -6391,6 +6396,7 @@ "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", "dev": true, "dependencies": { + "graceful-fs": "^4.1.6", "universalify": "^2.0.0" }, "optionalDependencies": { @@ -6474,6 +6480,7 @@ "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", "dev": true, "dependencies": { + "graceful-fs": "^4.1.6", "universalify": "^2.0.0" }, "optionalDependencies": { @@ -6717,6 +6724,7 @@ "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", "dev": true, "dependencies": { + "graceful-fs": "^4.1.6", "universalify": "^2.0.0" }, "optionalDependencies": { @@ -10271,6 +10279,7 @@ "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", + "fsevents": "~2.3.2", "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", @@ -10504,6 +10513,7 @@ "integrity": "sha512-gnB85c3MGC7Nm9I/FkiasNBOKjOiO1RNuXXarQms37q4QMpWdlbBgD/VnOStA2faG1dpXMv31RFApjX1/QdgWQ==", "dev": true, "dependencies": { + "colors": "^1.1.2", "object-assign": "^4.1.0", "string-width": "^4.2.0" }, @@ -13365,7 +13375,8 @@ "dependencies": { "esprima": "~1.0.4", "estraverse": "~1.5.0", - "esutils": "~1.0.0" + "esutils": "~1.0.0", + "source-map": "~0.1.30" }, "bin": { "escodegen": "bin/escodegen.js", @@ -14115,6 +14126,9 @@ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", "dev": true, + "dependencies": { + "graceful-fs": "^4.1.6" + }, "optionalDependencies": { "graceful-fs": "^4.1.6" } @@ -15191,6 +15205,7 @@ "minimist": "^1.2.5", "neo-async": "^2.6.0", "source-map": "^0.6.1", + "uglify-js": "^3.1.4", "wordwrap": "^1.0.0" }, "bin": { @@ -17693,6 +17708,7 @@ "@types/node": "*", "anymatch": "^3.0.3", "fb-watchman": "^2.0.0", + "fsevents": "^2.1.2", "graceful-fs": "^4.2.4", "jest-regex-util": "^26.0.0", "jest-serializer": "^26.6.2", @@ -18049,6 +18065,9 @@ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", "dev": true, + "dependencies": { + "graceful-fs": "^4.1.6" + }, "optionalDependencies": { "graceful-fs": "^4.1.6" } @@ -18328,6 +18347,9 @@ "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", "dev": true, + "dependencies": { + "graceful-fs": "^4.1.9" + }, "optionalDependencies": { "graceful-fs": "^4.1.9" } @@ -18402,7 +18424,14 @@ "dev": true, "dependencies": { "copy-anything": "^2.0.1", + "errno": "^0.1.1", + "graceful-fs": "^4.1.2", + "image-size": "~0.5.0", + "make-dir": "^2.1.0", + "mime": "^1.4.1", + "needle": "^2.5.2", "parse-node-version": "^1.0.1", + "source-map": "~0.6.0", "tslib": "^1.10.0" }, "bin": { @@ -18702,6 +18731,7 @@ "anymatch": "^2.0.0", "async-each": "^1.0.1", "braces": "^2.3.2", + "fsevents": "^1.2.7", "glob-parent": "^3.1.0", "inherits": "^2.0.3", "is-binary-path": "^1.0.0", @@ -19736,6 +19766,7 @@ "integrity": "sha512-akCrLDWfbdAWkMLBxJEeWTdNsjML+dt5YgOI4gJ53vuO0vrmYQkUPxa6j6V65s9CcePIr2SSWqjT2EcrNseryQ==", "dev": true, "dependencies": { + "encoding": "^0.1.12", "minipass": "^3.1.0", "minipass-sized": "^1.0.3", "minizlib": "^2.0.0" @@ -25864,6 +25895,9 @@ "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.38.4.tgz", "integrity": "sha512-B0LcJhjiwKkTl79aGVF/u5KdzsH8IylVfV56Ut6c9ouWLJcUK17T83aZBetNYSnZtXf2OHD4+2PbmRW+Fp5ulg==", "dev": true, + "dependencies": { + "fsevents": "~2.3.1" + }, "bin": { "rollup": "dist/bin/rollup" }, @@ -27512,7 +27546,8 @@ "esprima": "^4.0.1", "estraverse": "^4.2.0", "esutils": "^2.0.2", - "optionator": "^0.8.1" + "optionator": "^0.8.1", + "source-map": "~0.6.1" }, "bin": { "escodegen": "bin/escodegen.js", @@ -27671,7 +27706,8 @@ "esprima": "^4.0.1", "estraverse": "^4.2.0", "esutils": "^2.0.2", - "optionator": "^0.8.1" + "optionator": "^0.8.1", + "source-map": "~0.6.1" }, "bin": { "escodegen": "bin/escodegen.js", @@ -30529,8 +30565,10 @@ "integrity": "sha512-9P3MWk6SrKjHsGkLT2KHXdQ/9SNkyoJbabxnKOoJepsvJjJG8uYTR3yTPxPQvNDI3w4Nz1xnE0TLHK4RIVe/MQ==", "dev": true, "dependencies": { + "chokidar": "^3.4.1", "graceful-fs": "^4.1.2", - "neo-async": "^2.5.0" + "neo-async": "^2.5.0", + "watchpack-chokidar2": "^2.0.1" }, "optionalDependencies": { "chokidar": "^3.4.1", @@ -30627,6 +30665,7 @@ "anymatch": "^2.0.0", "async-each": "^1.0.1", "braces": "^2.3.2", + "fsevents": "^1.2.7", "glob-parent": "^3.1.0", "inherits": "^2.0.3", "is-binary-path": "^1.0.0", @@ -31227,6 +31266,7 @@ "anymatch": "^2.0.0", "async-each": "^1.0.1", "braces": "^2.3.2", + "fsevents": "^1.2.7", "glob-parent": "^3.1.0", "inherits": "^2.0.3", "is-binary-path": "^1.0.0", @@ -35133,7 +35173,8 @@ "@graphql-typed-document-node/core": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.1.0.tgz", - "integrity": "sha512-wYn6r8zVZyQJ6rQaALBEln5B1pzxb9shV5Ef97kTvn6yVGrqyXVnDqnU24MXnFubR+rZjBY9NWuxX3FB2sTsjg==" + "integrity": "sha512-wYn6r8zVZyQJ6rQaALBEln5B1pzxb9shV5Ef97kTvn6yVGrqyXVnDqnU24MXnFubR+rZjBY9NWuxX3FB2sTsjg==", + "requires": {} }, "@istanbuljs/load-nyc-config": { "version": "1.1.0", @@ -35414,7 +35455,8 @@ "version": "1.6.22", "resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-1.6.22.tgz", "integrity": "sha512-TDoPum4SHdfPiGSAaRBw7ECyI8VaHpK8GJugbJIJuqyh6kzw9ZLJZW3HGL3NNrJGxcAixUvqROm+YuQOo5eXtg==", - "dev": true + "dev": true, + "requires": {} }, "@mdx-js/util": { "version": "1.6.22", @@ -35938,7 +35980,8 @@ "@progress/kendo-charts": { "version": "1.18.3", "resolved": "https://registry.npmjs.org/@progress/kendo-charts/-/kendo-charts-1.18.3.tgz", - "integrity": "sha512-d6mGNRE4+JzKM2j4MP+wyu+3smmfBa2bOvbgHu53ljQQPtX5q9jUbr8JOVtboxPAODdItM1HA0MWn8fMN6KmaA==" + "integrity": "sha512-d6mGNRE4+JzKM2j4MP+wyu+3smmfBa2bOvbgHu53ljQQPtX5q9jUbr8JOVtboxPAODdItM1HA0MWn8fMN6KmaA==", + "requires": {} }, "@progress/kendo-common": { "version": "0.2.1", @@ -36384,7 +36427,8 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/@storybook/addon-measure/-/addon-measure-2.0.0.tgz", "integrity": "sha512-ZhdT++cX+L9LwjhGYggvYUUVQH/MGn2rwbrAwCMzA/f2QTFvkjxzX8nDgMxIhaLCDC+gHIxfJG2wrWN0jkBr3g==", - "dev": true + "dev": true, + "requires": {} }, "@storybook/addon-toolbars": { "version": "6.3.2", @@ -38998,7 +39042,8 @@ "version": "5.3.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", - "dev": true + "dev": true, + "requires": {} }, "acorn-node": { "version": "1.8.2", @@ -39109,13 +39154,15 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.1.tgz", "integrity": "sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==", - "dev": true + "dev": true, + "requires": {} }, "ajv-keywords": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true + "dev": true, + "requires": {} }, "alphanum-sort": { "version": "1.0.2", @@ -40713,7 +40760,8 @@ "version": "5.2.2", "resolved": "https://registry.npmjs.org/circular-dependency-plugin/-/circular-dependency-plugin-5.2.2.tgz", "integrity": "sha512-g38K9Cm5WRwlaH6g03B9OEz/0qRizI+2I7n+Gz+L5DxXJAPAiWQvwlYNm1V1jkdpUv95bOe/ASm2vfi/G560jQ==", - "dev": true + "dev": true, + "requires": {} }, "class-utils": { "version": "0.3.6", @@ -40943,13 +40991,15 @@ "version": "9.0.0", "resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-9.0.0.tgz", "integrity": "sha512-ctjwuntPfZZT2mNj2NDIVu51t9cvbhl/16epc5xEwyzyDt76pX9UgwvY+MbXrf/C/FWwdtmNtfP698BKI+9leQ==", - "dev": true + "dev": true, + "requires": {} }, "@angular/core": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/@angular/core/-/core-9.0.0.tgz", "integrity": "sha512-6Pxgsrf0qF9iFFqmIcWmjJGkkCaCm6V5QNnxMy2KloO3SDq6QuMVRbN9RtC8Urmo25LP+eZ6ZgYqFYpdD8Hd9w==", - "dev": true + "dev": true, + "requires": {} }, "source-map": { "version": "0.5.7", @@ -42188,7 +42238,8 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/cssnano-utils/-/cssnano-utils-2.0.1.tgz", "integrity": "sha512-i8vLRZTnEH9ubIyfdZCAdIdgnHAUeQeByEeQ2I7oTilvP9oHO6RScpeq3GsFUVqeB8uZgOQ9pw8utofNn32hhQ==", - "dev": true + "dev": true, + "requires": {} }, "csso": { "version": "4.2.0", @@ -45632,7 +45683,8 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", - "dev": true + "dev": true, + "requires": {} }, "ieee754": { "version": "1.2.1", @@ -47105,7 +47157,8 @@ "version": "1.6.0", "resolved": "https://registry.npmjs.org/karma-jasmine-html-reporter/-/karma-jasmine-html-reporter-1.6.0.tgz", "integrity": "sha512-ELO9yf0cNqpzaNLsfFgXd/wxZVYkE2+ECUwhMHUD4PZ17kcsPsYsVyjquiRqyMn2jkd2sHt0IeMyAyq1MC23Fw==", - "dev": true + "dev": true, + "requires": {} }, "karma-source-map-support": { "version": "1.4.0", @@ -47183,7 +47236,8 @@ "leaflet.markercluster": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/leaflet.markercluster/-/leaflet.markercluster-1.5.0.tgz", - "integrity": "sha512-Fvf/cq4o806mJL50n+fZW9+QALDDLPvt7vuAjlD2vfnxx3srMDs2vWINJze4nKYJYRY45OC6tM/669C3pLwMCA==" + "integrity": "sha512-Fvf/cq4o806mJL50n+fZW9+QALDDLPvt7vuAjlD2vfnxx3srMDs2vWINJze4nKYJYRY45OC6tM/669C3pLwMCA==", + "requires": {} }, "less": { "version": "4.1.1", @@ -47935,7 +47989,8 @@ "version": "7.1.3", "resolved": "https://registry.npmjs.org/markdown-to-jsx/-/markdown-to-jsx-7.1.3.tgz", "integrity": "sha512-jtQ6VyT7rMT5tPV0g2EJakEnXLiPksnvlYtwQsVVZ611JsWGN8bQ1tVSDX4s6JllfEH6wmsYxNjTUAMrPmNA8w==", - "dev": true + "dev": true, + "requires": {} }, "marked": { "version": "0.7.0", @@ -51085,25 +51140,29 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/postcss-discard-comments/-/postcss-discard-comments-5.0.1.tgz", "integrity": "sha512-lgZBPTDvWrbAYY1v5GYEv8fEO/WhKOu/hmZqmCYfrpD6eyDWWzAOsl2rF29lpvziKO02Gc5GJQtlpkTmakwOWg==", - "dev": true + "dev": true, + "requires": {} }, "postcss-discard-duplicates": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/postcss-discard-duplicates/-/postcss-discard-duplicates-5.0.1.tgz", "integrity": "sha512-svx747PWHKOGpAXXQkCc4k/DsWo+6bc5LsVrAsw+OU+Ibi7klFZCyX54gjYzX4TH+f2uzXjRviLARxkMurA2bA==", - "dev": true + "dev": true, + "requires": {} }, "postcss-discard-empty": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/postcss-discard-empty/-/postcss-discard-empty-5.0.1.tgz", "integrity": "sha512-vfU8CxAQ6YpMxV2SvMcMIyF2LX1ZzWpy0lqHDsOdaKKLQVQGVP1pzhrI9JlsO65s66uQTfkQBKBD/A5gp9STFw==", - "dev": true + "dev": true, + "requires": {} }, "postcss-discard-overridden": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/postcss-discard-overridden/-/postcss-discard-overridden-5.0.1.tgz", "integrity": "sha512-Y28H7y93L2BpJhrdUR2SR2fnSsT+3TVx1NmVQLbcnZWwIUpJ7mfcTC6Za9M2PG6w8j7UQRfzxqn8jU2VwFxo3Q==", - "dev": true + "dev": true, + "requires": {} }, "postcss-flexbugs-fixes": { "version": "4.2.1", @@ -51291,7 +51350,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz", "integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==", - "dev": true + "dev": true, + "requires": {} }, "postcss-modules-local-by-default": { "version": "4.0.0", @@ -51326,7 +51386,8 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/postcss-normalize-charset/-/postcss-normalize-charset-5.0.1.tgz", "integrity": "sha512-6J40l6LNYnBdPSk+BHZ8SF+HAkS4q2twe5jnocgd+xWpz/mx/5Sa32m3W1AA8uE8XaXN+eg8trIlfu8V9x61eg==", - "dev": true + "dev": true, + "requires": {} }, "postcss-normalize-display-values": { "version": "5.0.1", @@ -52149,7 +52210,8 @@ "version": "5.2.2", "resolved": "https://registry.npmjs.org/react-colorful/-/react-colorful-5.2.2.tgz", "integrity": "sha512-Xdb1Rl6lZ5SMdNBH59eE0lGqR1g2LVD8IgPlw0WeMDrOC65lYI8fgMEwj/0dDpVRVMh5qp73ciISDst/t2O2iQ==", - "dev": true + "dev": true, + "requires": {} }, "react-dev-utils": { "version": "11.0.4", @@ -56560,7 +56622,8 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/use-isomorphic-layout-effect/-/use-isomorphic-layout-effect-1.1.1.tgz", "integrity": "sha512-L7Evj8FGcwo/wpbv/qvSfrkHFtOpCzvM5yl2KVyDJoylVuSvzphiiasmjgQPttIGBAy2WKiBNR98q8w7PiNgKQ==", - "dev": true + "dev": true, + "requires": {} }, "use-latest": { "version": "1.2.0", @@ -58219,7 +58282,8 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/webpack-filter-warnings-plugin/-/webpack-filter-warnings-plugin-1.2.1.tgz", "integrity": "sha512-Ez6ytc9IseDMLPo0qCuNNYzgtUl8NovOqjIq4uAU8LTD4uoa1w1KpZyyzFtLTEMZpkkOkLfL9eN+KGYdk1Qtwg==", - "dev": true + "dev": true, + "requires": {} }, "webpack-hot-middleware": { "version": "2.25.0", @@ -58586,7 +58650,8 @@ "ws": { "version": "7.4.6", "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", - "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==" + "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", + "requires": {} }, "xml2js": { "version": "0.4.23", diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index c68ed3bf32..05eaa4a67c 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -21,8 +21,7 @@ export class VaConversationComponent implements OnInit, OnChanges { public conv: Message[] = []; public iCurrentQuestion: number; - public endConv: boolean; - public endConvChoiceMsg: string; + public restartMsg: string; public userImgLink: string; public vaImgLink: string; @@ -34,8 +33,7 @@ export class VaConversationComponent implements OnInit, OnChanges { this.iCurrentQuestion = 0; - this.endConvChoiceMsg = 'restart'; - this.endConv = false; + this.restartMsg = 'restart'; this.currentRecord = {}; @@ -79,7 +77,7 @@ export class VaConversationComponent implements OnInit, OnChanges { // send simple reply message (TEXT) sendReplyMsgText(msg: string): void { console.log(this.iCurrentQuestion); - if (!this.endConv && msg !== '' && this.form[this.iCurrentQuestion - 1].type === 'text'){ + if (msg !== '' && this.form[this.iCurrentQuestion - 1].type === 'text'){ this.addMsg('', msg, 'true', new User('Me', this.userImgLink), Date.now(), []); // this.records.push(msg); @@ -92,7 +90,7 @@ export class VaConversationComponent implements OnInit, OnChanges { // send reply message after clicking on a choice (RADIOGROUP) sendReplyMsgChoice(ch: Choices): void { - if (!this.endConv && ch.text !== ''){ + if (ch.text !== ''){ this.addMsg('', ch.text, 'true', new User('Me', this.userImgLink), Date.now(), []); this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = ch.value; this.afterReply(); @@ -115,8 +113,8 @@ export class VaConversationComponent implements OnInit, OnChanges { // send final conversation message sendReplyMsgTextEnd(): void { - if (this.endConvChoiceMsg !== '') { - this.addMsg('', this.endConvChoiceMsg, 'true', new User('Me', this.userImgLink), Date.now(), []); + if (this.restartMsg !== '') { + this.addMsg('', this.restartMsg, 'true', new User('Me', this.userImgLink), Date.now(), []); this.afterReply(); } } @@ -129,7 +127,6 @@ export class VaConversationComponent implements OnInit, OnChanges { } restartForm(): void { - this.endConv = false; this.sendReplyMsgTextEnd(); this.iCurrentQuestion = 0; this.currentRecord = {}; @@ -148,14 +145,12 @@ export class VaConversationComponent implements OnInit, OnChanges { } } else if (this.iCurrentQuestion === this.form.length) { - this.endConv = true; - // add this record this.records.push(this.currentRecord); console.log(this.records); this.addMsg('text', this.endMessage, 'false', new User('Assistant', this.vaImgLink), Date.now(), - [new Choices(this.endConvChoiceMsg, this.endConvChoiceMsg + '?')]); + [new Choices(this.restartMsg, this.restartMsg + '?')]); this.iCurrentQuestion++; this.updateScrollViewPos(); @@ -191,7 +186,7 @@ export class VaConversationComponent implements OnInit, OnChanges { // click on a choice (radio) choiceClick(choice: Choices): void{ - if (choice.value === this.endConvChoiceMsg){ + if (choice.value === this.restartMsg){ this.restartForm(); } else { From 9085a9af290709e731dcc165f3078d3a211d5fce Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 12 Jul 2021 17:08:23 +0200 Subject: [PATCH 25/56] [SAFE-411] addRecord added + dropdown type added --- .../back-office/src/app/graphql/mutations.ts | 22 +++++++++++ .../conversation-message.component.html | 6 +-- .../va-conversation.component.ts | 39 +++++++++++++++---- .../virtual-assistant.component.html | 2 +- .../virtual-assistant.component.ts | 20 +++++++++- .../safe/src/lib/services/download.service.ts | 35 ----------------- 6 files changed, 76 insertions(+), 48 deletions(-) diff --git a/projects/back-office/src/app/graphql/mutations.ts b/projects/back-office/src/app/graphql/mutations.ts index 7b8e585e4c..8ee4885967 100644 --- a/projects/back-office/src/app/graphql/mutations.ts +++ b/projects/back-office/src/app/graphql/mutations.ts @@ -198,6 +198,28 @@ export interface DeleteResourceMutationResponse{ deletedResource: Resource; } +// === ADD RECORD === +export const ADD_RECORD = gql` +mutation addRecord($form: ID!, $data: JSON!, $display: Boolean) { + addRecord(form: $form, data: $data) { + id + createdAt + modifiedAt + data(display: $display) + form { + uniqueRecord { + id + modifiedAt + data + } + } + } +}`; + +export interface AddRecordMutationResponse { + loading: boolean; + addRecord: Record; +} // === DELETE RECORD === export const DELETE_RECORD = gql` diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html index 67aa998cc9..264c7f3537 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html @@ -14,11 +14,11 @@
-
-
+
+
-
+
diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 05eaa4a67c..853ae28968 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from '@angular/core'; +import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild} from '@angular/core'; import {CdkVirtualScrollViewport} from '@angular/cdk/scrolling'; import {Message} from '../models/message.model'; import {User} from '../models/user.model'; @@ -21,19 +21,23 @@ export class VaConversationComponent implements OnInit, OnChanges { public conv: Message[] = []; public iCurrentQuestion: number; - public restartMsg: string; + public restartChoiceMsg: string; + public endChoiceMsg: string; public userImgLink: string; public vaImgLink: string; public endMessage: string; + @Output() endConversation: EventEmitter = new EventEmitter(); + constructor() { this.currentText = ''; this.iCurrentQuestion = 0; - this.restartMsg = 'restart'; + this.restartChoiceMsg = 'restart'; + this.endChoiceMsg = 'end'; this.currentRecord = {}; @@ -113,8 +117,8 @@ export class VaConversationComponent implements OnInit, OnChanges { // send final conversation message sendReplyMsgTextEnd(): void { - if (this.restartMsg !== '') { - this.addMsg('', this.restartMsg, 'true', new User('Me', this.userImgLink), Date.now(), []); + if (this.restartChoiceMsg !== '') { + this.addMsg('', this.restartChoiceMsg, 'true', new User('Me', this.userImgLink), Date.now(), []); this.afterReply(); } } @@ -150,7 +154,10 @@ export class VaConversationComponent implements OnInit, OnChanges { console.log(this.records); this.addMsg('text', this.endMessage, 'false', new User('Assistant', this.vaImgLink), Date.now(), - [new Choices(this.restartMsg, this.restartMsg + '?')]); + [ + new Choices(this.restartChoiceMsg, this.restartChoiceMsg + '?'), + new Choices(this.endChoiceMsg, this.endChoiceMsg + '?') + ]); this.iCurrentQuestion++; this.updateScrollViewPos(); @@ -166,6 +173,7 @@ export class VaConversationComponent implements OnInit, OnChanges { new User('Assistant', this.vaImgLink), Date.now(), []); break; case 'radiogroup': + case 'dropdown': case 'checkbox': this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', new User('Assistant', this.vaImgLink), Date.now(), this.form[this.iCurrentQuestion].choices); @@ -178,6 +186,7 @@ export class VaConversationComponent implements OnInit, OnChanges { r = false; break; default: + this.currentRecord[this.form[this.iCurrentQuestion].name] = null, r = false; break; } @@ -186,9 +195,25 @@ export class VaConversationComponent implements OnInit, OnChanges { // click on a choice (radio) choiceClick(choice: Choices): void{ - if (choice.value === this.restartMsg){ + if (choice.value === this.restartChoiceMsg){ this.restartForm(); } + else if (choice.value === this.endChoiceMsg){ + this.endConversation.emit(this.records); + // add record + // this.apollo.watchQuery({ + // query: ADD_RECORD, + // variables: { + // form: this.id, + // data: this.records + // } + // }).valueChanges.subscribe((res: any) => { + // console.log('APOLLO: res.data.form'); + // console.log(res); + // this.form = JSON.parse(res.data.form.structure).pages[0].elements; + // }); + // close the window + } else { this.sendReplyMsgChoice(choice); } diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html index 9c5d0261a6..5e72b6386a 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html @@ -34,6 +34,6 @@ va-face - + diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts index bdce6611eb..cb4a552a26 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts @@ -3,8 +3,9 @@ import {Subscription} from 'rxjs'; import {ActivatedRoute} from '@angular/router'; import {SafeDownloadService} from '../../../../safe/src/lib/services/download.service'; import {Apollo} from 'apollo-angular'; -// import {GET_FORM_BY_ID, GetFormByIdQueryResponse} from '../../../../../dist/safe/lib/graphql/queries'; -import {GET_FORM_BY_ID, GET_SHORT_FORMS, GetFormByIdQueryResponse, GetFormsQueryResponse} from '../graphql/queries'; +import {GET_FORM_BY_ID, GetFormByIdQueryResponse} from '../graphql/queries'; +import {ADD_RECORD, AddRecordMutationResponse} from '../graphql/mutations'; +// import {ADD_RECORD, AddRecordMutationResponse} from '../../../../../dist/safe/lib/graphql/mutations'; @Component({ selector: 'app-virtual-assistant', @@ -81,4 +82,19 @@ export class VirtualAssistantComponent implements OnInit { this.vaCols = 12; } } + + vaEndConversation(records: any): void { + console.log('vaEndConversation'); + console.log(records); + for (const r of records){ + console.log(r); + this.apollo.mutate({ + mutation: ADD_RECORD, + variables: { + form: this.id, + data: r + } + }).subscribe((res) => { console.log(res); }); + } + } } diff --git a/projects/safe/src/lib/services/download.service.ts b/projects/safe/src/lib/services/download.service.ts index 6676662d14..ffaa257423 100644 --- a/projects/safe/src/lib/services/download.service.ts +++ b/projects/safe/src/lib/services/download.service.ts @@ -43,39 +43,4 @@ export class SafeDownloadService { link.click(); setTimeout(() => link.remove(), 0); } - - async getForm(path: string): Promise { - // const url = `${this.baseUrl}/download/form/${id}`; - const url = path.startsWith('http') ? path : `${this.baseUrl}/${path}`; - const token = localStorage.getItem('msal.idtoken'); - const headers = new HttpHeaders({ - 'Content-Type': 'application/json', - Authorization: `Bearer ${token}` - }); - console.log(url); - // console.log(headers); - let response; - let reason; - await this.http.get(url, { headers }).toPromise().then((res) => { - response = res; - // console.log('res'); - // console.log(res); - }).catch((reas => {console.log(reas); reason = reas; })); - // console.log(response); - // console.log(reason); - let dataReturn = null; - if (reason == null) { - dataReturn = { - status: true, - data: response - }; - } - else { - dataReturn = { - status: false, - data: reason - }; - } - return dataReturn; - } } From cae5eb03e4b9b64ff4c5f4394756cbe9a40af3e4 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Tue, 13 Jul 2021 12:43:05 +0200 Subject: [PATCH 26/56] [SAFE-411] text to speech added + start conversation style modification --- package-lock.json | 165 +++++------------- package.json | 1 + .../conversation-message.component.ts | 5 + .../va-conversation.component.html | 4 +- .../va-conversation.component.ts | 102 ++++++++--- .../virtual-assistant.component.html | 10 +- .../virtual-assistant.component.scss | 16 +- .../virtual-assistant.component.ts | 33 ++-- 8 files changed, 167 insertions(+), 169 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3670ca05bb..faf6674bcf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,6 +54,7 @@ "leaflet.markercluster": "^1.4.1", "msal": "^1.4.4", "rxjs": "~6.6.7", + "speak-tts": "^2.0.8", "subscriptions-transport-ws": "^0.9.18", "survey-angular": "^1.8.54", "survey-creator": "^1.8.54", @@ -555,7 +556,6 @@ "version": "11.2.14", "resolved": "https://registry.npmjs.org/@angular/compiler-cli/-/compiler-cli-11.2.14.tgz", "integrity": "sha512-A7ltnCp03/EVqK/Q3tVUDsokgz5GHW3dSPGl0Csk7Ys5uBB9ibHTmVt4eiXA4jt0+6Bk+mKxwe5BEDqLvwYFAg==", - "dev": true, "dependencies": { "@babel/core": "^7.8.6", "@babel/types": "^7.8.6", @@ -591,7 +591,6 @@ "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true, "bin": { "semver": "bin/semver.js" } @@ -600,7 +599,6 @@ "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -867,7 +865,6 @@ "version": "7.14.7", "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.14.7.tgz", "integrity": "sha512-nS6dZaISCXJ3+518CWiBfEr//gHyMO02uDxBkXTKZDN5POruCnOZ1N4YBRZDCabwF8nZMWBpRxIicmXtBs+fvw==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -876,7 +873,6 @@ "version": "7.14.6", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.14.6.tgz", "integrity": "sha512-gJnOEWSqTk96qG5BoIrl5bVtc23DCycmIePPYnamY9RboYdI4nFy5vAQMSl81O5K/W0sLDWfGysnOECC+KUUCA==", - "dev": true, "dependencies": { "@babel/code-frame": "^7.14.5", "@babel/generator": "^7.14.5", @@ -906,7 +902,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.14.5.tgz", "integrity": "sha512-y3rlP+/G25OIX3mYKKIOlQRcqj7YgrvHxOLbVmyLJ9bPmi5ttvUmpydVjcFjZphOktWuA7ovbx91ECloWTfjIA==", - "dev": true, "dependencies": { "@babel/types": "^7.14.5", "jsesc": "^2.5.1", @@ -920,7 +915,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.14.5.tgz", "integrity": "sha512-6Z3Po85sfxRGachLULUhOmvAaOo7xCvqGQtxINai2mEGPFm6pQ4z5QInFnUrRpfoSV60BnjyF5F3c+15fxFV1g==", - "dev": true, "dependencies": { "@babel/code-frame": "^7.14.5", "@babel/parser": "^7.14.5", @@ -934,7 +928,6 @@ "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true, "bin": { "semver": "bin/semver.js" } @@ -943,7 +936,6 @@ "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -995,7 +987,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.14.5.tgz", "integrity": "sha512-v+QtZqXEiOnpO6EYvlImB6zCD2Lel06RzOPzmkz/D/XgQiUu3C/Jb1LOqSt/AIA34TYi/Q+KlT8vTQrgdxkbLw==", - "dev": true, "dependencies": { "@babel/compat-data": "^7.14.5", "@babel/helper-validator-option": "^7.14.5", @@ -1013,7 +1004,6 @@ "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true, "bin": { "semver": "bin/semver.js" } @@ -1146,7 +1136,6 @@ "version": "7.14.7", "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.14.7.tgz", "integrity": "sha512-TMUt4xKxJn6ccjcOW7c4hlwyJArizskAhoSTOCkA0uZ+KghIaci0Qg9R043kUMWI9mtQfgny+NQ5QATnZ+paaA==", - "dev": true, "dependencies": { "@babel/types": "^7.14.5" }, @@ -1158,7 +1147,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.14.5.tgz", "integrity": "sha512-SwrNHu5QWS84XlHwGYPDtCxcA0hrSlL2yhWYLgeOc0w7ccOl2qv4s/nARI0aYZW+bSwAL5CukeXA47B/1NKcnQ==", - "dev": true, "dependencies": { "@babel/types": "^7.14.5" }, @@ -1170,7 +1158,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.14.5.tgz", "integrity": "sha512-iXpX4KW8LVODuAieD7MzhNjmM6dzYY5tfRqT+R9HDXWl0jPn/djKmA+G9s/2C2T9zggw5tK1QNqZ70USfedOwA==", - "dev": true, "dependencies": { "@babel/helper-module-imports": "^7.14.5", "@babel/helper-replace-supers": "^7.14.5", @@ -1189,7 +1176,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.14.5.tgz", "integrity": "sha512-6Z3Po85sfxRGachLULUhOmvAaOo7xCvqGQtxINai2mEGPFm6pQ4z5QInFnUrRpfoSV60BnjyF5F3c+15fxFV1g==", - "dev": true, "dependencies": { "@babel/code-frame": "^7.14.5", "@babel/parser": "^7.14.5", @@ -1203,7 +1189,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.14.5.tgz", "integrity": "sha512-IqiLIrODUOdnPU9/F8ib1Fx2ohlgDhxnIDU7OEVi+kAbEZcyiF7BLU8W6PfvPi9LzztjS7kcbzbmL7oG8kD6VA==", - "dev": true, "dependencies": { "@babel/types": "^7.14.5" }, @@ -1238,7 +1223,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.14.5.tgz", "integrity": "sha512-3i1Qe9/8x/hCHINujn+iuHy+mMRLoc77b2nI9TB0zjH1hvn9qGlXjWlggdwUcju36PkPCy/lpM7LLUdcTyH4Ow==", - "dev": true, "dependencies": { "@babel/helper-member-expression-to-functions": "^7.14.5", "@babel/helper-optimise-call-expression": "^7.14.5", @@ -1253,7 +1237,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.14.5.tgz", "integrity": "sha512-nfBN9xvmCt6nrMZjfhkl7i0oTV3yxR4/FztsbOASyTvVcoYd0TRHh7eMLdlEcCqobydC0LAF3LtC92Iwxo0wyw==", - "dev": true, "dependencies": { "@babel/types": "^7.14.5" }, @@ -1296,7 +1279,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.14.5.tgz", "integrity": "sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -8513,7 +8495,6 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", - "dev": true, "dependencies": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" @@ -9421,7 +9402,6 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true, "engines": { "node": ">=8" } @@ -9654,7 +9634,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, "dependencies": { "fill-range": "^7.0.1" }, @@ -9815,7 +9794,6 @@ "version": "4.16.6", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.6.tgz", "integrity": "sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ==", - "dev": true, "dependencies": { "caniuse-lite": "^1.0.30001219", "colorette": "^1.2.2", @@ -10130,7 +10108,6 @@ "version": "1.0.30001241", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001241.tgz", "integrity": "sha512-1uoSZ1Pq1VpH0WerIMqwptXHNNGfdl7d1cJUFs80CwQ/lVzdhTvsFZCeNFslze7AjsQnb4C85tzclPa1VShbeQ==", - "dev": true, "funding": { "type": "opencollective", "url": "https://opencollective.com/browserslist" @@ -10139,8 +10116,7 @@ "node_modules/canonical-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/canonical-path/-/canonical-path-1.0.0.tgz", - "integrity": "sha512-feylzsbDxi1gPZ1IjystzIQZagYYLvfKrSuygUCgf7z6x790VEzze5QEkdSV1U58RA7Hi0+v6fv4K54atOzATg==", - "dev": true + "integrity": "sha512-feylzsbDxi1gPZ1IjystzIQZagYYLvfKrSuygUCgf7z6x790VEzze5QEkdSV1U58RA7Hi0+v6fv4K54atOzATg==" }, "node_modules/capture-exit": { "version": "2.0.0", @@ -10275,7 +10251,6 @@ "version": "3.5.2", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", - "dev": true, "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -10736,8 +10711,7 @@ "node_modules/colorette": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.2.tgz", - "integrity": "sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==", - "dev": true + "integrity": "sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==" }, "node_modules/colors": { "version": "1.4.0", @@ -12464,7 +12438,6 @@ "version": "0.7.2", "resolved": "https://registry.npmjs.org/dependency-graph/-/dependency-graph-0.7.2.tgz", "integrity": "sha512-KqtH4/EZdtdfWX0p6MGP9jljvxSY6msy/pRUD4jgNwVpv3v1QmNLlsB3LDSSUg79BRVSn7jI1QPRtArGABovAQ==", - "dev": true, "engines": { "node": ">= 0.6.0" } @@ -12966,8 +12939,7 @@ "node_modules/electron-to-chromium": { "version": "1.3.762", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.762.tgz", - "integrity": "sha512-LehWjRpfPcK8F1Lf/NZoAwWLWnjJVo0SZeQ9j/tvnBWYcT99qDqgo4raAfS2oTKZjPrR/jxruh85DGgDUmywEA==", - "dev": true + "integrity": "sha512-LehWjRpfPcK8F1Lf/NZoAwWLWnjJVo0SZeQ9j/tvnBWYcT99qDqgo4raAfS2oTKZjPrR/jxruh85DGgDUmywEA==" }, "node_modules/element-resize-detector": { "version": "1.2.3", @@ -14165,7 +14137,6 @@ "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, "dependencies": { "to-regex-range": "^5.0.1" }, @@ -14662,7 +14633,6 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.2.tgz", "integrity": "sha1-+RcExT0bRh+JNFKwwwfZmXZHq2s=", - "dev": true, "dependencies": { "graceful-fs": "^4.1.2", "jsonfile": "^4.0.0", @@ -14732,7 +14702,6 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, "hasInstallScript": true, "optional": true, "os": [ @@ -15012,7 +14981,6 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, "dependencies": { "is-glob": "^4.0.1" }, @@ -15129,8 +15097,7 @@ "node_modules/graceful-fs": { "version": "4.2.6", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", - "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==", - "dev": true + "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==" }, "node_modules/graphql": { "version": "15.5.1", @@ -16884,7 +16851,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, "dependencies": { "binary-extensions": "^2.0.0" }, @@ -17069,7 +17035,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -17092,7 +17057,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "dev": true, "dependencies": { "is-extglob": "^2.1.1" }, @@ -17164,7 +17128,6 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, "engines": { "node": ">=0.12.0" } @@ -18064,7 +18027,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "dev": true, "dependencies": { "graceful-fs": "^4.1.6" }, @@ -21709,8 +21671,7 @@ "node_modules/node-releases": { "version": "1.1.73", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.73.tgz", - "integrity": "sha512-uW7fodD6pyW2FZNZnp/Z3hvWKeEW1Y8R1+1CnErE8cXFXzl5blBOoVB41CvMer6P6Q0S5FXDwcHgFd1Wj0U9zg==", - "dev": true + "integrity": "sha512-uW7fodD6pyW2FZNZnp/Z3hvWKeEW1Y8R1+1CnErE8cXFXzl5blBOoVB41CvMer6P6Q0S5FXDwcHgFd1Wj0U9zg==" }, "node_modules/node-sass-tilde-importer": { "version": "1.0.2", @@ -21767,7 +21728,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -22988,7 +22948,6 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", - "dev": true, "engines": { "node": ">=8.6" }, @@ -24731,7 +24690,7 @@ "version": "16.14.0", "resolved": "https://registry.npmjs.org/react/-/react-16.14.0.tgz", "integrity": "sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==", - "dev": true, + "devOptional": true, "dependencies": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1", @@ -25202,7 +25161,6 @@ "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, "dependencies": { "picomatch": "^2.2.1" }, @@ -25230,8 +25188,7 @@ "node_modules/reflect-metadata": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", - "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==", - "dev": true + "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==" }, "node_modules/refractor": { "version": "3.4.0", @@ -27360,6 +27317,11 @@ "wbuf": "^1.7.3" } }, + "node_modules/speak-tts": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/speak-tts/-/speak-tts-2.0.8.tgz", + "integrity": "sha512-VY6Q6mRjdou6bF+x0LspvM7GJhBxHx8CLyGPTNQQ7jrztiGutyI4QNZn0cA17c4uk0FnFbA4PaMI3skeZ6PiFg==" + }, "node_modules/speed-measure-webpack-plugin": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/speed-measure-webpack-plugin/-/speed-measure-webpack-plugin-1.4.2.tgz", @@ -28833,7 +28795,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, "dependencies": { "is-number": "^7.0.0" }, @@ -29727,7 +29688,6 @@ "version": "4.0.8", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.8.tgz", "integrity": "sha512-oz1765PN+imfz1MlZzSZPtC/tqcwsCyIYA8L47EkRnRW97ztRk83SzMiWLrnChC0vqoYxSU1fcFUDA5gV/ZiPg==", - "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -30122,7 +30082,6 @@ "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true, "engines": { "node": ">= 4.0.0" } @@ -33339,7 +33298,6 @@ "version": "11.2.14", "resolved": "https://registry.npmjs.org/@angular/compiler-cli/-/compiler-cli-11.2.14.tgz", "integrity": "sha512-A7ltnCp03/EVqK/Q3tVUDsokgz5GHW3dSPGl0Csk7Ys5uBB9ibHTmVt4eiXA4jt0+6Bk+mKxwe5BEDqLvwYFAg==", - "dev": true, "requires": { "@babel/core": "^7.8.6", "@babel/types": "^7.8.6", @@ -33361,14 +33319,12 @@ "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" } } }, @@ -33537,14 +33493,12 @@ "@babel/compat-data": { "version": "7.14.7", "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.14.7.tgz", - "integrity": "sha512-nS6dZaISCXJ3+518CWiBfEr//gHyMO02uDxBkXTKZDN5POruCnOZ1N4YBRZDCabwF8nZMWBpRxIicmXtBs+fvw==", - "dev": true + "integrity": "sha512-nS6dZaISCXJ3+518CWiBfEr//gHyMO02uDxBkXTKZDN5POruCnOZ1N4YBRZDCabwF8nZMWBpRxIicmXtBs+fvw==" }, "@babel/core": { "version": "7.14.6", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.14.6.tgz", "integrity": "sha512-gJnOEWSqTk96qG5BoIrl5bVtc23DCycmIePPYnamY9RboYdI4nFy5vAQMSl81O5K/W0sLDWfGysnOECC+KUUCA==", - "dev": true, "requires": { "@babel/code-frame": "^7.14.5", "@babel/generator": "^7.14.5", @@ -33567,7 +33521,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.14.5.tgz", "integrity": "sha512-y3rlP+/G25OIX3mYKKIOlQRcqj7YgrvHxOLbVmyLJ9bPmi5ttvUmpydVjcFjZphOktWuA7ovbx91ECloWTfjIA==", - "dev": true, "requires": { "@babel/types": "^7.14.5", "jsesc": "^2.5.1", @@ -33578,7 +33531,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.14.5.tgz", "integrity": "sha512-6Z3Po85sfxRGachLULUhOmvAaOo7xCvqGQtxINai2mEGPFm6pQ4z5QInFnUrRpfoSV60BnjyF5F3c+15fxFV1g==", - "dev": true, "requires": { "@babel/code-frame": "^7.14.5", "@babel/parser": "^7.14.5", @@ -33588,14 +33540,12 @@ "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" } } }, @@ -33639,7 +33589,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.14.5.tgz", "integrity": "sha512-v+QtZqXEiOnpO6EYvlImB6zCD2Lel06RzOPzmkz/D/XgQiUu3C/Jb1LOqSt/AIA34TYi/Q+KlT8vTQrgdxkbLw==", - "dev": true, "requires": { "@babel/compat-data": "^7.14.5", "@babel/helper-validator-option": "^7.14.5", @@ -33650,8 +33599,7 @@ "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" } } }, @@ -33754,7 +33702,6 @@ "version": "7.14.7", "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.14.7.tgz", "integrity": "sha512-TMUt4xKxJn6ccjcOW7c4hlwyJArizskAhoSTOCkA0uZ+KghIaci0Qg9R043kUMWI9mtQfgny+NQ5QATnZ+paaA==", - "dev": true, "requires": { "@babel/types": "^7.14.5" } @@ -33763,7 +33710,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.14.5.tgz", "integrity": "sha512-SwrNHu5QWS84XlHwGYPDtCxcA0hrSlL2yhWYLgeOc0w7ccOl2qv4s/nARI0aYZW+bSwAL5CukeXA47B/1NKcnQ==", - "dev": true, "requires": { "@babel/types": "^7.14.5" } @@ -33772,7 +33718,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.14.5.tgz", "integrity": "sha512-iXpX4KW8LVODuAieD7MzhNjmM6dzYY5tfRqT+R9HDXWl0jPn/djKmA+G9s/2C2T9zggw5tK1QNqZ70USfedOwA==", - "dev": true, "requires": { "@babel/helper-module-imports": "^7.14.5", "@babel/helper-replace-supers": "^7.14.5", @@ -33788,7 +33733,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.14.5.tgz", "integrity": "sha512-6Z3Po85sfxRGachLULUhOmvAaOo7xCvqGQtxINai2mEGPFm6pQ4z5QInFnUrRpfoSV60BnjyF5F3c+15fxFV1g==", - "dev": true, "requires": { "@babel/code-frame": "^7.14.5", "@babel/parser": "^7.14.5", @@ -33801,7 +33745,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.14.5.tgz", "integrity": "sha512-IqiLIrODUOdnPU9/F8ib1Fx2ohlgDhxnIDU7OEVi+kAbEZcyiF7BLU8W6PfvPi9LzztjS7kcbzbmL7oG8kD6VA==", - "dev": true, "requires": { "@babel/types": "^7.14.5" } @@ -33827,7 +33770,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.14.5.tgz", "integrity": "sha512-3i1Qe9/8x/hCHINujn+iuHy+mMRLoc77b2nI9TB0zjH1hvn9qGlXjWlggdwUcju36PkPCy/lpM7LLUdcTyH4Ow==", - "dev": true, "requires": { "@babel/helper-member-expression-to-functions": "^7.14.5", "@babel/helper-optimise-call-expression": "^7.14.5", @@ -33839,7 +33781,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.14.5.tgz", "integrity": "sha512-nfBN9xvmCt6nrMZjfhkl7i0oTV3yxR4/FztsbOASyTvVcoYd0TRHh7eMLdlEcCqobydC0LAF3LtC92Iwxo0wyw==", - "dev": true, "requires": { "@babel/types": "^7.14.5" } @@ -33869,8 +33810,7 @@ "@babel/helper-validator-option": { "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.14.5.tgz", - "integrity": "sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow==", - "dev": true + "integrity": "sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow==" }, "@babel/helper-wrap-function": { "version": "7.14.5", @@ -39288,7 +39228,6 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", - "dev": true, "requires": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" @@ -40021,8 +39960,7 @@ "binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" }, "bindings": { "version": "1.5.0", @@ -40217,7 +40155,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, "requires": { "fill-range": "^7.0.1" } @@ -40362,7 +40299,6 @@ "version": "4.16.6", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.6.tgz", "integrity": "sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ==", - "dev": true, "requires": { "caniuse-lite": "^1.0.30001219", "colorette": "^1.2.2", @@ -40606,14 +40542,12 @@ "caniuse-lite": { "version": "1.0.30001241", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001241.tgz", - "integrity": "sha512-1uoSZ1Pq1VpH0WerIMqwptXHNNGfdl7d1cJUFs80CwQ/lVzdhTvsFZCeNFslze7AjsQnb4C85tzclPa1VShbeQ==", - "dev": true + "integrity": "sha512-1uoSZ1Pq1VpH0WerIMqwptXHNNGfdl7d1cJUFs80CwQ/lVzdhTvsFZCeNFslze7AjsQnb4C85tzclPa1VShbeQ==" }, "canonical-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/canonical-path/-/canonical-path-1.0.0.tgz", - "integrity": "sha512-feylzsbDxi1gPZ1IjystzIQZagYYLvfKrSuygUCgf7z6x790VEzze5QEkdSV1U58RA7Hi0+v6fv4K54atOzATg==", - "dev": true + "integrity": "sha512-feylzsbDxi1gPZ1IjystzIQZagYYLvfKrSuygUCgf7z6x790VEzze5QEkdSV1U58RA7Hi0+v6fv4K54atOzATg==" }, "capture-exit": { "version": "2.0.0", @@ -40716,7 +40650,6 @@ "version": "3.5.2", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", - "dev": true, "requires": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -41079,8 +41012,7 @@ "colorette": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.2.tgz", - "integrity": "sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==", - "dev": true + "integrity": "sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==" }, "colors": { "version": "1.4.0", @@ -42479,8 +42411,7 @@ "dependency-graph": { "version": "0.7.2", "resolved": "https://registry.npmjs.org/dependency-graph/-/dependency-graph-0.7.2.tgz", - "integrity": "sha512-KqtH4/EZdtdfWX0p6MGP9jljvxSY6msy/pRUD4jgNwVpv3v1QmNLlsB3LDSSUg79BRVSn7jI1QPRtArGABovAQ==", - "dev": true + "integrity": "sha512-KqtH4/EZdtdfWX0p6MGP9jljvxSY6msy/pRUD4jgNwVpv3v1QmNLlsB3LDSSUg79BRVSn7jI1QPRtArGABovAQ==" }, "des.js": { "version": "1.0.1", @@ -42920,8 +42851,7 @@ "electron-to-chromium": { "version": "1.3.762", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.762.tgz", - "integrity": "sha512-LehWjRpfPcK8F1Lf/NZoAwWLWnjJVo0SZeQ9j/tvnBWYcT99qDqgo4raAfS2oTKZjPrR/jxruh85DGgDUmywEA==", - "dev": true + "integrity": "sha512-LehWjRpfPcK8F1Lf/NZoAwWLWnjJVo0SZeQ9j/tvnBWYcT99qDqgo4raAfS2oTKZjPrR/jxruh85DGgDUmywEA==" }, "element-resize-detector": { "version": "1.2.3", @@ -43923,7 +43853,6 @@ "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, "requires": { "to-regex-range": "^5.0.1" } @@ -44333,7 +44262,6 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.2.tgz", "integrity": "sha1-+RcExT0bRh+JNFKwwwfZmXZHq2s=", - "dev": true, "requires": { "graceful-fs": "^4.1.2", "jsonfile": "^4.0.0", @@ -44402,7 +44330,6 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, "optional": true }, "function-bind": { @@ -44621,7 +44548,6 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, "requires": { "is-glob": "^4.0.1" } @@ -44710,8 +44636,7 @@ "graceful-fs": { "version": "4.2.6", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", - "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==", - "dev": true + "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==" }, "graphql": { "version": "15.5.1", @@ -46067,7 +45992,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, "requires": { "binary-extensions": "^2.0.0" } @@ -46198,8 +46122,7 @@ "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" }, "is-fullwidth-code-point": { "version": "3.0.0", @@ -46216,7 +46139,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "dev": true, "requires": { "is-extglob": "^2.1.1" } @@ -46265,8 +46187,7 @@ "is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" }, "is-number-object": { "version": "1.0.5", @@ -46950,7 +46871,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "dev": true, "requires": { "graceful-fs": "^4.1.6" } @@ -49885,8 +49805,7 @@ "node-releases": { "version": "1.1.73", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.73.tgz", - "integrity": "sha512-uW7fodD6pyW2FZNZnp/Z3hvWKeEW1Y8R1+1CnErE8cXFXzl5blBOoVB41CvMer6P6Q0S5FXDwcHgFd1Wj0U9zg==", - "dev": true + "integrity": "sha512-uW7fodD6pyW2FZNZnp/Z3hvWKeEW1Y8R1+1CnErE8cXFXzl5blBOoVB41CvMer6P6Q0S5FXDwcHgFd1Wj0U9zg==" }, "node-sass-tilde-importer": { "version": "1.0.2", @@ -49935,8 +49854,7 @@ "normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" }, "normalize-range": { "version": "0.1.2", @@ -50909,8 +50827,7 @@ "picomatch": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", - "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", - "dev": true + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==" }, "pify": { "version": "2.3.0", @@ -52199,7 +52116,7 @@ "version": "16.14.0", "resolved": "https://registry.npmjs.org/react/-/react-16.14.0.tgz", "integrity": "sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==", - "dev": true, + "devOptional": true, "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1", @@ -52567,7 +52484,6 @@ "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, "requires": { "picomatch": "^2.2.1" } @@ -52589,8 +52505,7 @@ "reflect-metadata": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", - "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==", - "dev": true + "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==" }, "refractor": { "version": "3.4.0", @@ -54308,6 +54223,11 @@ "wbuf": "^1.7.3" } }, + "speak-tts": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/speak-tts/-/speak-tts-2.0.8.tgz", + "integrity": "sha512-VY6Q6mRjdou6bF+x0LspvM7GJhBxHx8CLyGPTNQQ7jrztiGutyI4QNZn0cA17c4uk0FnFbA4PaMI3skeZ6PiFg==" + }, "speed-measure-webpack-plugin": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/speed-measure-webpack-plugin/-/speed-measure-webpack-plugin-1.4.2.tgz", @@ -55473,7 +55393,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, "requires": { "is-number": "^7.0.0" } @@ -56180,8 +56099,7 @@ "typescript": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.8.tgz", - "integrity": "sha512-oz1765PN+imfz1MlZzSZPtC/tqcwsCyIYA8L47EkRnRW97ztRk83SzMiWLrnChC0vqoYxSU1fcFUDA5gV/ZiPg==", - "dev": true + "integrity": "sha512-oz1765PN+imfz1MlZzSZPtC/tqcwsCyIYA8L47EkRnRW97ztRk83SzMiWLrnChC0vqoYxSU1fcFUDA5gV/ZiPg==" }, "ua-parser-js": { "version": "0.7.28", @@ -56470,8 +56388,7 @@ "universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" }, "unix-crypt-td-js": { "version": "1.1.4", diff --git a/package.json b/package.json index b4172a77b9..9392c06f2d 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "leaflet.markercluster": "^1.4.1", "msal": "^1.4.4", "rxjs": "~6.6.7", + "speak-tts": "^2.0.8", "subscriptions-transport-ws": "^0.9.18", "survey-angular": "^1.8.54", "survey-creator": "^1.8.54", diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index 5d66d8284b..61acb1bf69 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -24,6 +24,7 @@ export class ConversationMessageComponent implements OnInit { @Output() btnChoiceClick: EventEmitter = new EventEmitter(); @Output() btnChoiceCheckBoxValidateClick: EventEmitter = new EventEmitter(); + @Output() btnChoiceCheckBoxClick: EventEmitter = new EventEmitter(); public ml = ''; public mr = ''; @@ -59,12 +60,16 @@ export class ConversationMessageComponent implements OnInit { btnChoiceCheckBoxClickFn($event: any, ch: Choices): void { console.log($event.currentTarget); + let e; if (this.checkBoxChoices.includes(ch)){ + e = {choice: ch, state: false}; this.checkBoxChoices.splice(this.checkBoxChoices.indexOf(ch), 1); } else { + e = {choice: ch, state: true}; this.checkBoxChoices.push(ch); } + this.btnChoiceCheckBoxClick.emit(e); } btnChoiceCheckBoxValidateClickFn($event: any): void { diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html index e04457f2ae..b9f48a6226 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html @@ -2,8 +2,8 @@
- +
- +
diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 853ae28968..4223446c5c 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -3,6 +3,8 @@ import {CdkVirtualScrollViewport} from '@angular/cdk/scrolling'; import {Message} from '../models/message.model'; import {User} from '../models/user.model'; import {Choices} from '../models/choices.model'; +// @ts-ignore +import Speech from 'speak-tts'; @Component({ selector: 'app-va-conversation', @@ -31,6 +33,12 @@ export class VaConversationComponent implements OnInit, OnChanges { @Output() endConversation: EventEmitter = new EventEmitter(); + public speech: any; + public speechData: any; + + public userMe: User; + public userVa: User; + constructor() { this.currentText = ''; @@ -44,31 +52,21 @@ export class VaConversationComponent implements OnInit, OnChanges { this.userImgLink = 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'; this.vaImgLink = 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'; + this.userMe = new User('Me', this.userImgLink); + this.userVa = new User('Assistant', this.vaImgLink); + this.endMessage = 'Thank you for your time, bye!'; + + this.speech = new Speech(); } ngOnInit(): void { - // this.speechToTextService.endSpeechEvent.subscribe( - // (text) => { - // this.currentText = text; - // } - // ); - // this.controllerService.botReplied.subscribe( - // () => { - // this.updateScrollViewPos(); - // } - // ); - - // window.setTimeout(() => { - // console.log('this.form'); - // console.log(this.form); - // this.sendQuestionMsg(this.form[0].name); - // }, 5000); + this.speakInit(this.speech, this.speechData); } ngOnChanges(changes: SimpleChanges): void{ if (this.form !== undefined) { - this.sendNextQuestion(); + // this.sendNextQuestion(); } } @@ -82,7 +80,7 @@ export class VaConversationComponent implements OnInit, OnChanges { sendReplyMsgText(msg: string): void { console.log(this.iCurrentQuestion); if (msg !== '' && this.form[this.iCurrentQuestion - 1].type === 'text'){ - this.addMsg('', msg, 'true', new User('Me', this.userImgLink), Date.now(), []); + this.addMsg('', msg, 'true', this.userMe, Date.now(), []); // this.records.push(msg); // complete current record @@ -95,12 +93,25 @@ export class VaConversationComponent implements OnInit, OnChanges { // send reply message after clicking on a choice (RADIOGROUP) sendReplyMsgChoice(ch: Choices): void { if (ch.text !== ''){ - this.addMsg('', ch.text, 'true', new User('Me', this.userImgLink), Date.now(), []); + + this.speak(this.speech, ch.text); + + this.addMsg('', ch.text, 'true', this.userMe, Date.now(), []); this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = ch.value; this.afterReply(); } } + // click on a checkbox choice + choiceCheckBoxClick(e: any): void { + if (e.state === true){ + this.speak(this.speech, e.choice.text); + } + else { + this.speak(this.speech, e.choice.text + ' removed'); + } + } + // click on a validate button (CHECKBOX) choiceCheckBoxValidateClick(choices: any[]): void { let text = ''; const choicesRecord: string[] = []; @@ -110,7 +121,7 @@ export class VaConversationComponent implements OnInit, OnChanges { text = text + ' ' + ch.text; }); - this.addMsg('', text, 'true', new User('Me', this.userImgLink), Date.now(), []); + this.addMsg('', text, 'true', this.userMe, Date.now(), []); this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = choicesRecord; this.afterReply(); } @@ -118,7 +129,7 @@ export class VaConversationComponent implements OnInit, OnChanges { // send final conversation message sendReplyMsgTextEnd(): void { if (this.restartChoiceMsg !== '') { - this.addMsg('', this.restartChoiceMsg, 'true', new User('Me', this.userImgLink), Date.now(), []); + this.addMsg('', this.restartChoiceMsg, 'true', this.userMe, Date.now(), []); this.afterReply(); } } @@ -153,7 +164,7 @@ export class VaConversationComponent implements OnInit, OnChanges { this.records.push(this.currentRecord); console.log(this.records); - this.addMsg('text', this.endMessage, 'false', new User('Assistant', this.vaImgLink), Date.now(), + this.addMsg('text', this.endMessage, 'false', this.userVa, Date.now(), [ new Choices(this.restartChoiceMsg, this.restartChoiceMsg + '?'), new Choices(this.endChoiceMsg, this.endChoiceMsg + '?') @@ -170,18 +181,18 @@ export class VaConversationComponent implements OnInit, OnChanges { switch (this.form[this.iCurrentQuestion].type){ case 'text': this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', - new User('Assistant', this.vaImgLink), Date.now(), []); + this.userVa, Date.now(), []); break; case 'radiogroup': case 'dropdown': case 'checkbox': this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', - new User('Assistant', this.vaImgLink), Date.now(), this.form[this.iCurrentQuestion].choices); + this.userVa, Date.now(), this.form[this.iCurrentQuestion].choices); break; case 'expression': if (this.form[this.iCurrentQuestion].description){ this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].description, 'false', - new User('Assistant', this.vaImgLink), Date.now(), []); + this.userVa, Date.now(), []); } r = false; break; @@ -226,6 +237,12 @@ export class VaConversationComponent implements OnInit, OnChanges { user: User, date: number, choices: Choices[]): void { + console.log('@@ ADDMSG @@'); + if (reply === 'false'){ + console.log('speak'); + this.speak(this.speech, text); + console.log('HIII'); + } this.conv.push(new Message(type, text, reply, user, date, choices)); } @@ -244,7 +261,38 @@ export class VaConversationComponent implements OnInit, OnChanges { }, 50); } - startSpeech(): void { - // this.speechToTextService.start(); + /* TTS */ + speakInit(speech: Speech, speechData: any): void { + if (speech.hasBrowserSupport()) { // returns a boolean + console.log('speech synthesis supported'); + speech.init({ + volume: 1, + lang: 'en-GB', + rate: 1, + pitch: 1, + voice: 'Google UK English Male', + splitSentences: true, + listeners: { + } + }).then((data: any) => { + // The "data" object contains the list of available voices and the voice synthesis params + console.log('Speech is ready, voices are available', data); + speechData = data; + this.sendNextQuestion(); + + }).catch((e: any) => { + console.error('An error occured while initializing : ', e); + }); + } + } + + speak(speech: Speech, msg: string): void { + speech.speak({ + text: msg, + }).then(() => { + console.log('Success !'); + }).catch((e: any) => { + console.error('An error occurred :', e); + }); } } diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html index 5e72b6386a..ac503467e1 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html @@ -29,11 +29,13 @@ - - - va-face +
va-face
+ + + va-face - + + diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss index e6279cc3e5..225ec5754a 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss @@ -1,5 +1,8 @@ -#va-face { - height: 250px; +.va-face { + position: absolute;; + top: 50%; + left: calc(50% - 100px); + width: 200px; } .conversation .mat-figure { top: 0; @@ -14,3 +17,12 @@ padding: 0; margin: 0; } + +#btn-start { + position: absolute; + font-size: large; + height: 50px; + width: 100px; + top: 90%; + left: calc(50% - 50px); +} diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts index cb4a552a26..83ba067e0c 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts @@ -21,6 +21,9 @@ export class VirtualAssistantComponent implements OnInit { public iQuestion: any; public messages: any; public vaCols: number; + public chatCols: number; + + public start: boolean; // === ROUTE === private routeSubscription?: Subscription; @@ -28,8 +31,12 @@ export class VirtualAssistantComponent implements OnInit { constructor(private route: ActivatedRoute, private downloadService: SafeDownloadService, private apollo: Apollo) { - this.vaCols = 6; + // this.vaCols = 6; + this.vaCols = 2; + this.chatCols = 0; this.iQuestion = 0; + + this.start = false; } ngOnInit(): void { @@ -73,15 +80,15 @@ export class VirtualAssistantComponent implements OnInit { }); } - onChatButton(event: any): void { - console.log('onChatButton'); - if (this.vaCols !== 6) { - this.vaCols = 6; - } - else { - this.vaCols = 12; - } - } + // onChatButton(event: any): void { + // console.log('onChatButton'); + // if (this.vaCols !== 6) { + // this.vaCols = 6; + // } + // else { + // this.vaCols = 12; + // } + // } vaEndConversation(records: any): void { console.log('vaEndConversation'); @@ -97,4 +104,10 @@ export class VirtualAssistantComponent implements OnInit { }).subscribe((res) => { console.log(res); }); } } + + btnStartClick(): void { + this.vaCols = 1; + this.chatCols = 1; + this.start = true; + } } From 5e4bc35b227d85a75faa0437282e44eba3513190 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Tue, 13 Jul 2021 12:57:20 +0200 Subject: [PATCH 27/56] [SAFE-411] limitation text sending (when end message) --- .../va-conversation.component.html | 9 ++++++++- .../va-conversation.component.ts | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html index b9f48a6226..87dfbbd992 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html @@ -2,7 +2,14 @@
- + +
diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 4223446c5c..88b649829e 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -79,14 +79,16 @@ export class VaConversationComponent implements OnInit, OnChanges { // send simple reply message (TEXT) sendReplyMsgText(msg: string): void { console.log(this.iCurrentQuestion); - if (msg !== '' && this.form[this.iCurrentQuestion - 1].type === 'text'){ - this.addMsg('', msg, 'true', this.userMe, Date.now(), []); - - // this.records.push(msg); - // complete current record - // -1 because the chat start with a message of the bot - this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = msg; - this.afterReply(); + if (this.iCurrentQuestion < this.form.length){ + if (msg !== '' && this.form[this.iCurrentQuestion - 1].type === 'text'){ + this.addMsg('', msg, 'true', this.userMe, Date.now(), []); + + // this.records.push(msg); + // complete current record + // -1 because the chat start with a message of the bot + this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = msg; + this.afterReply(); + } } } From 47d116e8d5cccedade5fa23474e9a08d176f3051 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Tue, 13 Jul 2021 15:09:18 +0200 Subject: [PATCH 28/56] [SAFE-411] window closing --- .../va-conversation.component.ts | 19 +++++-------------- .../virtual-assistant.component.ts | 5 ++++- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 88b649829e..430bde6dc8 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -214,18 +214,8 @@ export class VaConversationComponent implements OnInit, OnChanges { else if (choice.value === this.endChoiceMsg){ this.endConversation.emit(this.records); // add record - // this.apollo.watchQuery({ - // query: ADD_RECORD, - // variables: { - // form: this.id, - // data: this.records - // } - // }).valueChanges.subscribe((res: any) => { - // console.log('APOLLO: res.data.form'); - // console.log(res); - // this.form = JSON.parse(res.data.form.structure).pages[0].elements; - // }); // close the window + // window.close(); } else { this.sendReplyMsgChoice(choice); @@ -239,15 +229,15 @@ export class VaConversationComponent implements OnInit, OnChanges { user: User, date: number, choices: Choices[]): void { - console.log('@@ ADDMSG @@'); if (reply === 'false'){ console.log('speak'); this.speak(this.speech, text); - console.log('HIII'); } this.conv.push(new Message(type, text, reply, user, date, choices)); } + /* ----- STYLE ----- */ + updateScrollViewPos(): void { setTimeout(() => { this.viewport.scrollTo({ @@ -263,7 +253,8 @@ export class VaConversationComponent implements OnInit, OnChanges { }, 50); } - /* TTS */ + /* ----- TTS ----- */ + speakInit(speech: Speech, speechData: any): void { if (speech.hasBrowserSupport()) { // returns a boolean console.log('speech synthesis supported'); diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts index 83ba067e0c..de5fd2d6b9 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts @@ -101,7 +101,10 @@ export class VirtualAssistantComponent implements OnInit { form: this.id, data: r } - }).subscribe((res) => { console.log(res); }); + }).subscribe((res) => { + console.log(res); + window.close(); + }); } } From aae0e3c2c719529afa7528c14cab278af1631626 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Tue, 13 Jul 2021 17:49:31 +0200 Subject: [PATCH 29/56] [SAFE-411] inputTypes added + ngOnChange issue fixed --- .../conversation-footer.component.html | 2 +- .../conversation-footer.component.ts | 3 ++- .../va-conversation/va-conversation.component.html | 2 +- .../va-conversation/va-conversation.component.ts | 13 ++++++++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html index 5d04de2792..e2c78a5d73 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html @@ -1,5 +1,5 @@ diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts index b6763804a6..67e5dff76b 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts @@ -18,10 +18,11 @@ export class ConversationFooterComponent implements OnInit, OnChanges { public btnRec: any; @Input() inputValue = ''; + @Input() inputType = ''; ngOnChanges(changes: SimpleChanges): void { // we skip that at the beginning when object are not yet set - if (this.input !== undefined){ + if (this.input !== undefined && changes.inputValue !== undefined){ this.msgChange(changes.inputValue.currentValue); this.input.focus(); } diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html index 87dfbbd992..3217851b43 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html @@ -12,5 +12,5 @@
- +
diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 430bde6dc8..71f47f15ee 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -39,6 +39,8 @@ export class VaConversationComponent implements OnInit, OnChanges { public userMe: User; public userVa: User; + public inputMsgType: string; + constructor() { this.currentText = ''; @@ -58,6 +60,8 @@ export class VaConversationComponent implements OnInit, OnChanges { this.endMessage = 'Thank you for your time, bye!'; this.speech = new Speech(); + + this.inputMsgType = 'text'; } ngOnInit(): void { @@ -180,8 +184,15 @@ export class VaConversationComponent implements OnInit, OnChanges { // control the bot format message depending on the type questionController(): boolean { let r = true; - switch (this.form[this.iCurrentQuestion].type){ + const t = this.form[this.iCurrentQuestion].type; + switch (t){ case 'text': + if (this.form[this.iCurrentQuestion].inputType !== null) { + this.inputMsgType = this.form[this.iCurrentQuestion].inputType; + } + else { + this.inputMsgType = 'text'; + } this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', this.userVa, Date.now(), []); break; From 44b7de58ca22529115a3ee241aebeb840a087348 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Tue, 13 Jul 2021 18:04:50 +0200 Subject: [PATCH 30/56] [SAFE-411] expression type fixed --- .../va-conversation/va-conversation.component.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 71f47f15ee..053a082140 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -66,6 +66,8 @@ export class VaConversationComponent implements OnInit, OnChanges { ngOnInit(): void { this.speakInit(this.speech, this.speechData); + console.log('this.form'); + console.log(this.form); } ngOnChanges(changes: SimpleChanges): void{ @@ -204,11 +206,16 @@ export class VaConversationComponent implements OnInit, OnChanges { break; case 'expression': if (this.form[this.iCurrentQuestion].description){ - this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].description, 'false', + this.addMsg(this.form[this.iCurrentQuestion].type, + this.form[this.iCurrentQuestion].title + '\n' + this.form[this.iCurrentQuestion].description, + 'false', this.userVa, Date.now(), []); } r = false; break; + // case 'comment': + // this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].description, 'false', + // this.userVa, Date.now(), []); default: this.currentRecord[this.form[this.iCurrentQuestion].name] = null, r = false; From 25b19db012e421bba9d044f5f30c1c5cb6403781 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Thu, 15 Jul 2021 10:16:35 +0200 Subject: [PATCH 31/56] [SAFE-411] comment type added --- .../va-conversation.component.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 053a082140..a2553f2e45 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -82,11 +82,12 @@ export class VaConversationComponent implements OnInit, OnChanges { } } - // send simple reply message (TEXT) + // send simple reply message (TEXT) (click on send msg or enter) sendReplyMsgText(msg: string): void { console.log(this.iCurrentQuestion); - if (this.iCurrentQuestion < this.form.length){ - if (msg !== '' && this.form[this.iCurrentQuestion - 1].type === 'text'){ + console.log(this.form[this.iCurrentQuestion - 1].type); + if (this.iCurrentQuestion - 1 < this.form.length){ + if ((msg !== '' && this.form[this.iCurrentQuestion - 1].type === 'text') || (msg !== '' && this.form[this.iCurrentQuestion - 1].type === 'comment')){ this.addMsg('', msg, 'true', this.userMe, Date.now(), []); // this.records.push(msg); @@ -185,6 +186,7 @@ export class VaConversationComponent implements OnInit, OnChanges { // control the bot format message depending on the type questionController(): boolean { + this.inputMsgType = 'text'; let r = true; const t = this.form[this.iCurrentQuestion].type; switch (t){ @@ -192,9 +194,13 @@ export class VaConversationComponent implements OnInit, OnChanges { if (this.form[this.iCurrentQuestion].inputType !== null) { this.inputMsgType = this.form[this.iCurrentQuestion].inputType; } - else { - this.inputMsgType = 'text'; - } + // else { + // this.inputMsgType = 'text'; + // } + this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', + this.userVa, Date.now(), []); + break; + case 'comment': this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', this.userVa, Date.now(), []); break; From 8988b6e1a8b85170a193cde54fd72caa1bc6b61b Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Thu, 15 Jul 2021 10:19:25 +0200 Subject: [PATCH 32/56] [SAFE-411] comment type fixed --- .../va-conversation/va-conversation.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index a2553f2e45..6387576acc 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -86,8 +86,8 @@ export class VaConversationComponent implements OnInit, OnChanges { sendReplyMsgText(msg: string): void { console.log(this.iCurrentQuestion); console.log(this.form[this.iCurrentQuestion - 1].type); - if (this.iCurrentQuestion - 1 < this.form.length){ - if ((msg !== '' && this.form[this.iCurrentQuestion - 1].type === 'text') || (msg !== '' && this.form[this.iCurrentQuestion - 1].type === 'comment')){ + if (this.iCurrentQuestion - 1 < this.form.length){ + if (msg !== '' && (this.form[this.iCurrentQuestion - 1].type === 'text' || this.form[this.iCurrentQuestion - 1].type === 'comment')){ this.addMsg('', msg, 'true', this.userMe, Date.now(), []); // this.records.push(msg); From c820810c8948eee495dc780e99d06f4b2d1e3978 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Thu, 15 Jul 2021 10:35:12 +0200 Subject: [PATCH 33/56] [SAFE-411] iCurrentQuestion fixed --- .../va-conversation.component.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 6387576acc..4360f02bf8 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -44,7 +44,7 @@ export class VaConversationComponent implements OnInit, OnChanges { constructor() { this.currentText = ''; - this.iCurrentQuestion = 0; + this.iCurrentQuestion = -1; this.restartChoiceMsg = 'restart'; this.endChoiceMsg = 'end'; @@ -86,14 +86,15 @@ export class VaConversationComponent implements OnInit, OnChanges { sendReplyMsgText(msg: string): void { console.log(this.iCurrentQuestion); console.log(this.form[this.iCurrentQuestion - 1].type); - if (this.iCurrentQuestion - 1 < this.form.length){ - if (msg !== '' && (this.form[this.iCurrentQuestion - 1].type === 'text' || this.form[this.iCurrentQuestion - 1].type === 'comment')){ + console.log(this.form[this.iCurrentQuestion].type); + if (this.iCurrentQuestion < this.form.length){ + if (msg !== '' && (this.form[this.iCurrentQuestion].type === 'text' || this.form[this.iCurrentQuestion].type === 'comment')){ this.addMsg('', msg, 'true', this.userMe, Date.now(), []); // this.records.push(msg); // complete current record // -1 because the chat start with a message of the bot - this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = msg; + this.currentRecord[this.form[this.iCurrentQuestion].name] = msg; this.afterReply(); } } @@ -106,7 +107,7 @@ export class VaConversationComponent implements OnInit, OnChanges { this.speak(this.speech, ch.text); this.addMsg('', ch.text, 'true', this.userMe, Date.now(), []); - this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = ch.value; + this.currentRecord[this.form[this.iCurrentQuestion].name] = ch.value; this.afterReply(); } } @@ -131,7 +132,7 @@ export class VaConversationComponent implements OnInit, OnChanges { }); this.addMsg('', text, 'true', this.userMe, Date.now(), []); - this.currentRecord[this.form[this.iCurrentQuestion - 1].name] = choicesRecord; + this.currentRecord[this.form[this.iCurrentQuestion].name] = choicesRecord; this.afterReply(); } @@ -152,7 +153,7 @@ export class VaConversationComponent implements OnInit, OnChanges { restartForm(): void { this.sendReplyMsgTextEnd(); - this.iCurrentQuestion = 0; + this.iCurrentQuestion = -1; this.currentRecord = {}; window.setTimeout(() => { this.sendNextQuestion(); @@ -160,9 +161,9 @@ export class VaConversationComponent implements OnInit, OnChanges { } sendNextQuestion(): void { + this.iCurrentQuestion++; if (this.iCurrentQuestion < this.form.length){ const r = this.questionController(); - this.iCurrentQuestion++; this.updateScrollViewPos(); if (!r){ this.sendNextQuestion(); @@ -179,7 +180,7 @@ export class VaConversationComponent implements OnInit, OnChanges { new Choices(this.endChoiceMsg, this.endChoiceMsg + '?') ]); - this.iCurrentQuestion++; + // this.iCurrentQuestion++; this.updateScrollViewPos(); } } From e5d0f24e33b9ff5118abb1c9dddb9e6829c4b97c Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Thu, 15 Jul 2021 11:11:34 +0200 Subject: [PATCH 34/56] [SAFE-411] tagbox type added --- .../conversation-message/conversation-message.component.html | 3 +-- .../va-conversation/va-conversation.component.ts | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html index 264c7f3537..3c9551d99a 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html @@ -14,7 +14,7 @@
-
+
@@ -22,4 +22,3 @@
- diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 4360f02bf8..0345c36f76 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -208,6 +208,7 @@ export class VaConversationComponent implements OnInit, OnChanges { case 'radiogroup': case 'dropdown': case 'checkbox': + case 'tagbox': this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', this.userVa, Date.now(), this.form[this.iCurrentQuestion].choices); break; From 3dc620fa6d6849d650d5b75dce594de00d8a4f24 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Thu, 15 Jul 2021 12:16:31 +0200 Subject: [PATCH 35/56] [SAFE-411] boolean type added --- .../conversation-message.component.html | 9 ++++++++- .../conversation-message.component.ts | 3 +++ .../va-conversation.component.ts | 5 +++++ .../virtual-assistant.component.ts | 1 + .../virtual-assistant.module.ts | 18 ++++++++++-------- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html index 3c9551d99a..daefbe28c8 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html @@ -11,9 +11,12 @@

-
+
+ + +
@@ -22,3 +25,7 @@
+ + + + diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index 61acb1bf69..4b943e08a1 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -76,4 +76,7 @@ export class ConversationMessageComponent implements OnInit { this.btnChoiceCheckBoxValidateClick.emit(this.checkBoxChoices); $event.currentTarget.parentElement.parentElement.setAttribute('style', 'display: none'); } + + btnBooleanClickFn(value: any): void { + } } diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 0345c36f76..b9792843d8 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -205,6 +205,11 @@ export class VaConversationComponent implements OnInit, OnChanges { this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', this.userVa, Date.now(), []); break; + case 'boolean': + this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', + this.userVa, Date.now(), [new Choices('false', this.form[this.iCurrentQuestion].labelFalse), + new Choices('true', this.form[this.iCurrentQuestion].labelTrue)]); + break; case 'radiogroup': case 'dropdown': case 'checkbox': diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts index de5fd2d6b9..ecae5af014 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts @@ -77,6 +77,7 @@ export class VirtualAssistantComponent implements OnInit { console.log('APOLLO: res.data.form'); console.log(res); this.form = JSON.parse(res.data.form.structure).pages[0].elements; + console.log(this.form); }); } diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts index 9fef03a3f3..09870a60cc 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts @@ -10,6 +10,7 @@ import { VaConversationComponent } from './va-conversation/va-conversation.compo import {ConversationHeaderComponent} from './va-conversation/conversation-header/conversation-header.component'; import {ConversationMessageComponent} from './va-conversation/conversation-message/conversation-message.component'; import {ConversationFooterComponent} from './va-conversation/conversation-footer/conversation-footer.component'; +import {MatSlideToggleModule} from '@angular/material/slide-toggle'; @NgModule({ declarations: [VirtualAssistantComponent, @@ -17,14 +18,15 @@ import {ConversationFooterComponent} from './va-conversation/conversation-footer ConversationHeaderComponent, ConversationMessageComponent, ConversationFooterComponent], - imports: [ - CommonModule, - VirtualAssistantRoutingModule, - MatIconModule, - MatButtonModule, - MatGridListModule, - ScrollingModule - ], + imports: [ + CommonModule, + VirtualAssistantRoutingModule, + MatIconModule, + MatButtonModule, + MatGridListModule, + ScrollingModule, + MatSlideToggleModule + ], exports: [VirtualAssistantComponent] }) export class VirtualAssistantModule { } From 502cbb95ccefaa009d5a3261e6664c46278e794c Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Thu, 15 Jul 2021 12:20:39 +0200 Subject: [PATCH 36/56] [SAFE-411] code cleaned --- .../conversation-message.component.html | 7 ------- .../va-conversation/va-conversation.component.ts | 15 --------------- 2 files changed, 22 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html index daefbe28c8..86f4a7e609 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.html @@ -14,9 +14,6 @@
- - -
@@ -25,7 +22,3 @@
- - - - diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index b9792843d8..b7dc6bd8c6 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -85,15 +85,9 @@ export class VaConversationComponent implements OnInit, OnChanges { // send simple reply message (TEXT) (click on send msg or enter) sendReplyMsgText(msg: string): void { console.log(this.iCurrentQuestion); - console.log(this.form[this.iCurrentQuestion - 1].type); - console.log(this.form[this.iCurrentQuestion].type); if (this.iCurrentQuestion < this.form.length){ if (msg !== '' && (this.form[this.iCurrentQuestion].type === 'text' || this.form[this.iCurrentQuestion].type === 'comment')){ this.addMsg('', msg, 'true', this.userMe, Date.now(), []); - - // this.records.push(msg); - // complete current record - // -1 because the chat start with a message of the bot this.currentRecord[this.form[this.iCurrentQuestion].name] = msg; this.afterReply(); } @@ -195,9 +189,6 @@ export class VaConversationComponent implements OnInit, OnChanges { if (this.form[this.iCurrentQuestion].inputType !== null) { this.inputMsgType = this.form[this.iCurrentQuestion].inputType; } - // else { - // this.inputMsgType = 'text'; - // } this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', this.userVa, Date.now(), []); break; @@ -226,9 +217,6 @@ export class VaConversationComponent implements OnInit, OnChanges { } r = false; break; - // case 'comment': - // this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].description, 'false', - // this.userVa, Date.now(), []); default: this.currentRecord[this.form[this.iCurrentQuestion].name] = null, r = false; @@ -244,9 +232,6 @@ export class VaConversationComponent implements OnInit, OnChanges { } else if (choice.value === this.endChoiceMsg){ this.endConversation.emit(this.records); - // add record - // close the window - // window.close(); } else { this.sendReplyMsgChoice(choice); From 4d90de00743a8377a1013b65a7d822ad86ea6c32 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Thu, 15 Jul 2021 15:34:22 +0200 Subject: [PATCH 37/56] [SAFE-411] multiple text added --- .../va-conversation.component.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index b7dc6bd8c6..62098f5a6b 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -41,6 +41,9 @@ export class VaConversationComponent implements OnInit, OnChanges { public inputMsgType: string; + public mtObjectTemp: any; + public iCurMtQ: number; + constructor() { this.currentText = ''; @@ -62,6 +65,9 @@ export class VaConversationComponent implements OnInit, OnChanges { this.speech = new Speech(); this.inputMsgType = 'text'; + + this.mtObjectTemp = {}; + this.iCurMtQ = -1; } ngOnInit(): void { @@ -91,6 +97,13 @@ export class VaConversationComponent implements OnInit, OnChanges { this.currentRecord[this.form[this.iCurrentQuestion].name] = msg; this.afterReply(); } + else if (this.form[this.iCurrentQuestion].type === 'multipletext'){ + this.addMsg('', msg, 'true', this.userMe, Date.now(), []); + this.mtObjectTemp[this.form[this.iCurrentQuestion].items[this.iCurMtQ ].name] = msg; + this.currentText = ''; + this.updateScrollViewPos(); + this.sendNextMtQuestion(); + } } } @@ -217,6 +230,11 @@ export class VaConversationComponent implements OnInit, OnChanges { } r = false; break; + case 'multipletext': + this.iCurMtQ = -1; + this.mtObjectTemp = {}; + this.sendNextMtQuestion(); + break; default: this.currentRecord[this.form[this.iCurrentQuestion].name] = null, r = false; @@ -225,6 +243,18 @@ export class VaConversationComponent implements OnInit, OnChanges { return r; } + sendNextMtQuestion(): void { + this.iCurMtQ ++ ; + if (this.iCurMtQ < this.form[this.iCurrentQuestion].items.length){ + this.addMsg('text', this.form[this.iCurrentQuestion].items[this.iCurMtQ].title, 'false', this.userVa, Date.now(), []); + } + else { + console.log('FINISHED'); + this.currentRecord[this.form[this.iCurrentQuestion].name] = this.mtObjectTemp; + this.sendNextQuestion(); + } + } + // click on a choice (radio) choiceClick(choice: Choices): void{ if (choice.value === this.restartChoiceMsg){ From d4e191f54ae9af259b28b627933989d4f0742f0a Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Thu, 15 Jul 2021 18:48:34 +0200 Subject: [PATCH 38/56] [SAFE-411] Boolean type issue fixed --- .../virtual-assistant/models/choices.model.ts | 4 +-- .../conversation-message.component.ts | 3 -- .../va-conversation.component.ts | 31 +++++++------------ 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/models/choices.model.ts b/projects/back-office/src/app/virtual-assistant/models/choices.model.ts index 42615b5045..3bb8f7795c 100644 --- a/projects/back-office/src/app/virtual-assistant/models/choices.model.ts +++ b/projects/back-office/src/app/virtual-assistant/models/choices.model.ts @@ -1,8 +1,8 @@ export class Choices { - value: string; + value: any; text: string; - constructor(value: string, text: string) { + constructor(value: any, text: string) { this.value = value; this.text = text; } diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts index 4b943e08a1..61acb1bf69 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-message/conversation-message.component.ts @@ -76,7 +76,4 @@ export class ConversationMessageComponent implements OnInit { this.btnChoiceCheckBoxValidateClick.emit(this.checkBoxChoices); $event.currentTarget.parentElement.parentElement.setAttribute('style', 'display: none'); } - - btnBooleanClickFn(value: any): void { - } } diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 62098f5a6b..dd6ead4bf0 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -26,9 +26,6 @@ export class VaConversationComponent implements OnInit, OnChanges { public restartChoiceMsg: string; public endChoiceMsg: string; - public userImgLink: string; - public vaImgLink: string; - public endMessage: string; @Output() endConversation: EventEmitter = new EventEmitter(); @@ -54,20 +51,17 @@ export class VaConversationComponent implements OnInit, OnChanges { this.currentRecord = {}; - this.userImgLink = 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'; - this.vaImgLink = 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'; - - this.userMe = new User('Me', this.userImgLink); - this.userVa = new User('Assistant', this.vaImgLink); + this.userMe = new User('Me', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Circle-icons-profile.svg/1024px-Circle-icons-profile.svg.png'); + this.userVa = new User('Assistant', 'https://www.121outsource.com/wp-content/uploads/2018/08/virtual-assitants.png'); - this.endMessage = 'Thank you for your time, bye!'; - - this.speech = new Speech(); + this.endMessage = 'Thank you for your time, do you want to start another session or end now?'; this.inputMsgType = 'text'; this.mtObjectTemp = {}; this.iCurMtQ = -1; + + this.speech = new Speech(); } ngOnInit(): void { @@ -109,10 +103,13 @@ export class VaConversationComponent implements OnInit, OnChanges { // send reply message after clicking on a choice (RADIOGROUP) sendReplyMsgChoice(ch: Choices): void { + console.log('@@ sendReplyMsgChoice @@'); if (ch.text !== ''){ - + console.log('## sendReplyMsgChoice ##'); + console.log(ch); + console.log(ch.text); + console.log(ch.value); this.speak(this.speech, ch.text); - this.addMsg('', ch.text, 'true', this.userMe, Date.now(), []); this.currentRecord[this.form[this.iCurrentQuestion].name] = ch.value; this.afterReply(); @@ -152,7 +149,6 @@ export class VaConversationComponent implements OnInit, OnChanges { } afterReply(): void { - // reset input text this.currentText = ''; this.updateScrollViewPos(); this.sendNextQuestion(); @@ -186,8 +182,6 @@ export class VaConversationComponent implements OnInit, OnChanges { new Choices(this.restartChoiceMsg, this.restartChoiceMsg + '?'), new Choices(this.endChoiceMsg, this.endChoiceMsg + '?') ]); - - // this.iCurrentQuestion++; this.updateScrollViewPos(); } } @@ -211,8 +205,8 @@ export class VaConversationComponent implements OnInit, OnChanges { break; case 'boolean': this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', - this.userVa, Date.now(), [new Choices('false', this.form[this.iCurrentQuestion].labelFalse), - new Choices('true', this.form[this.iCurrentQuestion].labelTrue)]); + this.userVa, Date.now(), [new Choices(false, this.form[this.iCurrentQuestion].labelFalse), + new Choices(true, this.form[this.iCurrentQuestion].labelTrue)]); break; case 'radiogroup': case 'dropdown': @@ -249,7 +243,6 @@ export class VaConversationComponent implements OnInit, OnChanges { this.addMsg('text', this.form[this.iCurrentQuestion].items[this.iCurMtQ].title, 'false', this.userVa, Date.now(), []); } else { - console.log('FINISHED'); this.currentRecord[this.form[this.iCurrentQuestion].name] = this.mtObjectTemp; this.sendNextQuestion(); } From 62862bbaec8876cd449bee525712427ac193aea0 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Fri, 16 Jul 2021 09:32:41 +0200 Subject: [PATCH 39/56] [SAFE-411] color input default value fixed --- .../va-conversation/va-conversation.component.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index dd6ead4bf0..89d49c19c3 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -195,6 +195,9 @@ export class VaConversationComponent implements OnInit, OnChanges { case 'text': if (this.form[this.iCurrentQuestion].inputType !== null) { this.inputMsgType = this.form[this.iCurrentQuestion].inputType; + if (this.inputMsgType === 'color'){ + this.currentText = '#000000'; + } } this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', this.userVa, Date.now(), []); From 57bced0177d0e238ae553812dfea416ef4ae3cd9 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Fri, 16 Jul 2021 12:07:17 +0200 Subject: [PATCH 40/56] [SAFE-411] multiple text empty issue fixed --- .../conversation-footer.component.ts | 15 +++++++ .../va-conversation.component.html | 2 +- .../va-conversation.component.ts | 40 +++++++++++-------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts index 67e5dff76b..5d4820b855 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts @@ -23,6 +23,21 @@ export class ConversationFooterComponent implements OnInit, OnChanges { ngOnChanges(changes: SimpleChanges): void { // we skip that at the beginning when object are not yet set if (this.input !== undefined && changes.inputValue !== undefined){ + // if (this.inputType === 'color'){ + // this.inputValue = '#000000'; + // } + // if (this.inputType === 'range'){ + // this.inputValue = '50'; + // } + // if (this.inputType === 'tel'){ + // console.log('### TEL ###'); + // this.inputValue = '+'; + // } + console.log('changes.inputValue.currentValue : ' + changes.inputValue.currentValue); + console.log('this.inputValue : ' + this.inputValue); + console.log('this.inputType : ' + this.inputType); + console.log('this.input.value : ' + this.input.value); + this.input.value = this.inputValue; this.msgChange(changes.inputValue.currentValue); this.input.focus(); } diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html index 3217851b43..0406e2c341 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html @@ -12,5 +12,5 @@
- + diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 89d49c19c3..bc23cce782 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -42,6 +42,7 @@ export class VaConversationComponent implements OnInit, OnChanges { public iCurMtQ: number; constructor() { + console.log('currentText CHANGED'); this.currentText = ''; this.iCurrentQuestion = -1; @@ -78,22 +79,24 @@ export class VaConversationComponent implements OnInit, OnChanges { msgUpdated(msg: any): void{ if (typeof msg === 'string'){ + console.log('currentText CHANGED msgUpdtaed'); + console.log(msg); this.currentText = msg; } } // send simple reply message (TEXT) (click on send msg or enter) - sendReplyMsgText(msg: string): void { + sendReplyMsgText(): void { console.log(this.iCurrentQuestion); if (this.iCurrentQuestion < this.form.length){ - if (msg !== '' && (this.form[this.iCurrentQuestion].type === 'text' || this.form[this.iCurrentQuestion].type === 'comment')){ - this.addMsg('', msg, 'true', this.userMe, Date.now(), []); - this.currentRecord[this.form[this.iCurrentQuestion].name] = msg; + if (this.currentText !== '' && (this.form[this.iCurrentQuestion].type === 'text' || this.form[this.iCurrentQuestion].type === 'comment')){ + this.addMsg('', this.currentText, 'true', this.userMe, Date.now(), []); + this.currentRecord[this.form[this.iCurrentQuestion].name] = this.currentText; this.afterReply(); } - else if (this.form[this.iCurrentQuestion].type === 'multipletext'){ - this.addMsg('', msg, 'true', this.userMe, Date.now(), []); - this.mtObjectTemp[this.form[this.iCurrentQuestion].items[this.iCurMtQ ].name] = msg; + else if (this.currentText !== '' && this.form[this.iCurrentQuestion].type === 'multipletext'){ + this.addMsg('', this.currentText, 'true', this.userMe, Date.now(), []); + this.mtObjectTemp[this.form[this.iCurrentQuestion].items[this.iCurMtQ ].name] = this.currentText; this.currentText = ''; this.updateScrollViewPos(); this.sendNextMtQuestion(); @@ -103,13 +106,8 @@ export class VaConversationComponent implements OnInit, OnChanges { // send reply message after clicking on a choice (RADIOGROUP) sendReplyMsgChoice(ch: Choices): void { - console.log('@@ sendReplyMsgChoice @@'); if (ch.text !== ''){ - console.log('## sendReplyMsgChoice ##'); - console.log(ch); - console.log(ch.text); - console.log(ch.value); - this.speak(this.speech, ch.text); + // this.speak(this.speech, ch.text); this.addMsg('', ch.text, 'true', this.userMe, Date.now(), []); this.currentRecord[this.form[this.iCurrentQuestion].name] = ch.value; this.afterReply(); @@ -119,10 +117,10 @@ export class VaConversationComponent implements OnInit, OnChanges { // click on a checkbox choice choiceCheckBoxClick(e: any): void { if (e.state === true){ - this.speak(this.speech, e.choice.text); + // this.speak(this.speech, e.choice.text); } else { - this.speak(this.speech, e.choice.text + ' removed'); + // this.speak(this.speech, e.choice.text + ' removed'); } } @@ -164,6 +162,8 @@ export class VaConversationComponent implements OnInit, OnChanges { } sendNextQuestion(): void { + console.log('sendNextQuestion'); + console.log(this.currentText); this.iCurrentQuestion++; if (this.iCurrentQuestion < this.form.length){ const r = this.questionController(); @@ -195,9 +195,17 @@ export class VaConversationComponent implements OnInit, OnChanges { case 'text': if (this.form[this.iCurrentQuestion].inputType !== null) { this.inputMsgType = this.form[this.iCurrentQuestion].inputType; + console.log(this.inputMsgType); if (this.inputMsgType === 'color'){ this.currentText = '#000000'; } + if (this.inputMsgType === 'range'){ + this.currentText = '50'; + } + // if (this.inputMsgType === 'tel'){ + // console.log('### TEL ###'); + // this.currentText = '+'; + // } } this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', this.userVa, Date.now(), []); @@ -273,7 +281,7 @@ export class VaConversationComponent implements OnInit, OnChanges { choices: Choices[]): void { if (reply === 'false'){ console.log('speak'); - this.speak(this.speech, text); + // this.speak(this.speech, text); } this.conv.push(new Message(type, text, reply, user, date, choices)); } From 4a22eb775ce31564dffdf7e307995b78d8825c7c Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Fri, 16 Jul 2021 13:59:35 +0200 Subject: [PATCH 41/56] [SAFE-411] test and try to fix the input value issue, but it is still there --- .../conversation-footer.component.ts | 14 ++++++++++++-- .../va-conversation/va-conversation.component.ts | 7 ++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts index 5d4820b855..17b6d19b69 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts @@ -23,6 +23,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges { ngOnChanges(changes: SimpleChanges): void { // we skip that at the beginning when object are not yet set if (this.input !== undefined && changes.inputValue !== undefined){ + console.log('ngOnChanges : ' + this.inputValue); // if (this.inputType === 'color'){ // this.inputValue = '#000000'; // } @@ -33,12 +34,21 @@ export class ConversationFooterComponent implements OnInit, OnChanges { // console.log('### TEL ###'); // this.inputValue = '+'; // } + this.input.value = null; + console.log('this.input.value : ' + this.input.value); + this.input.value = null; + console.log('this.input.value : ' + this.input.value); + this.input.value = null; console.log('changes.inputValue.currentValue : ' + changes.inputValue.currentValue); console.log('this.inputValue : ' + this.inputValue); console.log('this.inputType : ' + this.inputType); console.log('this.input.value : ' + this.input.value); - this.input.value = this.inputValue; - this.msgChange(changes.inputValue.currentValue); + if (changes.inputValue.currentValue === '' && this.inputValue !== ''){ + // this.msgChange(this.inputValue); + } + else if (changes.inputValue.currentValue !== ''){ + this.msgChange(changes.inputValue.currentValue); + } this.input.focus(); } } diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index bc23cce782..d69166a5f5 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -79,7 +79,7 @@ export class VaConversationComponent implements OnInit, OnChanges { msgUpdated(msg: any): void{ if (typeof msg === 'string'){ - console.log('currentText CHANGED msgUpdtaed'); + console.log('msgUpdated'); console.log(msg); this.currentText = msg; } @@ -147,6 +147,7 @@ export class VaConversationComponent implements OnInit, OnChanges { } afterReply(): void { + console.log('AFTER REPLYYYYY'); this.currentText = ''; this.updateScrollViewPos(); this.sendNextQuestion(); @@ -202,10 +203,6 @@ export class VaConversationComponent implements OnInit, OnChanges { if (this.inputMsgType === 'range'){ this.currentText = '50'; } - // if (this.inputMsgType === 'tel'){ - // console.log('### TEL ###'); - // this.currentText = '+'; - // } } this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', this.userVa, Date.now(), []); From a576eab63c214098f098c1998b91e696efd2ea2c Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 19 Jul 2021 09:16:16 +0200 Subject: [PATCH 42/56] [SAFE-411] change input type at the end --- .../va-conversation/va-conversation.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index d69166a5f5..155b5e0271 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -183,6 +183,7 @@ export class VaConversationComponent implements OnInit, OnChanges { new Choices(this.restartChoiceMsg, this.restartChoiceMsg + '?'), new Choices(this.endChoiceMsg, this.endChoiceMsg + '?') ]); + this.inputMsgType = 'text'; this.updateScrollViewPos(); } } From 694b84c1a6cf4c9a6970ddb3a8859294305a28be Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 19 Jul 2021 11:10:30 +0200 Subject: [PATCH 43/56] [SAFE-411] add title + description display --- .../va-conversation.component.ts | 49 ++++++++++++------- .../virtual-assistant.component.html | 2 +- .../virtual-assistant.component.ts | 5 ++ 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 155b5e0271..376f940f3d 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -14,6 +14,7 @@ import Speech from 'speak-tts'; export class VaConversationComponent implements OnInit, OnChanges { @Input() form: any[] = []; + @Input() td: {title: string, description: string}; public records: any[] = []; public currentRecord: any; @@ -63,6 +64,8 @@ export class VaConversationComponent implements OnInit, OnChanges { this.iCurMtQ = -1; this.speech = new Speech(); + + this.td = {title: '', description: ''}; } ngOnInit(): void { @@ -165,27 +168,35 @@ export class VaConversationComponent implements OnInit, OnChanges { sendNextQuestion(): void { console.log('sendNextQuestion'); console.log(this.currentText); - this.iCurrentQuestion++; - if (this.iCurrentQuestion < this.form.length){ - const r = this.questionController(); - this.updateScrollViewPos(); - if (!r){ - this.sendNextQuestion(); - } + if (this.conv.length === 0){ + this.addMsg('text', this.td.title, 'false', this.userVa, Date.now(), []); + this.addMsg('text', this.td.description, 'false', this.userVa, Date.now(), []); + this.sendNextQuestion(); } - else if (this.iCurrentQuestion === this.form.length) { - // add this record - this.records.push(this.currentRecord); - console.log(this.records); - - this.addMsg('text', this.endMessage, 'false', this.userVa, Date.now(), - [ - new Choices(this.restartChoiceMsg, this.restartChoiceMsg + '?'), - new Choices(this.endChoiceMsg, this.endChoiceMsg + '?') - ]); - this.inputMsgType = 'text'; - this.updateScrollViewPos(); + else { + this.iCurrentQuestion++; + if (this.iCurrentQuestion < this.form.length){ + const r = this.questionController(); + this.updateScrollViewPos(); + if (!r){ + this.sendNextQuestion(); + } + } + else if (this.iCurrentQuestion === this.form.length) { + // add this record + this.records.push(this.currentRecord); + console.log(this.records); + + this.addMsg('text', this.endMessage, 'false', this.userVa, Date.now(), + [ + new Choices(this.restartChoiceMsg, this.restartChoiceMsg + '?'), + new Choices(this.endChoiceMsg, this.endChoiceMsg + '?') + ]); + this.inputMsgType = 'text'; + this.updateScrollViewPos(); + } } + } // control the bot format message depending on the type diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html index ac503467e1..7abb5d9de8 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html @@ -35,7 +35,7 @@ va-face
- +
diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts index ecae5af014..344699bc18 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts @@ -18,6 +18,7 @@ export class VirtualAssistantComponent implements OnInit { // === DATA === public id = ''; public form: any; + public td: any; public iQuestion: any; public messages: any; public vaCols: number; @@ -77,6 +78,10 @@ export class VirtualAssistantComponent implements OnInit { console.log('APOLLO: res.data.form'); console.log(res); this.form = JSON.parse(res.data.form.structure).pages[0].elements; + this.td = { + title: JSON.parse(res.data.form.structure).pages[0].title, + description: JSON.parse(res.data.form.structure).pages[0].description + }; console.log(this.form); }); } From 958993e4ace09eb0ab7c4b133df8243beb48e8b8 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 19 Jul 2021 12:19:12 +0200 Subject: [PATCH 44/56] [SAFE-411] title + description form fixed --- .../conversation-footer.component.ts | 5 +++++ .../va-conversation.component.ts | 8 ++++++-- .../virtual-assistant.component.ts | 19 ++++++++++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts index 17b6d19b69..5307c3dc85 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts @@ -49,6 +49,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges { else if (changes.inputValue.currentValue !== ''){ this.msgChange(changes.inputValue.currentValue); } + console.log('*** FOCUS ***'); this.input.focus(); } } @@ -62,6 +63,10 @@ export class ConversationFooterComponent implements OnInit, OnChanges { this.btnRec = document.getElementById('btnRec'); } + inputFocus(): void { + this.input.focus(); + } + msgChange(text: string): void { this.inputChange.emit(text); if (text === ''){ diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 376f940f3d..6785d807df 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -169,8 +169,12 @@ export class VaConversationComponent implements OnInit, OnChanges { console.log('sendNextQuestion'); console.log(this.currentText); if (this.conv.length === 0){ - this.addMsg('text', this.td.title, 'false', this.userVa, Date.now(), []); - this.addMsg('text', this.td.description, 'false', this.userVa, Date.now(), []); + if (this.td.title !== undefined){ + this.addMsg('text', this.td.title, 'false', this.userVa, Date.now(), []); + } + if (this.td.description !== undefined){ + this.addMsg('text', this.td.description, 'false', this.userVa, Date.now(), []); + } this.sendNextQuestion(); } else { diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts index 344699bc18..bda7f004d5 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts @@ -18,7 +18,7 @@ export class VirtualAssistantComponent implements OnInit { // === DATA === public id = ''; public form: any; - public td: any; + public td: {title: string, description: string}; public iQuestion: any; public messages: any; public vaCols: number; @@ -38,6 +38,11 @@ export class VirtualAssistantComponent implements OnInit { this.iQuestion = 0; this.start = false; + + this.td = { + title: '', + description: '' + }; } ngOnInit(): void { @@ -78,10 +83,14 @@ export class VirtualAssistantComponent implements OnInit { console.log('APOLLO: res.data.form'); console.log(res); this.form = JSON.parse(res.data.form.structure).pages[0].elements; - this.td = { - title: JSON.parse(res.data.form.structure).pages[0].title, - description: JSON.parse(res.data.form.structure).pages[0].description - }; + if (JSON.parse(res.data.form.structure).pages[0].title !== undefined){ + console.log(JSON.parse(res.data.form.structure).pages[0].title); + this.td.title = JSON.parse(res.data.form.structure).pages[0].title; + } + if (JSON.parse(res.data.form.structure).pages[0].description !== undefined){ + console.log(JSON.parse(res.data.form.structure).pages[0].description); + this.td.description = JSON.parse(res.data.form.structure).pages[0].description; + } console.log(this.form); }); } From a9f3d8ea9613ac5211f1e39ecd0565adf0e4f38d Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 19 Jul 2021 13:08:42 +0200 Subject: [PATCH 45/56] [SAFE-411] Input focus fixed --- .../conversation-footer.component.ts | 5 ++++ .../va-conversation.component.html | 2 +- .../va-conversation.component.ts | 25 ++++++++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts index 5307c3dc85..3da7f96b09 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts @@ -83,4 +83,9 @@ export class ConversationFooterComponent implements OnInit, OnChanges { this.btnSend.setAttribute('style', 'display: inline'); } } + + testFn(): void { + console.log('## testFn'); + this.input.focus(); + } } diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html index 0406e2c341..22b5677f10 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.html @@ -12,5 +12,5 @@ - + diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 6785d807df..1bca525cef 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -1,10 +1,23 @@ -import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild} from '@angular/core'; +import { + AfterViewInit, + Component, + ElementRef, + EventEmitter, + Input, + OnChanges, + OnInit, + Output, + SimpleChanges, + ViewChild +} from '@angular/core'; import {CdkVirtualScrollViewport} from '@angular/cdk/scrolling'; import {Message} from '../models/message.model'; import {User} from '../models/user.model'; import {Choices} from '../models/choices.model'; // @ts-ignore import Speech from 'speak-tts'; +import {ConversationFooterComponent} from './conversation-footer/conversation-footer.component'; + @Component({ selector: 'app-va-conversation', @@ -13,6 +26,8 @@ import Speech from 'speak-tts'; }) export class VaConversationComponent implements OnInit, OnChanges { + // @ts-ignore + @ViewChild('footerComponent') conversationFooterComponent: ConversationFooterComponent; @Input() form: any[] = []; @Input() td: {title: string, description: string}; public records: any[] = []; @@ -66,6 +81,8 @@ export class VaConversationComponent implements OnInit, OnChanges { this.speech = new Speech(); this.td = {title: '', description: ''}; + + // this.conversationFooterComponent; } ngOnInit(): void { @@ -80,6 +97,10 @@ export class VaConversationComponent implements OnInit, OnChanges { } } + // ngAfterViewInit(): void { + // this.conversationFooterComponent.testFn(); + // } + msgUpdated(msg: any): void{ if (typeof msg === 'string'){ console.log('msgUpdated'); @@ -199,6 +220,7 @@ export class VaConversationComponent implements OnInit, OnChanges { this.inputMsgType = 'text'; this.updateScrollViewPos(); } + // this.conversationFooterComponent.testFn(); } } @@ -297,6 +319,7 @@ export class VaConversationComponent implements OnInit, OnChanges { // this.speak(this.speech, text); } this.conv.push(new Message(type, text, reply, user, date, choices)); + this.conversationFooterComponent.testFn(); } /* ----- STYLE ----- */ From 98540db60c13c2abc116b2a28ab0df1380435e89 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 19 Jul 2021 14:38:24 +0200 Subject: [PATCH 46/56] [SAFE-411] code cleaning --- .../conversation-footer/conversation-footer.component.ts | 2 -- .../va-conversation/va-conversation.component.ts | 2 -- 2 files changed, 4 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts index 3da7f96b09..50cabd50fa 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts @@ -49,7 +49,6 @@ export class ConversationFooterComponent implements OnInit, OnChanges { else if (changes.inputValue.currentValue !== ''){ this.msgChange(changes.inputValue.currentValue); } - console.log('*** FOCUS ***'); this.input.focus(); } } @@ -85,7 +84,6 @@ export class ConversationFooterComponent implements OnInit, OnChanges { } testFn(): void { - console.log('## testFn'); this.input.focus(); } } diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 1bca525cef..091dff377f 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -58,7 +58,6 @@ export class VaConversationComponent implements OnInit, OnChanges { public iCurMtQ: number; constructor() { - console.log('currentText CHANGED'); this.currentText = ''; this.iCurrentQuestion = -1; @@ -171,7 +170,6 @@ export class VaConversationComponent implements OnInit, OnChanges { } afterReply(): void { - console.log('AFTER REPLYYYYY'); this.currentText = ''; this.updateScrollViewPos(); this.sendNextQuestion(); From 81be1a0418cf40a53b222b115c637a43d104f992 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 19 Jul 2021 14:47:08 +0200 Subject: [PATCH 47/56] [SAFE-411] button chat and rec display modification --- .../conversation-footer.component.html | 2 +- .../conversation-footer.component.ts | 37 +++++++------------ 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html index e2c78a5d73..ead10c8f5c 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.html @@ -1,5 +1,5 @@ diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts index 50cabd50fa..2691a4b6d9 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts @@ -24,16 +24,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges { // we skip that at the beginning when object are not yet set if (this.input !== undefined && changes.inputValue !== undefined){ console.log('ngOnChanges : ' + this.inputValue); - // if (this.inputType === 'color'){ - // this.inputValue = '#000000'; - // } - // if (this.inputType === 'range'){ - // this.inputValue = '50'; - // } - // if (this.inputType === 'tel'){ - // console.log('### TEL ###'); - // this.inputValue = '+'; - // } + this.input.value = null; console.log('this.input.value : ' + this.input.value); this.input.value = null; @@ -68,19 +59,19 @@ export class ConversationFooterComponent implements OnInit, OnChanges { msgChange(text: string): void { this.inputChange.emit(text); - if (text === ''){ - this.btnSend.setAttribute('disabled', ''); - this.btnSend.setAttribute('style', 'display: none'); - - this.btnRec.removeAttribute('disabled'); - this.btnRec.setAttribute('style', 'display: inline'); - } else { - this.btnRec.setAttribute('disabled', ''); - this.btnRec.setAttribute('style', 'display: none'); - - this.btnSend.removeAttribute('disabled'); - this.btnSend.setAttribute('style', 'display: inline'); - } + // if (text === ''){ + // this.btnSend.setAttribute('disabled', ''); + // this.btnSend.setAttribute('style', 'display: none'); + // + // this.btnRec.removeAttribute('disabled'); + // this.btnRec.setAttribute('style', 'display: inline'); + // } else { + // this.btnRec.setAttribute('disabled', ''); + // this.btnRec.setAttribute('style', 'display: none'); + // + // this.btnSend.removeAttribute('disabled'); + // this.btnSend.setAttribute('style', 'display: inline'); + // } } testFn(): void { From 7b9d0e8a372f68394086b461ca88425861978f3a Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 19 Jul 2021 15:39:33 +0200 Subject: [PATCH 48/56] [SAFE-411] footer style fixed + loading form spinner and start button management --- .../virtual-assistant.component.html | 7 ++++--- .../virtual-assistant.component.scss | 6 ++++++ .../virtual-assistant.component.ts | 20 +++++++++++++------ .../virtual-assistant.module.ts | 4 +++- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html index 7abb5d9de8..2e8de6361b 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html @@ -29,13 +29,14 @@ -
va-face
+
va-face
- + va-face - + + diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss index 225ec5754a..2b2223a187 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss @@ -26,3 +26,9 @@ top: 90%; left: calc(50% - 50px); } + +#spinner-loading-form { + position: absolute; + top: 90%; + left: calc(50% - 50px); +} diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts index bda7f004d5..9c1e7f4c27 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts @@ -25,6 +25,8 @@ export class VirtualAssistantComponent implements OnInit { public chatCols: number; public start: boolean; + public startBtn: boolean; + public loadingForm: boolean; // === ROUTE === private routeSubscription?: Subscription; @@ -38,6 +40,8 @@ export class VirtualAssistantComponent implements OnInit { this.iQuestion = 0; this.start = false; + this.startBtn = false; + this.loadingForm = true; this.td = { title: '', @@ -82,16 +86,19 @@ export class VirtualAssistantComponent implements OnInit { }).valueChanges.subscribe((res: any) => { console.log('APOLLO: res.data.form'); console.log(res); - this.form = JSON.parse(res.data.form.structure).pages[0].elements; - if (JSON.parse(res.data.form.structure).pages[0].title !== undefined){ + const formStruct = JSON.parse(res.data.form.structure).pages[0]; + this.form = formStruct.elements; + if (formStruct.title !== undefined){ console.log(JSON.parse(res.data.form.structure).pages[0].title); - this.td.title = JSON.parse(res.data.form.structure).pages[0].title; + this.td.title = formStruct.title; } - if (JSON.parse(res.data.form.structure).pages[0].description !== undefined){ - console.log(JSON.parse(res.data.form.structure).pages[0].description); - this.td.description = JSON.parse(res.data.form.structure).pages[0].description; + if (formStruct.description !== undefined){ + console.log(formStruct.description); + this.td.description = formStruct.description; } console.log(this.form); + this.startBtn = true; + this.loadingForm = false; }); } @@ -127,5 +134,6 @@ export class VirtualAssistantComponent implements OnInit { this.vaCols = 1; this.chatCols = 1; this.start = true; + this.startBtn = false; } } diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts index 09870a60cc..a95398a72a 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts @@ -11,6 +11,7 @@ import {ConversationHeaderComponent} from './va-conversation/conversation-header import {ConversationMessageComponent} from './va-conversation/conversation-message/conversation-message.component'; import {ConversationFooterComponent} from './va-conversation/conversation-footer/conversation-footer.component'; import {MatSlideToggleModule} from '@angular/material/slide-toggle'; +import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'; @NgModule({ declarations: [VirtualAssistantComponent, @@ -25,7 +26,8 @@ import {MatSlideToggleModule} from '@angular/material/slide-toggle'; MatButtonModule, MatGridListModule, ScrollingModule, - MatSlideToggleModule + MatSlideToggleModule, + MatProgressSpinnerModule ], exports: [VirtualAssistantComponent] }) From 1da88982d10363c8a64df1a8923c4698ef03f71d Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 19 Jul 2021 15:54:59 +0200 Subject: [PATCH 49/56] [SAFE-411] code cleaning --- .../conversation-footer.component.scss | 4 ---- .../conversation-footer.component.ts | 21 ------------------- .../va-conversation.component.ts | 6 +----- 3 files changed, 1 insertion(+), 30 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss index 904724ff8a..be17b5968b 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.scss @@ -2,9 +2,7 @@ height: 50px; border-top: 1px solid lightgray; border-radius: 0 0 5px 5px; - //align-content: center; text-align: center; - //align-items: center; } #inputMsg { @@ -18,8 +16,6 @@ } .btnFoot { - //height: 30px; - //width: 30px; margin-left: 10px; } diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts index 2691a4b6d9..84ed89a117 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts @@ -24,12 +24,8 @@ export class ConversationFooterComponent implements OnInit, OnChanges { // we skip that at the beginning when object are not yet set if (this.input !== undefined && changes.inputValue !== undefined){ console.log('ngOnChanges : ' + this.inputValue); - - this.input.value = null; - console.log('this.input.value : ' + this.input.value); this.input.value = null; console.log('this.input.value : ' + this.input.value); - this.input.value = null; console.log('changes.inputValue.currentValue : ' + changes.inputValue.currentValue); console.log('this.inputValue : ' + this.inputValue); console.log('this.inputType : ' + this.inputType); @@ -59,22 +55,5 @@ export class ConversationFooterComponent implements OnInit, OnChanges { msgChange(text: string): void { this.inputChange.emit(text); - // if (text === ''){ - // this.btnSend.setAttribute('disabled', ''); - // this.btnSend.setAttribute('style', 'display: none'); - // - // this.btnRec.removeAttribute('disabled'); - // this.btnRec.setAttribute('style', 'display: inline'); - // } else { - // this.btnRec.setAttribute('disabled', ''); - // this.btnRec.setAttribute('style', 'display: none'); - // - // this.btnSend.removeAttribute('disabled'); - // this.btnSend.setAttribute('style', 'display: inline'); - // } - } - - testFn(): void { - this.input.focus(); } } diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 091dff377f..de1d2c01b3 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -1,7 +1,5 @@ import { - AfterViewInit, Component, - ElementRef, EventEmitter, Input, OnChanges, @@ -80,8 +78,6 @@ export class VaConversationComponent implements OnInit, OnChanges { this.speech = new Speech(); this.td = {title: '', description: ''}; - - // this.conversationFooterComponent; } ngOnInit(): void { @@ -317,7 +313,7 @@ export class VaConversationComponent implements OnInit, OnChanges { // this.speak(this.speech, text); } this.conv.push(new Message(type, text, reply, user, date, choices)); - this.conversationFooterComponent.testFn(); + this.conversationFooterComponent.inputFocus(); } /* ----- STYLE ----- */ From c733a65ed98e0d1697c84bf33eeca065cf11a099 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 19 Jul 2021 17:29:01 +0200 Subject: [PATCH 50/56] [SAFE-411] message model reply field modification (from string to boolean) --- .../virtual-assistant/models/message.model.ts | 4 +-- .../va-conversation.component.ts | 33 +++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/models/message.model.ts b/projects/back-office/src/app/virtual-assistant/models/message.model.ts index 2949adfe10..b4df089824 100644 --- a/projects/back-office/src/app/virtual-assistant/models/message.model.ts +++ b/projects/back-office/src/app/virtual-assistant/models/message.model.ts @@ -4,7 +4,7 @@ import {Choices} from './choices.model'; export class Message { type: string; text: string; - reply: string; + reply: boolean; user: User; date: number; choices: Choices[]; @@ -12,7 +12,7 @@ export class Message { // tslint:disable-next-line:max-line-length constructor(type: string, text: string, - reply: string, + reply: boolean, user: User, date: number, choices: Choices[]) { diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index de1d2c01b3..4c85488f72 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -109,12 +109,12 @@ export class VaConversationComponent implements OnInit, OnChanges { console.log(this.iCurrentQuestion); if (this.iCurrentQuestion < this.form.length){ if (this.currentText !== '' && (this.form[this.iCurrentQuestion].type === 'text' || this.form[this.iCurrentQuestion].type === 'comment')){ - this.addMsg('', this.currentText, 'true', this.userMe, Date.now(), []); + this.addMsg('', this.currentText, true, this.userMe, Date.now(), []); this.currentRecord[this.form[this.iCurrentQuestion].name] = this.currentText; this.afterReply(); } else if (this.currentText !== '' && this.form[this.iCurrentQuestion].type === 'multipletext'){ - this.addMsg('', this.currentText, 'true', this.userMe, Date.now(), []); + this.addMsg('', this.currentText, true, this.userMe, Date.now(), []); this.mtObjectTemp[this.form[this.iCurrentQuestion].items[this.iCurMtQ ].name] = this.currentText; this.currentText = ''; this.updateScrollViewPos(); @@ -127,7 +127,7 @@ export class VaConversationComponent implements OnInit, OnChanges { sendReplyMsgChoice(ch: Choices): void { if (ch.text !== ''){ // this.speak(this.speech, ch.text); - this.addMsg('', ch.text, 'true', this.userMe, Date.now(), []); + this.addMsg('', ch.text, true, this.userMe, Date.now(), []); this.currentRecord[this.form[this.iCurrentQuestion].name] = ch.value; this.afterReply(); } @@ -152,7 +152,7 @@ export class VaConversationComponent implements OnInit, OnChanges { text = text + ' ' + ch.text; }); - this.addMsg('', text, 'true', this.userMe, Date.now(), []); + this.addMsg('', text, true, this.userMe, Date.now(), []); this.currentRecord[this.form[this.iCurrentQuestion].name] = choicesRecord; this.afterReply(); } @@ -160,7 +160,7 @@ export class VaConversationComponent implements OnInit, OnChanges { // send final conversation message sendReplyMsgTextEnd(): void { if (this.restartChoiceMsg !== '') { - this.addMsg('', this.restartChoiceMsg, 'true', this.userMe, Date.now(), []); + this.addMsg('', this.restartChoiceMsg, true, this.userMe, Date.now(), []); this.afterReply(); } } @@ -185,10 +185,10 @@ export class VaConversationComponent implements OnInit, OnChanges { console.log(this.currentText); if (this.conv.length === 0){ if (this.td.title !== undefined){ - this.addMsg('text', this.td.title, 'false', this.userVa, Date.now(), []); + this.addMsg('text', this.td.title, false, this.userVa, Date.now(), []); } if (this.td.description !== undefined){ - this.addMsg('text', this.td.description, 'false', this.userVa, Date.now(), []); + this.addMsg('text', this.td.description, false, this.userVa, Date.now(), []); } this.sendNextQuestion(); } @@ -206,7 +206,7 @@ export class VaConversationComponent implements OnInit, OnChanges { this.records.push(this.currentRecord); console.log(this.records); - this.addMsg('text', this.endMessage, 'false', this.userVa, Date.now(), + this.addMsg('text', this.endMessage, false, this.userVa, Date.now(), [ new Choices(this.restartChoiceMsg, this.restartChoiceMsg + '?'), new Choices(this.endChoiceMsg, this.endChoiceMsg + '?') @@ -216,7 +216,6 @@ export class VaConversationComponent implements OnInit, OnChanges { } // this.conversationFooterComponent.testFn(); } - } // control the bot format message depending on the type @@ -236,15 +235,15 @@ export class VaConversationComponent implements OnInit, OnChanges { this.currentText = '50'; } } - this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', + this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, false, this.userVa, Date.now(), []); break; case 'comment': - this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', + this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, false, this.userVa, Date.now(), []); break; case 'boolean': - this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', + this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, false, this.userVa, Date.now(), [new Choices(false, this.form[this.iCurrentQuestion].labelFalse), new Choices(true, this.form[this.iCurrentQuestion].labelTrue)]); break; @@ -252,14 +251,14 @@ export class VaConversationComponent implements OnInit, OnChanges { case 'dropdown': case 'checkbox': case 'tagbox': - this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, 'false', + this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, false, this.userVa, Date.now(), this.form[this.iCurrentQuestion].choices); break; case 'expression': if (this.form[this.iCurrentQuestion].description){ this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title + '\n' + this.form[this.iCurrentQuestion].description, - 'false', + false, this.userVa, Date.now(), []); } r = false; @@ -280,7 +279,7 @@ export class VaConversationComponent implements OnInit, OnChanges { sendNextMtQuestion(): void { this.iCurMtQ ++ ; if (this.iCurMtQ < this.form[this.iCurrentQuestion].items.length){ - this.addMsg('text', this.form[this.iCurrentQuestion].items[this.iCurMtQ].title, 'false', this.userVa, Date.now(), []); + this.addMsg('text', this.form[this.iCurrentQuestion].items[this.iCurMtQ].title, false, this.userVa, Date.now(), []); } else { this.currentRecord[this.form[this.iCurrentQuestion].name] = this.mtObjectTemp; @@ -304,11 +303,11 @@ export class VaConversationComponent implements OnInit, OnChanges { // add a message to the conversation addMsg(type: string, text: string, - reply: string, + reply: boolean, user: User, date: number, choices: Choices[]): void { - if (reply === 'false'){ + if (reply === false){ console.log('speak'); // this.speak(this.speech, text); } From 5246c5a6561f3a4e3fc578ebf0ac9450415a89ca Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 19 Jul 2021 18:04:53 +0200 Subject: [PATCH 51/56] [SAFE-411] code cleaning --- .../va-conversation.component.ts | 5 --- .../virtual-assistant.component.html | 31 ------------------- .../virtual-assistant.component.ts | 30 ------------------ 3 files changed, 66 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 4c85488f72..7fedac12e4 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -92,10 +92,6 @@ export class VaConversationComponent implements OnInit, OnChanges { } } - // ngAfterViewInit(): void { - // this.conversationFooterComponent.testFn(); - // } - msgUpdated(msg: any): void{ if (typeof msg === 'string'){ console.log('msgUpdated'); @@ -214,7 +210,6 @@ export class VaConversationComponent implements OnInit, OnChanges { this.inputMsgType = 'text'; this.updateScrollViewPos(); } - // this.conversationFooterComponent.testFn(); } } diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html index 2e8de6361b..8f64526fba 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html @@ -1,34 +1,3 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
va-face
diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts index 9c1e7f4c27..42f7227603 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts @@ -5,7 +5,6 @@ import {SafeDownloadService} from '../../../../safe/src/lib/services/download.se import {Apollo} from 'apollo-angular'; import {GET_FORM_BY_ID, GetFormByIdQueryResponse} from '../graphql/queries'; import {ADD_RECORD, AddRecordMutationResponse} from '../graphql/mutations'; -// import {ADD_RECORD, AddRecordMutationResponse} from '../../../../../dist/safe/lib/graphql/mutations'; @Component({ selector: 'app-virtual-assistant', @@ -59,25 +58,6 @@ export class VirtualAssistantComponent implements OnInit { } async getForm(): Promise{ - // const path = `download/form/${this.id}`; - // const dataReturn = await this.downloadService.getForm(path); - // if (dataReturn.status === true) { - // // console.log(JSON.parse(dataReturn.data.structure)); - // this.form = JSON.parse(dataReturn.data.structure).pages[0].elements; - // console.log('this.form'); - // console.log(this.form); - // } - // else { - // // problem with the form - // } - - // this.apollo.watchQuery({ - // query: GET_SHORT_FORMS, - // }).valueChanges.subscribe((res: any) => { - // console.log('Apollo: res.data.forms'); - // console.log(res.data.forms); - // }); - this.apollo.watchQuery({ query: GET_FORM_BY_ID, variables: { @@ -102,16 +82,6 @@ export class VirtualAssistantComponent implements OnInit { }); } - // onChatButton(event: any): void { - // console.log('onChatButton'); - // if (this.vaCols !== 6) { - // this.vaCols = 6; - // } - // else { - // this.vaCols = 12; - // } - // } - vaEndConversation(records: any): void { console.log('vaEndConversation'); console.log(records); From 2a36eb51affde9b5e847940b6a585ec9db3f1401 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Fri, 23 Jul 2021 15:18:34 +0200 Subject: [PATCH 52/56] [SAFE-411] language select menu added (not working for the moment) --- .../va-conversation.component.ts | 14 ++-- .../virtual-assistant.component.html | 34 ++++++++- .../virtual-assistant.component.scss | 21 ++++-- .../virtual-assistant.component.ts | 69 +++++++++++++++++-- 4 files changed, 117 insertions(+), 21 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 7fedac12e4..d3e0219279 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -31,6 +31,8 @@ export class VaConversationComponent implements OnInit, OnChanges { public records: any[] = []; public currentRecord: any; + @Input() language: string; + public currentText: string; @ViewChild(CdkVirtualScrollViewport) viewport: any; @@ -78,6 +80,8 @@ export class VaConversationComponent implements OnInit, OnChanges { this.speech = new Speech(); this.td = {title: '', description: ''}; + + this.language = 'en-GB'; } ngOnInit(): void { @@ -122,7 +126,7 @@ export class VaConversationComponent implements OnInit, OnChanges { // send reply message after clicking on a choice (RADIOGROUP) sendReplyMsgChoice(ch: Choices): void { if (ch.text !== ''){ - // this.speak(this.speech, ch.text); + this.speak(this.speech, ch.text); this.addMsg('', ch.text, true, this.userMe, Date.now(), []); this.currentRecord[this.form[this.iCurrentQuestion].name] = ch.value; this.afterReply(); @@ -132,10 +136,10 @@ export class VaConversationComponent implements OnInit, OnChanges { // click on a checkbox choice choiceCheckBoxClick(e: any): void { if (e.state === true){ - // this.speak(this.speech, e.choice.text); + this.speak(this.speech, e.choice.text); } else { - // this.speak(this.speech, e.choice.text + ' removed'); + this.speak(this.speech, e.choice.text + ' removed'); } } @@ -304,7 +308,7 @@ export class VaConversationComponent implements OnInit, OnChanges { choices: Choices[]): void { if (reply === false){ console.log('speak'); - // this.speak(this.speech, text); + this.speak(this.speech, text); } this.conv.push(new Message(type, text, reply, user, date, choices)); this.conversationFooterComponent.inputFocus(); @@ -334,7 +338,7 @@ export class VaConversationComponent implements OnInit, OnChanges { console.log('speech synthesis supported'); speech.init({ volume: 1, - lang: 'en-GB', + lang: this.language, rate: 1, pitch: 1, voice: 'Google UK English Male', diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html index 8f64526fba..98f91c6e55 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html @@ -1,11 +1,39 @@ -
va-face
+
+ + + + + + + va-face + + + + + + + + + + + + +
va-face - + - + diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss index 2b2223a187..eb811adef1 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss @@ -1,7 +1,10 @@ +//.va-face { +// position: absolute;; +// top: 50%; +// left: calc(50% - 100px); +// width: 200px; +//} .va-face { - position: absolute;; - top: 50%; - left: calc(50% - 100px); width: 200px; } .conversation .mat-figure { @@ -18,13 +21,19 @@ margin: 0; } +//#btn-start { +// position: absolute; +// font-size: large; +// height: 50px; +// width: 100px; +// top: 90%; +// left: calc(50% - 50px); +//} + #btn-start { - position: absolute; font-size: large; height: 50px; width: 100px; - top: 90%; - left: calc(50% - 50px); } #spinner-loading-form { diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts index 42f7227603..4d58e8a598 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts @@ -20,22 +20,20 @@ export class VirtualAssistantComponent implements OnInit { public td: {title: string, description: string}; public iQuestion: any; public messages: any; - public vaCols: number; - public chatCols: number; public start: boolean; public startBtn: boolean; public loadingForm: boolean; + public voiceLanguage: {value: string, text: string}[]; + public curLanguage: string; + // === ROUTE === private routeSubscription?: Subscription; constructor(private route: ActivatedRoute, private downloadService: SafeDownloadService, private apollo: Apollo) { - // this.vaCols = 6; - this.vaCols = 2; - this.chatCols = 0; this.iQuestion = 0; this.start = false; @@ -46,6 +44,56 @@ export class VirtualAssistantComponent implements OnInit { title: '', description: '' }; + + // tslint:disable-next-line:max-line-length + // this.voiceLanguage = ['ar-SA', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en', 'en-AU', 'en-GB', 'en-IE', 'en-IN', 'en-US', 'en-ZA', 'es-AR', + // tslint:disable-next-line:max-line-length + // 'es-ES', 'es-MX', 'es-US', 'fi-FI', 'fr-CA', 'fr-FR', 'he-IL', 'hi-IN', 'hu-HU', 'id-ID', 'it-IT', 'ja-JP', 'ko-KR', 'nb-NO', 'nl-BE', + // 'nl-NL', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sk-SK', 'sv-SE', 'th-TH', 'tr-TR', 'zh-CN', 'zh-HK', 'zh-TW']; + this.voiceLanguage = [ + {value: 'ar-SA', text: 'ar'}, + {value: 'cs-CZ', text: 'cs'}, + {value: 'da-DK', text: 'danmark'}, + {value: 'de-DE', text: 'german - DE'}, + {value: 'el-GR', text: 'gr'}, + {value: 'en', text: 'english'}, + {value: 'en-AU', text: 'english - AU'}, + {value: 'en-GB', text: 'english - GB'}, + {value: 'en-IE', text: 'english - IE'}, + {value: 'en-IN', text: 'english - IN'}, + {value: 'en-US', text: 'english - US'}, + {value: 'en-ZA', text: 'english - ZA'}, + {value: 'es-AR', text: 'spanish - AR'}, + {value: 'es-ES', text: 'spanish - ES'}, + {value: 'es-MX', text: 'spanish - MX'}, + {value: 'es-US', text: 'spanish - US'}, + {value: 'fi-FI', text: 'fi'}, + {value: 'fr-CA', text: 'french - CA'}, + {value: 'fr-FR', text: 'french - FR'}, + {value: 'he-IL', text: 'hr'}, + {value: 'hi-IN', text: 'hi'}, + {value: 'hu-HU', text: 'hu'}, + {value: 'id-ID', text: 'id'}, + {value: 'it-IT', text: 'it'}, + {value: 'ja-JP', text: 'ja'}, + {value: 'ko-KR', text: 'ko'}, + {value: 'nb-NO', text: 'nb'}, + {value: 'nl-BE', text: 'dutch - BE'}, + {value: 'nl-NL', text: 'dutch - NL'}, + {value: 'pl-PL', text: 'polish - PL'}, + {value: 'pt-BR', text: 'pt - BR'}, + {value: 'pt-PT', text: 'pt - PT'}, + {value: 'ro-RO', text: 'ro - RO'}, + {value: 'ru-RU', text: 'ru - RU'}, + {value: 'sk-SK', text: 'sk - SK'}, + {value: 'sv-SE', text: 'sv - SE'}, + {value: 'th-TH', text: 'th - TH'}, + {value: 'tr-TR', text: 'tr - TR'}, + {value: 'zh-CN', text: 'zh - CN'}, + {value: 'zh-HK', text: 'zh - HK'}, + {value: 'zh-TW', text: 'zh - TW'}]; + + this.curLanguage = 'ar-SA'; } ngOnInit(): void { @@ -101,9 +149,16 @@ export class VirtualAssistantComponent implements OnInit { } btnStartClick(): void { - this.vaCols = 1; - this.chatCols = 1; this.start = true; this.startBtn = false; } + + langClick(lang: any): void { + console.log(lang); + } + + langChanges(e: any): void { + console.log(e.target.value); + this.curLanguage = e.target.value; + } } From 329f47f4721b3eb021e76558955650247f72fb9b Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 26 Jul 2021 10:04:13 +0200 Subject: [PATCH 53/56] [SAFE-411] voice language fixed --- .../va-conversation/va-conversation.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index d3e0219279..1759e44a5d 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -341,7 +341,7 @@ export class VaConversationComponent implements OnInit, OnChanges { lang: this.language, rate: 1, pitch: 1, - voice: 'Google UK English Male', + // voice: 'Google UK English Male', splitSentences: true, listeners: { } From 3d39c1beed22cf59608f2ef10703c2ca0594c0e7 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 26 Jul 2021 10:22:16 +0200 Subject: [PATCH 54/56] [SAFE-411] code cleaning --- .../va-conversation.component.ts | 6 ++--- .../virtual-assistant.component.html | 9 +------ .../virtual-assistant.component.scss | 25 ++++--------------- .../virtual-assistant.component.ts | 5 ---- 4 files changed, 8 insertions(+), 37 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 1759e44a5d..9dba8109a0 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -306,7 +306,7 @@ export class VaConversationComponent implements OnInit, OnChanges { user: User, date: number, choices: Choices[]): void { - if (reply === false){ + if (!reply){ console.log('speak'); this.speak(this.speech, text); } @@ -334,19 +334,17 @@ export class VaConversationComponent implements OnInit, OnChanges { /* ----- TTS ----- */ speakInit(speech: Speech, speechData: any): void { - if (speech.hasBrowserSupport()) { // returns a boolean + if (speech.hasBrowserSupport()) { console.log('speech synthesis supported'); speech.init({ volume: 1, lang: this.language, rate: 1, pitch: 1, - // voice: 'Google UK English Male', splitSentences: true, listeners: { } }).then((data: any) => { - // The "data" object contains the list of available voices and the voice synthesis params console.log('Speech is ready, voices are available', data); speechData = data; this.sendNextQuestion(); diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html index 98f91c6e55..c10d34b337 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html @@ -1,6 +1,4 @@
- - @@ -16,12 +14,9 @@ - - - - + @@ -35,5 +30,3 @@ - - diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss index eb811adef1..875717b289 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss @@ -1,9 +1,3 @@ -//.va-face { -// position: absolute;; -// top: 50%; -// left: calc(50% - 100px); -// width: 200px; -//} .va-face { width: 200px; } @@ -21,23 +15,14 @@ margin: 0; } -//#btn-start { -// position: absolute; -// font-size: large; -// height: 50px; -// width: 100px; -// top: 90%; -// left: calc(50% - 50px); -//} - #btn-start { font-size: large; height: 50px; width: 100px; } -#spinner-loading-form { - position: absolute; - top: 90%; - left: calc(50% - 50px); -} +//#spinner-loading-form { +// position: absolute; +// top: 90%; +// left: calc(50% - 50px); +//} diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts index 4d58e8a598..f5b6829030 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts @@ -45,11 +45,6 @@ export class VirtualAssistantComponent implements OnInit { description: '' }; - // tslint:disable-next-line:max-line-length - // this.voiceLanguage = ['ar-SA', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en', 'en-AU', 'en-GB', 'en-IE', 'en-IN', 'en-US', 'en-ZA', 'es-AR', - // tslint:disable-next-line:max-line-length - // 'es-ES', 'es-MX', 'es-US', 'fi-FI', 'fr-CA', 'fr-FR', 'he-IL', 'hi-IN', 'hu-HU', 'id-ID', 'it-IT', 'ja-JP', 'ko-KR', 'nb-NO', 'nl-BE', - // 'nl-NL', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sk-SK', 'sv-SE', 'th-TH', 'tr-TR', 'zh-CN', 'zh-HK', 'zh-TW']; this.voiceLanguage = [ {value: 'ar-SA', text: 'ar'}, {value: 'cs-CZ', text: 'cs'}, From 5712cceeb995e2907178a1d6f58f5f3333a5e933 Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 26 Jul 2021 11:03:55 +0200 Subject: [PATCH 55/56] [SAFE-411] select language style --- .../virtual-assistant.component.html | 34 ++++++++++++------- .../virtual-assistant.component.scss | 4 +++ .../virtual-assistant.component.ts | 11 +++--- .../virtual-assistant.module.ts | 24 +++++++------ 4 files changed, 44 insertions(+), 29 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html index c10d34b337..dd17353286 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html @@ -1,29 +1,37 @@ -
+
- + va-face - + - + - - - + + + Choose language + + Select language + + {{ lang.text }} + + + + This field is required + + You can choose your language here + + - +
- + va-face diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss index 875717b289..4ba24c8706 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.scss @@ -21,6 +21,10 @@ width: 100px; } +#select-lang { + margin-right: 10px; +} + //#spinner-loading-form { // position: absolute; // top: 90%; diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts index f5b6829030..6065f6eb18 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.ts @@ -5,6 +5,7 @@ import {SafeDownloadService} from '../../../../safe/src/lib/services/download.se import {Apollo} from 'apollo-angular'; import {GET_FORM_BY_ID, GetFormByIdQueryResponse} from '../graphql/queries'; import {ADD_RECORD, AddRecordMutationResponse} from '../graphql/mutations'; +import {FormControl, Validators} from '@angular/forms'; @Component({ selector: 'app-virtual-assistant', @@ -28,6 +29,8 @@ export class VirtualAssistantComponent implements OnInit { public voiceLanguage: {value: string, text: string}[]; public curLanguage: string; + selectFormControl = new FormControl('', Validators.required); + // === ROUTE === private routeSubscription?: Subscription; @@ -148,12 +151,8 @@ export class VirtualAssistantComponent implements OnInit { this.startBtn = false; } - langClick(lang: any): void { + langChanges(lang: any): void { console.log(lang); - } - - langChanges(e: any): void { - console.log(e.target.value); - this.curLanguage = e.target.value; + this.curLanguage = lang; } } diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts b/projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts index a95398a72a..431b2ee167 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.module.ts @@ -12,6 +12,8 @@ import {ConversationMessageComponent} from './va-conversation/conversation-messa import {ConversationFooterComponent} from './va-conversation/conversation-footer/conversation-footer.component'; import {MatSlideToggleModule} from '@angular/material/slide-toggle'; import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'; +import {MatSelectModule} from '@angular/material/select'; +import {ReactiveFormsModule} from '@angular/forms'; @NgModule({ declarations: [VirtualAssistantComponent, @@ -19,16 +21,18 @@ import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'; ConversationHeaderComponent, ConversationMessageComponent, ConversationFooterComponent], - imports: [ - CommonModule, - VirtualAssistantRoutingModule, - MatIconModule, - MatButtonModule, - MatGridListModule, - ScrollingModule, - MatSlideToggleModule, - MatProgressSpinnerModule - ], + imports: [ + CommonModule, + VirtualAssistantRoutingModule, + MatIconModule, + MatButtonModule, + MatGridListModule, + ScrollingModule, + MatSlideToggleModule, + MatProgressSpinnerModule, + MatSelectModule, + ReactiveFormsModule + ], exports: [VirtualAssistantComponent] }) export class VirtualAssistantModule { } From ce4f85f78d22debb72efaf5a0ab3afcf52c4988b Mon Sep 17 00:00:00 2001 From: MartinGbz Date: Mon, 26 Jul 2021 12:52:17 +0200 Subject: [PATCH 56/56] [SAFE-411] trying to fix input value issue --- .../conversation-footer/conversation-footer.component.ts | 3 ++- .../va-conversation/va-conversation.component.ts | 8 ++++++-- .../virtual-assistant/virtual-assistant.component.html | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts index 84ed89a117..1ad7e827ac 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/conversation-footer/conversation-footer.component.ts @@ -25,6 +25,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges { if (this.input !== undefined && changes.inputValue !== undefined){ console.log('ngOnChanges : ' + this.inputValue); this.input.value = null; + this.input.value = ''; console.log('this.input.value : ' + this.input.value); console.log('changes.inputValue.currentValue : ' + changes.inputValue.currentValue); console.log('this.inputValue : ' + this.inputValue); @@ -36,7 +37,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges { else if (changes.inputValue.currentValue !== ''){ this.msgChange(changes.inputValue.currentValue); } - this.input.focus(); + this.inputFocus(); } } diff --git a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts index 9dba8109a0..07e679ee4d 100644 --- a/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts +++ b/projects/back-office/src/app/virtual-assistant/va-conversation/va-conversation.component.ts @@ -97,6 +97,7 @@ export class VaConversationComponent implements OnInit, OnChanges { } msgUpdated(msg: any): void{ + console.log('MSGGG'); if (typeof msg === 'string'){ console.log('msgUpdated'); console.log(msg); @@ -106,6 +107,7 @@ export class VaConversationComponent implements OnInit, OnChanges { // send simple reply message (TEXT) (click on send msg or enter) sendReplyMsgText(): void { + console.log('sendReplyMsgText()'); console.log(this.iCurrentQuestion); if (this.iCurrentQuestion < this.form.length){ if (this.currentText !== '' && (this.form[this.iCurrentQuestion].type === 'text' || this.form[this.iCurrentQuestion].type === 'comment')){ @@ -121,6 +123,8 @@ export class VaConversationComponent implements OnInit, OnChanges { this.sendNextMtQuestion(); } } + console.log('this.currentText = '); + console.log(this.currentText); } // send reply message after clicking on a choice (RADIOGROUP) @@ -228,10 +232,10 @@ export class VaConversationComponent implements OnInit, OnChanges { this.inputMsgType = this.form[this.iCurrentQuestion].inputType; console.log(this.inputMsgType); if (this.inputMsgType === 'color'){ - this.currentText = '#000000'; + this.currentText = '#3131dc'; } if (this.inputMsgType === 'range'){ - this.currentText = '50'; + this.currentText = '67'; } } this.addMsg(this.form[this.iCurrentQuestion].type, this.form[this.iCurrentQuestion].title, false, diff --git a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html index dd17353286..471f77b10e 100644 --- a/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html +++ b/projects/back-office/src/app/virtual-assistant/virtual-assistant.component.html @@ -1,8 +1,8 @@ -
+
- + - + va-face @@ -31,7 +31,7 @@
- + va-face