Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
2b88bef
[SAFE-411] init + get form object
MartinGbz Jul 5, 2021
6e473b2
[SAFE-411] code cleaning
MartinGbz Jul 5, 2021
0167ceb
[SAFE-411] new virtual-assistant component (opened in a new tab)
MartinGbz Jul 5, 2021
8bce5c6
[SAFE-411] routing-module problems fixed + starting page design
MartinGbz Jul 5, 2021
a097ab0
[SAFE-411] interface
MartinGbz Jul 6, 2021
76400df
[SAFE-411] conversation works (style: Bottom)
MartinGbz Jul 7, 2021
1da2200
[SAFE-411] conversation works (+ style top right)
MartinGbz Jul 7, 2021
9f5ddf6
[SAFE-411] showing questions
MartinGbz Jul 7, 2021
0d4fec7
[SAFE-411] console log
MartinGbz Jul 7, 2021
fdf9bf6
[SAFE-411] test
MartinGbz Jul 7, 2021
8cf4c3a
[SAFE-411] form object + other issues fixed
MartinGbz Jul 7, 2021
05d6727
[SAFE-411] message display + style
MartinGbz Jul 8, 2021
f153b00
[SAFE-411] conversation + records works
MartinGbz Jul 8, 2021
3119be7
[SAFE-411] add question controller
MartinGbz Jul 8, 2021
70b9451
[SAFE-411] add Choices Model
MartinGbz Jul 8, 2021
5a6ad23
[SAFE-411] restart button bug fixed
MartinGbz Jul 9, 2021
4eb0d46
[SAFE-411] buttons disappearing fixed
MartinGbz Jul 9, 2021
b03895d
[SAFE-411] expression type added
MartinGbz Jul 9, 2021
ce52a96
[SAFE-411] checkbox type added
MartinGbz Jul 9, 2021
6d7a332
[SAFE-411] display of buttons (for checkbox type) fixed
MartinGbz Jul 9, 2021
2d53d1c
[SAFE-411] code refactoring
MartinGbz Jul 9, 2021
eedfc0f
[SAFE-411] virtual-assistant directory moved + text messages sending …
MartinGbz Jul 9, 2021
d4e69b9
[SAFE-411] get form by id request (from REST request to GraphQL request)
MartinGbz Jul 12, 2021
ebfa386
[SAFE-411] modules problems fixed + endConv boolean removed
MartinGbz Jul 12, 2021
9085a9a
[SAFE-411] addRecord added + dropdown type added
MartinGbz Jul 12, 2021
cae5eb0
[SAFE-411] text to speech added + start conversation style modification
MartinGbz Jul 13, 2021
5e4bc35
[SAFE-411] limitation text sending (when end message)
MartinGbz Jul 13, 2021
47d116e
[SAFE-411] window closing
MartinGbz Jul 13, 2021
aae0e3c
[SAFE-411] inputTypes added + ngOnChange issue fixed
MartinGbz Jul 13, 2021
44b7de5
[SAFE-411] expression type fixed
MartinGbz Jul 13, 2021
25b19db
[SAFE-411] comment type added
MartinGbz Jul 15, 2021
8988b6e
[SAFE-411] comment type fixed
MartinGbz Jul 15, 2021
c820810
[SAFE-411] iCurrentQuestion fixed
MartinGbz Jul 15, 2021
e5d0f24
[SAFE-411] tagbox type added
MartinGbz Jul 15, 2021
3dc620f
[SAFE-411] boolean type added
MartinGbz Jul 15, 2021
502cbb9
[SAFE-411] code cleaned
MartinGbz Jul 15, 2021
4d90de0
[SAFE-411] multiple text added
MartinGbz Jul 15, 2021
d4e191f
[SAFE-411] Boolean type issue fixed
MartinGbz Jul 15, 2021
62862bb
[SAFE-411] color input default value fixed
MartinGbz Jul 16, 2021
57bced0
[SAFE-411] multiple text empty issue fixed
MartinGbz Jul 16, 2021
4a22eb7
[SAFE-411] test and try to fix the input value issue, but it is still…
MartinGbz Jul 16, 2021
a576eab
[SAFE-411] change input type at the end
MartinGbz Jul 19, 2021
694b84c
[SAFE-411] add title + description display
MartinGbz Jul 19, 2021
958993e
[SAFE-411] title + description form fixed
MartinGbz Jul 19, 2021
a9f3d8e
[SAFE-411] Input focus fixed
MartinGbz Jul 19, 2021
98540db
[SAFE-411] code cleaning
MartinGbz Jul 19, 2021
81be1a0
[SAFE-411] button chat and rec display modification
MartinGbz Jul 19, 2021
7b9d0e8
[SAFE-411] footer style fixed + loading form spinner and start button…
MartinGbz Jul 19, 2021
1da8898
[SAFE-411] code cleaning
MartinGbz Jul 19, 2021
c733a65
[SAFE-411] message model reply field modification (from string to boo…
MartinGbz Jul 19, 2021
5246c5a
[SAFE-411] code cleaning
MartinGbz Jul 19, 2021
2a36eb5
[SAFE-411] language select menu added (not working for the moment)
MartinGbz Jul 23, 2021
329f47f
[SAFE-411] voice language fixed
MartinGbz Jul 26, 2021
3d39c1b
[SAFE-411] code cleaning
MartinGbz Jul 26, 2021
5712cce
[SAFE-411] select language style
MartinGbz Jul 26, 2021
ce4f85f
[SAFE-411] trying to fix input value issue
MartinGbz Jul 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
290 changes: 136 additions & 154 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 12 additions & 1 deletion projects/back-office/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 './virtual-assistant/virtual-assistant.component';

const routes: Routes = [
{
Expand Down Expand Up @@ -31,7 +32,17 @@ const routes: Routes = [
.then(m => m.AppPreviewModule),
}
]
}
},
{
path: 'va',
children: [
{
path: ':id',
loadChildren: () => import('./virtual-assistant/virtual-assistant.module')
.then(m => m.VirtualAssistantModule),
}
]
},
],
canActivate: [MsalGuard, AccessGuard]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@
<mat-icon>delete</mat-icon>
Delete
</button>
<button mat-menu-item (click)="onExportAssistant(element, $event)">
<mat-icon>support_agent</mat-icon>
Virtual assistant
</button>
</mat-menu>
</td>
</ng-container>
Expand All @@ -188,4 +192,4 @@
[ngClass]="{'clickable': ( row.canCreate && (row.status === 'active') )}"
[routerLink]="( row.canCreate && (row.status === 'active') ) ? ['/forms/answer', row.id] : []"></tr>
</table>
</ng-container>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -191,4 +193,13 @@ export class FormsComponent implements OnInit, OnDestroy, AfterViewInit {
this.coreFilter = '';
this.clearDateFilter();
}

async onExportAssistant(element: any, $event: any): Promise<void> {
console.log(element);
// 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;
}
}
22 changes: 22 additions & 0 deletions projects/back-office/src/app/graphql/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export class Choices {
value: any;
text: string;

constructor(value: any, text: string) {
this.value = value;
this.text = text;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { User } from './user.model';
import {Choices} from './choices.model';

export class Message {
type: string;
text: string;
reply: boolean;
user: User;
date: number;
choices: Choices[];

// tslint:disable-next-line:max-line-length
constructor(type: string,
text: string,
reply: boolean,
user: User,
date: number,
choices: Choices[]) {
this.type = type;
this.text = text;
this.reply = reply;
this.user = user;
this.date = date;
this.choices = choices;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export class User {
name: string;
avatar: string;

constructor(name: string, avatar: string) {
this.name = name;
this.avatar = avatar;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div id="footer">
<input id="inputMsg" placeholder="Tap your message here" [value]="inputValue" [type]="inputType" #test (input)="msgChange(test.value)">
<button mat-mini-fab id="btnSend" class="btnFoot" (click)="btnSendClick.emit($event)" disabled><mat-icon>chat</mat-icon></button>
<button mat-mini-fab id="btnRec" class="btnFoot" (click)="btnRecClick.emit($event)"><mat-icon>mic</mat-icon></button>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#footer {
height: 50px;
border-top: 1px solid lightgray;
border-radius: 0 0 5px 5px;
text-align: center;
}

#inputMsg {
height: 30px;
margin-top: 7px;
margin-left: 5px;
width: 390px;
border: 1px solid lightgray;
border-radius: 5px;
padding-left: 5px;
}

.btnFoot {
margin-left: 10px;
}

#btnSend {
background-color: green;
color: white;
}

#btnRec {
background-color: indianred;
color: white;
}
Original file line number Diff line number Diff line change
@@ -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<ConversationFooterComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ConversationFooterComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ConversationFooterComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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<any> = new EventEmitter();
@Output() btnRecClick: EventEmitter<any> = new EventEmitter();

@Output() inputChange: EventEmitter<any> = new EventEmitter();

public input: any;
public btnSend: any;
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 && 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);
console.log('this.inputType : ' + this.inputType);
console.log('this.input.value : ' + this.input.value);
if (changes.inputValue.currentValue === '' && this.inputValue !== ''){
// this.msgChange(this.inputValue);
}
else if (changes.inputValue.currentValue !== ''){
this.msgChange(changes.inputValue.currentValue);
}
this.inputFocus();
}
}

constructor() {
}

ngOnInit(): void {
this.input = document.getElementById('inputMsg');
this.btnSend = document.getElementById('btnSend');
this.btnRec = document.getElementById('btnRec');
}

inputFocus(): void {
this.input.focus();
}

msgChange(text: string): void {
this.inputChange.emit(text);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div id="header">
<p id="convName">chat</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#header {
height: 50px;
border-radius: 5px 5px 0 0;
background-color: #60d295;
display: flex;
align-items: center;
color: white;
}

#convName {
display: inline;
margin-left: 10px;
}
Original file line number Diff line number Diff line change
@@ -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<ConversationHeaderComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ConversationHeaderComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ConversationHeaderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -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 {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div *ngIf="reply=='true'; then thenBlock else elseBlock"></div>
<ng-template #thenBlock >
<div class="messageGlobal" style="margin-left:{{ml}}; margin-right: {{mr}}; background-color: {{backgroundColorReply}}">
<img alt="profile_photo" src="{{imgSrc}}">
<p innerText="{{text}}"></p>
</div>
</ng-template>
<ng-template #elseBlock >
<div class="messageGlobal" style="margin-left:{{ml}}; margin-right: {{mr}}; background-color: {{backgroundColor}}">
<img alt="profile_photo" src="{{imgSrc}}">
<p innerText="{{text}}"></p>
</div>
</ng-template>
<div class="btnChoicesCont" *ngIf="choices!=null && (type == 'radiogroup' || type == 'text' || type == 'boolean')">
<button mat-flat-button color="primary" class="btnChoices" *ngFor="let ch of this.choices" (click)="btnChoiceClickFn($event, ch)">{{ch.text}}</button>
</div>
<div *ngIf="choices!=null && (type == 'checkbox' || type == 'dropdown' || type == 'tagbox')">
<div class="btnChoicesCont">
<button mat-flat-button [color]="(this.checkBoxChoices.includes(ch) ? 'accent' : 'primary')" class="btnChoices" *ngFor="let ch of this.choices" (click)="btnChoiceCheckBoxClickFn($event, ch)">{{ch.text}}</button>
</div>
<div class="btnChoicesValidateCont">
<button mat-flat-button id="btnChoicesValidate" (click)="btnChoiceCheckBoxValidateClickFn($event)"> OK </button>
</div>
</div>
Loading