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