ht-telecom.js 11 KB

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