Ext.Msg.cls="adminAlert";Ext.Msg.layout={type:"anchor",pack:"center",align:"center"};Ext.define("AgentUpgrade.controller.Main",{extend:"Ext.app.Controller",views:["AgentUpgradeView"],requires:["AgentUpgrade.view.AgentUpgradeView"],refs:[{selector:"agentupgradeview",ref:"agentupgradeview"}],init:function(){ctrler=this;
this.buildMainData();this.control({"agentupgradeview":{"boxready":this.afterMainRender},'agentupgradeview button[id="updateTab1"]':{"click":this.updateAutoUpgrade},'agentupgradeview button[id="updateTab2"]':{"click":this.updateAgentSettings},'agentupgradeview button[id="updateTab3"]':{"click":this.updateUpgradeNow},});
},buildMainData:function(){Ext.Ajax.request({url:"AgentUpgrade/data/EgManageAgentsJson.jsp?node=tab1",method:"POST",async:false,timeout:30000,success:function(a){if(a.status==200&&!Ext.isEmpty(a.responseText)){var b=a.responseText;publicJSON=Ext.decode(b);}}});initialLoad="false";},afterMainRender:function(){var a=Ext.getCmp("autoUpgrade");
a.fromField.store.removeAll();a.toField.store.removeAll();if(publicJSON.leftEntries!=null){a.fromField.store.add(publicJSON.leftEntries);}if(publicJSON.rightEntries!=null){a.toField.store.add(publicJSON.rightEntries);}if(publicJSON.leftEntries==null&&publicJSON.rightEntries==null){Ext.getCmp("updateTab1").hide();
}},loadThisTab:function(a){if(a=="tab1"){this.loadTab1();}else{if(a=="tab2"){this.loadTab2();}else{if(a=="tab3"){this.loadTab3();}}}},loadTab1:function(){if(initialLoad=="false"){ctrler.buildMainData();ctrler.afterMainRender();}initialLoad="false";},loadTab2:function(){Ext.Ajax.request({url:"AgentUpgrade/data/EgManageAgentsJson.jsp?optvalue=interval&node=tab2",method:"POST",async:false,timeout:30000,success:function(a){if(a.status==200&&!Ext.isEmpty(a.responseText)){var b=a.responseText;
publicJSON=Ext.decode(b);}}});Ext.getCmp("upgradeCheckInts").getStore().removeAll();Ext.getCmp("upgradeStatus").getStore().removeAll();Ext.getCmp("upgradeCheckInts").getStore().loadRawData(publicJSON.timeIntervals);Ext.getCmp("upgradeCheckInts").setValue(publicJSON.selectedInterval);Ext.getCmp("upgradeStatus").getStore().loadRawData(publicJSON.upgradeModes);
Ext.getCmp("upgradeStatus").setValue(publicJSON.selectedUpgradeMode);},loadTab3:function(){Ext.Ajax.request({url:"AgentUpgrade/data/EgManageAgentsJson.jsp?optvalue=now&node=tab3",method:"POST",async:false,timeout:30000,success:function(b){if(b.status==200&&!Ext.isEmpty(b.responseText)){var c=b.responseText;
publicJSON=Ext.decode(c);}}});var a=Ext.getCmp("upgradeNowItemSel");a.fromField.store.removeAll();a.toField.store.removeAll();if(publicJSON.leftEntries!=null){a.show();a.fromField.store.add(publicJSON.leftEntries);Ext.getCmp("updateTab3").show();Ext.getCmp("updateTab3Container").show();}if(publicJSON.rightEntries!=null){a.show();
a.toField.store.add(publicJSON.rightEntries);Ext.getCmp("updateTab3").show();Ext.getCmp("updateTab3Container").show();}if(publicJSON.leftEntries==null&&publicJSON.rightEntries==null){Ext.getCmp("updateTab3").hide();Ext.getCmp("updateTab3Container").hide();a.hide();}if(publicJSON.rightEntries!=null){Ext.getCmp("wlcNote").hide();
Ext.getCmp("nextStepNote").show();Ext.getCmp("nextStepNote").update(publicJSON.upgradeNowMainMsg);Ext.getCmp("upgradeNowItemSelCont").show();}else{if(publicJSON.leftEntries==null){Ext.getCmp("nextStepNote").hide();Ext.getCmp("wlcNote").show();Ext.getCmp("upgradeNowItemSelCont").hide();Ext.getCmp("wlcNote").update(publicJSON.upgradeNowMainMsg);
}else{if(publicJSON.leftEntries!=null&&publicJSON.rightEntries==null){Ext.getCmp("nextStepNote").hide();Ext.getCmp("wlcNote").hide();Ext.getCmp("upgradeNowItemSelCont").show();}}}},updateAutoUpgrade:function(){var a=Ext.getCmp("autoUpgrade");var d="";var g=a.toField.store;for(var p=0;p<g.getCount();p++){var b=g.getAt(p).get("valueField");
var o=false;for(var l in publicJSON.rightEntries){var e=publicJSON.rightEntries[l];var k=e.valueField;if(k==b){o=true;break;}}if(!o){d+=b+"$$";}}var f="";g=a.fromField.store;for(var p=0;p<g.getCount();p++){var b=g.getAt(p).get("valueField");var o=false;for(var l in publicJSON.leftEntries){var e=publicJSON.leftEntries[l];
var k=e.valueField;if(k==b){o=true;break;}}if(!o){f+=b+"$$";}}if(f==""&&d==""){Ext.Msg.show({title:tab1Titlle,msg:alert1,buttons:Ext.Msg.OK,icon:"iconExclamation"});return;}var h="AgentUpgrade/data/EgmanageagentspJson.jsp?node=tab1";var j=Ext.getCmp("hiddenContnr");j.removeAll();var m=publicJSON.hiddenVals;
for(var c in m){j.add({xtype:"hidden",name:c,value:m[c]});}j.add({xtype:"hidden",name:"fmanage",value:filterEncode(f)});j.add({xtype:"hidden",name:"funmanage",value:filterEncode(d)});var i=this.getAgentupgradeview().getForm();var n=new Ext.LoadMask(Ext.getBody(),{msg:updating+"..."});n.show();this.getAgentupgradeview().submit({url:h,params:ctrler.encodeFieldParams(i),method:"POST",timeout:30000,success:function(q,s){n.hide();
var r=s.response.responseText;var t=Ext.decode(r);if(t.ResultAlert){Ext.Msg.show({title:t.ResultTitle,msg:t.ResultMsg,buttons:Ext.Msg.OK,icon:"iconInformation",fn:function(u){if(u=="ok"){ctrler.loadTab1();}}});}},failure:function(q,r){n.hide();}});},updateAgentSettings:function(){var e=Ext.getCmp("upgradeCheckInts").getValue();
if(e==0){Ext.Msg.show({title:tab2Title,msg:alert2,buttons:Ext.Msg.OK,icon:"iconExclamation"});return;}var d=Ext.getCmp("upgradeStatus").getValue();var g="AgentUpgrade/data/EgmanageagentspJson.jsp";var f=Ext.getCmp("hiddenContnr");f.removeAll();var c=publicJSON.hiddenVals;for(var h in c){f.add({xtype:"hidden",name:h,value:c[h]});
}var b=this.getAgentupgradeview().getForm();var a=new Ext.LoadMask(Ext.getBody(),{msg:updating+"..."});a.show();this.getAgentupgradeview().submit({url:g,method:"POST",params:ctrler.encodeFieldParams(b)+"&node=tab2",timeout:30000,success:function(i,k){a.hide();var j=k.response.responseText;var l=Ext.decode(j);
if(l.ResultAlert){Ext.Msg.show({title:l.ResultTitle,msg:l.ResultMsg,buttons:Ext.Msg.OK,icon:"iconInformation"});}},failure:function(i,j){a.hide();}});},updateUpgradeNow:function(){var a=Ext.getCmp("upgradeNowItemSel");var d="";var g=a.toField.store;for(var p=0;p<g.getCount();p++){var b=g.getAt(p).get("valueField");
var o=false;for(var l in publicJSON.rightEntries){var e=publicJSON.rightEntries[l];var k=e.valueField;if(k==b){o=true;break;}}if(!o){d+=b+"$$";}}var f="";g=a.fromField.store;for(var p=0;p<g.getCount();p++){var b=g.getAt(p).get("valueField");var o=false;for(var l in publicJSON.leftEntries){var e=publicJSON.leftEntries[l];
var k=e.valueField;if(k==b){o=true;break;}}if(!o){f+=b+"$$";}}if(f==""&&d==""){Ext.Msg.show({title:tab3Title,msg:alert1,buttons:Ext.Msg.OK,icon:"iconExclamation"});return;}var h="AgentUpgrade/data/EgmanageagentspJson.jsp?";var j=Ext.getCmp("hiddenContnr");j.removeAll();var m=publicJSON.hiddenVals;for(var c in m){j.add({xtype:"hidden",name:c,value:m[c]});
}j.add({xtype:"hidden",name:"fmanage",value:filterEncode(f)});j.add({xtype:"hidden",name:"funmanage",value:filterEncode(d)});var i=this.getAgentupgradeview().getForm();var n=new Ext.LoadMask(Ext.getBody(),{msg:updating+"..."});n.show();this.getAgentupgradeview().submit({url:h,method:"POST",params:ctrler.encodeFieldParams(i),timeout:30000,success:function(q,s){n.hide();
var r=s.response.responseText;var t=Ext.decode(r);if(t.ResultAlert){Ext.Msg.show({title:t.ResultTitle,msg:t.ResultMsg,buttons:Ext.Msg.OK,icon:"iconInformation"});ctrler.buildMainData();ctrler.afterMainRender();ctrler.loadTab3();}},failure:function(q,r){n.hide();}});},searchAgents:function(c,a){var b=this,f;
if(c=="managed"){f="managedSeacrchBox";}else{f="unmanagedSeacrchBox";}if(a==""||a.length==0){Ext.get("MyTrigger_"+f+"_0").setStyle("display","none");Ext.get("MyTrigger_"+f+"_1").setStyle("display","block");}else{Ext.get("MyTrigger_"+f+"_1").setStyle("display","none");Ext.get("MyTrigger_"+f+"_0").setStyle("display","block");
}var d="";var e="";if(a.length==0||a=="Search"){d="AgentUpgrade/data/EgManageAgentsJson.jsp";e="node=tab1&upgrade_status="+c;}else{d="AgentUpgrade/data/EgManageAgentsJson.jsp";e="node=tab1&strSearch="+encodeURICompoent(filterEncode(a))+"&upgrade_status="+c;}Ext.Ajax.request({url:d,method:"POST",params:e,async:false,timeout:30000,success:function(g){if(g.status==200&&!Ext.isEmpty(g.responseText)){var i=g.responseText;
publicJSON=Ext.decode(i);var h=Ext.getCmp("autoUpgrade");h.fromField.store.removeAll();h.toField.store.removeAll();if(publicJSON.leftEntries!=null){h.fromField.store.add(publicJSON.leftEntries);}if(publicJSON.rightEntries!=null){h.toField.store.add(publicJSON.rightEntries);}if(publicJSON.leftEntries==null&&publicJSON.rightEntries==null){Ext.getCmp("updateTab1").hide();
}}}});},encodeFieldParams:function(e){var a=new Array();a.push("node");a.push("optvalue");a.push("upgradeCheckInts");a.push("upgradeStatus");a.push("old_default_status");a.push("old_interval");a.push("alreadyEnabledAgents");a.push("fmanage");a.push("funmanage");a.push("alreadyEnabledAgents");a.push("alreadyEnabledAgents");
a.push("alreadyEnabledAgents");var g="";var c=e.getFields().items;for(var d in c){var f=c[d].name;var b=c[d].value;if(Ext.isEmpty(f)||f==undefined||a.indexOf(f)==-1){Ext.getCmp(c[d].id).submitValue=false;}}}});