Ext.define("currentAlarms.controller.Main",{extend:"Ext.app.Controller",requires:["currentAlarms.view.Main"],refs:[{selector:"main",ref:"main"},{selector:"currentalarmssummary",ref:"currentalarmssummary"},{selector:"acknowledgementpanel",ref:"acknowledgementpanel"},{selector:"alarmfilters",ref:"alarmfilters"},],init:function(){this.control({"main":{"boxready":this.loadDefaults},"alarmfilters button[id=backButton]":{"click":this.goBack},"currentalarmssummary":{"afterrender":this.aftercurrentalarmssummary,},'alarmfilters combo[name="showCombo"]':{"select":this.loadAlarms},'alarmfilters combo[name="filterCombo"]':{"select":this.loadAlarms},'alarmfilters combo[name="subFilterCombo"]':{"select":this.loadAlarms},'alarmfilters combo[name="searchByCombo"]':{"select":this.loadAlarms},'main textfield[name="searchTextBox"]':{"keyup":this.searchAlarms},"#searchTextBox":{"ontriggerclick":this.searchAlarms},'acknowledgementpanel button[id="submitBtn"]':{"click":this.alarmAckSubmit},'acknowledgementpanel button[id="unAckBtn"]':{"click":this.goToUnAcknowledge},'acknowledgementpanel button[id="clearBtn"]':{"click":this.clearAckDescription},"main commonbackbutton":{"click":function(){document.location="/final/servlet/com.eg.EgMonitorController?monCmd=dashboard";
}}});},aftercurrentalarmssummary:function(){if(isPopupWindow!=null&&isPopupWindow=="true"){}else{Ext.getCmp("currentAlarmsGrid").setHeight(570);Ext.getCmp("currentAlarmsGrid").doLayout();Ext.getCmp("currentAlarmsGrid").doComponentLayout();Ext.getCmp("currentalarmsmain").doLayout();Ext.getCmp("currentalarmsmain").doComponentLayout();
}},checkSpecialCharacter:function(a){var c='="';for(var b=0;b<a.length;b++){check_char=c.indexOf(a.charAt(b));if(check_char>=0){return true;}}return false;},clearAckDescription:function(){Ext.getCmp("textaraObj").setValue("");},goToUnAcknowledge:function(){var a=Ext.getCmp("textaraObj").getValue();if(!checkblankVal(a)){Ext.MessageBox.show({title:"Alert",msg:unAckDescriptionAlert,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}else{Ext.MessageBox.confirm("Confirm",unAckDeleteConfirmAlert,this.unAcknowledgeAlarm,this);}},unAcknowledgeAlarm:function(a){if(a=="yes"){var i=Ext.getCmp("textaraObj").getValue();var b=alarmAckHiddenParams["userAck"];var g=alarmAckHiddenParams["alarmId"];var k="Unacknowledge";try{i=window.opener.filterEncode(i);
}catch(h){i=parent.filterEncode(i);}var j="desc="+encodeURIComponent(i)+"&hiddesc="+encodeURIComponent(i)+"&userID="+userId+"&alarmID="+g+"&userAck="+b+"&ackAlarmDB="+k;Ext.getCmp("ackWindowObj").destroy();var c=this;var f=Ext.get("emptyTextTb");try{if(f!=null){Ext.get("emptyTextTb").hide();}}catch(h){}alarmLoadMask.show();
var d=get_browser_info();Ext.Ajax.request({url:"/final/servlet/com.eg.EgCurrentAlarmsC",method:"POST",params:j+"&doAlarmAcknowledgementEvent=true&acknowledgementEvent=unAcknowledge&screenWidth="+(Ext.getBody().getViewSize().width)+"&screenHeight="+(Ext.getBody().getViewSize().height)+"&isBro="+d.name+"&isFromQuickLink="+isFromQuickLink,scope:this,success:function(e){var l=JSON.parse(e.responseText);
var m=l["unacknowledge"];alarmLoadMask.hide();if(ttIntegrationenabled!=null&&ttIntegrationenabled=="Yes"||ttIntegrationenabled=="true"){var n="sendTTAcknowledgement=true&desc="+encodeURIComponent(i)+"&alarm_Id="+g;Ext.Ajax.request({url:"/final/servlet/com.eg.EgCurrentAlarmsC",method:"POST",params:n,scope:this,success:function(o){var p=JSON.parse(o.responseText);
}});}c.loadAlarms(null);}});}else{return false;}},alarmAckSubmit:function(a){var b=alarmAckHiddenParams["alarmAckEvent"];if(b!=null){if(b=="Delete_Alarm"){this.alarmDelete(a);}else{if(b=="AckOrUnack"){this.alarmAcknowledge(a);}}}},alarmAcknowledge:function(a){var i=Ext.getCmp("textaraObj").getValue();
var l=true;if(isDoubleByteEnabled=="false"){l=validateSingleByte(i);}if(!checkblankVal(i)){Ext.MessageBox.show({title:"Alert",msg:ackDescriptionAlert,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}else{if(this.checkSpecialCharacter(i)){Ext.Msg.show({title:"Alert",msg:ackDescriptionSplCharAlert,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return;}else{if(!l){Ext.MessageBox.show({title:"Alert",msg:ackdbyteAlert,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}else{if(isDoubleByteEnabled&&isOracleDB){if(i!=null&&i!=""&&i.length>1024){Ext.MessageBox.show({title:"Alert",msg:maxAcknowledgeDescForDByte,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}}else{if(i!=null&&i!=""&&i.length>2048){Ext.MessageBox.show({title:"Alert",msg:maxAcknowledgeDescForSByte,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}}if(i==null||i==""){i="-";}var b=alarmAckHiddenParams["userAck"];var g=alarmAckHiddenParams["alarmId"];var k=alarmAckHiddenParams["ackAlarmDB"];
try{i=window.opener.filterEncode(i);}catch(h){i=parent.filterEncode(i);}var j="desc="+encodeURIComponent(i)+"&hiddesc="+encodeURIComponent(i)+"&userID="+userId+"&alarmID="+g+"&userAck="+b+"&ackAlarmDB="+k;Ext.getCmp("ackWindowObj").destroy();var c=this;var f=Ext.get("emptyTextTb");try{if(f!=null){Ext.get("emptyTextTb").hide();
}}catch(h){}alarmLoadMask.show();var d=get_browser_info();Ext.Ajax.request({url:"/final/servlet/com.eg.EgCurrentAlarmsC",method:"POST",params:j+"&doAlarmAcknowledgementEvent=true&acknowledgementEvent=acknowledge&screenWidth="+(Ext.getBody().getViewSize().width)+"&screenHeight="+(Ext.getBody().getViewSize().height)+"&isBro="+d.name+"&isFromQuickLink="+isFromQuickLink,scope:this,success:function(e){var m=JSON.parse(e.responseText);
var n=m["acknowledge"];alarmLoadMask.hide();if(ttIntegrationenabled!=null&&ttIntegrationenabled=="Yes"||ttIntegrationenabled=="true"){var p="sendTTAcknowledgement=true&desc="+encodeURIComponent(i)+"&alarm_Id="+g;Ext.Ajax.request({url:"/final/servlet/com.eg.EgCurrentAlarmsC",method:"POST",params:p,scope:this,success:function(q){var r=JSON.parse(q.responseText);
}});}var o=Ext.getCmp("searchTextBox");if(!Ext.isEmpty(o.getValue())){this.searchAlarms(o,"fire");}else{o.setValue("");c.loadAlarms(a);}}});}}}},alarmDelete:function(b){var h=Ext.getCmp("textaraObj").getValue();var p=true;if(isDoubleByteEnabled=="false"){p=validateSingleByte(h);}if(this.checkSpecialCharacter(h)){Ext.Msg.show({title:"Alert",msg:ackDescriptionSplCharAlert,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return;}else{if(!p){Ext.MessageBox.show({title:"Alert",msg:ackdbyteAlert,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}else{if(isDoubleByteEnabled&&isOracleDB){if(h!=null&&h!=""&&h.length>1024){Ext.MessageBox.show({title:"Alert",msg:maxAcknowledgeDescForDByte,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}}else{if(h!=null&&h!=""&&h.length>2048){Ext.MessageBox.show({title:"Alert",msg:maxAcknowledgeDescForSByte,buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}}if(h==null||h==""){h="-";}try{h=window.opener.filterEncode(h);}catch(r){h=parent.filterEncode(h);}publicJson["hiddenParams"]["userID"]=alarmAckHiddenParams["userId"];
publicJson["hiddenParams"]["alarmID"]=alarmAckHiddenParams["alarmId"];publicJson["hiddenParams"]["desc"]=h;publicJson["hiddenParams"]["isDelAlarms"]="true";publicJson["hiddenParams"]["ackAlarmDbDelete"]=alarmAckHiddenParams["ackdelAlarmDb"];publicJson["hiddenParams"]["delAlarmIDs"]="";var g=alarmAckHiddenParams["ackdelAlarmDb"];
if(eventDeleteFlag&&!Ext.isEmpty(g)&&g!=undefined&&g!="undefined"&&g=="Delete Alarm"){var t=Ext.getCmp("option").getValue();if(!Ext.isEmpty(t)&&t!=undefined&&t=="All"){publicJson["hiddenParams"]["deleteOptions"]=t;}else{if(!Ext.isEmpty(t)&&t!=undefined&&t=="Selected"){publicJson["hiddenParams"]["deleteOptions"]=t;
var q="";var i=null;if(eventGrpDeleteFlag){i=Ext.getCmp("selEventDescriptors");}else{i=Ext.getCmp("selDescriptors");}if(!Ext.isEmpty(i)){var j=i.getValue();var s=i.getStore();if(!Ext.isEmpty(s)&&!Ext.isEmpty(j)){for(var l=0;l<j.length;l++){var c=j[l];for(var n=0;n<s.getCount();n++){var o=s.getAt(n).data.value;
if(o==c){if(q==""){q=c;}else{q=q+"~!~"+c;}}}}}}publicJson["hiddenParams"]["deleteSelectedInfos"]=q;}}}var a=this.updateQueryString(b.getId());Ext.getCmp("ackWindowObj").destroy();var f=this;var d=Ext.get("emptyTextTb");try{if(d!=null){Ext.get("emptyTextTb").hide();}}catch(r){}alarmLoadMask.show();var u=get_browser_info();
Ext.Ajax.request({url:"/final/servlet/com.eg.EgCurrentAlarmsC",method:"POST",params:a+"&screenWidth="+(Ext.getBody().getViewSize().width)+"&screenHeight="+(Ext.getBody().getViewSize().height)+"&isBro="+u.name+"&isFromQuickLink="+isFromQuickLink,scope:this,success:function(e){var k=JSON.parse(e.responseText);
publicJson=k;alarmLoadMask.hide();if(ttIntegrationenabled!=null&&ttIntegrationenabled=="Yes"||ttIntegrationenabled=="true"){var m=alarmAckHiddenParams["alarmId"];var v="sendTTAcknowledgement=true&desc="+encodeURIComponent(h)+"&alarm_Id="+m;Ext.Ajax.request({url:"/final/servlet/com.eg.EgCurrentAlarmsC",method:"POST",params:v,scope:this,success:function(w){var x=JSON.parse(w.responseText);
}});}f.loadDefaults(true);publicJson["hiddenParams"]["alarmID"]="";publicJson["hiddenParams"]["desc"]="";publicJson["hiddenParams"]["delAlarmIDs"]="";publicJson["hiddenParams"]["isDelAlarms"]="false";publicJson["hiddenParams"]["ackAlarmDbDelete"]="";publicJson["hiddenParams"]["deleteOptions"]="";publicJson["hiddenParams"]["deleteSelectedInfos"]="";
}});}}},loadDefaults:function(a){if((Ext.isEmpty(publicJson["Current_Alarms"])||publicJson["Current_Alarms"]=="undefined")&&(Ext.isEmpty(publicJson["History_Alarms"])||publicJson["History_Alarms"]=="undefined")){var f=this;var i=publicJson["dataAvailable"];var g=this.getMain();if(a){g.removeAll();}var j=new Array();
if(!isUED){j.push({xtype:"alarmfilters"});}var b=575;if(isPopupWindow!=null&&isPopupWindow=="true"){b=335;}if(i!=null&&i=="true"){j.push({xtype:"currentalarmssummary",height:b});}else{var e=publicJson["errorMsg"];if(!Ext.isEmpty(e)){j.push({xtype:"currentalarmssummary",height:b,emptyText:'<table width="100%" id="emptyTextTb"><tr><td align="center" valign="middle"><div class="iconNoalarms" style="margin:12% auto 0% auto"></div>'+e+"</td></tr></table>"});
}}var h=publicJson["soundTag"];if(h==null||h=="undefined"){h="";}j.push({xtype:"container",cls:"x-hidden",id:"currentAlarmsSoundAlertDiv",name:"currentAlarmsSoundAlertDiv",html:h});var c=publicJson["pageParams"]["showDeleteBtn"];var d=publicJson["pageParams"]["showAcknowledgeBtn"];if((c!=null&&c=="true")||(d!=null&&d=="true")){j.push({xtype:"acknowledgementoptions"});
}g.add(j);g.doLayout();this.getCurrentalarmssummary().loadData();metaRefreshUrl=publicJson["pageParams"]["metaRefreshUrl"];metaRefreshUrl=metaRefreshUrl+"&isFromDashBoard="+!hideBackButton;metaRefreshUrl=urlParamReplace(metaRefreshUrl);}},ajaxCall:function(h,c,d,a,g,f,b,e){Ext.Ajax.request({url:"/final/servlet/com.eg.EgCurrentAlarmsC",method:"POST",params:h,scope:this,success:function(i){var m=1;
var n=window.JSON&&window.JSON.parse?window.JSON.parse(i.responseText):(new Function("return "+i.responseText))();publicJson=n;Ext.destroy(alarmLoadMask);try{m=b.getStore().currentPage;}catch(q){}if(disablerefresh||m>1){return;}var l=this;if(isPopupWindow!=null&&isPopupWindow=="true"){AlarmsMainTitle="";
}var p=publicJson["pageParams"];d.getStore().loadRawData([]);d.getStore().loadRawData(publicJson["showOptionsJson"]);d.setValue(p["selectedShowOption"]);a.clearValue();a.applyEmptyText();a.getStore().loadRawData(publicJson["filterOptions"]);a.setValue(p["selectedFilterOption"]);g.getStore().loadRawData(publicJson["optionsForFilterSelection"]);
g.clearValue();g.applyEmptyText();g.setValue(p["selectedSubFilterOption"]);if(!Ext.isEmpty(g)&&Ext.isEmpty(g.getValue())||g.getValue()==undefined||g.getValue()==null){g.setValue(g.getStore().getAt(0).get("valueField"));}var j=p["showDeleteBtn"];var k=p["showAcknowledgeBtn"];if((j!=null&&j=="true")||(k!=null&&k=="true")){}var r=publicJson["dataAvailable"];
if(r!=null&&r=="true"){var o=publicJson["soundTag"];if(o!=null&&o!="undefined"){if(!Ext.isEmpty(f)){f.update(o);}f=null;delete f;}if(j!=null&&j=="true"&&d.getValue()!="CurrentUnknown"){if(Ext.isEmpty(Ext.getCmp("ackOptionsid"))){e.add({xtype:"acknowledgementoptions"});}Ext.getCmp("ackOptionsid").show();
Ext.getCmp("AlarmDeleteBtn").show();}else{if(!Ext.isEmpty(Ext.getCmp("ackOptionsid"))&&d.getValue()=="CurrentUnknown"){Ext.getCmp("ackOptionsid").hide();}}if(k!=null&&k=="true"&&d.getValue()!="CurrentUnknown"){if(Ext.isEmpty(Ext.getCmp("ackOptionsid"))){e.add({xtype:"acknowledgementoptions"});}Ext.getCmp("ackOptionsid").show();
Ext.getCmp("AlarmAcknowledgeBtn").show();}else{if(!Ext.isEmpty(Ext.getCmp("ackOptionsid"))&&d.getValue()=="CurrentUnknown"){Ext.getCmp("ackOptionsid").hide();}}b.getView().refresh();}else{if(!Ext.isEmpty(Ext.getCmp("ackOptionsid"))){Ext.getCmp("ackOptionsid").hide();}if(j!=null&&j=="true"&&d.getValue()!="CurrentUnknown"){Ext.getCmp("AlarmDeleteBtn").hide();
}if(k!=null&&k=="true"&&d.getValue()!="CurrentUnknown"){Ext.getCmp("AlarmAcknowledgeBtn").hide();}b.getView().refresh();}b.generateAlarmGrid();var s=Ext.getCmp("searchTextBox");if(searchAck){if(!Ext.isEmpty(s.getValue())){this.searchAlarms(s,"fire");}}else{s.setValue("");}}});},refreshAlarms:function(o){try{var c=Ext.getCmp("ackWindowObj");
if(c!=undefined||!Ext.isEmpty(c)){return;}}catch(i){}o=o.substring(o.indexOf("?")+1);var j=this;var k=this.getCurrentalarmssummary();var g=Ext.get("emptyTextTb");try{if(g!=null){Ext.get("emptyTextTb").hide();}}catch(i){}alarmLoadMask.show();var f=get_browser_info();if(sortbyalarm!=null&&sortbyalarm!=""){o=o.replace(/(arrangeAlarms=)[^\&]+/,"$1"+sortbyalarm);
}if(orderbyalarm!=null&&orderbyalarm!=""){if(o.indexOf("arrangeOrderBy=")>-1){o=o.replace(/(arrangeOrderBy=)[^\&]+/,"$1"+orderbyalarm);}else{o=o+"&arrangeOrderBy="+orderbyalarm;}}try{if(isCitrix){if(loadUnknown){o=ctx_defaultParams+"&state=UNKNOWN";}else{var l=Ext.getCmp("subFilterCombo").getValue();
if(!Ext.isEmpty(l)&&l!=null&&l!=undefined&&l.indexOf("&")!=-1){l=l.replace(/&/g,"|amp|");}o=ctx_defaultParams+"&state="+encodeURIComponent(l);}}}catch(d){}var n=Ext.getCmp("showCombo");var b=Ext.getCmp("filterCombo");var a=Ext.getCmp("subFilterCombo");var h=Ext.getCmp("currentAlarmsSoundAlertDiv");var m=this.getMain();
j.ajaxCall(o,f,n,b,a,h,k,m);metaRefreshUrl=o;var p=null;Ext.Ajax.on("requestcomplete",function(e,q){if(!Ext.isEmpty(p)){clearTimeout(p);}p=Ext.defer(function(){if(metaRefreshUrl.indexOf("?")>-1){metaRefreshUrl=metaRefreshUrl.substring(metaRefreshUrl.indexOf("?")+1);}j.ajaxCall(metaRefreshUrl,f,n,b,a,h,k,m);
},refreshFreq);});},searchAlarms:function(j,a){var f=false;if(!Ext.isEmpty(a)&&!Ext.isEmpty(a.type)&&a.type!=null&&a.type!=undefined&&a.type=="click"){f=true;}else{if(!Ext.isEmpty(a)&&a=="fire"){f=true;}}searchAck=false;var g=publicJson["pageParams"]["alarmType"];var c=publicJson["pageParams"]["showDeleteBtn"];
var d=publicJson["pageParams"]["showAcknowledgeBtn"];var e="";if(g!=null&&(g=="CurrentAlarms"||g=="longestAlarms")){e='<div style="height:100%;width:100%;display:table"><div class="msgFont" style="display:table-cell;vertical-align:middle"> <div class="iconNoalarms" style="margin:0px auto"></div><div style="text-align:center">No alarms found</div></div></div>';
}else{if(g!=null&&g=="unAcknowledged"){e='<div style="height:100%;width:100%;display:table"><div class="msgFont" style="display:table-cell;vertical-align:middle"> <div class="iconInformation" style="margin:0px auto"></div><div style="text-align:center">No UnAcknowledged alarms found</div></div></div>';
}else{if(g!=null&&g=="Acknowledged"){e='<div style="height:100%;width:100%;display:table"><div class="msgFont" style="display:table-cell;vertical-align:middle"> <div class="iconInformation" style="margin:0px auto"></div><div style="text-align:center">No Acknowledged alarms found</div></div></div>';}else{e='<div style="height:100%;width:100%;display:table"><div class="msgFont" style="display:table-cell;vertical-align:middle"> <div class="iconNoalarms" style="margin:0px auto"></div><div style="text-align:center">No unknowns found</div></div></div>';
}}}if((c!=null&&c=="true")||(d!=null&&d=="true")){if(c!=null&&c=="true"&&g!="CurrentUnknown"){Ext.getCmp("AlarmDeleteBtn").show();}else{if((c==undefined||c==null||c=="false")&&g=="CurrentUnknown"){Ext.getCmp("AlarmDeleteBtn").hide();}}if(d!=null&&d=="true"&&g!="CurrentUnknown"){Ext.getCmp("AlarmAcknowledgeBtn").show();
}else{if((d==undefined||d==null||d=="false")&&g=="CurrentUnknown"){Ext.getCmp("AlarmAcknowledgeBtn").hide();}}}if(f||a.getKey()==a.ENTER){if(j==null||j==undefined||j.value==null||j.value==undefined){return;}if(Ext.String.trim(j.value).length>0&&(Ext.String.trim(j.value)!=""||Ext.String.trim(j.value)!=null)){this.getCurrentalarmssummary().getView().emptyText="";
if(j.value=="*"){this.getCurrentalarmssummary().getStore().clearFilter();Ext.getCmp("pagingtoolbarid").getStore().clearFilter();Ext.getCmp("pagingtoolbarid").getStore().loadPage(1);}else{if(j.value=="("||j.value==")"||j.value=="\\"||j.value=="?"||j.value=="["){Ext.MessageBox.show({title:"Alert",msg:"Please enter the valid search pattern",buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
this.getCurrentalarmssummary().getStore().clearFilter();Ext.getCmp("pagingtoolbarid").getStore().clearFilter();Ext.getCmp("pagingtoolbarid").getStore().loadPage(1);}else{var k=Ext.getCmp("showCombo").getValue();j.value=j.value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var i=RegExp(j.value,"i");
var h=this.getCurrentalarmssummary().getStore();var l=[];h.clearFilter(true);h.filter(new Ext.util.Filter({caseSensitive:true,filterFn:function(n){var m=false;Ext.Object.each(n.data,function(p,o){if(k!="CurrentUnknown"){m=m||i.test(String(n.data.COLUMN_2))||i.test(String(n.data.COLUMN_3))||i.test(String(parseWrdfrHtml(n.data.COLUMN_4)))||i.test(String(n.data.COLUMN_5));
}else{if(k=="CurrentUnknown"){m=m||i.test(String(n.data.COLUMN_1))||i.test(String(n.data.COLUMN_2))||i.test(String(n.data.COLUMN_3))||i.test(String(parseWrdfrHtml(n.data.COLUMN_4)));}}});if(true){searchAck=true;l.push(n.data);}return m;}}));var l=Ext.getCmp("pagingtoolbarid").getStore();l.clearFilter(true);
l.filter(new Ext.util.Filter({caseSensitive:true,filterFn:function(n){var m=false;Ext.Object.each(n.data,function(p,o){if(k!="CurrentUnknown"){m=m||i.test(String(n.data.COLUMN_2))||i.test(String(n.data.COLUMN_3))||i.test(String(parseWrdfrHtml(n.data.COLUMN_4)))||i.test(String(n.data.COLUMN_5));}else{if(k=="CurrentUnknown"){m=m||i.test(String(n.data.COLUMN_1))||i.test(String(n.data.COLUMN_2))||i.test(String(n.data.COLUMN_3))||i.test(String(parseWrdfrHtml(n.data.COLUMN_4)));
}}});searchAck=true;return m;}}));l.loadPage(1);var b=this;Ext.defer(function(){if(h!=null&&h.data.length>0){$(".x-grid-view").css("height","auto");if(!Ext.isEmpty(Ext.getCmp("ackOptionsid"))){Ext.getCmp("ackOptionsid").show();b.getCurrentalarmssummary().getView().emptyText="";}else{b.getCurrentalarmssummary().getView().emptyText="";
}}else{$(".x-grid-view").css("height","100%");if(!Ext.isEmpty(Ext.getCmp("ackOptionsid"))){b.getCurrentalarmssummary().getView().emptyText=e;Ext.getCmp("ackOptionsid").hide();}else{b.getCurrentalarmssummary().getView().emptyText=e;}b.getCurrentalarmssummary().getView().refresh();}},10);}}}else{if(!Ext.isEmpty(Ext.getCmp("pagingtoolbarid"))&&Ext.getCmp("pagingtoolbarid").getStore().data.length>0){$(".x-grid-view").css("height","auto");
}else{$(".x-grid-view").css("height","100%");}this.getCurrentalarmssummary().getView().emptyText="";this.getCurrentalarmssummary().getStore().clearFilter();Ext.getCmp("pagingtoolbarid").getStore().clearFilter();Ext.getCmp("pagingtoolbarid").getStore().loadPage(1);if(!Ext.isEmpty(Ext.getCmp("ackOptionsid"))){Ext.getCmp("ackOptionsid").show();
this.getCurrentalarmssummary().getView().emptyText=e;}}}j.focus();},updateQueryString:function(b){var c=Ext.getCmp("filterCombo").getValue();var h=Ext.getCmp("showCombo").getValue();var a=Ext.getCmp("subFilterCombo").getValue();var e="";var f=publicJson["pageParams"]["AllAlarmsOptVal"];if(f!=null&&!Ext.isEmpty(f)){while(f.indexOf("&")>-1){f=f.replace("&","|amp|");
}}if(b!=null&&b!="filterCombo"){if((c!=null&&c=="States")){if(b!=null&&b=="subFilterCombo"){showAlarms=a;do{showAlarms=showAlarms.replace("&","|amp|");}while(showAlarms.indexOf("&")>0);e=e+"&selectedSubFilterOption="+encodeURIComponent(showAlarms);}else{if(b!=null&&b=="searchByCombo"){showAlarms=f;e=e+"&selectedSubFilterOption="+encodeURIComponent(showAlarms);
}else{showAlarms=a;do{showAlarms=showAlarms.replace("&","|amp|");}while(showAlarms.indexOf("&")>0);e=e+"&selectedSubFilterOption="+encodeURIComponent(showAlarms);}}}else{e=e+"&selectedSubFilterOption="+a;}}else{showAlarms=f;e=e+"&selectedSubFilterOption=";}if(h!=null&&(h=="CurrentAlarms"||h=="Acknowledged"||h=="unAcknowledged")){e=e+"&showAlarms="+encodeURIComponent(showAlarms);
}e=e+"&alarmType="+h;var d="";var j=publicJson["hiddenParams"];for(var g in j){var i=j[g];if(i!=null){d=d+"&"+g+"="+encodeURIComponent(i);}else{d=d+"&"+g+"="+i;}}e=e+"&selectedFilterOption="+c+d;e=e+"&isFromDashBoard="+!hideBackButton;return e;},loadAlarms:function(a){var k="";var l=this.getMain();if(a!=null){k=a.getId();
}var h=this.updateQueryString(k);var i=this.getCurrentalarmssummary();var m=Ext.getCmp("showCombo");var b="";if(!Ext.isEmpty(h)&&h!=null&&h!=undefined&&h.indexOf("zoneDashboard")!=-1&&h.indexOf("zoneName")!=-1){b=h;}if(k!=null&&k=="showCombo"){if((!Ext.isEmpty(m)&&m!=null&&m!=undefined&&m.getValue()=="CurrentAlarms")){h="currentMainPage=NotAlarms";
if(!Ext.isEmpty(b)){h+=b;}}}if((!Ext.isEmpty(m)&&m!=null&&m!=undefined)&&m.getValue()!="CurrentAlarms"&&(isPopupWindow!=null&&isPopupWindow=="true")){h+="&isPopupWindow="+true;}if(!Ext.isEmpty(longestAlarms)&&longestAlarms!=null&&longestAlarms!=undefined){h+="&maxDurationAlarmIds="+longestAlarms;}var f=Ext.get("emptyTextTb");
try{if(f!=null){Ext.get("emptyTextTb").hide();}}catch(g){}try{if(isCitrix){if(loadUnknown){h=ctx_defaultParams+"&state=UNKNOWN";}else{var j=Ext.getCmp("subFilterCombo").getValue();if(!Ext.isEmpty(j)&&j!=null&&j!=undefined&&j.indexOf("&")!=-1){j=j.replace(/&/g,"|amp|");}h=ctx_defaultParams+"&state="+encodeURIComponent(j);
}}}catch(d){}alarmLoadMask.show();var c=get_browser_info();Ext.Ajax.request({url:"/final/servlet/com.eg.EgCurrentAlarmsC",method:"POST",params:h+"&screenWidth="+(Ext.getBody().getViewSize().width)+"&screenHeight="+(Ext.getBody().getViewSize().height)+"&isBro="+c.name,scope:this,success:function(q){var v=JSON.parse(q.responseText);
publicJson=v;alarmLoadMask.hide();var t=this;if(isPopupWindow!=null&&isPopupWindow=="true"){AlarmsMainTitle="";}metaRefreshUrl=publicJson["pageParams"]["metaRefreshUrl"];metaRefreshUrl=urlParamReplace(metaRefreshUrl);var x=publicJson["pageParams"];var z=Ext.getCmp("showCombo");z.getStore().loadRawData();
z.getStore().loadRawData(publicJson["showOptionsJson"]);z.setValue(x["selectedShowOption"]);var o=Ext.getCmp("filterCombo");o.getStore().loadRawData();o.getStore().loadRawData(publicJson["filterOptions"]);o.setValue(x["selectedFilterOption"]);var n=Ext.getCmp("subFilterCombo");n.getStore().loadRawData();
n.getStore().loadRawData(publicJson["optionsForFilterSelection"]);var A=n.getStore().getCount();var p=n.getStore().getAt(A-1).get("valueField");if(k!=null&&k!="subFilterCombo"){if(x.hasOwnProperty("selectedSubFilterOption")&&!Ext.isEmpty(x["selectedSubFilterOption"])){n.setValue(x["selectedSubFilterOption"]);
}else{n.setValue(p);}}else{n.setValue(x["selectedSubFilterOption"]);}if(!Ext.isEmpty(n)&&Ext.isEmpty(n.getValue())||n.getValue()==undefined||n.getValue()==null){n.setValue(n.getStore().getAt(0).get("valueField"));}n.setFieldLabel(o.getRawValue());var w=publicJson["hiddenParams"]["zoneName"];var y=false;
if(!Ext.isEmpty(w)&&w!=null&&w!=undefined&&w!="null"&&w!="undefined"){y=true;}if((publicJson["pageParams"]["alarmType"]!="longestAlarms")){if(!y){if(!Ext.isEmpty(o)&&o!=null&&o!=undefined){Ext.getCmp("filterCombo").show();}if(!Ext.isEmpty(n)&&n!=null&&n!=undefined){Ext.getCmp("subFilterCombo").show();
}if(!Ext.isEmpty(Ext.getCmp("searchTextBox"))&&Ext.getCmp("searchTextBox")!=null&&Ext.getCmp("searchTextBox")!=undefined){Ext.getCmp("searchTextBox").show();}}else{if(!Ext.isEmpty(o)&&o!=null&&o!=undefined){Ext.getCmp("filterCombo").hide();}if(!Ext.isEmpty(n)&&n!=null&&n!=undefined){Ext.getCmp("subFilterCombo").hide();
}if(!Ext.isEmpty(Ext.getCmp("searchTextBox"))&&Ext.getCmp("searchTextBox")!=null&&Ext.getCmp("searchTextBox")!=undefined){Ext.getCmp("searchTextBox").hide();}}}else{if(publicJson["pageParams"]["alarmType"]=="longestAlarms"){if(!Ext.isEmpty(o)&&o!=null&&o!=undefined){Ext.getCmp("filterCombo").hide();}if(!Ext.isEmpty(n)&&n!=null&&n!=undefined){Ext.getCmp("subFilterCombo").hide();
}if(!Ext.isEmpty(Ext.getCmp("searchTextBox"))&&Ext.getCmp("searchTextBox")!=null&&Ext.getCmp("searchTextBox")!=undefined){Ext.getCmp("searchTextBox").hide();}disablerefresh=true;}}var r=x["showDeleteBtn"];var s=x["showAcknowledgeBtn"];if((r!=null&&r=="true")||(s!=null&&s=="true")){}if(r!=null&&r=="true"&&z.getValue()!="CurrentUnknown"){if(Ext.isEmpty(Ext.getCmp("ackOptionsid"))){l.add({xtype:"acknowledgementoptions"});
}Ext.getCmp("ackOptionsid").show();Ext.getCmp("AlarmDeleteBtn").show();}else{if(!Ext.isEmpty(Ext.getCmp("ackOptionsid"))&&z.getValue()=="CurrentUnknown"){Ext.getCmp("ackOptionsid").hide();}}if(s!=null&&s=="true"&&z.getValue()!="CurrentUnknown"){if(Ext.isEmpty(Ext.getCmp("ackOptionsid"))){l.add({xtype:"acknowledgementoptions"});
}Ext.getCmp("ackOptionsid").show();Ext.getCmp("AlarmAcknowledgeBtn").show();}else{if(!Ext.isEmpty(Ext.getCmp("ackOptionsid"))&&z.getValue()=="CurrentUnknown"){Ext.getCmp("ackOptionsid").hide();}}i.generateAlarmGrid();var B=Ext.getCmp("searchTextBox");if(searchAck){if(!Ext.isEmpty(B.getValue())){this.searchAlarms(B,"fire");
}}else{B.setValue("");}get_row=document.getElementsByClassName("x-grid-row");row_hei=Math.round(get_row.length*$(".x-grid-row").height());if(row_hei>$("#currentAlarmsGrid-body").height()){Ext.getCmp("removeLineForTvMode").show();}else{Ext.getCmp("iconAutomaticScrollRun").hide();Ext.getCmp("removeLineForTvMode").hide();
Ext.getCmp("iconAutomaticScrollJumpToTop").hide();}Ext.getCmp("iconAutomaticScrollStop").hide();try{if(isCitrix){z.hide();o.hide();Ext.getCmp("AlarmDeleteBtn").hide();Ext.getCmp("AlarmAcknowledgeBtn").hide();}}catch(u){}clearTimeout(scrolldelay);}});},changeAlarmType:function(c){var b="";if(c!=null){b=c.getId();
}var a=this.updateQueryString(b);if(isPopupWindow!=null&&isPopupWindow=="true"){a+="&isPopupWindow="+true;}document.location="/final/monitor/EgAlarms.jsp?"+a+"&screenWidth="+(Ext.getBody().getViewSize().width)+"&screenHeight="+(Ext.getBody().getViewSize().height);},goBack:function(){var b=requestParams.treeSession;
var a=requestParams.thisPageSession;b=(!Ext.isEmpty(b))?b:"";a=(!Ext.isEmpty(a))?a:"";if(FromDashBoard!=null&&FromDashBoard!=undefined&&FromDashBoard=="true"){document.location="/final/servlet/com.eg.EgMonitorController?monCmd=dashboard";}else{if(a!=null&&a!=undefined&&arrangeAlarms!=null&&arrangeAlarms!=undefined){document.location=a;
}else{window.history.back();}}}});