d88afa9c77602b8354d394e193f516f437a70512
[usecase-ui.git] /
1 import { Component, OnInit } from '@angular/core';
2 import { NzMessageService } from 'ng-zorro-antd';
3 import { intentBaseService } from '../../../../core/services/intentBase.service';
4
5 @Component({
6   selector: 'app-intent-based-predict',
7   templateUrl: './intent-based-predict.component.html',
8   styleUrls: ['./intent-based-predict.component.less']
9 })
10 export class IntentBasedPredictComponent implements OnInit {
11
12   constructor(
13     private myhttp: intentBaseService,
14     private msg: NzMessageService
15   ) {}
16   
17   // textarea input predict param
18   communicationMessage: String = "";
19   // button loading
20   isConfirmCreating: boolean = false;
21   // modal param
22   modalParam: Object = {};
23   // cloud modal show flag
24   cloudModalShowFlag: boolean = false;
25   // business modal show flag
26   businessModalShowFlag: boolean = false;
27
28   ngOnInit() {
29     this.communicationMessage = '';
30   }
31
32   ngOnChange() {}
33
34   submitFormMessage(): void {
35     this.isConfirmCreating = true;
36     this.myhttp.intentBasedUnifyPredict({
37       "text": this.communicationMessage
38     }).subscribe(
39       (response) => {
40         this.isConfirmCreating = false;
41         const { code, message, data: { type, formData } } = response;
42         if (code !== 200) {
43           this.msg.error(message);
44           return;
45         }
46
47         this.modalParam = {
48           ...formData,
49           intentContent: this.communicationMessage
50         };
51
52         if (type === 'ccvpn') {
53           this.cloudModalShowFlag = true;
54         }
55
56         if (type === '5gs') {
57           this.businessModalShowFlag = true;
58         }
59       },
60       (err) => {
61         this.isConfirmCreating = false;
62         console.log(err);
63       }
64     )
65   }
66
67   modalClose() {
68     this.cloudModalShowFlag = false;
69     this.businessModalShowFlag = false;
70     this.modalParam = {};
71     this.communicationMessage = '';
72   }
73 }