Ext.Msg.cls="adminAlert";Ext.Msg.layout={type:"anchor",pack:"center",align:"center"};Ext.define("RemoteAgent.controller.Main",{extend:"Ext.app.Controller",views:["RemoteAgents","RemoteAgent","AssignRemoteAgent","DeleteRemoteAgents","VmComponentTable","VMStatistics"],requires:["RemoteAgent.view.RemoteAgent","RemoteAgent.view.FileUploadForm","RemoteAgent.view.FileUpload"],refs:[{selector:"remoteagents",ref:"remoteagents"},{selector:"assignremoteagent",ref:"assignremoteagent"},{selector:"deleteremoteagents",ref:"deleteremoteagents"},{selector:"remoteagent",ref:"remoteagent"},{selector:"vmstatistics",ref:"vmstatistics"},{selector:"vmcomponenttable",ref:"vmcomponenttable"},{selector:"fileuploadform",ref:"fileuploadform"}],init:function(){appRmtCnt=this;
this.buildMainData();this.control({"remoteagents":{"afterrender":this.afterMainRender},'remoteagents trigger[name="gridRmtSearch"]':{"change":this.mainGridSearch},'remoteagents button[id="addRmtAgent"]':{"click":this.addAgent},'remoteagents button[id="DeleteRmtOver"]':{"click":this.deleteOver},'remoteagent button[id="updateBtn"]':{"click":this.addUpdate},'remoteagents button[id="associateDissociate"]':{"click":this.associateDissociate},'remoteagents button[id="vMStatistics"]':{"click":this.agentVmStatistics},'remoteagents button[id="dwnldAgent"]':{"click":this.dwnldAgent},'assignremoteagent combo[id="rmtAgent"]':{"select":this.comboFromFieldLoad},'assignremoteagent combo[id="otherRmtAgent"]':{"select":this.comboToFieldLoad},'assignremoteagent button[id="UpdateBTN"]':{"click":this.updation},'assignremoteagent button[id="backbutton"]':{"click":this.backbutton},'deleteremoteagents button[id="deleteBtn"]':{"click":this.deletefun},'deleteremoteagents trigger[name="agentsearch"]':{"change":this.mainFormEvent},'deleteremoteagents button[id="backDelbutton"]':{"click":this.backDelButton},'vmstatistics button[id="backVmStaticsBtn"]':{"click":this.backVMStatisticsEvent},'vmstatistics combo[id="remoteAgentCombo"]':{"change":this.remoteAgentComboChangeEvent},'vmstatistics [id="physicalServerVmsPoweredonGrid"]':{"cellclick":this.showVmTableCellClickEvent,},'vmstatistics button[id="refreshButton"]':{"click":this.refreshFile},'remoteagents button[action="openPopupWin"]':{"click":this.openPopupWin},'fileupload button[action="bulkAgentAction"]':{click:this.bulkAgentAction}});
},refreshFile:function(){if(vmComponentWindow.isVisible()){vmComponentWindow.close();}Ext.getCmp("noRemoteAgentSelectContainer").hide();if(loading){Ext.Msg.show({title:"Warning",msg:alreadyLoading,buttons:Ext.Msg.OK,icon:"iconExclamation"});return false;}else{var a=Ext.getCmp("remoteAgentCombo").getValue();
if(a=="-1"){Ext.Msg.show({title:pageName2,msg:selectOneMsg,buttons:Ext.Msg.OK,icon:"iconExclamation"});return false;}this.remoteAgentComboChangeEvent();}},showVmTableCellClickEvent:function(a,b,i,c,h,k,d,f){var j=a.getSelectionModel().getCurrentPosition();c=a.store.getAt(j.row);colname=a.getHeaderCt().getHeaderAtIndex(i).dataIndex;
cellvalue=c.data[colname];var m=a.getHeaderCt().getHeaderAtIndex(i).dataIndex;if(m!=null&&m=="physicalServer"){componentName=Ext.getCmp("remoteAgentCombo").getValue();var g=publicJson["phyServerwithTypeObj"][cellvalue];var l=Ext.getCmp("remoteviewport");myMask=new Ext.LoadMask(l,{msg:"Loading..."});loading=true;
myMask.show();Ext.Ajax.request({url:"RemoteAgent/data/EgVmLogDisplayJson.jsp?componentName="+encodeURIComponent(componentName)+"&file=eg_vm.ini&vmtable=true&from=vm&phyServer="+cellvalue+"&type="+g,method:"post",scope:this,success:function(e){if(e.status==200&&!Ext.isEmpty(e.responseText)){var q=e.responseText;
jsonData=Ext.decode(q);vmComponentWindow=Ext.widget("vmcomponenttable");myMask.hide();loading=false;vmComponentWindow.show();var o=jsonData["type"];var n=jsonData["componentViewGridArr"];var p=jsonData["componentViewGridTitle"];if(p!=null&&!Ext.isEmpty(p)){Ext.getCmp("vmComponentTableWindowId").setTitle(p);
}if(n!=null&&!Ext.isEmpty(n)){Ext.getCmp("noVmDetailsContainer").hide();Ext.getCmp("hyperComponentViewGrid").hide();Ext.getCmp("xenComponentViewGrid").hide();Ext.getCmp("esxComponentViewGrid").hide();var r=jsonData[o];if(o!=null&&!Ext.isEmpty(o)&&o=="esx"){if(r!=null&&!Ext.isEmpty(r)){Ext.getCmp("esx1").setText(r[0]);
Ext.getCmp("esx2").setText(r[1]);Ext.getCmp("esx3").setText(r[2]);Ext.getCmp("esx4").setText(r[3]);Ext.getCmp("esx5").setText(r[4]);Ext.getCmp("esx6").setText(r[5]);Ext.getCmp("esx7").setText(r[6]);}Ext.getCmp("esxComponentViewGrid").show();Ext.getCmp("esxComponentViewGrid").getStore().removeAll();Ext.getCmp("esxComponentViewGrid").getStore().loadRawData(n);
}else{if(o!=null&&!Ext.isEmpty(o)&&(o=="xen"||o=="Xen")){if(r!=null&&!Ext.isEmpty(r)){Ext.getCmp("xen1").setText(r[0]);Ext.getCmp("xen2").setText(r[1]);Ext.getCmp("xen3").setText(r[2]);Ext.getCmp("xen4").setText(r[3]);Ext.getCmp("xen5").setText(r[4]);}Ext.getCmp("xenComponentViewGrid").show();Ext.getCmp("xenComponentViewGrid").getStore().removeAll();
Ext.getCmp("xenComponentViewGrid").getStore().loadRawData(n);}else{if(o!=null&&!Ext.isEmpty(o)&&o=="hyper"){if(r!=null&&!Ext.isEmpty(r)){Ext.getCmp("hyper1").setText(r[0]);Ext.getCmp("hyper2").setText(r[1]);Ext.getCmp("hyper3").setText(r[3]);Ext.getCmp("hyper4").setText(r[2]);}Ext.getCmp("hyperComponentViewGrid").show();
Ext.getCmp("hyperComponentViewGrid").getStore().removeAll();Ext.getCmp("hyperComponentViewGrid").getStore().loadRawData(n);}}}}else{NoDataMsg=jsonData["NoDataMsg"];Ext.getCmp("xenComponentViewGrid").hide();Ext.getCmp("esxComponentViewGrid").hide();Ext.getCmp("hyperComponentViewGrid").hide();Ext.getCmp("noVmDetailsContainer").show();
}}}});}},remoteAgentComboChangeEvent:function(){componentName=Ext.getCmp("remoteAgentCombo").getValue();if(componentName!=null&&componentName=="-1"&&!firstTime){Ext.Msg.show({title:pageName2,msg:selectOneMsg,buttons:Ext.Msg.OK,icon:"iconExclamation"});return false;}else{if(componentName!=null&&componentName!="-1"){firstTime=false;
var a=Ext.getCmp("remoteviewport");myMask=new Ext.LoadMask(a,{msg:label4});loading=true;myMask.show();Ext.Ajax.request({url:"RemoteAgent/data/EgVmLogDisplayJson.jsp?componentName="+encodeURIComponent(componentName)+"&file=eg_vm.ini&vmtable=false",method:"POST",scope:this,timeout:6000000,success:function(h){if(h.status==200&&!Ext.isEmpty(h.responseText)){var e=h.responseText;
publicJson=Ext.decode(e);var k=publicJson["isNoData"];if(k){Ext.getCmp("physicalServerVmsPoweredonGrid").hide();Ext.getCmp("vmsValidUserGrid").hide();Ext.getCmp("insideViewFailedVmsGrid").hide();Ext.getCmp("agentFailedVmsGrid").hide();var b=publicJson["NoDataMsg"];Ext.getCmp("noRemoteAgentSelectContainer").show();
Ext.getCmp("noRemoteAgentSelectedLabel").update(b);}else{Ext.getCmp("noRemoteAgentSelectContainer").hide();var p=publicJson["phyServerVmsPoweredonGridArr"];var g=publicJson["phyServerTitle"];var m=publicJson["validUserTitle"];var o=publicJson["vmsValidUserGridArr"];var i=publicJson["insideViewFailedVmsGridArr"];
var c=publicJson["vmagentFailedVmsGridArr"];var d=publicJson["insideViewTitle"];var q=publicJson["agentViewTitle"];var f=publicJson[g];var j=publicJson[m];var n=publicJson[d];var l=publicJson[q];if(p!=null&&!Ext.isEmpty(p)){if(f!=null&&!Ext.isEmpty(f)){Ext.getCmp("poweredVmGrid1").setText(f[0]);Ext.getCmp("poweredVmGrid2").setText(f[1]);
Ext.getCmp("poweredVmGrid3").setText(f[2]);Ext.getCmp("poweredVmGrid4").setText(f[3]);}Ext.getCmp("physicalServerVmsPoweredonGrid").show();Ext.getCmp("physicalServerVmsPoweredonGrid").setTitle(g);Ext.getCmp("physicalServerVmsPoweredonGrid").getStore().removeAll();Ext.getCmp("physicalServerVmsPoweredonGrid").getStore().loadRawData(p);
}if(o!=null&&!Ext.isEmpty(o)){Ext.getCmp("vmsValidUserGrid").show();if(j!=null&&!Ext.isEmpty(j)){Ext.getCmp("validUserGrid1").setText(j[0]);Ext.getCmp("validUserGrid2").setText(j[1]);Ext.getCmp("validUserGrid3").setText(j[2]);Ext.getCmp("validUserGrid4").setText(j[3]);}Ext.getCmp("vmsValidUserGrid").setTitle(m);
Ext.getCmp("vmsValidUserGrid").getStore().removeAll();Ext.getCmp("vmsValidUserGrid").getStore().loadRawData(o);}if(i!=null&&!Ext.isEmpty(i)){Ext.getCmp("insideViewFailedVmsGrid").show();if(n!=null&&!Ext.isEmpty(n)){Ext.getCmp("insideViewGrid1").setText(n[0]);Ext.getCmp("insideViewGrid2").setText(n[1]);
Ext.getCmp("insideViewGrid3").setText(n[2]);Ext.getCmp("insideViewGrid4").setText(n[3]);}Ext.getCmp("insideViewFailedVmsGrid").setTitle(d);Ext.getCmp("insideViewFailedVmsGrid").getStore().removeAll();Ext.getCmp("insideViewFailedVmsGrid").getStore().loadRawData(i);}if(c!=null&&!Ext.isEmpty(c)){Ext.getCmp("agentFailedVmsGrid").show();
if(l!=null&&!Ext.isEmpty(l)){Ext.getCmp("agentViewGrid1").setText(l[0]);Ext.getCmp("agentViewGrid2").setText(l[1]);Ext.getCmp("agentViewGrid3").setText(l[2]);Ext.getCmp("agentViewGrid4").setText(l[3]);}Ext.getCmp("agentFailedVmsGrid").setTitle(q);Ext.getCmp("agentFailedVmsGrid").getStore().removeAll();
Ext.getCmp("agentFailedVmsGrid").getStore().loadRawData(c);}}myMask.hide();loading=false;}}});}}},buildMainData:function(){Ext.Ajax.request({url:"RemoteAgent/data/EgDispRemoteAgentsJson.jsp",method:"POST",async:false,success:function(b){if(b.status==200&&!Ext.isEmpty(b.responseText)){var c=b.responseText;
publicJSON=Ext.decode(c);if(!Ext.isEmpty(publicJSON.strrmtList)){var a=publicJSON.strrmtList;rmtListStr=a.split(",");}}}});},showAssignHosts:function(c,a){var b=Ext.getCmp(a);var d=b.getStore().getAt(c);assignAgent=d.get("Hostname");Ext.getCmp("remoteviewport").removeAll();this.getController("RemoteAgent.controller.AssignRmtCtrl").buildFieldData();
Ext.getCmp("remoteviewport").add({xtype:"assignremoteagent"});this.getController("RemoteAgent.controller.AssignRmtCtrl").buildGivenAgentData(assignAgent);this.getController("RemoteAgent.controller.AssignRmtCtrl").afterMainRender();},handleDeleteIconClick:function(d,e,b){var c=Ext.getCmp("gridRmtDisplay").getStore().getAt(e);
var a=c.get("Hostname");this.deleteTask(a,e);},handleEditIconClick:function(e,f,b){btnText="Change IP";var d=Ext.getCmp("gridRmtDisplay").getStore().getAt(f);var a=d.get("Hostname");var c=d.get("HostIP");this.showEditWindow(a,c);},showEditWindow:function(a,d){Ext.widget("remoteagent").show();Ext.getCmp("Hostname").setValue(a).disable();
Ext.getCmp("HostIp").setValue(d);Ext.getCmp("updateBtn").setText("Update");Ext.getCmp("AddModRmtView").setTitle(rmtModPageTitle);this.getController("RemoteAgent.controller.AddRmtCtrl").buildAddFieldData();extListStr=publicJSON["extAgentsArr"];var b=publicJSON["enableNickNameEdit"];if(b){Ext.getCmp("Hostname").setValue(a).enable();
}Ext.getCmp("HostIp").focus();Ext.getCmp("hostIpCt").setFieldLabel(publicJSON["screenLabels"]["admin.remote.Agent IP Address"]);Ext.getCmp("Hostname").setFieldLabel(publicJSON["screenLabels"]["admin.remote.Agent Host/Nick Name"]);Ext.getCmp("addAsExtAgent").setFieldLabel(publicJSON["screenLabels"]["admin.remote.Add as External agent"]);
Ext.getCmp("HostIp").setValue(publicJSON["hostValue"]["AgentIp"]);Ext.getCmp("Hostname").setValue(publicJSON["hostValue"]["AgenthostNic"]);var e=publicJSON["rtype"];if(RmtIpAgent==HostIp){Ext.getCmp("addAsExtAgent").hide();}var c=publicJSON["extnothasragent"];if(c=="No"){Ext.getCmp("addAsExtAgent").hide();
}else{Ext.getCmp("addAsExtAgent").show();Ext.getCmp("addasExtNo").setValue(true);}oldHostIp=publicJSON["hostValue"]["AgentIp"];oldNickName=publicJSON["hostValue"]["AgenthostNic"];},commonDelete:function(a,c){var b=this;Ext.Msg.show({title:"DELETE REMOTE AGENT",msg:deleteSingleRmtAgntMsg+"'"+a+"'"+"?",buttons:Ext.Msg.YESNO,icon:"iconConfirmation",fn:function(e){if(e==="yes"){var d=new Ext.LoadMask(Ext.getBody(),{msg:"Updating..."});
d.show();Ext.Ajax.request({url:"RemoteAgent/data/EgnewremoteagentspJson.jsp?mode=del&eagent="+encodeURIComponent(a),method:"POST",success:function(h){d.hide();var l=h.responseText;publicJSON=Ext.decode(l);if(!Ext.isEmpty(l)&&h.status==200){var k=publicJSON["requestStatus"];if(k=="success"||k.indexOf("success")!=-1){var k=publicJSON["result"];
var f=publicJSON["doubleAlert"];if(f!=undefined&&f=="true"){Ext.Msg.show({title:k["title"],msg:k["message1"],buttons:Ext.Msg.OKCANCEL,icon:"iconConfirmation",fn:function(n){if(n=="ok"){d.show();Ext.Ajax.request({url:"ExternalAgent/data/EgnewextagentspJson.jsp?mode=del&eagent="+encodeURIComponent(a),method:"POST",success:function(p){d.hide();
var r=p.responseText;publicJSON=Ext.decode(r);if(!Ext.isEmpty(r)&&p.status==200){var q=publicJSON["requestStatus"];if(q=="success"||q.indexOf("success")!=-1){var o=publicJSON["result"];Ext.Msg.show({title:o["title"],msg:o["message1"],buttons:Ext.Msg.OK,icon:"iconInformation"});}else{var q=publicJSON["error"];
Ext.MessageBox.show({titel:q["title"],msg:q["message1"],buttons:Ext.Msg.OK,icon:"iconExclamation"});}}},failure:function(){d.hide();}});}}});}else{Ext.Msg.show({title:k["title"],msg:k["message1"],buttons:Ext.Msg.OK,icon:"iconInformation"});}}else{var k=publicJSON["error"];Ext.MessageBox.show({title:k["title"],msg:k["message1"],buttons:Ext.Msg.OK,icon:"iconExclamation"});
}Ext.getCmp("gridRmtSearch").setRawValue("");b.buildMainData();var j=publicJSON["gridRmtAgents"];if(j==null||j.length==0){Ext.getCmp("gridRmtSearch").disable();Ext.getCmp("associateDissociate").disable();Ext.getCmp("gridRmtDisplay").getView().emptyText='<div class="egFlexCenterByColumnWise" style="height:98%"><div class="iconInformation"></div><div class="commonErrorMsgText" >'+NoRmtDesc+".</div></div>";
}else{Ext.getCmp("gridRmtSearch").enable();Ext.getCmp("associateDissociate").enable();Ext.getCmp("gridRmtDisplay").getStore().loadRawData(j);var g=Ext.getCmp("gridRmtDisplay").getView();var m=g.headerCt;var i=m.child("gridcolumn[isCheckerHd]");if(i){i.el.removeCls(Ext.baseCSSPrefix+"grid-hd-checker-on");
}}}b.buildMainData();var j=publicJSON["gridRmtAgents"];Ext.getCmp("gridRmtDisplay").getStore().loadRawData(j);Ext.getCmp("gridRmtSearch").setRawValue("");},failure:function(){d.hide();}});}}});},deleteTask:function(a,b){this.commonDelete(a,b);},mainGridSearch:function(b){var a=Ext.getCmp("gridRmtSearch").getValue();
if(a==""||a.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:"RemoteAgent/data/EgDispRemoteAgentsJson.jsp?egTitleSearchStr="+encodeURIComponent(filterEncode(a)),method:"POST",success:function(c){if(c.status==200&&!Ext.isEmpty(c.responseText)){var e=c.responseText;
publicJSON=Ext.decode(e);}var d=publicJSON["gridRmtAgents"];Ext.getCmp("gridRmtDisplay").show();Ext.getCmp("associateDissociate").enable();if(d!=null&&d.length>0){Ext.getCmp("gridRmtDisplay").store.loadData(publicJSON["gridRmtAgents"]);}else{Ext.getCmp("gridRmtDisplay").store.loadData("");Ext.getCmp("gridRmtDisplay").getView().emptyText='<div class="egFlexCenterByColumnWise" style="height:98%"><div class="iconInformation"></div><div class="commonErrorMsgText" >'+NoRmtFound+".</div></div>";
Ext.getCmp("gridRmtDisplay").getView().refresh();}}});},addAgent:function(a){btnText="Add";Ext.widget("remoteagent").show();Ext.getCmp("updateBtn").setText("Add");Ext.getCmp("AddModRmtView").setTitle(rmtAddPageTitle);this.getController("RemoteAgent.controller.AddRmtCtrl").buildAddFieldData();this.getController("RemoteAgent.controller.AddRmtCtrl").afterMainRender();
},openPopupWin:function(){Ext.widget("fileupload").show();},bulkAgentAction:function(){var e=this;var f=Ext.getCmp("FILE_0").getValue();var c=Ext.getCmp("bulkRemoteAgent").getValue().actionType;var b=addOrDeleteRmtAgentInBulkTitle;if(c=="add"){b=addRmtAgentInBulkTitle;}else{if(c=="delete"){b=deleteRmtAgentInBulkTitle;
}}if(f!=null&&f!=""&&f!=undefined&&f!="undefined"){var d=f;d=d.substring(d.lastIndexOf(".")+1);if(d=="csv"){var a="";if(c=="add"){a="/final/servlet/com.egurkha.admin.EgCLIBulkActionController?action=addRemoteAgent";e.doAction(a);}else{if(c=="delete"){a="/final/servlet/com.egurkha.admin.EgCLIBulkActionController?action=deleteRemoteAgent";
Ext.Msg.show({title:b,msg:deleteSelected,buttons:Ext.Msg.YESNO,icon:"iconConfirmation",fn:function(g){if(g=="yes"){e.doAction(a);}}});}}}else{Ext.Msg.show({title:b,msg:selectValidFile,buttons:Ext.MessageBox.OK,icon:"iconExclamation"});}}else{Ext.Msg.show({title:b,msg:selectCompsListFile,buttons:Ext.MessageBox.OK,icon:"iconInformation"});
}},doAction:function(b){var e=this.getFileuploadform().getForm();var d=Ext.getCmp("bulkRemoteAgent").getValue().actionType;var c=addOrDeleteRmtAgentInBulkTitle;if(d=="add"){c=addRmtAgentInBulkTitle;}else{if(d=="delete"){c=deleteRmtAgentInBulkTitle;}}if(e.isValid()){var a=new Ext.LoadMask("fileUpload",{msg:"Please wait..."});
a.show();e.submit({url:b,scope:this,async:true,method:"POST",enctype:"multipart/form-data",success:function(h,j){a.hide();var i=j.response.responseText;i=Ext.decode(i);var g=i["errorMsg"];var m=i["errorInfo"];var f=i["resultMsg"];var k=i["tempErrorMsg"];var l=i["ErrMsgsJson"];if(!Ext.isEmpty(i)){if(Ext.isEmpty(k)){if(!Ext.isEmpty(f)){Ext.Msg.show({title:c,msg:f,icon:"iconInformation",buttons:Ext.Msg.OK});
}else{if(!Ext.isEmpty(l)){Ext.Msg.show({title:c,msg:g,icon:"iconExclamation",buttons:Ext.Msg.OK});}else{if(!Ext.isEmpty(m)){Ext.Msg.show({title:c,msg:m,icon:"iconInformation",buttons:Ext.Msg.OK});}else{if(!Ext.isEmpty(g)){Ext.Msg.show({title:c,msg:g,icon:"iconExclamation",buttons:Ext.Msg.OK});}}}}}else{Ext.Msg.show({title:c,msg:k,icon:"iconExclamation",buttons:Ext.Msg.OK});
}}},failure:function(f,g){a.hide();Ext.Msg.show({title:c,msg:"Failure Notice",icon:"iconExclamation",buttons:Ext.Msg.OK});}});}},deleteOver:function(){var a=Ext.getCmp("DispRmtHostName").getValue();window.location.href="RemoteAgent/data/EgnewremoteagentspJson.jsp?mode=del&eagent="+encodeURIComponent(a);
},addUpdate:function(e){var h=Ext.getCmp("HostIp").getValue();var c=Ext.getCmp("Hostname").getValue();var g=this;var d=g.validationForAddModify();var f=false;if(btnText!="Add"){if(oldHostIp!=null&&oldNickName!=null&&oldHostIp!=h&&oldNickName!=c){Ext.Msg.show({title:rmtPageTitle,msg:checkSingleEdit+".",icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(i){Ext.getCmp("HostIp").focus(true);
}});d=false;}else{for(var b=0;b<extListStr.length;b++){var a=extListStr[b].trim();if(a==oldNickName){f=true;}}}}if(d){if(oldNickName!=c){if(f){Ext.Msg.show({title:rmtPageTitle,msg:sameNameAlert1+". "+sameNameAlert2+". "+sameNameAlert3,buttons:Ext.Msg.YESNO,icon:"iconConfirmation",fn:function(i){if(i=="yes"){g.addUpdateProcess();
}}});}else{g.addUpdateProcess();}}else{g.addUpdateProcess();}}},addUpdateProcess:function(){var h=this;var f=this;this.getController("RemoteAgent.controller.AddRmtCtrl").buildAddFieldData();var a=Ext.getCmp("HostIp").getValue();var i=Ext.getCmp("Hostname").getValue();var c="";var e="";if(btnText=="Add"){e="add";
}else{e="modifyip";}var e=publicJSON["mode"];var g="";var b=Ext.getCmp("addasExtYes").getValue();if(b==true){g="true";}else{g="false";}var d=null;var j=publicJSON["OrgWithGivenNick"];if(j!=""&&j!=null&&j.length>0&&e=="add"){Ext.Msg.show({title:rmtAddPageTitle,msg:nickShareMsg1+" ("+j+"). "+nickShareMsg2+". "+nickShareMsg3,buttons:Ext.Msg.OKCANCEL,icon:"iconConfirmation",fn:function(k){if(k=="ok"){c=g+"&mode="+e+"&hostip="+a+"&hostname="+encodeURIComponent(i)+"&old_name="+oldNickName+"&old_ip="+oldHostIp+"&eagent="+d+"&OrgWithGivenNick="+j;
f.forwardGivenUrl1(c,a,i);}else{Ext.getCmp("AddModRmtView").destroy();}}});}else{c=g+"&mode="+e+"&hostip="+a+"&hostname="+encodeURIComponent(i)+"&old_name="+oldNickName+"&old_ip="+oldHostIp+"&eagent="+d;f.forwardGivenUrl1(c,a,i);}},forwardGivenUrl1:function(d,f,c){var b=publicJSON["OrgWithGivenNick"];
var e=this;var a=new Ext.LoadMask(Ext.getBody(),{msg:"Updating..."});a.show();Ext.Ajax.request({url:"RemoteAgent/data/EgnewremoteagentspJson.jsp?external="+d,method:"POST",success:function(l){a.hide();var i=l.responseText;publicJSON=Ext.decode(i);if(!Ext.isEmpty(i)&&l.status==200){var n=publicJSON["requestStatus"];
if(n=="success"||n.indexOf("success")!=-1){var n=publicJSON["result"];var g=publicJSON["addToExternal"];var h=publicJSON["toExternalModify"];if(g==undefined&&h==undefined){Ext.MessageBox.show({title:n["title"],msg:n["message1"],icon:"iconInformation",buttons:Ext.Msg.OK,width:400,fn:function(r){Ext.getCmp("AddModRmtView").destroy();
}});}if(g!=null&&g=="true"){var m="";if(d.indexOf("OrgWithGivenNick")!=-1){m="NewAgnt&remoteUpdateResult=0&addAsExternal=true&clientEmulation=false&hostip="+f+"&hostname="+encodeURI(c)+"&OrgWithGivenNick="+b;}else{m="NewAgnt&remoteUpdateResult=0&addAsExternal=true&clientEmulation=false&hostip="+f+"&hostname="+encodeURI(c);
}a.show();Ext.Ajax.request({url:"ExternalAgent/data/EgnewextagentspJson.jsp?Btype="+m,method:"POST",success:function(r){a.hide();var u=r.responseText;publicJSON=Ext.decode(u);if(!Ext.isEmpty(u)&&r.status==200){var t=publicJSON["requestStatus"];if(t=="success"||t.indexOf("success")!=-1){var t=publicJSON["result"];
Ext.MessageBox.show({title:t["title"],msg:t["message1"],icon:"iconInformation",buttons:Ext.Msg.OK,width:400,fn:function(v){Ext.getCmp("AddModRmtView").destroy();}});}else{var s=publicJSON["error"];Ext.MessageBox.show({title:s["title"],msg:s["message1"]+s["message2"],icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(v){Ext.getCmp("AddModRmtView").destroy();
}});}}},failure:function(){a.hide();}});}if(h!=null&&h=="true"){var q="NewAgnt&addAsExternal=true&clientEmulation=false&hostip="+f+"&hostname="+encodeURI(c);a.show();Ext.Ajax.request({url:"ExternalAgent/data/EgnewextagentspJson.jsp?Btype="+q,method:"POST",success:function(r){a.hide();var u=r.responseText;
publicJSON=Ext.decode(u);if(!Ext.isEmpty(u)&&r.status==200){var t=publicJSON["requestStatus"];if(t=="success"||t.indexOf("success")!=-1){var t=publicJSON["result"];Ext.MessageBox.show({title:t["title"],msg:t["message1"],icon:"iconInformation",buttons:Ext.Msg.OK,fn:function(v){Ext.getCmp("AddModRmtView").destroy();
}});}else{var s=publicJSON["error"];Ext.MessageBox.show({title:s["title"],msg:s["message1"]+s["message2"],icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(v){Ext.getCmp("AddModRmtView").destroy();}});}}},failure:function(){a.hide();}});}}else{var j=publicJSON["error"];var p=publicJSON.error_type;
if(p=="confirmNickSuggestion"){Ext.Msg.confirm({title:j["title"],msg:j["message1"]+j["message2"],buttons:Ext.Msg.YESNO,icon:"iconConfirmation",fn:function(r){if(r=="yes"){var s=j.forward_URL;var u=j.IP;var t=j.nickName;s="RemoteAgent/data/"+s;e.forwardGivenURL(s,u,t);}else{Ext.getCmp("Hostname").focus();
}}});}else{Ext.MessageBox.show({title:j["title"],msg:j["message1"]+j["message2"],icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(r){if(p=="alert"){Ext.getCmp("Hostname").focus();}else{Ext.getCmp("AddModRmtView").destroy();}}});var o=publicJSON["AddSameAsExt"];if(o!=undefined&&o=="true"){Ext.Msg.show({title:j["title"],msg:j["message1"]+j["message2"],buttons:Ext.Msg.OKCANCEL,icon:"iconExclamation",fn:function(r){if(r=="ok"){a.show();
Ext.Ajax.request({url:"ExternalAgent/data/EgnewextagentspJson.jsp?Btype=NewAgnt&addAsExternal=true&clientEmulation=false&hostip="+f+"&hostname="+encodeURI(c),method:"POST",success:function(t){a.hide();var v=t.responseText;publicJSON=Ext.decode(v);if(!Ext.isEmpty(v)&&t.status==200){var u=publicJSON["requestStatus"];
if(u=="success"||u.indexOf("success")!=-1){var s=publicJSON["result"];Ext.MessageBox.show({title:s["title"],msg:s["message1"],buttons:Ext.Msg.OK,icon:"iconInformation",fn:function(w){Ext.getCmp("AddModRmtView").destroy();}});}}},failure:function(){a.hide();}});}else{Ext.getCmp("AddModRmtView").destroy();
}}});}}}e.buildMainData();var k=publicJSON["gridRmtAgents"];Ext.getCmp("gridRmtSearch").enable();Ext.getCmp("associateDissociate").enable();Ext.getCmp("gridRmtDisplay").getStore().loadRawData(k);Ext.getCmp("gridRmtSearch").setRawValue("");}},failure:function(){a.hide();}});},forwardGivenURL:function(e,d,b){var c=this;
var a=new Ext.LoadMask(Ext.getBody(),{msg:"Updating..."});a.show();Ext.Ajax.request({url:e,method:"POST",success:function(k){a.hide();var h=k.responseText;publicJSON=Ext.decode(h);if(!Ext.isEmpty(h)&&k.status==200){var m=publicJSON["requestStatus"];if(m=="success"||m.indexOf("success")!=-1){var m=publicJSON["result"];
var f=publicJSON["addToExternal"];var g=publicJSON["toExternalModify"];if(f==undefined&&g==undefined){Ext.MessageBox.show({title:m["title"],msg:m["message1"],icon:"iconInformation",buttons:Ext.Msg.OK,width:400,fn:function(p){Ext.getCmp("AddModRmtView").destroy();}});}if(f!=null&&f=="true"){var l="NewAgnt&remoteUpdateResult=0&addAsExternal=true&clientEmulation=false&hostip="+d+"&hostname="+encodeURI(b);
a.show();Ext.Ajax.request({url:"ExternalAgent/data/EgnewextagentspJson.jsp?Btype="+l,method:"POST",success:function(p){a.hide();var s=p.responseText;publicJSON=Ext.decode(s);if(!Ext.isEmpty(s)&&p.status==200){var r=publicJSON["requestStatus"];if(r=="success"||r.indexOf("success")!=-1){var r=publicJSON["result"];
Ext.MessageBox.show({title:r["title"],msg:r["message1"],icon:"iconInformation",buttons:Ext.Msg.OK,width:400,fn:function(t){Ext.getCmp("AddModRmtView").destroy();}});}else{var q=publicJSON["error"];Ext.MessageBox.show({title:q["title"],msg:q["message1"]+q["message2"],icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(t){Ext.getCmp("AddModRmtView").destroy();
}});}}},failure:function(){a.hide();}});}if(g!=null&&g=="true"){var o="NewAgnt&addAsExternal=true&clientEmulation=false&hostip="+d+"&hostname="+encodeURI(b);a.show();Ext.Ajax.request({url:"ExternalAgent/data/EgnewextagentspJson.jsp?Btype="+o,method:"POST",success:function(p){a.hide();var s=p.responseText;
publicJSON=Ext.decode(s);if(!Ext.isEmpty(s)&&p.status==200){var r=publicJSON["requestStatus"];if(r=="success"||r.indexOf("success")!=-1){var r=publicJSON["result"];Ext.MessageBox.show({title:r["title"],msg:r["message1"],icon:"iconInformation",buttons:Ext.Msg.OK,fn:function(t){Ext.getCmp("AddModRmtView").destroy();
}});}else{var q=publicJSON["error"];Ext.MessageBox.show({title:q["title"],msg:q["message1"]+q["message2"],icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(t){Ext.getCmp("AddModRmtView").destroy();}});}}},failure:function(){a.hide();}});}}else{var i=publicJSON["error"];Ext.MessageBox.show({title:i["title"],msg:i["message1"]+i["message2"],icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(p){Ext.getCmp("AddModRmtView").destroy();
}});var n=publicJSON["AddSameAsExt"];if(n!=undefined&&n=="true"){Ext.Msg.show({title:i["title"],msg:i["message1"]+i["message2"],buttons:Ext.Msg.OKCANCEL,icon:"iconExclamation",fn:function(p){if(p=="ok"){a.show();Ext.Ajax.request({url:"ExternalAgent/data/EgnewextagentspJson.jsp?Btype=NewAgnt&addAsExternal=true&clientEmulation=false&hostip="+d+"&hostname="+encodeURI(b),method:"POST",success:function(r){a.hide();
var t=r.responseText;publicJSON=Ext.decode(t);if(!Ext.isEmpty(t)&&r.status==200){var s=publicJSON["requestStatus"];if(s=="success"||s.indexOf("success")!=-1){var q=publicJSON["result"];Ext.MessageBox.show({title:q["title"],msg:q["message1"],buttons:Ext.Msg.OK,icon:"iconInformation",fn:function(u){Ext.getCmp("AddModRmtView").destroy();
}});}}},failure:function(){a.hide();}});}else{Ext.getCmp("AddModRmtView").destroy();}}});}}c.buildMainData();var j=publicJSON["gridRmtAgents"];Ext.getCmp("gridRmtSearch").enable();Ext.getCmp("associateDissociate").enable();Ext.getCmp("gridRmtDisplay").getStore().loadRawData(j);Ext.getCmp("gridRmtSearch").setRawValue("");
}},failure:function(){a.hide();}});},checkdots:function(){var b=Ext.getCmp("Hostname").getValue();if(b.charAt(0)=="."||b.charAt(b.length-1)=="."){Ext.Msg.show({title:"REMOTE AGENT",msg:checkdots+".",buttons:Ext.Msg.OK,icon:"iconExclamation"});return false;}else{for(var a=0;a<b.length;a++){if(b.charAt(a)=="."&&b.charAt(a+1)=="."){Ext.Msg.show({title:"REMOTE AGENT",msg:checkconsecutivedots+".",buttons:Ext.Msg.OK,icon:"iconExclamation"});
return false;}else{continue;}}}return true;},validationForAddModify:function(){var u=Ext.getCmp("HostIp").getValue();var l=Ext.getCmp("Hostname").getValue();var b=this;var x=b.checkdots();var f=/^(([0-9]+\.)+){3}[0-9]+$/;var k=f.test(l);var d=false;var g=false;var n=true;if(isDouble=="false"){n=validateSingleByte(l);
}if(btnText=="Add"){if(rmtListStr!=null){for(var q=0;q<rmtListStr.length;q++){var s=rmtListStr[q].trim();if(s.toLowerCase()==l.toLowerCase()){d=true;}}}if(remAgentCompListArr!=null&&remAgentCompListArr!=""){for(var q=0;q<remAgentCompListArr.length;q++){var h=remAgentCompListArr[q].trim();if(h.toLowerCase()==l.toLowerCase()){g=true;
}}}}var v=commonValidationsExtjs(u);var t=validateIpExtjs(u);var m=validateHostFieldExtjs(u);var w=checkspaceExtjs(u);var o=checkSpecialExtjs(u,"`~!@#$%^&*()+={}[]|;\"'<>,?/");var a=checkspaceExtjs(l);var c=checkSpecialExtjs(l,"`~!@#$%^&*()+={}[]|:;\"'<>,?\\/");var e=false;for(var r=0;r<intAgentsListStr.length;
r++){if(intAgentsListStr[r].trim()==l.trim()){e=true;break;}}if(!checkblank(u)){if(isAllowHostName=="false"){Ext.Msg.show({title:rmtPageTitle,msg:checkBlankIP+".",buttons:Ext.Msg.OK,icon:"iconExclamation"});}else{Ext.Msg.show({title:rmtPageTitle,msg:checkBlankIPName+".",buttons:Ext.Msg.OK,icon:"iconExclamation"});
}Ext.getCmp("HostIp").focus();}else{if(v!="0"){var p=this.getRespectiveMsg(v);Ext.Msg.show({title:rmtPageTitle,msg:p+".",icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(i){Ext.getCmp("HostIp").focus();}});}else{if(isAllowHostName=="false"&&t!="0"){var p=this.getRespectiveMsg(t);Ext.Msg.show({title:rmtPageTitle,msg:p+".",icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(i){Ext.getCmp("HostIp").focus();
}});}else{if(isAllowHostName=="true"&&m!="0"){var p=this.getRespectiveMsg(m);Ext.Msg.show({title:rmtPageTitle,msg:p+".",icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(i){Ext.getCmp("HostIp").focus();}});return;}else{if(isAllowHostName=="true"&&w!="0"){var p=this.getRespectiveMsg(w);Ext.Msg.show({title:rmtPageTitle,msg:p+".",icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(i){Ext.getCmp("HostIp").focus();
}});}else{if(isAllowHostName=="true"&&o!="0"){var p=this.getRespectiveMsg(o);Ext.Msg.show({title:rmtPageTitle,msg:p+".",icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(i){Ext.getCmp("HostIp").focus();}});}else{if(!checkblank(l)){Ext.Msg.show({title:rmtPageTitle,msg:checkBlankHostName+".",buttons:Ext.Msg.OK,icon:"iconExclamation"});
}else{if(l.trim().toLowerCase()=="none"){Ext.Msg.show({title:rmtPageTitle,msg:"You are not allowed to use eG reserved keyword '"+l+"' for remote agent"+".",buttons:Ext.Msg.OK,icon:"iconExclamation"});}else{if(a!="0"){var p=this.getRespectiveMsg(a);Ext.Msg.show({title:rmtPageTitle,msg:p+".",icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(i){Ext.getCmp("Hostname").focus();
}});}else{if(c!="0"){var p=this.getRespectiveMsg(c);Ext.Msg.show({title:rmtPageTitle,msg:p+".",icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(i){Ext.getCmp("Hostname").focus();}});}else{if(!x){Ext.getCmp("Hostname").focus();}else{if(k&&u!=l){Ext.Msg.show({title:rmtPageTitle,msg:hostNameIsIP+".",buttons:Ext.Msg.OK,icon:"iconExclamation"});
Ext.getCmp("Hostname").focus();}else{if(g){Ext.Msg.show({title:rmtPageTitle,msg:hostNameByOtherComp+".",buttons:Ext.Msg.OK,icon:"iconExclamation"});Ext.getCmp("Hostname").focus();}else{if(!n){Ext.Msg.show({title:rmtPageTitle,msg:checkDBL+".",buttons:Ext.Msg.OK,icon:"iconExclamation"});Ext.getCmp("Hostname").focus();
}else{if(e){Ext.Msg.show({title:rmtPageTitle,msg:intAgentMappingAlert+".",icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(i){Ext.getCmp("Hostname").focus(true);}});}else{return true;}}}}}}}}}}}}}}}},getRespectiveMsg:function(a){switch(a){case"1":return _checkIp;case"2":return _validateHostDot;case"3":return _validateHostUScore;
case"4":return _validateHostHypen;case"5":return _checkspaceIp;case"6":return _checkAlpha;case"7":return _checkspecial;case"8":return _valIp;case"9":return _validateIp;case"10":return _checknum;case"11":return _chkIpv6;case"12":return _doubleColon;case"13":return _grpIpv6;case"14":return _digitIpv6;case"15":return _validateIpv6;
case"16":return _checkNumberLabel;case"17":return _checkblank;}},associateDissociate:function(a){assignAgent="";Ext.getCmp("remoteviewport").removeAll();this.getController("RemoteAgent.controller.AssignRmtCtrl").buildFieldData();Ext.getCmp("remoteviewport").add({xtype:"assignremoteagent"});this.getController("RemoteAgent.controller.AssignRmtCtrl").afterMainRender();
},comboFromFieldLoad:function(){var c=this;this.getController("RemoteAgent.controller.AssignRmtCtrl").buildFieldData();var b=Ext.getCmp("rmtAgent").getValue();var a="null";if(b==-1){b="null";}Ext.Ajax.request({url:"RemoteAgent/data/EgConfigRemoteAgentsJson.jsp?eagent="+encodeURIComponent(b)+"&othereagent="+encodeURIComponent(a),method:"POST",success:function(d){if(d.status==200&&!Ext.isEmpty(d.responseText)){var e=d.responseText;
publicJSON=Ext.decode(e);}if(Ext.getCmp("itemselectremoteagent").fromField.store.getCount()>=1){Ext.getCmp("itemselectremoteagent").fromField.store.removeAll();}if(Ext.getCmp("itemselectremoteagent").toField.store.getCount()>=1){Ext.getCmp("itemselectremoteagent").toField.store.removeAll();}Ext.getCmp("itemselectremoteagent").fromField.store.add(publicJSON["ManagedHostByThisAgent"]);
c.getController("RemoteAgent.controller.AssignRmtCtrl").initializeFields2();if(b=="null"){Ext.getCmp("otherRmtAgent").setDisabled(true);}else{Ext.getCmp("otherRmtAgent").setDisabled(false);}Ext.getCmp("itemselectremoteagent").toField.store.add(publicJSON["ManagedHostByOthrAgnt"]);}});},comboToFieldLoad:function(){this.getController("RemoteAgent.controller.AssignRmtCtrl").buildFieldData();
var b=Ext.getCmp("rmtAgent").getValue();var a=Ext.getCmp("otherRmtAgent").getValue();if(b==-1){Ext.getCmp("otherRmtAgent").setValue(-1);b="null";}if(a==-1){a="null";}Ext.Ajax.request({url:"RemoteAgent/data/EgConfigRemoteAgentsJson.jsp?eagent="+encodeURIComponent(b)+"&othereagent="+encodeURIComponent(a),method:"POST",success:function(c){if(c.status==200&&!Ext.isEmpty(c.responseText)){var d=c.responseText;
publicJSON=Ext.decode(d);}if(Ext.getCmp("itemselectremoteagent").toField.store.getCount()>=1){Ext.getCmp("itemselectremoteagent").toField.store.removeAll();}Ext.getCmp("itemselectremoteagent").toField.store.add(publicJSON["ManagedHostByOthrAgnt"]);}});},updation:function(n){var E=this;var B=new Array();
var w=Ext.getCmp("rmtAgent");var o=w.getValue();var d=w.getStore().getCount();for(var x=0;x<d;x++){B[x]=w.getStore().getAt(x).get("valueField");}if(o=="-1"){Ext.Msg.show({title:assignRmtPageTitle,msg:publicJSON["screenLabels"]["admin.test.Please choose a remote agent"]+".",buttons:Ext.Msg.OK,icon:"iconExclamation"});
}else{var c=publicJSON["existingAgents"];if(c!=null&&c!="undefined"){var f=c.split(",");}var p=publicJSON["ManagedHostByOthrAgnt"];var g=publicJSON["UpdateLink"];var D=publicJSON["itemSelectorArray"];var h=Ext.getCmp("itemselectremoteagent").getValue();if(h==undefined){Ext.Msg.show({title:assignRmtPageTitle,msg:publicJSON["screenLabels"]["admin.remote.Please choose atleast one agent to manage or unmanage"]+".",buttons:Ext.Msg.OK,icon:"iconExclamation"});
return;}var t=new Array();var l=new Array();var r=Ext.getCmp("itemselectremoteagent").fromField.store.getCount();var e=Ext.getCmp("itemselectremoteagent").fromField.getValue();var u=new Array();for(var A=0;A<r;A++){u[u.length]=Ext.getCmp("itemselectremoteagent").fromField.store.getAt(A).get("valueField");
}if(E.remoteHasCompNick(B,u)){Ext.Msg.show({title:assignRmtPageTitle,msg:publicJSON["screenLabels"]["admin.remote.Please select another agent, as this agent name is already mapped to remote agent"]+".",buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(i){if(i==="ok"){E.comboFromFieldLoad();}}});return;
}for(var v=0;v<u.length;v++){var b=false;if(c!=null&&c.length>0){var f=c.split(",");for(var y=0;y<f.length;y++){if(u[v]==f[y]){b=true;break;}}if(!b){l[l.length]=u[v];}}else{l[l.length]=u[v];}}var q=l;if(c=="undefined"||c==null){c="null";}var s=Ext.getCmp("assignhiddenRemotecontainer");var C={xtype:"hiddenfield",name:"fmanage",value:t};
s.add(C);C={xtype:"hiddenfield",name:"existingAgents",value:c};s.add(C);C={xtype:"hiddenfield",name:"funmanage",value:q};s.add(C);var a=new Ext.LoadMask(Ext.getBody(),{msg:"Updating..."});a.show();var z=Ext.getCmp("assignremoteagent").getForm();z.submit({url:"RemoteAgent/data/EgconfigremoteagentspJson.jsp?eagent="+encodeURIComponent(o),method:"POST",timeout:500000,standardSubmit:false,success:function(k,G){a.hide();
var F=G.response.responseText;publicJSON=Ext.decode(F);if(!Ext.isEmpty(F)&&G.response.status==200){var m=publicJSON["requestStatus"];if(m=="success"||m.indexOf("success")!=-1){var i=publicJSON["resultUrl"];Ext.Msg.show({title:assignRmtPageTitle,msg:publicJSON["screenLabels"]["SucessfullyUpdated"],icon:"iconInformation",buttons:Ext.Msg.OK,fn:function(H){E.comboFromFieldLoad();
}});}else{var j=publicJSON["error"];Ext.Msg.show({title:j["title"],msg:j["message1"],icon:"iconExclamation",buttons:Ext.Msg.OK,fn:function(H){E.comboFromFieldLoad();}});}}s.removeAll();},failure:function(i,j){a.hide();s.removeAll();}});}},remoteHasCompNick:function(e,a){var g=false;if(e!=undefined&&e!=""&&a!=undefined&&a!=""){var j=new Array();
var b=new Array();if(e.indexOf(",")){j=e.toString().split(",");}if(a.indexOf(",")){b=a.toString().split(",");}for(var d=0;d<j.length;d++){var c=j[d].toLowerCase();for(var i=0;i<b.length;i++){if(c==b[i].toLowerCase()){g=true;break;}}}}return g;},backbutton:function(){if(fromPage=="AgentStatus"){window.location.href="/final/admin/EgServerList.jsp?from=AgentAssign&agentType=RemoteAgents&agentStatus="+agentState;
}else{if(fromPage=="Discovery"){window.location.href="/final/admin/EgDiscoveryPane.jsp?selectedNode=node2";}else{fromAssignRem="";Ext.getCmp("remoteviewport").removeAll();this.buildMainData();Ext.getCmp("remoteviewport").add({xtype:"remoteagents"});this.afterMainRender();}}},deleteAgent:function(a){Ext.getCmp("remoteviewport").removeAll();
this.getController("RemoteAgent.controller.DeleteRmtCtrl").buildDeleteFieldData();Ext.getCmp("remoteviewport").add({xtype:"deleteremoteagents"});this.getController("RemoteAgent.controller.DeleteRmtCtrl").afterMainRender();var b=publicJSON["remoteAgentArray"];if(b=""||b.length==0){Ext.getCmp("agentsearch").disable();
}else{Ext.getCmp("agentsearch").enable();}},agentVmStatistics:function(a){Ext.getCmp("remoteviewport").removeAll();Ext.getCmp("remoteviewport").add({xtype:"vmstatistics"});this.getController("RemoteAgent.controller.AgentVmStatistics").afterMainRender();},dwnldAgent:function(){window.location.href="/final/admin/EgDownloadAgentPack.jsp?from=Remote&fromWizard="+fromWizard;
},deletefun:function(){var a=Ext.getCmp("agents").getValue();if(a.length==0||a==""){Ext.Msg.show({title:deleteRmtPageTitle,msg:publicJSON["screenLabels"]["admin.common.Please select remote agent(s)"]+".",icon:"iconExclamation",buttons:Ext.Msg.OK});}else{Ext.MessageBox.show({title:deleteRmtPageTitle,msg:deleteMsg,fn:this.deleting,icon:"iconConfirmation",buttons:Ext.Msg.YESNO,scope:this});
}},handleDeleteSelected:function(){var e=Ext.getCmp("gridRmtDisplay").getSelectionModel().getSelection();var b="";var f=new Array();var a="";if(e==""){Ext.MessageBox.show({title:"Remote Agents",msg:noRmtSelected+".",icon:"iconExclamation",buttons:Ext.Msg.OK});return false;}for(var d=0;d<e.length;d++){b=e[d];
id=b.get("Hostname");if(id!=null){f.push(id);}}for(var c=0;c<f.length;c++){a+=f[c]+",";}Ext.Msg.show({title:"Remote Agents",msg:deleteSelected+".",icon:"iconConfirmation",buttons:Ext.Msg.YESNO,fn:function(h){if(h=="yes"){var g="from=deleteRemoteAgentsPage"+"&remoteAgents="+encodeURIComponent(a);Ext.Ajax.request({url:"RemoteAgent/data/deletegroupsremotepJson.jsp?index=Remote&"+g,method:"POST",success:function(i){var m=i.responseText;
publicJSON=Ext.decode(m);if(!Ext.isEmpty(m)&&i.status==200){var l=publicJSON["requestStatus"];if(l=="success"||l.indexOf("success")!=-1){var l=publicJSON["result"];Ext.MessageBox.show({title:l["title"],msg:l["message1"],icon:"iconInformation",buttons:Ext.Msg.OK,fn:appRmtCnt.buildMainData()});}else{var k=publicJSON["error"];
Ext.MessageBox.show({title:k["title"],msg:k["message1"],icon:"iconExclamation",buttons:Ext.Msg.OK,fn:refreshDelete});}}var j=publicJSON["gridRmtAgents"];if(j==null||j.length==0){Ext.getCmp("associateDissociate").disable();Ext.getCmp("gridRmtDisplay").store.loadData("");Ext.getCmp("gridRmtDisplay").getView().emptyText='<div class="egFlexCenterByColumnWise" style="height:98%"><div class="iconInformation"></div><div class="commonErrorMsgText" >'+NoRmtDesc+".</div></div>";
Ext.getCmp("gridRmtDisplay").getView().refresh();}else{Ext.getCmp("associateDissociate").enable();Ext.getCmp("gridRmtDisplay").getStore().loadRawData(j);}}});}}});},deleting:function(b){this.getController("RemoteAgent.controller.DeleteRmtCtrl").buildDeleteFieldData();if(b=="yes"){var a=Ext.getCmp("agents").getValue();
if(a==null){Ext.Msg.show({title:deleteRmtPageTitle,msg:publicJSON["screenLabels"]["admin.common.Please select remote agent(s)"]+".",icon:"iconExclamation",buttons:Ext.Msg.OK});}else{var d=publicJSON["deleteLink"];var c="from=deleteRemoteAgentsPage"+"&remoteAgents="+encodeURIComponent(a);Ext.Ajax.request({url:"RemoteAgent/data/deletegroupsremotepJson.jsp?index=Remote&"+c,method:"POST",success:function(e){var h=e.responseText;
publicJSON=Ext.decode(h);if(!Ext.isEmpty(h)&&e.status==200){var g=publicJSON["requestStatus"];if(g=="success"||g.indexOf("success")!=-1){var g=publicJSON["result"];Ext.MessageBox.show({title:g["title"],msg:g["message1"],icon:"iconInformation",buttons:Ext.Msg.OK,fn:refreshDelete});}else{var f=publicJSON["error"];
Ext.MessageBox.show({title:f["title"],msg:f["message1"],icon:"iconExclamation",buttons:Ext.Msg.OK,fn:refreshDelete});}}Ext.getCmp("agentsearch").setRawValue("");}});}}},mainFormEvent:function(a){this.getController("RemoteAgent.controller.DeleteRmtCtrl").buildDeleteFieldData();var b=Ext.getCmp("agentsearch").getValue();
if(b==""||b.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:"RemoteAgent/data/DeleteRemoteAgentsJson.jsp?compsearch="+b,method:"POST",success:function(c){if(c.status==200&&!Ext.isEmpty(c.responseText)){var e=c.responseText;
publicJSON=Ext.decode(e);}var d=publicJSON["searchArr"];if(d!=null&&d.length>0){Ext.getCmp("agents").show();Ext.getCmp("delRmtLabel").show();Ext.getCmp("deleteBtn").show();Ext.getCmp("NoDelSearchFound").hide();Ext.getCmp("agents").getStore().loadRawData(publicJSON["searchArr"]);}else{Ext.getCmp("agents").hide();
Ext.getCmp("delRmtLabel").hide();Ext.getCmp("deleteBtn").hide();Ext.getCmp("NoDelSearchFound").show();Ext.getCmp("DelSearch").update('<div class="egFlexCenterByColumnWise" style="height:98%"><div class="iconInformation"></div><div class="commonErrorMsgText" >'+NoRmtFound+".</div></div>");}}});},backDelButton:function(a){fromDeleteRem="";
Ext.getCmp("remoteviewport").removeAll();this.buildMainData();Ext.getCmp("remoteviewport").add({xtype:"remoteagents"});this.afterMainRender();},backVMStatisticsEvent:function(a){Ext.getCmp("remoteviewport").removeAll();this.buildMainData();Ext.getCmp("remoteviewport").add({xtype:"remoteagents"});this.afterMainRender();
},afterMainRender:function(){if(fromAssignRem!=null&&fromAssignRem=="true"){Ext.getCmp("remoteviewport").removeAll();this.getController("RemoteAgent.controller.AssignRmtCtrl").buildFieldData();Ext.getCmp("remoteviewport").add({xtype:"assignremoteagent"});this.getController("RemoteAgent.controller.AssignRmtCtrl").buildGivenAgentData(assignAgent);
this.getController("RemoteAgent.controller.AssignRmtCtrl").afterMainRender();}else{if(fromDeleteRem!=null&&fromDeleteRem=="true"){Ext.getCmp("remoteviewport").removeAll();this.getController("RemoteAgent.controller.DeleteRmtCtrl").buildDeleteFieldData();Ext.getCmp("remoteviewport").add({xtype:"deleteremoteagents"});
this.getController("RemoteAgent.controller.DeleteRmtCtrl").afterMainRender();}else{if(isLimitedAdmin=="true"){Ext.getCmp("bulkAddAgent").hide();}else{Ext.getCmp("bulkAddAgent").show();}var b=publicJSON["gridRmtAgents"];if(b==null||b.length==0){Ext.getCmp("associateDissociate").disable();Ext.getCmp("gridRmtDisplay").store.loadData("");
Ext.getCmp("gridRmtDisplay").getView().emptyText='<div class="egFlexCenterByColumnWise" style="height:98%"><div class="iconInformation"></div><div class="commonErrorMsgText" >'+NoRmtDesc+".</div></div>";Ext.getCmp("gridRmtDisplay").getView().refresh();}else{Ext.getCmp("associateDissociate").enable();
Ext.getCmp("gridRmtDisplay").getStore().loadRawData(b);}var a=publicJSON["NoRmtFound"];if(a=="true"){Ext.getCmp("gridRmtSearch").disable();}else{Ext.getCmp("gridRmtSearch").enable();}}}}});function refreshDelete(a){Ext.Ajax.request({url:"RemoteAgent/data/DeleteRemoteAgentsJson.jsp",method:"POST",async:false,success:function(b){if(b.status==200&&!Ext.isEmpty(b.responseText)){var c=b.responseText;
publicJSON=Ext.decode(c);}}});Ext.getCmp("agents").getStore().loadData(publicJSON["remoteAgentArray"]);}function refreshAssignRmt(a){var b=Ext.getCmp("rmtAgent").getValue();Ext.Ajax.request({url:"RemoteAgent/data/EgConfigRemoteAgentsJson.jsp?eagent="+encodeURIComponent(b),method:"POST",success:function(c){if(c.status==200&&!Ext.isEmpty(c.responseText)){var d=c.responseText;
publicJSON=Ext.decode(d);}if(Ext.getCmp("itemselectremoteagent").fromField.store.getCount()>=1){Ext.getCmp("itemselectremoteagent").fromField.store.removeAll();}if(Ext.getCmp("itemselectremoteagent").toField.store.getCount()>=1){Ext.getCmp("itemselectremoteagent").toField.store.removeAll();}Ext.getCmp("itemselectremoteagent").fromField.store.add(publicJSON["ManagedHostByThisAgent"]);
Ext.getCmp("itemselectremoteagent").toField.store.add(publicJSON["ManagedHostByOthrAgnt"]);}});}