var cmd=Ext.create("ConfigureControlAction.view.ConfigureControlActionCmd");Ext.define("ConfigureControlAction.controller.Main",{extend:"Ext.app.Controller",views:["Main"],refs:[{selector:"main",ref:"main"},{selector:"configurecontrolactionForm",ref:"configurecontrolactionForm"},{selector:"cmd",ref:"cmd"}],init:function(){this.control({'configurecontrolactionForm button[name="execute"]':{"click":this.showResult},'configurecontrolactionForm combo[id="commandOpts"]':{"select":this.changeCommand},"main":{"boxready":this.loadDefaultFormData},"main  #upbutton":{"click":this.toggleForm},'main button[id="bckBtn"]':{"click":this.goBack}});
},goBack:function(){var a=publicJson["pageParams"]["backButtonUrl"];if(a!=null&&a=="historyBack"){window.location.href="/final/monitor/ControlAgentsp.jsp";}else{window.location.href=a;}},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 m=publicJson["agentOS"];var i=f.findField("commandOpts").getValue();var n=f.findField("cmdSyntax").getValue();n=filterEncode(n);var k=f.findField("arugumentsTextBox").getValue();var b=f.findField("outputRqrd").getValue();
var l=f.findField("timeOutTextbox").getValue();if(i=="-1"){Ext.Msg.show({title:remoteControlTitle,msg:commandAlert,buttons:Ext.Msg.OK,width:250,icon:"iconExclamation"});return;}if(i=="-2"){i=n;if(n==""){Ext.Msg.show({title:remoteControlTitle,msg:commandSynAlert,buttons:Ext.Msg.OK,width:250,icon:"iconExclamation",fn:function(){f.findField("cmdSyntax").focus();
}});return;}}else{if(k!=null&&(k!="none"&&k!="")){if(i=="dir"){k=filterEncode(k);i=i+" "+k;}else{i=i+" "+k;}}}if(!checkNumberVal("+",l)||l.indexOf(".")>-1){Ext.Msg.show({title:remoteControlTitle,msg:timeoutInpAlert,buttons:Ext.Msg.OK,width:250,icon:"iconExclamation",fn:function(){f.findField("timeOutTextbox").focus();
}});return false;}else{var d=this.getCmd();d.removeAll();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(k)+"&txtCmd="+encodeURIComponent(h)+"&response="+b+"&txtTimeout="+l+g+"&agentOS="+encodeURIComponent(m);
var e=(parseInt(l)*1000)+10000;rcLoadMask.show();Ext.Ajax.request({url:"/final/monitor/ConfigureControlActionp.jsp",method:"POST",params:c,timeout:e,scope:this,success:function(q){rcLoadMask.hide();var v=q.responseText;var s=Ext.decode(v);if(!Ext.isEmpty(s)){var r=s["errorMessage"];if(r!=null&&r!="-"){var t=Ext.getCmp("emptyPanelContainer");
r="Agent not reporting to this manager";t.update('<div class = "iconInformation" style="margin:0 auto"></div><div>'+r+"</div>");Ext.getCmp("emtyPanel").show();}else{Ext.getCmp("emtyPanel").hide();var u=s["newMode"];if(u!=null&&u=="true"){window.location.href=s["forwardUrl"];}else{if(!Ext.isEmpty(Ext.getCmp("upbutton"))&&Ext.getCmp("upbutton")!=null&&Ext.getCmp("upbutton")!=undefined){Ext.getCmp("upbutton").hide();
}var p=s["output"];var o=Ext.getCmp("remote_cmd");o.add({xtype:"panel",margin:10,height:425,style:{"border":"1px solid #000000 !important"},bodyStyle:{"background":"#054277","overflow":"auto"},id:"updatepanel",html:p});o.doLayout();d.show();}}}},failure:function(){rcLoadMask.hide();if(!Ext.isEmpty(Ext.getCmp("upbutton"))&&Ext.getCmp("upbutton")!=null&&Ext.getCmp("upbutton")!=undefined){Ext.getCmp("upbutton").hide();
}var o=Ext.getCmp("remote_cmd");var p="<ul class='f11-bold' style='color:#fff;margin:10px'><li>Command execution was timed out</li></ul>";o.add({xtype:"panel",margin:10,height:425,style:{"border":"1px solid #000000 !important"},bodyStyle:{"background":"#054277","overflow":"auto"},id:"updatepanel",html:p});
o.doLayout();d.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();},loadDefaultFormData:function(){this.getConfigurecontrolactionForm().loadFormData();}});