Ext.Msg.cls="adminAlert";Ext.Msg.layout={type:"anchor",pack:"center",align:"center"};Ext.define("AgentStatus.controller.Main",{extend:"Ext.app.Controller",views:["AgentStatusView"],requires:["AgentStatus.view.AgentStatusView","Ext.ux.data.PagingMemoryProxy"],refs:[{selector:"agentstatusview",ref:"agentstatusview"},{selector:"agentinformation",ref:"agentinformation"}],init:function(){ctrler=this;
if(Ext.Array.contains(viewList,viewFrom)){this.buildMainData(sel_agent_type,selAgentStatus);}else{this.buildMainData("PremiumAgents","All");}this.control({"agentstatusview":{"afterrender":this.afterMainRender},'agentstatusview combo[id="agentType"]':{"select":this.agentTypeChange},'agentstatusview combo[id="agentStatus"]':{"select":this.agentStatusChange},'agentstatusview button[id="upgradeStatus"]':{"click":this.showUpgradeStatus},'agentstatusview button[id="restartAll"]':{"click":this.restartAllAgents},'agentstatusview button[id="homeBack"]':{"click":this.goHome},'agentstatusview  button[id="saveCSV"]':{"click":this.saveInCSVFormat},'agentinformation button[id="backbutton"]':{"click":this.goBack},'agentinformation button[id="restartAgent"]':{"click":this.restartAgentFrmAgentInfo},'agentinformation button[id="resetAgent"]':{"click":this.resetAgentFrmAgentInfo},'agentinformation button[id="showLogs"]':{"click":this.showLogsFrmAgentInfo},'agentinformation button[id="StopAgent"]':{"click":this.stopAgentButton},'agentinformation button[id="showXmx"]':{"click":this.showXmxFrmAgentInfo},'agentstatusview button[id="RemoteControl"]':{"click":this.callMonitorRemoteControl}});
},buildMainData:function(a,b){if(from=="AdminHome"||from=="AgentAssign"){a=selAgentType;b=selAgentStatus;}Ext.Ajax.request({url:"AgentStatus/data/EgServerListJson.jsp?agent="+a+"&status="+b,method:"POST",async:false,timeout:timeOut*1000,success:function(c){if(c.status==200&&!Ext.isEmpty(c.responseText)){var d=c.responseText;
publicJSON=Ext.decode(d);}}});jsonDataHolder=publicJSON;},afterMainRender:function(){totalCount=0;var j=this;var a=publicJSON.agentType;var f=publicJSON.agentState;var h="AgentStatus/data/EgServerListJson.jsp?agent="+a+"&status="+f;if(showAgentInformationView=="true"){var c="no";Ext.getCmp("agentstatusviewport").removeAll();
this.getController("AgentStatus.controller.AgentInfoCtrler").buildMainData(selectedAgentIP,c,a,f);Ext.getCmp("agentstatusviewport").add({xtype:"agentinformation"});this.getController("AgentStatus.controller.AgentInfoCtrler").afterMainRender();Ext.getCmp("agentIP").setValue(selectedAgentIP);}else{if(viewFrom=="AgentInfo"){Ext.getCmp("agentstatusviewport").removeAll();
this.getController("AgentStatus.controller.AgentInfoCtrler").buildMainData(selectedAgentIP,isDebugEnabled,sel_agent_type,f);Ext.getCmp("agentstatusviewport").add({xtype:"agentinformation"});this.getController("AgentStatus.controller.AgentInfoCtrler").afterMainRender();Ext.getCmp("agentIP").setValue(selectedAgentIP);
}else{Ext.getCmp("agentType").getStore().loadRawData(publicJSON.agentTypes);Ext.getCmp("agentType").setValue(publicJSON.agentType);Ext.getCmp("agentStatus").getStore().loadRawData(publicJSON.agentStatus);Ext.getCmp("agentStatus").setValue(publicJSON.agentState);var d=publicJSON.noManagedHostsFound;if(from=="AdminHome"){d=!publicJSON.managedHostsFoundForSearch;
Ext.getCmp("homeBack").show();}else{if(from=="AgentAssign"){var l=backHref.indexOf("EgLicenseInfo.jsp");if(l>-1){Ext.getCmp("homeBack").show();}}else{if(from=="licenseoverview"){var l=backHref.indexOf("EgLicenseInfo.jsp");if(l>-1){Ext.getCmp("homeBack").show();}}else{Ext.getCmp("homeBack").hide();}}}var b=Ext.getCmp("agentStatusView").getEl();
var e=Ext.getCmp("resultpanel");b.mask("Loading...","maskCenter");if(publicJSON.enableSearch){Ext.getCmp("saveCSV").enable();Ext.getCmp("resultpanel").show();Ext.getCmp("resultpanel").removeAll();var g=publicJSON.agentDetails;if(!Ext.isEmpty(g)){Ext.define("GridModel",{extend:"Ext.data.Model",fields:[{name:"AgentIP",sortType:"asAgentIP"},"Installed","Status","Output","Restart","Logs","AssignedHosts","StopAgent","Xmx","isAgentShared","RemoteControl"],});
var k=Ext.create("Ext.data.Store",{pageSize:50,model:"GridModel",proxy:{type:"pagingmemory",url:h,reader:{type:"json",root:"agentDetails",totalProperty:"totalProperty",},encodeFilters:function(m){return m[0].value;}},data:g,storeId:"store",remoteFilter:true,remoteSort:true,simpleSortMode:true,autoLoad:true});
e.add({xtype:"customgrid",ui:"newGridPanel whiteHeader",id:"agentInfoGrid",margin:10,border:true,flex:1,scroll:true,height:380,autoScroll:true,store:k,viewConfig:{forceFit:true,stripeRows:true},sortOnLoad:true,sorters:[{property:"AgentIP",direction:"ASC"}],dockedItems:[{xtype:"pagingtoolbar",id:"pagingtoolbarid",store:k,dock:"bottom",cls:"newPagination",displayInfo:true}],requires:["Ext.ux.CheckColumn","Ext.ux.RowExpander",],columns:[{text:agentIPNick,dataIndex:"AgentIP",flex:1,renderer:function(r,n,q,u,s,m){var p=r.substring(0,r.indexOf("~"));
var o=r.substring(r.indexOf("~")+1);var t="";if(o=="Yes"){t='<a class="eg_monlink" href="javascript:ctrler.showAgentInfo('+u+",'agentInfoGrid','"+a+"','"+publicJSON.agentState+"')\">"+p+"</a>";}else{t=p;}return t;}},{text:installed,dataIndex:"Installed",width:80,renderer:function(n){var m="";if(n=="Yes"){m='<center><div class="iconAgentInstalled" data-qtip="Agent Installed" data-qclass="yellowTip"></div></center>';
}else{m='<center><div class="iconAgentNotInstalled" data-qtip="Agent Not Installed" data-qclass="yellowTip"></div></center>';}return m;}},{text:status,dataIndex:"Status",width:90,renderer:function(n){var m="";if(n=="Running"){m='<center><img src="/final/images/'+theme+'/agentRunning.gif" border="0" vspace="0" data-qtip="Agent Running" data-qclass="yellowTip" valign="middle"></center>';
}else{m='<center><img src="/final/images/'+theme+'/agentNotRunning.gif" border="0" vspace="0" data-qtip="Agent Not Running" data-qclass="yellowTip" valign="middle"></center>';}return m;}},{xtype:"checkcolumn",text:opLog,dataIndex:"Output",width:190,listeners:{checkchange:function(o,q,p){var m=Ext.getCmp("agentInfoGrid").getStore().getAt(q);
var n=m.get("Installed");if(m.get("Status")=="Running"&&n=="Yes"&&!ctrler.disableAgentDebug(m.get("AgentIP"))){ctrler.outputLoggingChange(p,q,"agentInfoGrid");}else{if(p){m.set("Output",false);}else{m.set("Output",true);}return false;}}},renderer:function(q,o,n){var r=n.get("isAgentShared");var m=r.substring(r.indexOf("~")+1);
if(ctrler.disableAgentDebug(n.get("AgentIP"))){var p=new Ext.ux.CheckColumn().renderer(q);o.tdCls+=" "+"x-item-disabled";o.tdAttr='data-qtip= "'+"Output logging has been manully enabled"+'" data-qclass="tipCls" data-qwidth=215';return p;}if(m=="true"){var p=new Ext.ux.CheckColumn().renderer(q);o.tdCls+=" "+"x-item-disabled";
return p;}else{var p=new Ext.ux.CheckColumn().renderer(q);return p;}}},{text:logs,dataIndex:"Logs",width:50,sortable:false,renderer:function(q,o,n,s,p,r){var m="";if(q=="Show"){m='<center><a href="javascript:ctrler.showLogs('+s+',\'agentInfoGrid\');"><div class="iconData" data-qtip="Agent Logs" data-qclass="yellowTip"></div></a></center>';
}else{m='<center><div class="iconData" style="opacity: 0.3;filter: alpha(opacity=30);" data-qtip="Agent Logs" data-qclass="yellowTip"></div></center>';}return m;}},{text:restart,dataIndex:"Restart",width:80,sortable:false,renderer:function(r,o,q,t,s,n){var u="";var p=r.substring(0,r.indexOf("~"));var m=r.substring(r.indexOf("~")+1);
if(p=="Yes"){u='<center><a href="javascript:ctrler.restartAgent('+t+',\'agentInfoGrid\');"><div class="iconRestart"  data-qtip="Agent Restart" data-qclass="yellowTip"></div></a></center>';}else{u='<center><div class="iconRestart"  style="opacity: 0.3;filter: alpha(opacity=30);" data-qtip="Agent Restart" data-qclass="yellowTip"></div></center>';
}return u;}},{text:stopAgent,dataIndex:"StopAgent",width:50,sortable:false,renderer:function(r,o,q,t,s,n){var u="";var p=r.substring(0,r.indexOf("~"));var m=r.substring(r.indexOf("~")+1);if(p=="Yes"){u='<center><a href="javascript:ctrler.stopAgentButton('+t+',\'agentInfoGrid\');"><div class="iconStop"  data-qtip="Agent Stop" data-qclass="yellowTip"></div></a></center>';
}else{u='<center><div class="iconStop"  style="opacity: 0.3;filter: alpha(opacity=30);" data-qtip="Stop Agent" data-qclass="yellowTip"></div></center>';}return u;}},{text:xmx,dataIndex:"Xmx",width:50,sortable:false,renderer:function(q,o,n,s,p,r){var m="";if(q=="Show"){m='<center><a href="javascript:ctrler.showXmx('+s+',\'agentInfoGrid\');"><div class="iconSettings" data-qtip="Agent Xmx Setting" data-qclass="yellowTip"></div></a></center>';
}else{m='<center><div class="iconSettings" style="opacity: 0.3;filter: alpha(opacity=30);" data-qtip="Agent Xmx Setting" data-qclass="yellowTip"></div></center>';}return m;}},{text:assoHosts,dataIndex:"AssignHostsLink",width:125,sortable:false,renderer:function(q,o,n,s,p,r){m="";var m='<center><a href="javascript:ctrler.showAssignHosts('+s+',\'agentInfoGrid\');"><div class="iconShowAssociates"  data-qtip="Associate hosts" data-qclass="yellowTip"></div></a></center>';
return m;}},{text:agentShared,dataIndex:"isAgentShared",hidden:true,width:125,sortable:false,renderer:function(q,o,p,u,r,m){var s=q.substring(0,q.indexOf("~"));var n=q.substring(q.indexOf("~")+1);t="";var t="<center>"+s+"</center>";return t;}},{text:remotecontrol,dataIndex:"RemoteControl",width:120,sortable:false,renderer:function(t,o,q,w,u,n){var x="";
var v=t.indexOf("~");var s=t.lastIndexOf("~");var p=t.substring(0,v);var m=t.substring(v+1,s);var r=t.substring(s+1);if(p=="Yes"){x='<center><a href="javascript:ctrler.callMonitorRemoteControl('+w+",'agentInfoGrid','"+r+'\');"><div class="iconRemoteControl"  data-qtip="Remote Control" data-qclass="yellowTip"></div></a></center>';
}else{x='<center><div class="iconRemoteControl"  style="opacity: 0.3;filter: alpha(opacity=30);" data-qtip="Remote Control" data-qclass="yellowTip"></div></center>';}return x;}}],plugins:[{ptype:"rowexpander",expandOnDblClick:false,id:"rowExp",rowBodyTpl:["{[this.getRowView(values)]}",{getRowView:function(s){var o="<div><p><i>Assigned hosts</i></p></div>";
var m='<div style="padding-bottom:3px">'+s.AssignedHosts+"</div>";if(m.indexOf("-")==0){o+=m;}else{var q=m.split(",");var n=q.length;var u=n%3;if(u!=0){var p=3-u;for(var w=0;w<p;w++){m+=", ";}q=m.split(",");}o="<div><p><i>Assigned hosts ("+n+")</i></p></div>";o+="<table border='0' width='100%' style='margin-bottom:6px'>";
for(var r=0;r<q.length;r=r+3){o+="<tr><td style='padding:2px'>"+q[r]+"</td><td>"+q[r+1]+"</td><td>"+q[r+2]+"</td></tr>";}o+="</table>";}return o;}}]}],tbar:[{xtype:"displayfield",fieldLabel:numberOfAgents,labelSeparator:" :",id:"totalAgents",height:20,labelWidth:150},{xtype:"tbfill",},{xtype:"trigger",cls:"whitedropdown_search",trigger1Cls:"x-form-clear-trigger",trigger2Cls:"x-form-search-trigger",emptyText:"Search",padding:"2 6 2 0",disabled:true,onTrigger1Click:function(){this.reset();
},onTrigger2Click:function(){ctrler.filterRecords();},listeners:{specialkey:function(n,m){if(m.getKey()==m.ENTER){ctrler.filterRecords();}}},id:"searchBox",itemId:"searchTrigger",getTriggerMarkup:function(){var q=this,o=0,t=(q.readOnly||q.hideTrigger),m,r=q.triggerBaseCls,s=[],p=Ext.dom.Element.unselectableCls,n="width:"+q.triggerWidth+"px;"+(t?"display:none;":""),u=q.extraTriggerCls+" "+Ext.baseCSSPrefix+"trigger-cell "+p;
if(!q.trigger1Cls){q.trigger1Cls=q.triggerCls;}for(o=0;(m=q["trigger"+(o+1)+"Cls"])||o<1;o++){if(o==0){s.push({tag:"td",role:"presentation",valign:"top",cls:u,id:"MyTrigger_"+o,style:n+"display:none;",cn:{cls:[Ext.baseCSSPrefix+"trigger-index-"+o,r,m].join(" "),role:"presentation"}});}else{s.push({tag:"td",role:"presentation",valign:"top",cls:u,id:"MyTrigger_"+o,style:n,cn:{cls:[Ext.baseCSSPrefix+"trigger-index-"+o,r,m].join(" "),role:"presentation"}});
}}s[0].cn.cls+=" "+r+"-first";return Ext.DomHelper.markup(s);}}]});k.load();}var i=publicJSON.totalProperty;if(!Ext.isEmpty(i)){totalCount=i;Ext.getCmp("totalAgents").show();Ext.getCmp("totalAgents").setValue(i);}else{Ext.getCmp("totalAgents").hide();}if(isLimitedAdmin=="true"){Ext.getCmp("restartAll").hide();
}else{Ext.getCmp("restartAll").show();}Ext.getCmp("saveCSV").show();if(publicJSON.enableSearch){if(j.getAgentstatusview().down("#searchTrigger")){j.getAgentstatusview().down("#searchTrigger").enable();}Ext.getCmp("totalAgents").enable();}if(publicJSON.agentType=="ExternalAgents"||publicJSON.agentType=="RemoteAgents"){Ext.getCmp("agentInfoGrid").columns[0].setVisible(true);
if(isLimitedAdmin=="false"){Ext.getCmp("agentInfoGrid").columns[9].setVisible(true);}}else{Ext.getCmp("agentInfoGrid").columns[0].setVisible(false);Ext.getCmp("agentInfoGrid").columns[9].setVisible(false);}}else{Ext.getCmp("resultpanel").hide();Ext.getCmp("resultpanel").removeAll();if(j.getAgentstatusview().down("#searchTrigger")){j.getAgentstatusview().down("#searchTrigger").disable();
}Ext.getCmp("restartAll").hide();Ext.getCmp("saveCSV").disable();Ext.getCmp("NoUserAvailable").show();}e.doLayout();b.unmask();}}},filterRecords:function(){var f=Ext.getCmp("searchBox").getValue();var a=Ext.getStore("store");a.clearFilter();totalRecords=0;if(f==""||f.length==0){totalRecords=totalCount;
}else{var d=new Array();var b=f.split(" ");for(var c=0;c<b.length;c++){var g=b[c].trim();if(g!=""){d.push(g);}}var e=new Ext.util.Filter({filterFn:function(h){var i=h.get("AgentIP");if(doesExist(d,i)){return true;}}});a.suspendEvents(true);a.filter(e);a.resumeEvents();}if(totalRecords>0){Ext.getCmp("totalAgents").setValue(totalRecords);
Ext.getCmp("totalAgents").show();Ext.getCmp("saveCSV").enable();}else{Ext.getCmp("totalAgents").hide();Ext.getCmp("saveCSV").disable();Ext.getCmp("agentInfoGrid").getView().emptyText='<div class="egFlexCenterByColumnWise" style="height:98%"><div class="iconInformation"></div><div class="commonErrorMsgText">'+noAgentsFound+".</div></div>";
Ext.getCmp("agentInfoGrid").getView().refresh();}},searchAgent:function(){var b=Ext.getCmp("agentType").getValue();var d=Ext.getCmp("agentStatus").getValue();var c=Ext.getCmp("searchBox").getValue();c=encodeURIComponent(c);var f="AgentStatus/data/EgServerListJson.jsp?search=true&agent="+b+"&status="+d;
if(c!=""){f+="&hostname="+c;}if(c==""||c.length==0){Ext.get("MyTrigger_0").setStyle("display","none");Ext.get("MyTrigger_1").setStyle("display","block");}else{Ext.get("MyTrigger_1").setStyle("display","none");Ext.get("MyTrigger_0").setStyle("display","block");}Ext.Ajax.request({url:f,method:"POST",async:false,success:function(g){var h=g.responseText;
jsonDataHolder=Ext.decode(h);},failure:function(g){}});if(jsonDataHolder.search=="true"){var e=Ext.getCmp("agentInfoGrid");var a=jsonDataHolder.totalNoAgent;Ext.getCmp("totalAgents").setValue(a);if(jsonDataHolder.managedHostsFoundForSearch){if(isLimitedAdmin=="true"){Ext.getCmp("restartAll").hide();}else{Ext.getCmp("restartAll").show();
}Ext.getCmp("saveCSV").show();Ext.getCmp("totalAgents").enable();e.show();e.getStore().removeAll();e.getStore().loadRawData(jsonDataHolder.agentDetails);if(jsonDataHolder.agentType=="ExternalAgents"||jsonDataHolder.agentType=="RemoteAgents"){e.columns[0].setVisible(true);if(isLimitedAdmin=="false"){e.columns[9].setVisible(true);
}}else{e.columns[0].setVisible(false);e.columns[9].setVisible(false);}}else{Ext.getCmp("restartAll").hide();Ext.getCmp("saveCSV").hide();Ext.getCmp("totalAgents").disable();e.show();e.getStore().removeAll();Ext.get("noAgentAlrtDiv").update(noAgentsFound+".");}}},updateOutputLoging:function(){ctrler.buildGridOnChange(true);
},buildGridOnChange:function(c){var e=this;var a=Ext.getCmp("agentType").getValue();var f=Ext.getCmp("agentStatus").getValue();var g="AgentStatus/data/EgServerListJson.jsp?agent="+a+"&status="+f;var b=Ext.getCmp("searchBox").getValue();var d=Ext.getCmp("agentStatusView").getEl();var h=Ext.getCmp("resultpanel");
d.mask("Loading...","maskCenter");Ext.getCmp("resultpanel").hide();Ext.getCmp("NoUserAvailable").hide();Ext.Ajax.request({url:g,method:"POST",success:function(k){var l=k.responseText;jsonDataHolder=Ext.decode(l);if(jsonDataHolder.enableSearch){Ext.getCmp("saveCSV").enable();Ext.getCmp("resultpanel").show();
Ext.getCmp("resultpanel").removeAll();Ext.getCmp("NoUserAvailable").hide();var i=jsonDataHolder.agentDetails;if(!Ext.isEmpty(i)){Ext.define("GridModel",{extend:"Ext.data.Model",fields:[{name:"AgentIP",sortType:"asAgentIP"},"Installed","Status","Output","Restart","Logs","AssignedHosts","StopAgent","Xmx","isAgentShared","RemoteControl"],});
var j=Ext.create("Ext.data.Store",{pageSize:50,model:"GridModel",proxy:{type:"pagingmemory",url:g,reader:{type:"json",root:"agentDetails",totalProperty:"totalProperty",},encodeFilters:function(m){return m[0].value;}},data:i,storeId:"store",remoteFilter:true,remoteSort:true,simpleSortMode:true,autoLoad:true});
h.add({xtype:"customgrid",ui:"newGridPanel whiteHeader",id:"agentInfoGrid",margin:10,flex:1,border:true,scroll:true,height:380,autoScroll:true,store:j,dockedItems:[{xtype:"pagingtoolbar",id:"pagingtoolbarid",store:j,dock:"bottom",cls:"newPagination",displayInfo:true}],requires:["Ext.ux.CheckColumn","Ext.ux.RowExpander",],plugins:[{ptype:"rowexpander",expandOnDblClick:false,id:"rowExp",rowBodyTpl:["{[this.getRowView(values)]}",{getRowView:function(s){var o="<div><p><i>Assigned hosts</i></p></div>";
var m='<div style="padding-bottom:3px">'+s.AssignedHosts+"</div>";if(s.AssignedHosts=="- No assigned hosts found -"){o+=m;}else{var q=m.split(",");var n=q.length;var u=n%3;if(u!=0){var p=3-u;for(var w=0;w<p;w++){m+=", ";}q=m.split(",");}o="<div><p><i>Assigned hosts ("+n+")</i></p></div>";o+="<table border='0' width='100%' style='margin-bottom:6px'>";
for(var r=0;r<q.length;r=r+3){o+="<tr><td style='padding:2px'>"+q[r]+"</td><td>"+q[r+1]+"</td><td>"+q[r+2]+"</td></tr>";}o+="</table>";}return o;}}]}],columns:[{text:agentIPNick,dataIndex:"AgentIP",flex:1,renderer:function(r,n,q,u,s,m){var p=r.substring(0,r.indexOf("~"));var o=r.substring(r.indexOf("~")+1);
var t="";if(o=="Yes"){t='<a class="eg_monlink" href="javascript:ctrler.showAgentInfo('+u+",'agentInfoGrid','"+a+"','"+f+"')\">"+p+"</a>";}else{t=p;}return t;}},{text:installed,dataIndex:"Installed",width:80,renderer:function(n){var m="";if(n=="Yes"){m='<center><div class="iconAgentInstalled" data-qtip="Agent Installed" data-qclass="yellowTip"></div></center>';
}else{m='<center><div class="iconAgentNotInstalled" data-qtip="Agent Not Installed" data-qclass="yellowTip"></div></center>';}return m;}},{text:status,dataIndex:"Status",width:90,renderer:function(n){var m="";if(n=="Running"){m='<center><img src="/final/images/'+theme+'/agentRunning.gif" border="0" vspace="0" data-qtip="Agent Running" data-qclass="yellowTip" valign="middle"></center>';
}else{m='<center><img src="/final/images/'+theme+'/agentNotRunning.gif" border="0" vspace="0" data-qtip="Agent Not Running" data-qclass="yellowTip" valign="middle"></center>';}return m;}},{xtype:"checkcolumn",text:opLog,dataIndex:"Output",width:190,listeners:{checkchange:function(o,q,p){var m=Ext.getCmp("agentInfoGrid").getStore().getAt(q);
var n=m.get("Installed");if(m.get("Status")=="Running"&&n=="Yes"&&!ctrler.disableAgentDebug(m.get("AgentIP"))){ctrler.outputLoggingChange(p,q,"agentInfoGrid");}else{if(p){m.set("Output",false);}else{m.set("Output",true);}return false;}}},renderer:function(q,o,n){var r=n.get("isAgentShared");var m=r.substring(r.indexOf("~")+1);
if(ctrler.disableAgentDebug(n.get("AgentIP"))){var p=new Ext.ux.CheckColumn().renderer(q);o.tdCls+=" "+"x-item-disabled";o.tdAttr='data-qtip= "'+"Output logging has been manully enabled"+'" data-qclass="tipCls" data-qwidth=215';return p;}if(m=="true"){var p=new Ext.ux.CheckColumn().renderer(q);o.tdCls+=" "+"x-item-disabled";
return p;}else{var p=new Ext.ux.CheckColumn().renderer(q);return p;}}},{text:logs,dataIndex:"Logs",width:50,sortable:false,renderer:function(q,o,n,s,p,r){var m="";if(q=="Show"){m='<center><a href="javascript:ctrler.showLogs('+s+',\'agentInfoGrid\');"><div class="iconData" data-qtip="Agent Logs" data-qclass="yellowTip"></div></a></center>';
}else{m='<center><div class="iconData" style="opacity: 0.3;filter: alpha(opacity=30);" data-qtip="Agent Logs" data-qclass="yellowTip"></div></center>';}return m;}},{text:restart,dataIndex:"Restart",width:80,sortable:false,renderer:function(r,o,q,t,s,n){var u="";var p=r.substring(0,r.indexOf("~"));var m=r.substring(r.indexOf("~")+1);
if(p=="Yes"){u='<center><a href="javascript:ctrler.restartAgent('+t+',\'agentInfoGrid\');"><div class="iconRestart"  data-qtip="Agent Restart" data-qclass="yellowTip"></div></a></center>';}else{u='<center><div class="iconRestart"  style="opacity: 0.3;filter: alpha(opacity=30);" data-qtip="Agent Restart" data-qclass="yellowTip"></div></center>';
}return u;}},{text:stopAgent,dataIndex:"StopAgent",width:50,sortable:false,renderer:function(r,o,q,t,s,n){var u="";var p=r.substring(0,r.indexOf("~"));var m=r.substring(r.indexOf("~")+1);if(p=="Yes"){u='<center><a href="javascript:ctrler.stopAgentButton('+t+',\'agentInfoGrid\');"><div class="iconStop"  data-qtip="Agent Stop" data-qclass="yellowTip"></div></a></center>';
}else{u='<center><div class="iconStop"  style="opacity: 0.3;filter: alpha(opacity=30);" data-qtip="Stop Agent" data-qclass="yellowTip"></div></center>';}return u;}},{text:xmx,dataIndex:"Xmx",width:50,sortable:false,renderer:function(q,o,n,s,p,r){var m="";if(q=="Show"){m='<center><a href="javascript:ctrler.showXmx('+s+',\'agentInfoGrid\');"><div class="iconSettings" data-qtip="Agent Xmx Setting" data-qclass="yellowTip"></div></a></center>';
}else{m='<center><div class="iconSettings" style="opacity: 0.3;filter: alpha(opacity=30);" data-qtip="Agent Xmx Setting" data-qclass="yellowTip"></div></center>';}return m;}},{text:assoHosts,dataIndex:"AssignHostsLink",width:125,sortable:false,renderer:function(q,o,n,s,p,r){m="";var m='<center><a href="javascript:ctrler.showAssignHosts('+s+',\'agentInfoGrid\');"><div class="iconShowAssociates"  data-qtip="Associate hosts" data-qclass="yellowTip"></div></a></center>';
return m;}},{text:agentShared,dataIndex:"isAgentShared",hidden:true,width:125,sortable:false,renderer:function(q,o,p,u,r,m){var s=q.substring(0,q.indexOf("~"));var n=q.substring(q.indexOf("~")+1);t="";var t="<center>"+s+"</center>";return t;}},{text:remotecontrol,dataIndex:"RemoteControl",width:120,sortable:false,renderer:function(t,o,q,w,u,n){var x="";
var v=t.indexOf("~");var s=t.lastIndexOf("~");var p=t.substring(0,v);var m=t.substring(v+1,s);var r=t.substring(s+1);if(p=="Yes"){x='<center><a href="javascript:ctrler.callMonitorRemoteControl('+w+",'agentInfoGrid','"+r+'\');"><div class="iconRemoteControl"  data-qtip="Remote Control" data-qclass="yellowTip"></div></a></center>';
}else{x='<center><div class="iconRemoteControl"  style="opacity: 0.3;filter: alpha(opacity=30);" data-qtip="Remote Control" data-qclass="yellowTip"></div></center>';}return x;}}],tbar:[{xtype:"displayfield",fieldLabel:numberOfAgents,labelSeparator:" :",id:"totalAgents",height:20,labelWidth:150},{xtype:"tbfill",},{xtype:"trigger",cls:"whitedropdown_search",trigger1Cls:"x-form-clear-trigger",trigger2Cls:"x-form-search-trigger",emptyText:"Search",padding:"2 6 2 0",disabled:true,onTrigger1Click:function(){this.reset();
},onTrigger2Click:function(){ctrler.filterRecords();},listeners:{specialkey:function(n,m){if(m.getKey()==m.ENTER){ctrler.filterRecords();}}},id:"searchBox",itemId:"searchTrigger",getTriggerMarkup:function(){var q=this,o=0,t=(q.readOnly||q.hideTrigger),m,r=q.triggerBaseCls,s=[],p=Ext.dom.Element.unselectableCls,n="width:"+q.triggerWidth+"px;"+(t?"display:none;":""),u=q.extraTriggerCls+" "+Ext.baseCSSPrefix+"trigger-cell "+p;
if(!q.trigger1Cls){q.trigger1Cls=q.triggerCls;}for(o=0;(m=q["trigger"+(o+1)+"Cls"])||o<1;o++){if(o==0){s.push({tag:"td",role:"presentation",valign:"top",cls:u,id:"MyTrigger_"+o,style:n+"display:none;",cn:{cls:[Ext.baseCSSPrefix+"trigger-index-"+o,r,m].join(" "),role:"presentation"}});}else{s.push({tag:"td",role:"presentation",valign:"top",cls:u,id:"MyTrigger_"+o,style:n,cn:{cls:[Ext.baseCSSPrefix+"trigger-index-"+o,r,m].join(" "),role:"presentation"}});
}}s[0].cn.cls+=" "+r+"-first";return Ext.DomHelper.markup(s);}}]});j.load();}if(isLimitedAdmin=="true"){Ext.getCmp("restartAll").hide();}else{Ext.getCmp("restartAll").show();}Ext.getCmp("saveCSV").show();if(jsonDataHolder.enableSearch){if(e.getAgentstatusview().down("#searchTrigger")){e.getAgentstatusview().down("#searchTrigger").enable();
}Ext.getCmp("totalAgents").enable();}if(jsonDataHolder.agentType=="ExternalAgents"||jsonDataHolder.agentType=="RemoteAgents"){Ext.getCmp("agentInfoGrid").columns[0].setVisible(true);if(isLimitedAdmin=="false"){Ext.getCmp("agentInfoGrid").columns[9].setVisible(true);}}else{Ext.getCmp("agentInfoGrid").columns[0].setVisible(false);
Ext.getCmp("agentInfoGrid").columns[9].setVisible(false);}}else{if(e.getAgentstatusview().down("#searchTrigger")){e.getAgentstatusview().down("#searchTrigger").disable();}Ext.getCmp("restartAll").hide();Ext.getCmp("saveCSV").disable();Ext.getCmp("NoUserAvailable").show();}if(c&&!Ext.isEmpty(b)){Ext.getCmp("searchBox").setValue(b);
Ext.getCmp("totalAgents").setValue(totalRecords);ctrler.filterRecords();}else{totalCount=jsonDataHolder.totalProperty;Ext.getCmp("totalAgents").setValue(totalCount);}h.doLayout();d.unmask();},failure:function(i){h.doLayout();d.unmask();}});},agentTypeChange:function(){ctrler.buildGridOnChange(false);
},agentStatusChange:function(){this.agentTypeChange();},showUpgradeStatus:function(){window.location.href="/final/admin/EgUpgradeStatus.jsp?fromPage=AgentStatus";},restartAllAgents:function(){Ext.Msg.show({title:restartAll,msg:confirmMsg3,buttons:Ext.Msg.YESNO,icon:"iconConfirmation",fn:function(a){if(a=="yes"){var b="AgentStatus/data/EgAllAgentsRestartJson.jsp";
Ext.Ajax.request({url:b,method:"POST",timeout:timeOut*1000,success:function(c){var d=c.responseText;var e=Ext.decode(d);if(e.ResultAlert){Ext.Msg.show({title:e.ResultTitle,msg:e.ResultMsg,buttons:Ext.Msg.OK,icon:"iconInformation"});}}});}}});},restartAgent:function(e,a){var b=Ext.getCmp(a);var d=b.getStore().getAt(e);
var c=d.get("AgentIP");c=c.substring(0,c.indexOf("~"));Ext.Msg.show({title:restartAgent,msg:confirmMsg1+" '"+c+"'"+"?",buttons:Ext.Msg.YESNO,icon:"iconConfirmation",fn:function(g){if(g=="yes"){var f=new Ext.LoadMask(Ext.getBody(),{msg:"This process will take few minutes. Please wait..."});f.show();var h="AgentStatus/data/EgAgentRestartJson.jsp?mode=main&agentIp="+encodeURI(c)+"&agentOs=";
Ext.Ajax.request({url:h,method:"POST",timeout:timeOut*1000,success:function(i){f.hide();var k=i.responseText;var l=Ext.decode(k);var m=l.requestStatus;var j=l.Msg;if(m=="Success"){Ext.Msg.show({title:restartAlrtTitle,msg:j,buttons:Ext.Msg.OK,icon:"iconInformation"});}else{if(m=="Failure"){Ext.Msg.show({title:restartAlrtTitle,msg:j,buttons:Ext.Msg.OK,icon:"iconError"});
}}},failure:function(i){f.hide();}});}}});},showAgentInfo:function(j,h,b,g){var a=Ext.getCmp(h);var f=a.getStore().getAt(j);var e=f.get("AgentIP");e=e.substring(0,e.indexOf("~"));var d=f.get("Output");var i=f.get("isAgentShared");i=i.substring(0,i.indexOf("~"));var c="no";if(d){c="yes";}Ext.getCmp("agentstatusviewport").removeAll();
Ext.getCmp("agentstatusviewport").add({xtype:"agentinformation"});this.getController("AgentStatus.controller.AgentInfoCtrler").buildMainData(e,c,b,g);this.getController("AgentStatus.controller.AgentInfoCtrler").afterMainRender(i);},goBack:function(){if(showAgentInformationView=="true"){window.location.href="/final/admin/AdvanceSearch.jsp";
}else{resetView();var a=Ext.isEmpty(publicJSON.agentType)?sel_agent_type:publicJSON.agentType;var b=Ext.isEmpty(publicJSON.agentState)?selAgentStatus:publicJSON.agentState;Ext.getCmp("agentstatusviewport").removeAll();this.getController("AgentStatus.controller.Main").buildMainData(a,b);Ext.getCmp("agentstatusviewport").add({xtype:"agentstatusview"});
this.getController("AgentStatus.controller.Main").afterMainRender();}},goHome:function(){window.location.href=backHref;},saveInCSVFormat:function(){window.location.href="/final/servlet/com.eg.SaveInCSVFormat?user_language="+userLanguage;},restartAgentFrmAgentInfo:function(){if(agentRunningStatus=="notrunning"){Ext.Msg.show({title:pageTitle2,msg:agentNotReporting,buttons:Ext.Msg.OK,icon:"iconExclamation"});
return;}Ext.Msg.show({title:restartAgent,msg:confirmMsg1+" '"+publicJSON.AgentIP+"'"+"?",buttons:Ext.Msg.YESNO,icon:"iconConfirmation",fn:function(b){if(b=="yes"){var a=new Ext.LoadMask(Ext.getBody(),{msg:"Please wait..."});a.show();var c="AgentStatus/data/EgAgentRestartJson.jsp?mode=info&agentIp="+encodeURI(publicJSON.AgentIP)+"&agentOs="+publicJSON.OS;
Ext.Ajax.request({url:c,method:"POST",timeout:timeOut*1000,success:function(d){a.hide();var f=d.responseText;var g=Ext.decode(f);var h=g.requestStatus;var e=g.Msg;if(h=="Success"){Ext.Msg.show({title:restartAlrtTitle,msg:e,buttons:Ext.Msg.OK,icon:"iconInformation"});}else{if(h=="Failure"){Ext.Msg.show({title:restartAlrtTitle,msg:e,buttons:Ext.Msg.OK,icon:"iconError"});
}}},failure:function(d){a.hide();}});}}});},resetAgentFrmAgentInfo:function(){var a="AgentStatus/data/EgagentinfopJson.jsp?agentIp="+encodeURI(publicJSON.AgentIP);Ext.Ajax.request({url:a,method:"POST",timeout:timeOut*1000,success:function(b){var c=b.responseText;var d=Ext.decode(c);if(d.ResultAlert){Ext.Msg.show({title:d.ResultTitle,msg:d.ResultMsg,buttons:Ext.Msg.OK,icon:"iconInformation"});
}}});},showLogsFrmAgentInfo:function(){if(agentRunningStatus=="notrunning"){Ext.Msg.show({title:pageTitle2,msg:agentNotReporting,buttons:Ext.Msg.OK,icon:"iconExclamation"});}else{if(showAgentInformationView=="true"){window.location.href="/final/admin/EgAgentLogView.jsp?componentName="+encodeURI(publicJSON.AgentIP)+"&debug="+publicJSON.debug+"&showAgentInformationView=true&agentType="+publicJSON.agentType;
}else{window.location.href="/final/admin/EgAgentLogView.jsp?componentName="+encodeURI(publicJSON.AgentIP)+"&debug="+publicJSON.debug+"&agentType="+publicJSON.agentType+"&viewFrom=AgentInfo&agentStatus="+publicJSON.agentState;}}},showLogs:function(d,a){var c=Ext.getCmp(a);var g=c.getStore().getAt(d);var f=g.get("AgentIP");
f=f.substring(0,f.indexOf("~"));var b=Ext.getCmp("agentType").getValue();var e=Ext.getCmp("agentStatus").getValue();window.location.href="/final/admin/EgAgentLogView.jsp?viewFrom=AgentStatus&componentName="+encodeURI(f)+"&agentType="+b+"&agentStatus="+e;},showXmxFrmAgentInfo:function(){if(agentRunningStatus=="notrunning"){Ext.Msg.show({title:pageTitle2,msg:agentNotReporting,buttons:Ext.Msg.OK,icon:"iconExclamation"});
}else{if(showAgentInformationView=="true"){window.location.href="/final/admin/EgAgentXmxView.jsp?componentName="+encodeURI(publicJSON.AgentIP)+"&debug="+publicJSON.debug+"&showAgentInformationView=true";}else{window.location.href="/final/admin/EgAgentXmxView.jsp?componentName="+encodeURI(publicJSON.AgentIP)+"&debug="+publicJSON.debug;
}}},showXmx:function(d,a){var c=Ext.getCmp(a);var g=c.getStore().getAt(d);var f=g.get("AgentIP");f=f.substring(0,f.indexOf("~"));var b=Ext.getCmp("agentType").getValue();var e=Ext.getCmp("agentStatus").getValue();window.location.href="/final/admin/EgAgentXmxView.jsp?viewFrom=AgentXmx&componentName="+encodeURI(f)+"&agentType="+b+"&agentStatus="+e;
},showAssignHosts:function(d,a){var b=Ext.getCmp("agentType").getValue();var f=Ext.getCmp("agentStatus").getValue();var c=Ext.getCmp(a);var g=c.getStore().getAt(d);var e=g.get("AgentIP");e=e.substring(0,e.indexOf("~"));if(b=="RemoteAgents"){window.location.href="/final/admin/EgRemoteAgents.jsp?from=AgentStatus&fromAssignRem=true&eagent="+e+"&agentState="+f;
}else{window.location.href="/final/admin/EgExternalAgents.jsp?from=AgentStatus&fromAssignExt=true&eagent="+e+"&agentState="+f;}},outputLoggingChange:function(i,d,h){var a=Ext.getCmp(h);var j=a.getStore().getAt(d);var e=j.get("AgentIP");e=e.substring(0,e.indexOf("~"));var b=jsonDataHolder.agentType;var c=jsonDataHolder[e+"_IP"];
var f="No";if(i){f="Yes";}var g=this;Ext.Msg.show({title:agentLogEnable,msg:confirmMsg2+"   '"+e+"'"+"?",buttons:Ext.Msg.YESNO,icon:"iconConfirmation",fn:function(l){if(l=="yes"){var m=loadingMsg1+" "+plsWait;if(i){m=loadingMsg2+" "+plsWait;}var n="AgentStatus/data/changeAgentOutputFileJson.jsp?agentID="+encodeURI(e)+"&s_output="+f+"&agentType="+b+"&agent_ip_address="+c;
var k=new Ext.LoadMask(Ext.getBody(),{msg:m});k.show();g.getAgentstatusview().submit({url:n,method:"POST",timeout:timeOut,success:function(o,q){k.hide();var p=q.response.responseText;var r=Ext.decode(p);if(r.ResultAlert){Ext.Msg.show({title:r.ResultTitle,msg:r.ResultMsg,buttons:Ext.Msg.OK,icon:"iconInformation",fn:function(t){if(t=="ok"){var s=Ext.getCmp("searchBox").getValue();
g.updateOutputLoging();}}});}},failure:function(o,p){k.hide();}});}else{if(l=="no"||l=="cancel"){if(i){j.set("Output",false);}else{j.set("Output",true);}}}}});},stopAgentButton:function(e,a){var b=Ext.getCmp(a);var d=b.getStore().getAt(e);var c=d.get("AgentIP");c=c.substring(0,c.indexOf("~"));if(agentRunningStatus=="notrunning"){Ext.Msg.show({title:pageTitle2,msg:agentNotReporting,buttons:Ext.Msg.OK,icon:"iconExclamation"});
return;}Ext.Msg.show({title:stopAgent,msg:confirmMsg_stop+" '"+c+"'"+"?",buttons:Ext.Msg.YESNO,icon:"iconConfirmation",fn:function(g){if(g=="yes"){var f=new Ext.LoadMask(Ext.getBody(),{msg:"Please wait..."});f.show();var h="AgentStatus/data/stopAgentJson.jsp?agentIp="+encodeURI(c);Ext.Ajax.request({url:h,method:"POST",timeout:timeOut*1000,success:function(i){f.hide();
var k=i.responseText;var l=Ext.decode(k);var m=l.requestStatus;var j=l.Msg;if(m=="Success"){Ext.Msg.show({title:stopAlrtTitle,msg:j,buttons:Ext.Msg.OK,icon:"iconInformation"});}else{if(m=="Failure"){Ext.Msg.show({title:stopAlrtTitle,msg:j,buttons:Ext.Msg.OK,icon:"iconError"});}}},failure:function(i){f.hide();
}});}}});},callMonitorRemoteControl:function(h,f,e){var i=Ext.getCmp("agentType").getValue();var b=Ext.getCmp("agentStatus").getValue();var a=Ext.getCmp(f);var d=a.getStore().getAt(h);var c=d.get("AgentIP");c=c.substring(0,c.indexOf("~"));var g=new Ext.LoadMask(Ext.getBody(),{msg:"Agent ("+c+") is changing to control mode. Please wait for few minutes."});
g.show();Ext.Ajax.request({url:"AgentStatus/data/controlMode.jsp?agentIP="+encodeURI(c),method:"POST",timeout:timeOut*1000,scope:this,success:function(j){g.hide();var k=Ext.decode(j.responseText);if(k.agentStatus=="CONTROL_MODE"){window.location.href="/final/admin/remoteControl.jsp?agentIP="+encodeURI(c)+"&agentMode=CONTROL_MODE&agent_type="+i+"&agentStatus="+b;
}else{Ext.Msg.show({title:"Remote Control",msg:"Please try again.",buttons:Ext.Msg.OK,icon:"iconInformation"});}},failure:function(j){g.hide();Ext.Msg.show({title:"Remote Control",msg:"Please try again.",buttons:Ext.Msg.OK,icon:"iconInformation"});}});},disableAgentDebug:function(b){b=b.indexOf("~Yes")>-1?b.substring(0,b.indexOf("~Yes")):b;
var a=publicJSON.disabledIpList;if(!Ext.isEmpty(a)&&Ext.Array.contains(a,b)){return true;}return false;}});Ext.apply(Ext.data.SortTypes,{asAgentIP:function(b){var a=b.split("~")[0];return a.toUpperCase()+a.toLowerCase();}});function doesExist(c,d){for(var b=0;b<c.length;b++){var a=c[b];if(d.indexOf(a)!=-1||d.toLowerCase().indexOf(a.toLowerCase())!=-1){totalRecords++;
return true;}}return false;}