summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/views/services/intent-based-services/intent-based-predict/intent-based-predict.component.ts
blob: d2fe0fcebda4139884416a94eda9c66455a3b095 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { Router } from "@angular/router";
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 router:Router,
    private myhttp: intentBaseService,
    private msg: NzMessageService
  ) {}
  
  @Output() eventEmitter = new EventEmitter<any>();
  // 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);
      }
    )
  }

  cloudModalClose(param) {
    this.cloudModalShowFlag = false;
    this.modalParam = {};
    this.communicationMessage = '';
    if (param) {
      this.eventEmitter.emit();
    }
  }

  businessModalClose(param) {
    this.businessModalShowFlag = param.closeFlag;
    this.modalParam = {};
    this.communicationMessage = '';
    const to5gPage = param.to5gPage;
    if (to5gPage) {
      this.router.navigate(['/services/slicing-management']);
    }
  }
}