summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/input-business-order/input-business-order.component.ts
blob: 3196bbbadccaa5320a3b4be921076f98b8611e8b (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
89
90
91
92
93
94
95
96
97
98
99
100
101
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Util } from '../../../../../shared/utils/utils';
import { onboardService } from '../../../../../core/services/onboard.service';
import { Recorder } from '../../../../../shared/utils/recorder';

@Component({
  selector: 'app-input-business-order',
  templateUrl: './input-business-order.component.html',
  styleUrls: ['./input-business-order.component.less']
})
export class InputBusinessOrderComponent implements OnInit {

  constructor(private Util: Util, private Recorder: Recorder, private myhttp: onboardService) { }

  @Input() showModel: boolean;
  @Output() modalOpreation = new EventEmitter();
  isSpinning: boolean = false;
  communicationMessage: String = "";
  validateRulesShow: any[] = [];
  rulesText: any[] = [];
  radioValue: String = 'text';
  isPlay: boolean = false;
  clickRepeat: boolean = false;

  ngOnInit() {
    this.validateRulesShow = [];
    this.rulesText = [];
    this.communicationMessage = '';
  }

  ngOnChange() {
  }

  handleCancel(): void {
    this.showModel = false;
    this.communicationMessage = "";
    this.modalOpreation.emit({ "cancel": true });
  }

  handleOk(): void {
    if (this.clickRepeat) {
      return;
    }
    this.clickRepeat = true;
    if (this.radioValue === "text") {
      this.submitFormMessage();
      return;
    }
    this.clickRepeat = false;
    this.communicationMessage = "";
    this.showModel = false;
    let defaultParams = {
      coverageArea: "Beijing Beijing Haiding Wanshoulu",
      expDataRateDL: "1000",
      expDataRateUL: "1000",
      latency: "10",
      maxNumberofUEs: "10",
      name: "exclusive slicing service",
      resourceSharingLevel: "shared",
      uEMobilityLevel: "stationary"
    }
    this.modalOpreation.emit({ "cancel": false, "param": defaultParams });
  }
  submitFormMessage(): void {
    this.Util.validator("communicationMessage", "communicationMessage", this.communicationMessage, 0, this.rulesText, this.validateRulesShow);
    if (this.validateRulesShow.indexOf(true) > -1) {
      this.clickRepeat = false;
      return
    }
    let params = {
          "title": "predict",
          "text": this.communicationMessage
    };
    this.myhttp["analysisInputText"](params)
      .subscribe((data) => {
        this.clickRepeat = false;
        if (data === 0) {
          return;
        }
        let orderForm = { ...data };
        this.communicationMessage = "";
        this.showModel = false;
        this.modalOpreation.emit({ "cancel": false, "param": orderForm });
      }, (err) => {
        this.clickRepeat = false;
        console.log(err);
      })
  }
  startAudio(): void {
    this.isPlay = true;
    this.Recorder.beforeStartRecord();
  }
  stopAudio(): void {
    this.isPlay = false;
    this.Recorder.stopRecord();
  }
  playAudio(): void {
    let audio = document.querySelector('audio');
    audio["src"] = this.Recorder.playRecord();
  }
}