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.
20 interpolate: ["<!--", "-->"]
23 refreshByCond = function(){
27 var vm = avalon.define({
28 $id: "curAlarmsController",
34 curalarmsType: 'curalarms',
37 dataRangeLocationDisabled:true,
38 dataRangeTypeDisabled:true,
39 dataRangeCodeDisabled:true,
40 alCodeTree_affirm:false,
41 alLocationTree_affirm:false,
42 alarmCodeSelectedCount: 0,
43 alarmLocationSelectedCount: 0,
44 alarmTypeSelectedCount: 0,
53 {id: '1', name: $.i18n.prop("ngict_fm_iui_curalarm_critical"), value: true, type: "severityTypes", class: "alarm-serious"},
54 {id: '2', name: $.i18n.prop("ngict_fm_iui_curalarm_major"), value: true, type: "severityTypes", class: "alarm-important"},
55 {id: '3', name: $.i18n.prop("ngict_fm_iui_curalarm_minor"), value: true, type: "severityTypes", class: "alarm-secondary"},
56 {id: '4', name: $.i18n.prop("ngict_fm_iui_curalarm_warning"), value: true, type: "severityTypes", class: "alarm-slightly"}
60 {id: '1', name: $.i18n.prop("ngict_fm_iui_curalarm_ackAlarm"), value: false, type: "ackStateTypes"},
61 {id: '2', name: $.i18n.prop("ngict_fm_iui_curalarm_unackAlarm"), value: true, type: "ackStateTypes"}
65 {id: '1', name: $.i18n.prop("ngict_fm_iui_curalarm_visible"), value: true, type: "filterStateTypes"},
66 {id: '0', name: $.i18n.prop("ngict_fm_iui_curalarm_invisible"), value: false, type: "filterStateTypes"}
70 "Communications Alarm",
71 "Processing Error Alarm",
72 "Quality of Service Alarm",
74 "Environmental Alarm",
76 "Integrity Violation",
77 "Operational Violation",
80 "Time Domain Violation"
85 {"mData": null,name: "<input id='dataTableCheckBox' type='checkBox'/>","sClass": 'details-check',"sWidth": '5%',"fnRender": alarmsUtil.checkBox},
86 {"mData": "order", name: $.i18n.prop("ngict_fm_iui_curalarm_order"),"sClass": 'details-control', "sWidth": '6%'},
87 {"mData": "id", sWidth : "10%",name: $.i18n.prop("ngict_fm_iui_curalarm_id"),"bVisible": true},
88 {"mData": "position1DisplayName", sWidth : "10%",name:$.i18n.prop("ngict_fm_iui_curalarm_ne")},
89 {"mData": "mocName",sWidth : "14%", name: $.i18n.prop("ngict_fm_iui_curalarm_moc")},
90 {"mData": "probableCauseCodeNameAndCode", sWidth : "14%",name: $.i18n.prop("ngict_fm_iui_curalarm_probableCauseCode")},
91 {"mData": "alarmRaisedTime", sWidth : "15%",name: $.i18n.prop("ngict_fm_iui_curalarm_alarmRaisedTime"),"fnRender": alarmsUtil.timeRender},
92 {"mData": "perceivedSeverity",sWidth : "10%", name: $.i18n.prop("ngict_fm_iui_curalarm_perceivedSeverity"),fnRender:alarmsUtil.Severity},
93 {"mData": "alarmType",sWidth : "10%", name: $.i18n.prop("ngict_fm_iui_curalarm_alarmType"),"bVisible": false},
94 {"mData": "ackState",sClass:"ackState",sWidth : "10%", name: $.i18n.prop("ngict_fm_iui_curalarm_ackState"),"fnRender":alarmsUtil.ackState},
95 {"mData": "ackTime", sWidth : "13%",name: $.i18n.prop("ngict_fm_iui_curalarm_ackTime"),"fnRender": alarmsUtil.timeRender,"bVisible": false},
96 {"mData": "position1", name: $.i18n.prop("ngict_fm_iui_curalarm_position1"),"bVisible": false},
97 {"mData": "alarmChangedTime", name: $.i18n.prop("ngict_fm_iui_curalarm_alarmChangedTime"),"bVisible": false,"fnRender": alarmsUtil.timeRender},
98 {"mData": "ackUserId", name: $.i18n.prop("ngict_fm_iui_curalarm_ackUserId"),"bVisible": false},
99 {"mData": "ackSystemId", name: $.i18n.prop("ngict_fm_iui_curalarm_ackSystemId"),"bVisible": false},
100 {"mData": "alarmClearedTime", name: $.i18n.prop("ngict_fm_iui_curalarm_alarmClearedTime"),"bVisible": false,"fnRender": alarmsUtil.timeRender},
101 {"mData": "additionalText", name: $.i18n.prop("ngict_fm_iui_curalarm_additionalText"),"bVisible": false},
102 {"mData": "ackSystemId", name: $.i18n.prop("ngict_fm_iui_curalarm_ackSystem"),"bVisible": false},
103 {"mData": "clearUserId", name: $.i18n.prop("ngict_fm_iui_curalarm_clearUserId"),"bVisible": false},
104 {"mData": "clearSystemId", name: $.i18n.prop("ngict_fm_iui_curalarm_clearSystemId"),"bVisible": false},
105 {"mData": "clearType", name: $.i18n.prop("ngict_fm_iui_curalarm_clearType"),"bVisible": false},
106 {"mData": "probableCauseCode", name: $.i18n.prop("ngict_fm_iui_curalarm_probableCauseCode"),"bVisible": false},
107 {"mData": "specificProblem", name: $.i18n.prop("ngict_fm_iui_curalarm_specificProblem"),"bVisible": false},
108 {"mData": "neIp", name: $.i18n.prop("ngict_fm_iui_curalarm_neIp"),"bVisible": false},
109 {"mData": "pathIds", name: $.i18n.prop("ngict_fm_iui_curalarm_pathIds"),"bVisible": false},
110 {"mData": "pathName", name: $.i18n.prop("ngict_fm_iui_curalarm_pathName"),"bVisible": false}
115 "sProcessing": "<img src='../common/thirdparty/data-tables/images/loading-spinner-grey.gif'/><span> 处理中...</span>",
116 "sLengthMenu": $.i18n.prop("ngict-fm-iui-table-sLengthMenu"),
117 "sZeroRecords": $.i18n.prop("ngict-fm-iui-table-sZeroRecords"),
118 "sInfo": "<span class='seperator'></span>" + $.i18n.prop("ngict-fm-iui-table-sInfo"),
119 "sInfoEmpty": $.i18n.prop("ngict-fm-iui-table-sInfoEmpty"),
120 "sGroupActions": $.i18n.prop("ngict-fm-iui-table-sGroupActions"),
121 "sAjaxRequestGeneralError": $.i18n.prop("ngict-fm-iui-table-sAjaxRequestGeneralError"),
122 "sEmptyTable": $.i18n.prop("ngict-fm-iui-table-sEmptyTable"),
124 "sPrevious": $.i18n.prop("ngict-fm-iui-table-sPrevious"),
125 "sNext": $.i18n.prop("ngict-fm-iui-table-sNext"),
126 "sPage": $.i18n.prop("ngict-fm-iui-table-sPage"),
127 "sPageOf": $.i18n.prop("ngict-fm-iui-table-sPageOf")
131 $queryAlarmsInfoUrl: '/openoapi/umc/v1/fm/curalarms',
132 $saveCondUrl: '/web/rest/web/fm/rules?isc_dataFormat=json',
134 $sunburstSetting: {width: 450, height: 400},
136 $getLogCond: function(){
140 var filterState = [];
141 for (var i = 0; i < vm.severityTypes.length; i++) {
142 vm.severityTypes[i].value ? severitys.push(vm.severityTypes[i].id) : null;
144 for (var i = 0; i < vm.ackStateTypes.length; i++) {
145 vm.ackStateTypes[i].value ? cond.ackState = ackState.push(vm.ackStateTypes[i].id) : null;
147 for (var i = 0; i < vm.filterStateTypes.length; i++) {
148 vm.filterStateTypes[i].value ? cond.filterState = filterState.push(vm.filterStateTypes[i].id) : null;
150 cond.severity = severitys;
151 cond.ackState = ackState;
152 cond.filterState = filterState;
153 cond.location=vm.fmConds.location;
154 cond.ackTimeStarTime = vm.fmConds.ackTimeStarTime;
155 cond.ackTimeEndTime = vm.fmConds.ackTimeEndTime;
156 cond.ackRelativeTime = vm.fmConds.ackRelativeTime;
157 cond.ackTimeMode = vm.fmConds.ackTimeMode;
158 cond.alarmRaisedStartTime = vm.fmConds.alarmRaisedStartTime;
159 cond.alarmRaisedEndTime = vm.fmConds.alarmRaisedEndTime;
160 cond.alarmRaisedRelativeTime = vm.fmConds.alarmRaisedRelativeTime;
161 cond.alarmRaisedTimeMode = vm.fmConds.alarmRaisedTimeMode;
162 cond.clearedTimeStarTime = vm.fmConds.clearedTimeStarTime;
163 cond.clearedTimeEndTime = vm.fmConds.clearedTimeEndTime;
164 cond.clearedTimeMode = vm.fmConds.clearedTimeMode;
165 cond.probableCause = vm.fmConds.probableCause;
166 cond.alarmType = vm.fmConds.alarmType;
167 cond.ruleType = vm.ruleType;
171 $initRegister: function(){
172 $('#alCode .condSelect').click(function(){
173 $('#alCodeTree').modal('show');
176 $('#alCodeTree').on('hide.bs.modal', function(){
177 $table = $("#selectedProbableCausesTreeTable");
178 if(vm.alCodeTree_affirm===false){
179 $('#selectedProbableCausesTreeTable tbody').children().remove();
180 for(i=0;i<alarmTemp.length;i++){
181 $table.append(alarmTemp[i]);
184 vm.alCodeTree_affirm=false;
187 $('#alCodeTree').on('show.bs.modal', function(){
188 vm.alCodeTree_affirm=false;
190 var $trs=$("#selectedProbableCausesTreeTable tr");
192 for(var i=0;i<$trs.length;i++){
193 alarmTemp.push($trs.eq(i)[0].outerHTML);
195 $('#selectedProbableCausesTreeTable td').on("click", function(){
196 var $tds = $('#selectedProbableCausesTreeTable td');
197 for (var i = 0; i < $tds.length; i++) {
198 $tds.eq(i).removeClass('tallCellSelected');
199 $tds.eq(i).parent().removeClass('checked');
201 $(this).addClass('tallCellSelected');
202 $(this).parent().addClass("checked");
207 $('#alType .condSelect').click(function(){
208 $('#alTypeTree').modal('show');
212 $('#alLocation .condSelect').click(function(){
213 $('#alLocationTree').modal('show');
216 $('#alLocationTree').on('hide.bs.modal', function(){
217 $table = $("#selectedDeptTreeTable");
218 if(vm.alLocationTree_affirm===false){
219 $('#selectedDeptTreeTable tbody').children().remove();
220 for(i=0;i<alarmTemp.length;i++){
221 $table.append(alarmTemp[i]);
224 vm.alLocationTree_affirm=false;
227 $('#alLocationTree').on('show.bs.modal', function(){
228 vm.alLocationTree_affirm=false;
230 var $trs=$("#selectedDeptTreeTable tr");
232 for(var i=0;i<$trs.length;i++){
233 alarmTemp.push($trs.eq(i)[0].outerHTML);
236 $('#selectedDeptTreeTable td').on("click", function(){
237 var $tds = $('#selectedDeptTreeTable td');
238 for (var i = 0; i < $tds.length; i++) {
239 $tds.eq(i).removeClass('tallCellSelected');
240 $tds.eq(i).parent().removeClass('checked');
242 $(this).addClass('tallCellSelected');
243 $(this).parent().addClass("checked");
247 $(document).on("click", function(e){
248 var target = $(e.target);
249 if(target.closest("#alLocationTree").length == 0 && target.closest("#alLocation .condSelect").length==0){
250 $("#alLocationTree").fadeOut();
252 if(target.closest("#alCodeTree").length == 0 && target.closest("#alCode .condSelect").length==0){
253 $('#alCodeTree').fadeOut();
255 if(target.closest("#alTypeTree").length == 0 && target.closest("#alType .condSelect").length==0){
256 $('#alTypeTree').fadeOut();
261 $('#affirm').hover(function(){
262 $('#affirmTrip').show();
264 $('#affirmTrip').hide();
268 $('#unAffirm').hover(function(){
269 $('#unAffirmTrip').show();
271 $('#unAffirmTrip').hide();
275 $('.confirmTime input[type="radio"]').iCheck({
276 radioClass: 'iradio_square-aero',
281 $('#selectedAlTypeTable input[type="checkBox"]').on("ifChecked", function(){
282 $(this).parent().parent().addClass('tallCellSelected');
286 $('#selectedAlTypeTable input[type="checkBox"]').on("ifUnchecked", function(){
287 $(this).parent().parent().removeClass('tallCellSelected');
291 $initTable: function(){
293 setting.language = vm.$language;
294 setting.columns = vm.$alarmsTableFields[vm.curalarmsType];
295 setting.restUrl = vm.$queryAlarmsInfoUrl;
296 setting.tableId = "ict_alarms_table";
297 serverPageTable.initDataTable(setting, vm.$getLogCond(), 'ict_alarms_table_div');
300 condChange: function(){
304 moreCondClicked: function(){
305 $('#moreCond').fadeToggle();
306 var icon = $(this).children('span').eq(0);
307 if ($(this).hasClass('blueactive')) {
308 vm.moreCondBtn = false;
309 icon.removeClass('borderBottom');
310 icon.addClass('borderBotTop');
311 $("div.fliterline").show();
313 vm.moreCondBtn = true;
314 icon.removeClass('borderTop');
315 icon.addClass('borderBottom');
316 $("div.fliterline").hide();
320 alarmsCondSave: function(){
321 if ($('#saveCondId').val() != null && $.trim($('#saveCondId').val()) != '') {
322 var name = $('#saveCondId').val();
323 alarmsUtil.condSave(vm.$getLogCond(), vm.$saveCondUrl, name);
327 saveModal: function(){
328 $('#myModal').modal('show');
331 searchModal: function(){
335 tabClicked: function(modelItem, item){
336 if (!modelItem.value) {
337 modelItem.value = true;
339 modelItem.value = false;
344 moveTreeNode: function(item){
345 alarmsUtil.moveNode(item);
349 deptTreeAffirm: function(){
352 var $tds= $("#selectedDeptTreeTable td");
353 for (var i = 0; i < $tds.length; i++) {
355 obj.id=$tds.eq(i).attr('nodeid');
356 obj.oid=$tds.eq(i).attr('oid');
357 locationObj.push(obj);
359 selectName+=$tds.eq(i).text();
361 selectName+=","+$tds.eq(i).text();
364 vm.fmConds.location=locationObj;
365 vm.alarmLocationSelectedCount=locationObj.length;
366 vm.alLocationTree_affirm=true;
367 $('#alLocationTree').modal('hide')
371 probableCausesTreeAffirm: function(){
373 var probableCause=[];
374 var $tds= $("#selectedProbableCausesTreeTable td");
376 for (var i = 0; i < $tds.length; i++) {
378 obj.codeid=$tds.eq(i).attr('codeid');
379 obj.parentid=$tds.eq(i).attr('parentid');
380 obj.type=$tds.eq(i).attr('type');
381 probableCause.push(obj);
383 vm.fmConds.probableCause=probableCause;
384 vm.alarmCodeSelectedCount = probableCause.length;
385 vm.alCodeTree_affirm=true;
386 $('#alCodeTree').modal('hide');
390 alTypeTreeAffirm: function(){
393 var $tds=$("#selectedAlTypeTable td.tallCellSelected");
394 for (var i = 0; i < $tds.length; i++) {
398 selectName+=$tds.eq(i).text();
400 selectName+=","+$tds.eq(i).text();
403 vm.fmConds.alType=alType;
405 $('#alType .condSelect :selected').text(selectName);
407 $('#alType .condSelect :selected').text("请选择告警类型");
409 vm.alarmTypeSelectedCount = alType.length;
410 //$('#alTypeTree').fadeOut();
411 $('#alTypeTree').modal('hide')
416 initAlTypeTable = function(){
418 for (var i = 0; i < vm.alTypes.length; i++) {
419 html += "<tr><td><input type='checkbox'>" + vm.alTypes[i] + "</td></tr>";
421 $('#selectedAlTypeTable').append(html);
424 initPage = function(){
425 bootbox.setDefaults({
426 locale: lang.replace("-", "_")
429 alarmsUtil.setDateRange("daterangeConfirm", vm);
430 alarmsUtil.dateRangeEnableDisable("customAckTime");
432 alarmsUtil.setDateRange("daterangeOccur", vm);
433 alarmsUtil.dateRangeEnableDisable("customRaisedTime");
434 //高级菜单界面中,对告警发生时间、确认时间、清除时间初始化
435 alarmsUtil.dateRangeCustom(vm);
437 alarmsUtil.initTree();
442 localStorage.setItem("curRuleDataId",0);