Ext.define("Managerlog.controller.Main",{extend:"Ext.app.Controller",views:["ManagerLogView"],refs:[{selector:"main",ref:"main"},],init:function(){this.control({"main":{"afterrender":this.afterMainRender},'main combo[id="logFileDirectory"]':{"select":this.LogFileDirectoryOnchange},'main combo[id="ipnick"]':{"select":this.IpNickOnchange},'main combo[id="logFileName"]':{"select":this.LogFileNameOnchange},'main combo[id="dateFilter"]':{"select":this.DateFilterOnchange},"main button[action=refresh]":{"click":this.RefreshOnchange},"main button[action=download]":{"click":this.DownloadOnchange}});
},afterMainRender:function(){var a=new Ext.LoadMask(Ext.getBody(),{msg:"Loading..."});a.show();Ext.Ajax.request({url:requestURL,method:"GET",success:function(d){if(d.status==200&&!Ext.isEmpty(d.responseText)){var f=d.responseText;var c=d.responseText;var b="";var e="";if(f.indexOf("~#~")>0&&f.indexOf("^^^")>0){b=(f.substring(f.indexOf("~#~")+3,f.indexOf("^^^")));
f=(f.substring(0,f.indexOf("~#~")));e=(c.substring(c.indexOf("^^^")+3));}publicJSON=Ext.decode(f);Ext.getCmp("resultTexts").setValue(e);Ext.getCmp("ipnick").setVisible(publicJSON.allowToShowMgrIP);Ext.getCmp("ipnick").getStore().suspendEvents(true);Ext.getCmp("ipnick").getStore().loadRawData(publicJSON["nickNameList"]);
Ext.getCmp("ipnick").getStore().resumeEvents();if(ip.length==0){Ext.getCmp("ipnick").select(Ext.getCmp("ipnick").getStore().getAt(0));}else{Ext.getCmp("ipnick").select(ip);}Ext.getCmp("logFileDirectory").getStore().suspendEvents(true);Ext.getCmp("logFileDirectory").getStore().loadRawData(publicJSON["logFileDirectoryList"]);
Ext.getCmp("logFileDirectory").getStore().resumeEvents();if(logDir.length==0){Ext.getCmp("logFileDirectory").select(Ext.getCmp("logFileDirectory").getStore().getAt(0));}else{Ext.getCmp("logFileDirectory").select(logDir);}Ext.getCmp("logFileName").getStore().suspendEvents(true);Ext.getCmp("logFileName").getStore().loadRawData(publicJSON["logFileNameList"]);
Ext.getCmp("logFileName").getStore().resumeEvents();if(logFile.length==0){Ext.getCmp("logFileName").select(Ext.getCmp("logFileName").getStore().getAt(0));}else{Ext.getCmp("logFileName").select(logFile);}if(publicJSON["dateFilterList"]!=""){Ext.getCmp("dateFilter").getStore().suspendEvents(true);Ext.getCmp("dateFilter").getStore().loadRawData(publicJSON["dateFilterList"]);
Ext.getCmp("dateFilter").getStore().resumeEvents();if(date.length==0){Ext.getCmp("dateFilter").select(Ext.getCmp("dateFilter").getStore().getAt(0));}else{Ext.getCmp("dateFilter").select(date);}Ext.getCmp("dateFilter").setDisabled(false);}else{Ext.getCmp("dateFilter").setDisabled(true);}Ext.getCmp("modifiedTime").setValue(b);
a.hide();}}});},IpNickOnchange:function(){var a=new Ext.LoadMask(Ext.getBody(),{msg:"Loading..."});a.show();var d=Ext.getCmp("ipnick").getValue();var c=Ext.getCmp("logFileDirectory").getValue();var b=Ext.getCmp("logFileName").getValue();var e="managerIP="+encodeURI(d);Ext.Ajax.request({url:"Managerlog/data/managerLogJson.jsp",method:"GET",params:e,success:function(k){if(k.status==200&&!Ext.isEmpty(k.responseText)){var g=k.responseText;
var m="";var h="";if(g.indexOf("#$#")==0){Ext.Msg.alert("Alert Box",g.substring(g.indexOf("#$#")+3,g.indexOf("^$^")));if(g.indexOf("^$^")>0&&g.indexOf("~#~")>0){m=g.substring(g.indexOf("^$^")+3);h=m.substring(m.indexOf("~#~")+3);}publicJSON=Ext.decode(m.substring(0,m.indexOf("~#~")));Ext.getCmp("logFileDirectory").getStore().suspendEvents(true);
Ext.getCmp("logFileDirectory").getStore().loadRawData(publicJSON["logFileDirectoryList"]);Ext.getCmp("logFileDirectory").getStore().resumeEvents();Ext.getCmp("logFileDirectory").select(Ext.getCmp("logFileDirectory").getStore().getAt(0));Ext.getCmp("logFileName").reset();Ext.getCmp("dateFilter").reset();
Ext.getCmp("resultTexts").reset();}else{var p=k.responseText;var j="";var f="";if(g.indexOf("~#~")>0&&g.indexOf("^^^")>0){j=(g.substring(g.indexOf("~#~")+3,g.indexOf("^^^")));g=(g.substring(0,g.indexOf("~#~")));f=(p.substring(p.indexOf("^^^")+3));}publicJSON=Ext.decode(g);Ext.getCmp("resultTexts").setValue(f);
Ext.getCmp("logFileDirectory").getStore().suspendEvents(true);Ext.getCmp("logFileDirectory").getStore().loadRawData(publicJSON["logFileDirectoryList"]);Ext.getCmp("logFileDirectory").getStore().resumeEvents();Ext.getCmp("logFileDirectory").select(Ext.getCmp("logFileDirectory").getStore().getAt(0));Ext.getCmp("logFileName").getStore().suspendEvents(true);
Ext.getCmp("logFileName").getStore().loadRawData(publicJSON["logFileNameList"]);Ext.getCmp("logFileName").getStore().resumeEvents();var n=Ext.getCmp("logFileName").store.getCount();var o=false;for(var l=0;l<n;l++){if(Ext.getCmp("logFileName").getStore().getAt(l)==b){Ext.getCmp("logFileName").select(Ext.getCmp("logFileName").getStore().getAt(l));
o=true;break;}}if(!o){Ext.getCmp("logFileName").select(Ext.getCmp("logFileName").getStore().getAt(0));}Ext.getCmp("dateFilter").getStore().suspendEvents(true);Ext.getCmp("dateFilter").getStore().loadRawData(publicJSON["dateFilterList"]);Ext.getCmp("dateFilter").getStore().resumeEvents();Ext.getCmp("dateFilter").select(Ext.getCmp("dateFilter").getStore().getAt(0));
Ext.getCmp("modifiedTime").setValue(j);if(Ext.getCmp("dateFilter").getValue()==-1){Ext.getCmp("dateFilter").setDisabled(true);}else{Ext.getCmp("dateFilter").setDisabled(false);}}a.hide();}}});},LogFileDirectoryOnchange:function(){var a=new Ext.LoadMask(Ext.getBody(),{msg:"Loading..."});a.show();var d=Ext.getCmp("ipnick").getValue();
var c=Ext.getCmp("logFileDirectory").getValue();var b=Ext.getCmp("logFileName").getValue();var e="managerIP="+encodeURI(d)+"&logsDir="+encodeURI(c);Ext.Ajax.request({url:"Managerlog/data/managerLogJson.jsp",method:"GET",params:e,success:function(h){if(h.status==200&&!Ext.isEmpty(h.responseText)){var j=h.responseText;
var g=h.responseText;var f="";var i="";if(j.indexOf("~#~")>0&&j.indexOf("^^^")>0){f=(j.substring(j.indexOf("~#~")+3,j.indexOf("^^^")));j=(j.substring(0,j.indexOf("~#~")));i=(g.substring(g.indexOf("^^^")+3));}publicJSON=Ext.decode(j);Ext.getCmp("resultTexts").setValue(i);Ext.getCmp("logFileName").getStore().suspendEvents(true);
Ext.getCmp("logFileName").getStore().loadRawData(publicJSON["logFileNameList"]);Ext.getCmp("logFileName").getStore().resumeEvents();Ext.getCmp("logFileName").select(Ext.getCmp("logFileName").getStore().getAt(0));Ext.getCmp("dateFilter").getStore().suspendEvents(true);Ext.getCmp("dateFilter").getStore().loadRawData(publicJSON["dateFilterList"]);
Ext.getCmp("dateFilter").getStore().resumeEvents();Ext.getCmp("dateFilter").select(Ext.getCmp("dateFilter").getStore().getAt(0));Ext.getCmp("modifiedTime").setValue(f);if(Ext.getCmp("dateFilter").getValue()==-1){Ext.getCmp("dateFilter").setDisabled(true);}else{Ext.getCmp("dateFilter").setDisabled(false);
}a.hide();}}});},LogFileNameOnchange:function(){var a=new Ext.LoadMask(Ext.getBody(),{msg:"Loading..."});a.show();var d=Ext.getCmp("ipnick").getValue();var c=Ext.getCmp("logFileDirectory").getValue();var b=Ext.getCmp("logFileName").getValue();var e="managerIP="+encodeURI(d)+"&mgrLogFile="+encodeURI(b)+"&logsDir="+encodeURI(c);
Ext.Ajax.request({url:"Managerlog/data/managerLogJson.jsp",method:"GET",params:e,success:function(h){if(h.status==200&&!Ext.isEmpty(h.responseText)){var j=h.responseText;var g=h.responseText;var f="";var i="";if(j.indexOf("~#~")>0&&j.indexOf("^^^")>0){f=(j.substring(j.indexOf("~#~")+3,j.indexOf("^^^")));
j=(j.substring(0,j.indexOf("~#~")));i=(g.substring(g.indexOf("^^^")+3));}publicJSON=Ext.decode(j);Ext.getCmp("resultTexts").setValue(i);Ext.getCmp("dateFilter").getStore().suspendEvents(true);Ext.getCmp("dateFilter").getStore().loadRawData(publicJSON["dateFilterList"]);Ext.getCmp("dateFilter").getStore().resumeEvents();
Ext.getCmp("dateFilter").select(Ext.getCmp("dateFilter").getStore().getAt(0));Ext.getCmp("modifiedTime").setValue(f);if(Ext.getCmp("dateFilter").getValue()==-1){Ext.getCmp("dateFilter").setDisabled(true);}else{Ext.getCmp("dateFilter").setDisabled(false);}a.hide();}}});},DateFilterOnchange:function(){var a=new Ext.LoadMask(Ext.getBody(),{msg:"Loading..."});
a.show();var e=Ext.getCmp("ipnick").getValue();var c=Ext.getCmp("logFileDirectory").getValue();var b=Ext.getCmp("logFileName").getValue();var d=Ext.getCmp("dateFilter").getValue();var f="filter="+d+"&mgrLogFile="+encodeURI(b)+"&managerIP="+e+"&logsDir="+encodeURI(c);Ext.Ajax.request({url:"Managerlog/data/managerLogJson.jsp",method:"GET",params:f,success:function(i){if(i.status==200&&!Ext.isEmpty(i.responseText)){var k=i.responseText;
var h=i.responseText;var g="";var j="";if(k.indexOf("~#~")>0&&k.indexOf("^^^")>0){g=(k.substring(k.indexOf("~#~")+3,k.indexOf("^^^")));k=(k.substring(0,k.indexOf("~#~")));j=(h.substring(h.indexOf("^^^")+3));}publicJSON=Ext.decode(k);Ext.getCmp("resultTexts").setValue(j);Ext.getCmp("modifiedTime").setValue(g);
a.hide();}}});},RefreshOnchange:function(){var a=new Ext.LoadMask(Ext.getBody(),{msg:"Loading..."});a.show();Ext.getCmp("resultTexts").reset();var e=Ext.getCmp("ipnick").getValue();var c=Ext.getCmp("logFileDirectory").getValue();var b=Ext.getCmp("logFileName").getValue();var d=Ext.getCmp("dateFilter").getValue();
var f="managerIP="+encodeURI(e)+"&mgrLogFile="+encodeURI(b)+"&logsDir="+encodeURI(c);if(!Ext.isEmpty(d)&&d!="-1"){f+="&filter="+d;}Ext.Ajax.request({url:"Managerlog/data/managerLogJson.jsp",method:"POST",params:f,success:function(i){if(i.status==200&&!Ext.isEmpty(i.responseText)){var k=i.responseText;
var h=i.responseText;var g="";var j="";if(k.indexOf("~#~")>0&&k.indexOf("^^^")>0){g=(k.substring(k.indexOf("~#~")+3,k.indexOf("^^^")));k=(k.substring(0,k.indexOf("~#~")));j=(h.substring(h.indexOf("^^^")+3));}publicJSON=Ext.decode(k);Ext.getCmp("resultTexts").setValue(j);Ext.getCmp("modifiedTime").setValue(g);
Ext.getCmp("dateFilter").select(d);a.hide();}}});},DownloadOnchange:function(){var d=Ext.getCmp("ipnick").getValue();var b=Ext.getCmp("logFileDirectory").getValue();var a=Ext.getCmp("logFileName").getValue();var c=Ext.getCmp("dateFilter").getValue();window.location.href="Managerlog/data/managerLogJson.jsp?managerIP="+encodeURI(d)+"&mgrLogFile="+encodeURI(a)+"&logsDir="+encodeURI(b)+"&filter="+encodeURI(c)+"&download=true&com.eg.CSRF_NONCE="+csrfToken;
}});