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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { ServiceListService } from '../../../../core/services/serviceList.service';
@Component({
selector: 'app-create-model',
templateUrl: './create-model.component.html',
styleUrls: ['./create-model.component.less'],
})
export class CreateModelComponent implements OnInit {
@Input()isVisible: boolean;
@Input()customerList;
@Input()serviceTypeList;
@Input()customerSelected;
@Input()serviceTypeSelected;
@Output() cancel = new EventEmitter<boolean>();
@Output() createdModalShow = new EventEmitter<any>();
serviceTypes: any[];
currentCustomer: any;
currentServiceType: any;
templateTypeSelected:string = "CCVPN";
templates: any[] = [];
currentTemplate: object = { name: null };
orchestratorList: any[] = [];
orchestratorSelected: object = { name: null, id: null };
isSol005Interface: boolean = false;
temParametersTips: boolean = false;
createData: Object = {};
loadingAnimateShow: boolean = false;
constructor( private http: ServiceListService) {}
ngOnInit() {
this.serviceTypes = this.serviceTypeList;
this.currentCustomer = JSON.parse(JSON.stringify(this.customerSelected));
this.currentServiceType = JSON.parse(JSON.stringify(this.serviceTypeSelected));
this.getAlltemplates();
}
getServiceType(): void{
this.http.getServiceTypes(this.currentCustomer)
.subscribe((data) => {
this.serviceTypes = data.map((item) => {
return { name: item["service-type"] }
});
})
}
getAlltemplates() {
this.http.getAllServiceTemplates(this.templateTypeSelected)
.subscribe((data) => {
this.templates = data;
if (this.templateTypeSelected == "Network Service") {
this.templates = data.filter((d) => {
return typeof d.packageInfo.csarName == "string";
}).map((item) => {
let cName = item.packageInfo.csarName.split("/").reverse()[0];
return { name: cName, id: item.csarId, packageInfo: item.packageInfo }
});
}
this.currentTemplate = this.templates[0];
}, (err) => {
console.log(err);
})
}
getallOrchestrators() {
this.http.getAllOrchestrators()
.subscribe((data) => {
if(data.length > 0){
this.orchestratorList = data.map((item) => {
return { name: item["name"], id: item["name"] }
});
this.orchestratorSelected = this.orchestratorList[0];
}
})
}
handleCancel(): void {
this.isVisible = false;
this.cancel.emit(false);
this.loadingAnimateShow = false;
}
customerChange(): void {
this.getServiceType();
}
choseTemplateType() {
if(this.templateTypeSelected === 'E2E Service'){
this.getallOrchestrators();
}
this.getAlltemplates();
}
handleOk(): void {
if (this.templateTypeSelected === "SOTN" || this.templateTypeSelected === "CCVPN" || this.templateTypeSelected === "MDONS") {
this.createData = {
commonParams: {
customer: this.currentCustomer,
serviceType: this.currentServiceType,
templateType: this.templateTypeSelected
},
template: this.currentTemplate
};
} else if (this.templateTypeSelected === "E2E Service" || this.templateTypeSelected === "Network Service") {
this.createData = {
commonParams: {
customer: this.currentCustomer,
serviceType: this.currentServiceType,
templateType: this.templateTypeSelected
},
template: this.currentTemplate,
orchestrator: this.orchestratorSelected,
isSol005Interface: this.isSol005Interface
};
}
this.getTemParameters();
}
getTemParameters() {
let chosedtemplates = this.createData["template"];
let types = this.createData["commonParams"].templateType;
if (types == "E2E Service") {
types = "e2e";
} else if (types == "Network Service") {
types = "ns";
}
this.loadingAnimateShow = true;
this.http.getTemplateParameters(types, chosedtemplates)
.subscribe((data) => {
this.loadingAnimateShow = false;
if (data.status == "FAILED") {
this.temParametersTips = true;
this.isVisible = true;
} else {
this.cancel.emit(false);
this.temParametersTips = false;
this.createdModalShow.emit({templateType: this.templateTypeSelected, data, createData: this.createData})
}
})
}
}
|