summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/views/services/services-list/heal-model/heal-model.component.ts
blob: a7ffe663e97ba84ee3c5b90105d470a76ddabce1 (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
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';

@Component({
  selector: 'app-heal-model',
  templateUrl: './heal-model.component.html',
  styleUrls: ['./heal-model.component.less']
})
export class HealModelComponent implements OnInit {
  @Input()healModelVisible: boolean;
  @Input()thisService;
  @Input()nsParams;
  @Input()healActions;
  @Input()nsAdditional;
  @Input()vnfParams;
  @Input()vmSelected;
  @Input()vnfVms;
  @Input()templatehealstarting;
  @Input()templatehealSuccessFaild;

    @Output() cancel = new EventEmitter<boolean>();
    @Output() healModalOK = new EventEmitter<any>();

  constructor() { }

  ngOnInit() {
  }


    addActionsHealing() {
        this.healActions.push({ value: "" })
    }

    minusActionsHealing(index) {
        this.healActions.splice(index, 1);
    }

    addNsAdditional() {
        this.nsAdditional.push({ key: "", value: "" })
    }

    minusNsAdditional(index) {
        this.nsAdditional.splice(index, 1);
    }

    healOk() {
        this.healModelVisible = false;
        // nsParams
        this.nsParams.actionsHealing = this.healActions.map((item) => {
            return item.value
        });
        let additional = {};
        this.nsAdditional.forEach((item) => {
            additional[item.key] = item.value;
        });
        this.nsParams.additionalParamsforNs = JSON.stringify(additional);
        // vnfParams
        this.vnfParams.additionalParams.actionvminfo.vmid = this.vmSelected["vmId"];
        this.vnfParams.additionalParams.actionvminfo.vmname = this.vmSelected["vmName"];

        let requestBody = this.thisService["serviceDomain"] == "Network Service" ? { healNsData: this.nsParams } : { healVnfData: this.vnfParams };
        this.healModalOK.emit(requestBody)
    }

    healCancel() {
        this.healModelVisible = false;
    }

}