var cmd=Ext.create("RemoteControl.view.ConfigureControlActionCmd");Ext.define("RemoteControl.controller.Main",{extend:"Ext.app.Controller",views:["Main"],refs:[{selector:"main",ref:"main"},{selector:"configurecontrolactionForm",ref:"configurecontrolactionForm"},{selector:"cmd",ref:"cmd"}],init:function(){var a=this;
this.control({'configurecontrolactionForm button[name="execute"]':{"click":this.showResult},'configurecontrolactionForm combo[id="commandOpts"]':{"select":this.changeCommand},"main":{"boxready":this.loadDefaultValues},"main  #upbutton":{"click":this.toggleForm},'main button[id="bckBtn"]':{"click":this.goBack}});
},loadDefaultValues:function(){var a=this;Ext.Ajax.request({url:"/final/admin/RemoteControl/data/ConfigureControlActionJson.jsp",method:"POST",params:defaultParams+"&screenWidth="+(Ext.getBody().getViewSize().width)+"&screenHeight="+(Ext.getBody().getViewSize().height),scope:this,success:function(f){var d=f.responseText;
var m=Ext.decode(d);publicJson=m;var e=a.getConfigurecontrolactionForm();var l=publicJson["screenLabels"];var h=Ext.getCmp("AgentIp");h.setValue(publicJson["pageParams"]["selectedAgent"]);var b=Ext.getCmp("AgentMode");b.setValue(publicJson["pageParams"]["selectedAgentMode"]);var g=Ext.getCmp("commandOpts");
g.getStore().loadRawData(publicJson["commandOpts"]);g.setValue(publicJson["pageParams"]["selectedCmd"]);var i=Ext.getCmp("arugumentsTextBox");i.setValue(publicJson["pageParams"]["arguments"]);var c=Ext.getCmp("outputRqrd");c.getStore().loadRawData(publicJson["yesNoOpts"]);c.setValue(publicJson["pageParams"]["outputRequired"]);
var k=Ext.getCmp("timeOutTextbox");k.setValue(publicJson["pageParams"]["selectedTimeOutPeriod"]);var j=publicJson["pageParams"]["backButtonNeeded"];if(j!=null&&j=="Yes"){Ext.getCmp("bckBtn").show();}},failure:function(b){}});},goBack:function(){window.location.href="/final/admin/EgServerList.jsp?viewFrom=RemoteControl&reqfrom=navlink&from_remote_control_page=true&s_agent_type="+agent_type+"&agentStatus="+agent_State;
},toggleForm:function(){var a=Ext.getCmp("configcontrolform");a.toggleCollapse(true);},showResult:function(){var f=this.getConfigurecontrolactionForm().getForm();var j=f.findField("AgentIp").getValue();var a=f.findField("AgentMode").getValue();var o=publicJson["agentOS"];var i=f.findField("commandOpts").getValue();
var p=f.findField("cmdSyntax").getValue();p=filterEncode(p);var m=f.findField("arugumentsTextBox").getValue();var b=f.findField("outputRqrd").getValue();var n=f.findField("timeOutTextbox").getValue();if(i=="-1"){Ext.Msg.show({title:"Remote Control",msg:commandAlert,buttons:Ext.Msg.OK,icon:"iconExclamation"});
return;}else{if(i=="-2"){i=p;if(p==""){Ext.Msg.show({title:"Remote Control",msg:"Please provide a command syntax",buttons:Ext.Msg.OK,icon:"iconExclamation"});return;}}else{if(m!=null&&(m!="none"&&m!="")){if(i=="dir"){m=filterEncode(m);i=i+" "+m;}else{i=i+" "+m;}}}}if(!checkNumberValue("+",n)||n.indexOf(".")>-1){Ext.Msg.show({title:"Remote Control",msg:timeoutInpAlert,buttons:Ext.Msg.OK,icon:"iconExclamation"});
return false;}else{var d=this.getCmd();d.hide();var k=Ext.getCmp("emtyPanel");k.hide();var h=i.replace(/\r\n|\r|\n/g,"#");var g=publicJson["hiddenQStr"];var c="isJsonResp=true&response1=yes&&agentIP="+encodeURIComponent(j)+"&agentMode1="+encodeURIComponent(a)+"&selCmd="+encodeURIComponent(i)+"&txtCmd1="+encodeURIComponent(i)+"&arguments="+encodeURIComponent(m)+"&txtCmd="+encodeURIComponent(h)+"&response="+b+"&txtTimeout="+n+g+"&agent_type="+agent_type+"&agentOS="+encodeURIComponent(o);
var e=(parseInt(n)*1000)+10000;var l=new Ext.LoadMask(Ext.getBody(),{msg:"Command is being processed. Please wait for few seconds."});l.show();Ext.Ajax.request({url:"/final/admin/RemoteControl/data/ConfigureControlActionp.jsp",method:"POST",params:c,timeout:e,scope:this,success:function(s){l.hide();var x=s.responseText;
var u=Ext.decode(x);if(!Ext.isEmpty(u)){var t=u["errorMessage"];if(t!=null&&t!="-"){var v=Ext.getCmp("emptyPanelContainer");v.update('<table height="100%"><tr><td align="center" height="100%"><table><tr><td align="center"><img src="/final/admin/eg_images/spacer.gif" class="iconExclamation"/></td></tr><tr><td align="center" class="commonErrorMsgText" height="20px">'+t+"</td></tr></table></td></tr></table>");
k.show();}else{var w=u["newMode"];if(w!=null&&w=="true"){window.location.href=u["forwardUrl"];}else{var r=u["output"];var q=Ext.getCmp("remote_cmd");q.update(r);q.doLayout();d.show();}}}},failure:function(){Ext.MessageBox.hide();l.hide();var q=Ext.getCmp("emptyPanelContainer");q.update('<table height="100%"><tr><td align="center" height="100%"><table><tr><td align="center"><img src="/final/admin/eg_images/spacer.gif" class="iconExclamation"/></td></tr><tr><td align="center" class="commonErrorMsgText" height="20px">Command execution was timed out.</td></tr></table></td></tr></table>');
k.show();}});}},changeCommand:function(b){this.getCmd().hide();Ext.getCmp("emtyPanel").hide();var a=this.getConfigurecontrolactionForm().getForm();if(b.getValue()=="-2"){a.findField("cmdSyntax").show();a.findField("arugumentsTextBox").hide();}else{a.findField("cmdSyntax").hide();a.findField("arugumentsTextBox").show();
}},resizeMe:function(){cmd.setWidth(Ext.getBody().getViewSize().width-10);cmd.setHeight(Ext.getBody().getViewSize().height-10);},showCmd:function(){cmd.show();},cmdBack:function(a){cmd.hide();}});