2 * Copyright 2016-2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 //vimStatusTime:$.i18n.prop('com_zte_ums_eco_roc_vim_getting_info'),
24 // warning_block:false,
26 // $RTN_SUCCESS:"RTN_SUCCESS",
27 // $RTN_FAILED:"RTN_FAILED",
28 // wait : $.i18n.prop('com_zte_ums_eco_roc_vim_checking_status')
30 executeWait: {clazz: 'alert-info', visible: true, text: $.i18n.prop('com_zte_ums_eco_roc_vim_checking_status')},
31 executeError: {clazz: 'alert-danger', visible: true, text: 'error'},
35 displayActive: $.i18n.prop('com_zte_ums_eco_roc_vim_normal'),
36 displayInactive: $.i18n.prop('com_zte_ums_eco_roc_vim_abnormal')
39 action: {ADD: 'add', UPDATE: 'update'},
40 $queryVimInfoUrl: '/openoapi/extsys/v1/vims',
41 $addVimInfoUrl: '/openoapi/extsys/v1/vims/',
42 $updateVimInfoUrl: '/openoapi/extsys/v1/vims/',
43 $delVimInfoUrl: '/openoapi/extsys/v1/vims/{vim_id}',
44 $initTable: function () {
47 "url": vm.$queryVimInfoUrl,
49 "success": function (resp, statusText, jqXHR) {
50 if (jqXHR.status == "200") {
55 bootbox.alert($.i18n.prop("com_zte_ums_eco_roc_vim_growl_msg_query_failed"));
59 error: function (XMLHttpRequest, textStatus, errorThrown) {
60 bootbox.alert($.i18n.prop("com_zte_ums_eco_roc_vim_growl_msg_query_failed") + textStatus + ":" + errorThrown);
63 complete: function () {
64 resUtil.tooltipVimStatus();
70 condName: $.i18n.prop("com_zte_ums_eco_roc_vim_type"),
71 component_type: 'select',
79 cond_value: 'openstack',
86 titleName: $.i18n.prop("com_zte_ums_eco_roc_vim_register_info"),
102 $showVimTable: function (el, action) {
104 if (vm.action.ADD == action) {
105 vm.addVim.vimId = "";
106 vm.addVim.vimName = "";
107 vm.addVim.vimNameModify=false;
108 vm.addVim.userName = "";
109 vm.addVim.password = "";
111 vm.addVim.domain = "";
112 vm.addVim.domainVisable = true;
113 vm.addVim.description = "";
114 vm.addVim.tenant = "";
115 vm.addVim.vendor = "";
116 vm.addVim.saveType = "add";
117 vm.addVim.vimType = "openstack";
118 vm.addVim.titleName = $.i18n.prop("com_zte_ums_eco_roc_vim_register_info");
121 vm.addVim.vimId = el.vimId;
122 vm.addVim.vimName = el.name;
123 vm.addVim.vimNameModify=true;
124 vm.addVim.url = el.url;
125 vm.addVim.description = el.description;
126 vm.addVim.userName = el.userName;
127 vm.addVim.password = el.password;
128 vm.addVim.tenant = el.tenant;
129 vm.addVim.domain = el.domain;
130 vm.addVim.domainVisable=vm.$getdomainVisable(el.type);
131 vm.addVim.saveType = "update";
132 vm.addVim.titleName = $.i18n.prop('com_zte_ums_eco_roc_vim_modify_info');
133 vm.addVim.vimType = el.type;
134 vm.addVim.vendor = el.vendor;
135 vm.addVim.version = el.version;
137 vm.executeError.visible = false;
138 vm.executeWait.visible = false;
139 $(".form-group").each(function () {
140 $(this).removeClass('has-success');
141 $(this).removeClass('has-error');
142 $(this).find(".help-block[id]").remove();
144 $("#addVimDlg").modal("show");
147 $saveVimTable: function () {
151 if (form.valid() == false) {
155 vm.executeWait.visible = true;
156 vm.executeError.visible = false;
157 if (vm.addVim.saveType == "add") {
158 for( var i = 0; i < vm.vimInfo.length; i ++ ){
159 if(vm.addVim.name == vm.vimInfo[i].name){
160 resUtil.growl($.i18n.prop("com_zte_ums_eco_roc_vim_growl_msg_title") + ' already exists',"info");
161 $('#addVimDlg').modal('hide');
166 } else if (vm.addVim.saveType == "update") {
171 persistVim: function () {
174 url: vm.$addVimInfoUrl,
175 data: JSON.stringify({
176 name: vm.addVim.vimName,
178 userName: vm.addVim.userName,
179 password: vm.addVim.password,
180 tenant: vm.addVim.tenant,
181 domain: vm.addVim.domain,
182 vendor: vm.addVim.vendor,
183 version: vm.addVim.version,
184 description: vm.addVim.description,
185 type: vm.addVim.vimType,
189 contentType: 'application/json',
190 success: function (data, statusText, jqXHR) {
191 vm.executeWait.visible = false;
192 vm.executeError.visible = false;
193 if (jqXHR.status == "201") {
194 vm.addVim.vimId = data.vimId;
195 vm.addVim.name = data.name;
196 vm.addVim.tenant = data.tenant;
197 vm.addVim.type = data.type;
198 var newVim = jQuery.extend({}, vm.addVim);
199 vm.vimInfo.push(newVim);
201 $('#addVimDlg').modal('hide');
202 resUtil.growl($.i18n.prop("com_zte_ums_eco_roc_vim_growl_msg_title") + $.i18n.prop("com_zte_ums_eco_roc_vim_growl_msg_save_success"), "success");
204 vm.executeError.visible = true;
205 vm.executeError.text = $.i18n.prop("com_zte_ums_eco_roc_vim_growl_msg_save_failed");
208 error: function (XMLHttpRequest, textStatus, errorThrown) {
209 vm.executeError.visible = true;
210 vm.executeError.text = textStatus + ":" + errorThrown;
211 vm.executeWait.visible = false;
217 updateVim: function () {
220 url: vm.$updateVimInfoUrl + vm.addVim.vimId,
221 contentType: 'application/json',
222 data: JSON.stringify({
223 name: vm.addVim.vimName,
224 userName: vm.addVim.userName,
225 password: vm.addVim.password,
226 domain: vm.addVim.domain,
227 version: vm.addVim.version,
228 description: vm.addVim.description,
230 tenant: vm.addVim.tenant,
231 type: vm.addVim.vimType,
232 vendor: vm.addVim.vendor,
236 success: function (data, statusText, jqXHR) {
237 vm.executeWait.visible = false;
238 vm.executeError.visible = false;
239 if (jqXHR.status == "200") {
240 for (var i = 0; i < vm.vimInfo.length; i++) {
241 if (vm.vimInfo[i].vimId == vm.addVim.vimId) {
242 vm.vimInfo[i].name = vm.addVim.vimName;
243 vm.vimInfo[i].userName = vm.addVim.userName;
244 vm.vimInfo[i].password = vm.addVim.password;
245 vm.vimInfo[i].url = vm.addVim.url;
246 vm.vimInfo[i].tenant = vm.addVim.tenant;
247 vm.vimInfo[i].domain = vm.addVim.domain;
248 vm.vimInfo[i].description = vm.addVim.description;
249 vm.vimInfo[i].type = vm.addVim.vimType;
250 vm.vimInfo[i].version=vm.addVim.version;
251 vm.vimInfo[i].vendor=vm.addVim.vendor;
254 $('#addVimDlg').modal('hide');
255 resUtil.growl($.i18n.prop('com_zte_ums_eco_roc_vim_growl_msg_title') + $.i18n.prop('com_zte_ums_eco_roc_vim_growl_msg_save_success'), "success");
258 vm.executeError.visible = true;
259 vm.executeError.text = $.i18n.prop('com_zte_ums_eco_roc_vim_growl_msg_save_failed');
262 error: function (XMLHttpRequest, textStatus, errorThrown) {
264 vm.executeError.visible = true;
265 vm.executeError.text = textStatus + ":" + errorThrown;
266 vm.executeWait.visible = false;
270 delVim: function (el) {
271 bootbox.confirm($.i18n.prop('com_zte_ums_eco_roc_vim_confirm_delete_vim_record'), function (result) {
275 url: vm.$delVimInfoUrl.replace('{vim_id}', el.vimId),
276 success: function (data, statusText, jqXHR) {
277 if (jqXHR.status == "204") {
278 for (var i = 0; i < vm.vimInfo.length; i++) {
279 if (el.vimId == vm.vimInfo[i].vimId) {
280 vm.vimInfo.splice(i, 1);
284 resUtil.growl($.i18n.prop('com_zte_ums_eco_roc_vim_growl_msg_title') + $.i18n.prop('com_zte_ums_eco_roc_vim_growl_msg_remove_success'), "success");
287 resUtil.growl($.i18n.prop('com_zte_ums_eco_roc_vim_growl_msg_title') + $.i18n.prop('com_zte_ums_eco_roc_vim_growl_msg_remove_failed'), "warning");
290 error: function (XMLHttpRequest, textStatus, errorThrown) {
291 resUtil.growl($.i18n.prop('com_zte_ums_eco_roc_vim_growl_msg_title') + errorThrown, "danger");
297 gotoChartPage: function (oid, name, tenant) {
298 window.location.href = "vimChart.html?" + oid + "&" + name + "&" + tenant;
300 $getdomainVisable:function(vimType){
301 if ("openstack"==vimType){
308 vimTypeRendered:function(){
309 vm.addVim.domainVisable=vm.$getdomainVisable(vm.addVim.vimType);