summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/views/services/intent-based-services/intent-based-predict/intent-based-predict.component.ts
blob: d88afa9c77602b8354d394e193f516f437a70512 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { Component, OnInit } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd';
import { intentBaseService } from '../../../../core/services/intentBase.service';

@Component({
  selector: 'app-intent-based-predict',
  templateUrl: './intent-based-predict.component.html',
  styleUrls: ['./intent-based-predict.component.less']
})
export class IntentBasedPredictComponent implements OnInit {

  constructor(
    private myhttp: intentBaseService,
    private msg: NzMessageService
  ) {}
  
  // textarea input predict param
  communicationMessage: String = "";
  // button loading
  isConfirmCreating: boolean = false;
  // modal param
  modalParam: Object = {};
  // cloud modal show flag
  cloudModalShowFlag: boolean = false;
  // business modal show flag
  businessModalShowFlag: boolean = false;

  ngOnInit() {
    this.communicationMessage = '';
  }

  ngOnChange() {}

  submitFormMessage(): void {
    this.isConfirmCreating = true;
    this.myhttp.intentBasedUnifyPredict({
      "text": this.communicationMessage
    }).subscribe(
      (response) => {
        this.isConfirmCreating = false;
        const { code, message, data: { type, formData } } = response;
        if (code !== 200) {
          this.msg.error(message);
          return;
        }

        this.modalParam = {
          ...formData,
          intentContent: this.communicationMessage
        };

        if (type === 'ccvpn') {
          this.cloudModalShowFlag = true;
        }

        if (type === '5gs') {
          this.businessModalShowFlag = true;
        }
      },
      (err) => {
        this.isConfirmCreating = false;
        console.log(err);
      }
    )
  }

  modalClose() {
    this.cloudModalShowFlag = false;
    this.businessModalShowFlag = false;
    this.modalParam = {};
    this.communicationMessage = '';
  }
}