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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
/*
* Copyright (C) 2015 ZTE, Inc. and others. All rights reserved. (ZTE)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var vm = avalon.define({
$id : "tmTopoController",
templateId : "",
nodesData: [],
$language: {
"sProcessing": "<img src='../component/thirdparty/data-tables/images/loading-spinner-grey.gif'/><span> "
+$.i18n.prop("nfv-nso-iui-table-sProcess")+"</span>",
"sLengthMenu": $.i18n.prop("nfv-nso-iui-table-sLengthMenu"),
"sZeroRecords": $.i18n.prop("nfv-nso-iui-table-sZeroRecords"),
"sInfo": "<span class='seperator'> </span>" + $.i18n.prop("nfv-nso-iui-table-sInfo"),
"sInfoEmpty": $.i18n.prop("nfv-nso-iui-table-sInfoEmpty"),
"sGroupActions": $.i18n.prop("nfv-nso-iui-table-sGroupActions"),
"sAjaxRequestGeneralError":$.i18n.prop("nfv-nso-iui-table-sAjaxRequestGeneralError"),
"sEmptyTable": $.i18n.prop("nfv-nso-iui-table-sEmptyTable"),
"oPaginate": {
"sPrevious": $.i18n.prop("nfv-nso-iui-table-sPrevious"),
"sNext": $.i18n.prop("nfv-nso-iui-table-sNext"),
"sPage": $.i18n.prop("nfv-nso-iui-table-sPage"),
"sPageOf": $.i18n.prop("nfv-nso-iui-table-sPageOf")
}
},
$restUrl : {
queryNodeTemplateUrl : "/openoapi/catalog/v1/servicetemplates/{0}/nodetemplates",
queryTemplateInfoUrl : "/openoapi/catalog/v1/servicetemplates"
},
$init : function() {
vm.$initTemplateData();
vm.$initTopoNodesData();
},
$initTemplateData : function() {
$.ajax({
type : "GET",
url : vm.$restUrl.queryTemplateInfoUrl,
success : function(resp) {
if(resp) {
vm.servicesTemplateData = [];
for(var i=0; i<resp.length; i++) {
//generate node table display data
vm.servicesTemplateData.push(resp[i]);
}
//vm.$initNfvNodesTab();
}
},
error : function() {
commonUtil.showMessage($.i18n.prop("nfv-topology-iui-message-error"), "danger");
}
});
},
$initTopoNodesData : function() {
$.ajax({
type : "GET",
url : vm.$restUrl.queryNodeTemplateUrl,
success : function(resp) {
if(resp) {
vm.nodesDetail.nodesTemplateDetailData = [];
for(var i=0; i<resp.length; i++) {
//generate node table display data
var nodeTemplate = topoUtil.generateNodeTemplate(resp[i]);
vm.nodesData.push(nodeTemplate);
}
vm.nodesDetail.nodesTemplateDetailData = resp;
//generate topology graph display data
vm.topologyTab.topoTemplateData = topoUtil.generateTopoTemplate(vm.nodesData.$model);
//initialize topology data
topoUtil.initTopoData(vm.topologyTab.topoTemplateData.$model);
}
},
error : function() {
commonUtil.showMessage($.i18n.prop("nfv-topology-iui-message-error"), "danger");
}
});
},
topologyTab : {
topology : "topology.html",
vnfTip : $.i18n.prop("nfv-topology-iui-vnf-tip"),
btnTip : $.i18n.prop("nfv-topology-iui-btn-return-tip"),
topoTemplateData:[],
boxTopoDatas:[],
networkTopoDatas:[],
isShowNum: false,
returnBtnVisible : false,
$getColor: function(index) {
return topoUtil.getColor(index);
},
$getCidr: function(properties){
return topoUtil.getCidr(properties);
},
$getCpTop: function(index, parentBoxId){
return topoUtil.getCpTop(index, parentBoxId);
},
$initTopology : function() {
topoUtil.initTopoData(vm.topologyTab.topoTemplateData.$model);
},
$showTopo:function(id, name){
vm.nodesDetail.$showDetails("block", id, name);
},
$showVnfTopo: function(templateId) {
vm.topologyTab.returnBtnVisible = true;
vm.$restUrl.queryNodeTemplateUrl = "/openoapi/catalog/v1/servicetemplates/" + templateId + "/nodetemplates";
vm.$init();
},
$returnNS: function() {
vm.topologyTab.returnBtnVisible = false;
vm.$restUrl.queryNodeTemplateUrl = "/openoapi/catalog/v1/servicetemplates/" + vm.templateId + "/nodetemplates";
vm.$init();
}
},
//Nodes Details
nodesDetail : {
nodesTemplateDetailData: [],
detailTitle : "",
isShow : "none",
detailIndex : 0,
detailData : [
{id: "general", name: $.i18n.prop("nfv-templateDetail-nodesTab-iui-tab-general"), isActive: true},
{id: "properties", name: $.i18n.prop("nfv-templateDetail-nodesTab-iui-tab-properties"), isActive: false},
{id: "relationShips", name: $.i18n.prop("nfv-templateDetail-nodesTab-iui-tab-relationShips"), isActive: false}
],
$showDetails : function(isShow, nodetypeid, nodetypename) {
vm.nodesDetail.isShow = isShow;
if (isShow == "block") {
vm.nodesDetail.detailTitle = nodetypename + " " + $.i18n.prop("nfv-templateDetail-nodesTab-iui-title-nodeDetail"),
$('#' + vm.nodesDetail.detailData[0].id).click();
vm.nodesDetail.detailData[0].isActive = true;
vm.nodesDetail.$initNodeDetailTable(nodetypeid);
}
},
detailCondChange : function(index) {
vm.nodesDetail.detailIndex = index;
for(var i=0; i<vm.nodesDetail.detailData.length; i++) {
vm.nodesDetail.detailData[i].isActive = false;
}
vm.nodesDetail.detailData[index].isActive = true;
},
$tableFields : {// table columns
general: [
{"mData": "key", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-key"), "bSortable" : false},
{"mData": "value", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-value"), "bSortable" : false}
],
properties: [
{"mData": "key", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-key"), "bSortable" : false},
{"mData": "value", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-value"), "bSortable" : false}
],
relationShips: [
{"mData": "sourceNodeName", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-sourceNodeName"), "bSortable" : false},
{"mData": "targetNodeName", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-targetNodeName"), "bSortable" : false},
{"mData": "type", "name": $.i18n.prop("nfv-templateDetail-nodesTab-iui-field-type"), "bSortable" : false}
]
},
$initNodeDetailTable: function(nodetemplateid) {
var data = topoUtil.getCurrentDetailData(vm.nodesDetail.nodesTemplateDetailData.$model, nodetemplateid);
//initialize three tables of nodedetail
$.each(vm.nodesDetail.$tableFields, function(key, value){
var setting = {};
setting.language = vm.$language;
setting.paginate = false;
setting.info = false;
setting.columns = value;
setting.tableId = "ict_table_" + key;
serverPageTable.initTableWithData(setting, setting.tableId + '_div', data[key]);
});
}
},
});
var initParam = function() { //initialize template detail params
var paramStr = window.location.search.substring(1);
if(paramStr.length > 0) {
var params = paramStr.split("&");
var templateId = params[0].substring(params[0].indexOf('=') + 1);
var flavor = params[1].substring(params[1].indexOf('=') + 1);
avalon.scan();
vm.templateId = templateId;
vm.$restUrl.queryNodeTemplateUrl = commonUtil.format(vm.$restUrl.queryNodeTemplateUrl, templateId);
if(flavor) {
vm.$restUrl.queryNodeTemplateUrl += "?flavor=" + flavor;
}
vm.$init();
}
};
initParam();
|