Ext.define("AgentXmx.controller.Main",{extend:"Ext.app.Controller",views:["AgentXmxView"],refs:[{selector:"main",ref:"main"},],init:function(){ctlr=this;this.control({"main":{"afterrender":this.afterMainRender},'main button[id="updateBtn"]':{"click":this.update},"main button[action=goback]":{"click":this.goBack}});
},afterMainRender:function(){Ext.getCmp("agentName").setValue(componentName);var a=new Ext.LoadMask(Ext.getBody(),{msg:pleaseAlert});a.show();loading=true;var b="componentName="+encodeURI(componentName);Ext.Ajax.request({url:"AgentXmx/data/getXmx.jsp",params:b,method:"GET",timeout:300000,success:function(c){if(c.status==200&&!Ext.isEmpty(c.responseText)){var d=c.responseText;
xmxJson=Ext.decode(d);Ext.getCmp("updateBtn").setVisible(false);Ext.getCmp("currentXmx").setVisible(false);Ext.getCmp("newXmxValue").setVisible(false);if(xmxJson.timedout){Ext.Msg.alert(pageName,timeoutAlert);}else{var e=xmxJson.XmxValue;if(e.toLowerCase().charAt(e.length-1)=="m"){xmxUnit=e.substring(e.length-1);
e=e.substring(0,e.length-1);}Ext.getCmp("currentXmx").setValue(e);Ext.getCmp("currentXmx").setVisible(true);Ext.getCmp("newXmxValue").setVisible(true);Ext.getCmp("updateBtn").setVisible(true);}a.hide();loading=false;}},failure:function(c){a.hide();loading=false;}});},goBack:function(){var a="/final/admin/EgServerList.jsp";
if(showAgentInformationView=="true"){a+="?from=upgradeAdvancedSearchPage&agentIp="+encodeURI(agentID);}else{if(viewFrom=="AgentXmx"){a+="?viewFrom="+viewFrom+"&s_agent_type="+agentType+"&agentStatus="+agentStatus;}}window.location.href=a;},update:function(){var b=Ext.getCmp("currentXmx").getValue().trim();
var a=Ext.getCmp("newXmxValue").getValue().trim();if(!checkblank(a)){Ext.MessageBox.alert(pageName,emptyAlert);}else{if(a.indexOf(" ")>-1){Ext.MessageBox.alert(pageName,spaceAlert);}else{if(invalidCharsFound(a)){Ext.MessageBox.alert(pageName,numberAlert);}else{if(b==a){Ext.MessageBox.alert(pageName,sameValueAlert);
}else{if(parseInt(a)<256){Ext.MessageBox.alert(pageName,negativeAlert);}else{Ext.Msg.show({title:pageName,msg:restartAlert,buttons:Ext.Msg.YESNO,icon:"iconConfirmation",fn:function(d){if(d=="yes"){a+=xmxUnit;var c=new Ext.LoadMask(Ext.getBody(),{msg:pleaseAlert});c.show();loading=true;var e="componentName="+encodeURI(componentName)+"&currentXmxValue="+b+"&newXmxValue="+a;
Ext.Ajax.request({url:"AgentXmx/data/setXmx.jsp",params:e,method:"GET",timeout:300000,success:function(f){if(f.status==200&&!Ext.isEmpty(f.responseText)){var h=f.responseText;xmxJson=Ext.decode(h);var g="";if(xmxJson.timedout){g=timeoutAlert;}else{if(xmxJson.XmxValue.toLowerCase()=="done"){g=updatedMessage;
}else{g=xmxJson.XmxValue;}}Ext.Msg.show({title:pageName,msg:g,buttons:Ext.Msg.YES,icon:"iconConfirmation",fn:function(i){if(i=="yes"){c.hide();loading=false;ctlr.goBack();}}});c.hide();loading=false;}},failure:function(f){c.hide();loading=false;}});}else{if(d=="no"){}}}});}}}}}}});function invalidCharsFound(c){var a="0123456789";
for(var b=0;b<c.length;b++){if(a.indexOf(c.charAt(b))==-1){return true;}}return false;}