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