2 * Copyright 2016-2017, CMCC Technologies Co., Ltd.
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.
18 $id : "monitorController",
48 "sProcessing": "<img src='/openoui/common/thirdparty/data-tables/images/loading-spinner-grey.gif'/><span> Loadding...</span>",
49 "sLengthMenu": $.i18n.prop("openo-umc-monitor-iui-table-sLengthMenu"),
50 "sZeroRecords": $.i18n.prop("openo-umc-monitor-iui-table-sZeroRecords"),
51 "sInfo": "<span class='seperator'></span>" + $.i18n.prop("openo-umc-monitor-iui-table-sInfo"),
52 "sInfoEmpty": $.i18n.prop("openo-umc-monitor-iui-table-sInfoEmpty"),
53 "sGroupActions": $.i18n.prop("openo-umc-monitor-iui-table-sGroupActions"),
54 "sAjaxRequestGeneralError": $.i18n.prop("openo-umc-monitor-iui-table-sAjaxRequestGeneralError"),
55 "sEmptyTable": $.i18n.prop("openo-umc-monitor-iui-table-sEmptyTable"),
57 "sPrevious": $.i18n.prop("openo-umc-monitor-iui-table-sPrevious"),
58 "sNext": $.i18n.prop("openo-umc-monitor-iui-table-sNext"),
59 "sPage": $.i18n.prop("openo-umc-monitor-iui-table-sPage"),
60 "sPageOf": $.i18n.prop("openo-umc-monitor-iui-table-sPageOf")
64 $monitorListRestUrl :'/openoapi/umc/v1/monitor/monitorinfos',
65 $monitorInstanceRestUrl :'/openoapi/umc/v1/monitor/monitorinfo/',
66 $queryDacsRestUrl : '/openoapi/umc/v1/monitor/dacs',
67 $updateMonitorTaskRestUrl : '/openoapi/umc/v1/monitor/monitortask/',
76 cond_value : 'TELNET',
86 monitorSettingDlgInfo:{
90 queryMonitorList : function() {
94 "url": vm.$monitorListRestUrl,
96 "success": function (resp) {
99 var monitorInfo=resp[index]
101 if(monitorInfo.customPara!=""){
102 customPara=JSON.parse(monitorInfo.customPara);
103 if(typeof(customPara.PROXYIP) == "undefined")
105 customPara.PROXYIP="127.0.0.1";
109 customPara={PROXYIP:"127.0.0.1"};
111 monitorInfo.customPara=customPara;
114 vm.resource.monitorList = resp;
116 $('#monitorManagerTable').DataTable({
117 "oLanguage": vm.dataTableLanguage,
118 "sDom": '<"top"rt><"bottom"lip>',
119 "sPaginationType": "bootstrap_extended",
124 error: function(XMLHttpRequest, textStatus, errorThrown) {
125 monitorUtil.growl($.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_query_list_errInfo')+errorThrown,"danger");
132 queryMonitorInstance : function(oid){
134 vm.monitorInfo.oid=oid;
135 vm.monitorUrl=vm.$monitorInstanceRestUrl+oid;
139 "url": vm.monitorUrl,
141 "success": function (resp) {
143 var monitorInfo=resp;
145 if(monitorInfo.customPara!=""){
146 customPara=JSON.parse(monitorInfo.customPara);
147 if(typeof(customPara.PROXYIP) == "undefined")
149 customPara.PROXYIP="127.0.0.1";
153 customPara={PROXYIP:"127.0.0.1"};
155 monitorInfo.customPara=customPara;
156 vm.monitorInfo=monitorInfo;
158 vm.oldmonitorInfo.ipAddress=monitorInfo.ipAddress;
159 vm.oldmonitorInfo.label=monitorInfo.label;
160 vm.oldmonitorInfo.customPara=customPara;
165 error: function(XMLHttpRequest, textStatus, errorThrown) {
166 monitorUtil.growl($.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_query_monitor_errInfo')+errorThrown,"danger");
174 deleteMonitorInfo : function(oid){
175 vm.monitorInfo.oid=oid;
176 vm.monitorUrl=vm.$monitorInstanceRestUrl+oid;
180 "url": vm.monitorUrl,
182 "success": function (resp) {
183 vm.gotoMonitorListPage();
185 error: function(XMLHttpRequest, textStatus, errorThrown) {
186 monitorUtil.growl($.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_query_monitor_errInfo')+errorThrown,"danger");
193 updateMonitorSet:function(){
196 vm.monitorSettingDlgInfo.titleName=$.i18n.prop('com_zte_openo_umc_monitor_btn_monitorset');
197 vm.server_rtn.warning_block=false;
198 vm.server_rtn.info_block=false;
200 $(".form-group").each(function () {
201 $(this).removeClass('has-success');
202 $(this).removeClass('has-error');
203 $(this).find(".help-block[id]").remove();
206 if(vm.monitorInfo.customPara.PROXYIP=="" && vm.dac.selectItems.length>0){
207 vm.monitorInfo.customPara.PROXYIP=vm.dac.selectItems[0].ipAddress;
210 if(vm.monitorInfo.customPara.PROTOCOL==""){
211 vm.monitorInfo.customPara.PROTOCOL="SSH";
212 vm.monitorInfo.customPara.PORT="22";
215 $("#monitorSettingDlg").modal("show");
217 testMonitorSet:function(){
218 vm.server_rtn.warning_block=false;
219 vm.server_rtn.info_block=true;
220 vm.server_rtn.rtn_info="Monitor Set Access Test Pass";
222 saveMonitorSet : function() {
225 if (form.valid() == false) {
228 var propertyNames=vm.monitorInfo.customPara.$propertyNames.split("­");
229 var isPropertyUnEqual=false;
230 for(index in propertyNames)
232 var name=propertyNames[index]
233 if(vm.oldmonitorInfo.customPara[name]!=vm.monitorInfo.customPara[name])
235 isPropertyUnEqual=true;
239 // judge monitorInfo whether change
240 if( vm.oldmonitorInfo.ipAddress!=vm.monitorInfo.ipAddress ||
243 vm.server_rtn.warning_block=false;
244 vm.server_rtn.info_block=true;
245 vm.server_rtn.rtn_info=$.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_monitor_checkInfo');
246 var customPara=JSON.stringify(vm.monitorInfo.customPara.$model);
249 "url": vm.monitorUrl,
250 "data": JSON.stringify({
251 "ipAddress": vm.monitorInfo.ipAddress,
252 "oid": vm.monitorInfo.oid,
253 "neTypeId": vm.monitorInfo.neTypeId,
254 "label": vm.monitorInfo.label,
255 "origin": vm.monitorInfo.origin,
256 "extendPara": vm.monitorInfo.extendPara,
257 "customPara": customPara
260 "contentType" : "application/json",
261 success: function (resp) {
262 // judge PROXYIP whether change
264 if(vm.oldmonitorInfo.customPara.PROXYIP!=vm.monitorInfo.customPara.PROXYIP){
265 vm.ifPROXYIPChange=1;
268 vm.ifPROXYIPChange=0;
271 vm.updateMonitorTask();
273 vm.oldmonitorInfo.ipAddress=vm.monitorInfo.ipAddress;
274 vm.oldmonitorInfo.label=vm.monitorInfo.label;
275 var customPara=vm.monitorInfo.customPara.$model;
276 vm.oldmonitorInfo.customPara=customPara;
280 error: function(XMLHttpRequest, textStatus, errorThrown) {
282 vm.server_rtn.warning_block=true;
283 vm.server_rtn.info_block=false;
284 vm.server_rtn.rtn_info= $.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_monitor_save_failInfo')+errorThrown;
289 else if(vm.oldmonitorInfo.label!=vm.monitorInfo.label){
290 //only change label label
292 //save new monitorInfo
294 vm.server_rtn.warning_block=false;
295 vm.server_rtn.info_block=true;
296 vm.server_rtn.rtn_info=$.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_monitor_checkInfo');
297 var customPara=JSON.stringify(vm.monitorInfo.customPara.$model);
301 "url": vm.monitorUrl,
302 "data": JSON.stringify({
303 "ipAddress": vm.monitorInfo.ipAddress,
304 "oid": vm.monitorInfo.oid,
305 "neTypeId": vm.monitorInfo.neTypeId,
306 "label": vm.monitorInfo.label,
307 "origin": vm.monitorInfo.origin,
308 "extendPara": vm.monitorInfo.extendPara,
309 "customPara": customPara
312 "contentType" : "application/json",
313 success: function (resp) {
314 if(resp.result=="SUCCESS"){
316 vm.oldmonitorInfo.label=vm.monitorInfo.label;
317 $('#monitorSettingDlg').modal('hide');
318 monitorUtil.growl($.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_monitor_save_successInfo'),"success");
323 vm.server_rtn.warning_block=true;
324 vm.server_rtn.info_block=false;
325 vm.server_rtn.rtn_info= $.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_monitor_save_failInfo');
329 error: function(XMLHttpRequest, textStatus, errorThrown) {
331 vm.server_rtn.warning_block=true;
332 vm.server_rtn.info_block=false;
333 vm.server_rtn.rtn_info= $.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_monitor_save_failInfo')+errorThrown;
340 $('#monitorSettingDlg').modal('hide');
341 monitorUtil.growl($.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_monitor_save_successInfo'),"success");
349 cancelMonitorSet: function() {
351 vm.monitorInfo.ipAddress=vm.oldmonitorInfo.ipAddress;
352 vm.monitorInfo.name=vm.oldmonitorInfo.name;
353 vm.monitorInfo.customPara=vm.oldmonitorInfo.customPara;
354 $('#monitorSettingDlg').modal('hide');
357 queryDACs:function(){
362 "url": vm.$queryDacsRestUrl,
364 success: function (resp) {
365 vm.dac.selectItems = (resp==null)?[]:resp;
366 // vm.proxy.selectItems.sort(function(a,b){return a.ipAddress>b.ipAddress?1:-1});
368 error: function(XMLHttpRequest, textStatus, errorThrown) {
369 monitorUtil.growl($.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_dac_query_failInfo')+errorThrown,"danger");
373 updateMonitorTask:function(){
374 vm.server_rtn.warning_block=false;
375 vm.server_rtn.info_block=true;
376 vm.server_rtn.rtn_info=$.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_task_checkInfo');
379 var data= JSON.stringify({
380 oid:vm.monitorInfo.oid,
381 moc:vm.monitorInfo.neTypeId,
382 proxyIp:vm.monitorInfo.customPara.PROXYIP
387 "url": vm.$updateMonitorTaskRestUrl+vm.ifPROXYIPChange,
390 "contentType":"application/json",
391 success: function (resp) {
392 if(resp.result=="SUCCESS"){
394 $('#monitorSettingDlg').modal('hide');
395 monitorUtil.growl($.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_monitor_save_successInfo'),"success");
400 vm.server_rtn.warning_block=true;
401 vm.server_rtn.info_block=false;
402 vm.server_rtn.rtn_info= $.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_monitor_task_failInfo')+resp.info;
406 error: function(XMLHttpRequest, textStatus, errorThrown) {
408 vm.server_rtn.warning_block=true;
409 vm.server_rtn.info_block=false;
410 vm.server_rtn.rtn_info= $.i18n.prop('com_zte_openo_umc_monitor_monitorsetting_monitor_task_failInfo')+errorThrown;
416 gotoDACPage:function(){
417 window.location.href="dacList.html";
419 gotoMonitorSettingPage:function(oid){
420 window.location.href="monitorSetting.html?"+oid;
422 gotoMonitorListPage:function(){
423 window.location.href="monitorSettingList.html";