suyiScreen/public/htWeb/lib/plugin/ht-telecom.js

1 line
10 KiB
JavaScript

!function(z,F){"use strict";var I=ht.AlarmSeverity=function(P,j,O,q,U){this.value=P,this.name=j,this.nickName=O,this.color=q,this.displayName=U};ht.Default.def("ht.AlarmSeverity",F,{toString:function(){return this.displayName||this.name}}),function(){I.severities=new ht.List,I._vm={},I._nm={},I._cp=function(l,q){if(l&&q){var L=l.value-q.value;return L>0?1:0>L?-1:0}return l&&!q?1:!l&&q?-1:0},I.each=function(m,Z){I.severities.each(m,Z)},I.getSortFunction=function(){return I._cp},I.setSortFunction=function(p){I._cp=p,I.severities.sort(p)},I.add=function(D,w,c,e,d){var k=new I(D,w,c,e,d);return I._vm[D]=k,I._nm[w]=k,I.severities.add(k),I.severities.sort(I._cp),k},I.remove=function(x){var H=I._nm[x];return H&&(delete I._nm[x],delete I._vm[H.value],I.severities.remove(H)),H},I.CRITICAL=I.add(500,"Critical","C","#FF0000"),I.MAJOR=I.add(400,"Major","M","#FFA000"),I.MINOR=I.add(300,"Minor","m","#FFFF00"),I.WARNING=I.add(200,"Warning","W","#00FFFF"),I.INDETERMINATE=I.add(100,"Indeterminate","N","#C800FF"),I.CLEARED=I.add(0,"Cleared","R","#00FF00"),I.isClearedAlarmSeverity=function(Z){return Z?0===Z.value:!1},I.getByName=function($){return I._nm[$]},I.getByValue=function(l){return I._vm[l]},I.clear=function(){I.severities.clear(),I._vm={},I._nm={}},I.compare=function(y,a){return I._cp(y,a)}}();var i=ht.AlarmState=function(V){this._d=V,this._nm={},this._am={},this._ps=null,this._haa=null,this._hna=null,this._hoa=null,this._hta=null,this._hls=!1,this._aac=0,this._nac=0};ht.Default.def("ht.AlarmState",F,{_ep:!0,_f:function(){this._c1(),this._c2(),this._c3(),this._c4(),this._c5(),this._c6(),this._c7(),this._d.fp("alarmState",null,this)},getHighestAcknowledgedAlarmSeverity:function(){return this._haa},getHighestNewAlarmSeverity:function(){return this._hna},getHighestOverallAlarmSeverity:function(){return this._hoa},getHighestNativeAlarmSeverity:function(){return this._hta},hasLessSevereNewAlarms:function(){return this._hls},_c1:function(){var A=null;for(var O in this._am)O=I.getByName(O),I.isClearedAlarmSeverity(O)||0!==this.getAcknowledgedAlarmCount(O)&&(A=A?I.compare(A,O)>0?A:O:O);this._haa=A},_c2:function(){var t=null;for(var G in this._nm)G=I.getByName(G),I.isClearedAlarmSeverity(G)||0!==this.getNewAlarmCount(G)&&(t=t?I.compare(t,G)>0?t:G:G);this._hna=t},_c3:function(){if(!this._hna)return this._hls=!1,void 0;for(var Q in this._nm)if(Q=I.getByName(Q),!I.isClearedAlarmSeverity(Q)&&0!==this.getNewAlarmCount(Q)&&I.compare(this._hna,Q)>0)return this._hls=!0,void 0;this._hls=!1},_c4:function(){var y=this._haa,G=this._hna,F=this._ps;this._hoa=y,I.compare(G,this._hoa)>0&&(this._hoa=G),I.compare(F,this._hoa)>0&&(this._hoa=F)},_c5:function(){var g=this._haa,n=this._hna;this._hta=g,I.compare(n,this._hta)>0&&(this._hta=n)},increaseAcknowledgedAlarm:function(P,V){if(0!==V){V=V||1;var w=this._am[P.name]||0;w+=V,this._am[P.name]=w,this._f()}},increaseNewAlarm:function(l,B){if(0!==B){B=B||1;var c=this._nm[l.name]||0;c+=B,this._nm[l.name]=c,this._f()}},decreaseAcknowledgedAlarm:function(T,C){if(0!==C){C||(C=1);var N=this._am[T.name]||0;if(N-=C,0>N)throw"Alarm count can not be negative";this._am[T.name]=N,this._f()}},decreaseNewAlarm:function(S,y){if(0!==y){y||(y=1);var L=this._nm[S.name]||0;if(L-=y,0>L)throw"Alarm count can not be negative";this._nm[S.name]=L,this._f()}},acknowledgeAlarm:function(v){this.decreaseNewAlarm(v,1),this.increaseAcknowledgedAlarm(v,1)},acknowledgeAllAlarms:function(B){if(B){var o=this.getNewAlarmCount(B);this.decreaseNewAlarm(B,o),this.increaseAcknowledgedAlarm(B,o)}else for(var M in this._nm)this.acknowledgeAllAlarms(I.getByName(M))},_c6:function(){this._aac=0;for(var A in this._am)A=I.getByName(A),this._aac+=this.getAcknowledgedAlarmCount(A)},getAcknowledgedAlarmCount:function(X){return X?this._am[X.name]||0:this._aac},getAlarmCount:function(U){return this.getAcknowledgedAlarmCount(U)+this.getNewAlarmCount(U)},_c7:function(){this._nac=0;for(var _ in this._nm)this._nac+=this.getNewAlarmCount(I.getByName(_))},getNewAlarmCount:function(E){return E?this._nm[E.name]||0:this._nac},setNewAlarmCount:function(b,F){this._nm[b.name]=F,this._f()},removeAllNewAlarms:function(u){u?delete this._nm[u]:this._nm={},this._f()},setAcknowledgedAlarmCount:function(N,K){this._am[N.name]=K,this._f()},removeAllAcknowledgedAlarms:function(v){v?delete this._am[v.name]:this._am={},this._f()},isEmpty:function(){return!this._hoa},clear:function(){this._am={},this._nm={},this._f()},getPropagateSeverity:function(){return this._ps},setPropagateSeverity:function(A){if(this._ep||(A=null),this._ps!==A){var i=this._ps;this._ps=A,this._f(),this._d.fp("propagateSeverity",i,A)}},isEnablePropagation:function(){return this._ep},setEnablePropagation:function(A){var Q=this._ep;this._ep=A,this._d.fp("enablePropagation",Q,A)&&(A||this.setPropagateSeverity(null))}});var _=ht.AlarmStatePropagator=function(k){this._dataModel=k,this._enable=!1,this._isPropagating=!1};ht.Default.def("ht.AlarmStatePropagator",F,{getDataModel:function(){return this._dataModel},isEnable:function(){return this._enable},setEnable:function(H){this._enable!==H&&(this._enable=H,this._enable?(this._dataModel.mm(this.handleDataModelChange,this),this._dataModel.md(this.handleDataPropertyChange,this),this._dataModel.each(function(c){this.propagate(c)},this)):(this._dataModel.umm(this.handleDataModelChange,this),this._dataModel.umd(this.handleDataPropertyChange,this)))},handleDataModelChange:function(P){P.data&&this.propagate(P.data)},handleDataPropertyChange:function(h){if("alarmState"===h.property||"enablePropagation"===h.property)this.propagate(h.data);else if("parent"===h.property){var g=h.oldValue;g&&this.propagate(g),this.propagate(h.data)}},propagate:function(X){X&&!this._isPropagating&&(this._isPropagating=!0,this.propagateToTop(X),this._isPropagating=!1)},propagateToTop:function(o){for(this.propagateToParent(null,o);o&&o.getParent();)this.propagateToParent(o,o.getParent()),o=o.getParent()},propagateToParent:function(r,H){var u=null;H.getChildren().each(function(B){var h=B.getAlarmState().getHighestOverallAlarmSeverity();I.compare(h,u)>0&&(u=h)}),H.getAlarmState().setPropagateSeverity(u)}}),ht.AlarmStateStatistics=function(K){this.sumNew=0,this.sumAcked=0,this.sumTotal=0,this.severtiyMap={},this.dataMap={},this.setDataModel(K)},ht.Default.def("ht.AlarmStateStatistics",F,{ms_fire:1,getDataModel:function(){return this._dataModel},setDataModel:function(Z){var m=this._dataModel;m!==Z&&(m&&(m.umd(this.handleDataPropertyChange,this),m.umm(this.handleDataModelChange,this),this.severtiyMap={},this.dataMap={}),this._dataModel=Z,this.reset(),Z.md(this.handleDataPropertyChange,this),Z.mm(this.handleDataModelChange,this),this.fp("dataModel",m,Z))},dispose:function(){this._dataModel.umd(this.handleDataPropertyChange,this),this._dataModel.umm(this.handleDataModelChange,this),delete this._dataModel},handleDataPropertyChange:function(i){"alarmState"===i.property&&(this.increase(i.data),this.fireAlarmStateChange())},handleDataModelChange:function(z){"add"===z.kind?(this.increase(z.data),this.fireAlarmStateChange()):"remove"===z.kind?(this.decrease(z.data),this.fireAlarmStateChange()):"clear"===z.kind&&(this.severtiyMap={},this.dataMap={},this.fireAlarmStateChange())},fireAlarmStateChange:function(){this.sumAcked=0,this.sumNew=0,this.sumTotal=0,I.each(function(Y){var E=this.getSumInfo(Y);this.sumAcked+=E.ackedCount,this.sumNew+=E.newCount,this.sumTotal+=E.totalCount},this),this.fp("alarmState",!1,!0)},getNewAlarmCount:function(u){if(!u)return this.sumNew;var X=this.getSumInfo(u);return X.newCount},getAcknowledgedAlarmCount:function(R){if(!R)return this.sumAcked;var F=this.getSumInfo(R);return F.ackedCount},getTotalAlarmCount:function(s){if(!s)return this.sumTotal;var T=this.getSumInfo(s);return T.totalCount},getSumInfo:function(E){var u=this.severtiyMap[E.name];return u||(u={},u.newCount=0,u.ackedCount=0,u.totalCount=0,this.severtiyMap[E.name]=u),u},decrease:function(h){var x=this.dataMap[h.getId()];x&&(delete this.dataMap[h.getId()],I.each(function(N){var g=x[N.name],T=this.getSumInfo(N);T.newCount=T.newCount-g.newCount,T.ackedCount=T.ackedCount-g.ackedCount,T.totalCount=T.totalCount-g.totalCount},this))},increase:function(m){if(this.decrease(m),!this._filterFunc||this._filterFunc(m)){var N={},u=m.getAlarmState();this.dataMap[m.getId()]=N,I.each(function(H){var x={};x.newCount=u.getNewAlarmCount(H),x.ackedCount=u.getAcknowledgedAlarmCount(H),x.totalCount=u.getAlarmCount(H),N[H.name]=x;var V=this.getSumInfo(H);V.newCount=V.newCount+x.newCount,V.ackedCount=V.ackedCount+x.ackedCount,V.totalCount=V.totalCount+x.totalCount},this)}},reset:function(){this.severtiyMap={},this.dataMap={},this._dataModel.each(this.increase,this),this.fireAlarmStateChange()},setFilterFunc:function(C){var L=this._filterFunc;this._filterFunc=C,this.reset(),this.fp("filterFunc",L,C)},getFilterFunc:function(){return this._filterFunc}});var g=ht.Data.prototype;g.getAlarmState=function(){return this._alarmState||(this._alarmState=new i(this))},g=ht.DataModel.prototype,g.isEnableAlarmStatePropagator=function(){return!!this._alarmStatePropagator&&this._alarmStatePropagator.isEnable()},g.setEnableAlarmStatePropagator=function(d){d!=this.isEnableAlarmStatePropagator()&&(d?(this._alarmStatePropagator=new _(this)).setEnable(!0):this._alarmStatePropagator.setEnable(!1))},g=ht.graph.GraphView.prototype,g.getNote2=function(V){var i=V.getAlarmState().getHighestNewAlarmSeverity();if(i){var H=V.getAlarmState().getNewAlarmCount(i)+i.nickName;return V.getAlarmState().hasLessSevereNewAlarms()&&(H+="+"),H}return V.s("note2")},g.getNote2Background=function(T){var S=T.getAlarmState().getHighestNewAlarmSeverity();return S?S.color:T.s("note2.background")},g.getBodyColor=function(S){var B=S.getAlarmState().getHighestNativeAlarmSeverity();return B?B.color:S.s("body.color")},g.getBorderColor=function(i){var w=i.getAlarmState().getPropagateSeverity();return w?w.color:i.s("border.color")},g=ht.widget.TreeView.prototype,g.getBorderColor=function(X){var f=X.getAlarmState().getPropagateSeverity();return f?f.color:X.s("border.color")},g.getIcon=function(G){return G.getIcon()?"__alarmIcon__":null},g=ht.widget.TreeTableView.prototype,g.getBorderColor=function(p){var M=p.getAlarmState().getPropagateSeverity();return M?M.color:p.s("border.color")},g.getIcon=function(l){return l.getIcon()?"__alarmIcon__":null},ht.Default.setImage("__alarmIcon__",{width:16,height:16,comps:[{type:"image",name:{func:function(l){return l.getIcon()}},color:{func:function(D){var g=D.getAlarmState().getHighestNativeAlarmSeverity();return g?g.color:D.s("body.color")}},rect:[0,0,16,16]}]});var j=ht.Style;j["note2.expanded"]=!0,j["note2.color"]="#000"}("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:(0,eval)("this"),Object);