Ext.define("ComponentMeasureTabSet.controller.ThreadDetails",{extend:"Ext.app.Controller",requires:["ComponentMeasureTabSet.view.ThreadDetails"],views:["ThreadDetails"],refs:[{ref:"descriptionCombo",selector:'detailediagnosis combo[itemId= "infolist"]'},{ref:"measurementCombo",selector:'detailediagnosis combo[itemId= "measurelist"]'},{ref:"timelineCombo",selector:'detailediagnosis combo[itemId= "timeline"]'},{ref:"fromHrCombo",selector:'detailediagnosis combo[itemId= "fromHr"]'},{ref:"fromMinCombo",selector:'detailediagnosis combo[itemId= "fromMin"]'},{ref:"toHrCombo",selector:'detailediagnosis combo[itemId= "toHr"]'},{ref:"toMinCombo",selector:'detailediagnosis combo[itemId= "toMin"]'},{ref:"fromDate",selector:'detailediagnosis datefield[itemId= "fromdate"]'},{ref:"toDate",selector:'detailediagnosis datefield[itemId= "todate"]'},{ref:"detailedDiagnosisPanel",selector:"detailediagnosis"},{ref:"threaddetails",selector:"threaddetails"},{ref:"detailedDiagnosisPanel",selector:"detailediagnosis"},{ref:"threadName",selector:"threaddetails multiselect"}],init:function(){this.control({"threaddetails":{"boxready":this.loadform},'threaddetails combo[id="time"]':{"select":this.timeOnChange},'threaddetails combo[id="measure"]':{"select":this.measureOnChange},'threaddetails combo[id="sortByOrder"]':{"select":this.sortOnChange},"threaddetails #threadname":{"change":this.threadOnChange},});
},timeOnChange:function(a){this.loadform(a);},measureOnChange:function(a){this.loadform(a);},sortOnChange:function(a){this.loadform(a);},threadOnChange:function(a){this.loadFormForThreadName(a);},loadFormForThreadName:function(b){var d=Ext.getCmp("threadResulPanel");var a=Ext.getCmp("time").value;var c=Ext.getCmp("threadname").value;
params="time="+a+"&details="+encodeURIComponent(c);Ext.Ajax.request({async:false,url:"/final/monitor/jvmThreads.jsp",params:params,method:"POST",success:function(e){var f=Ext.decode(e.responseText);d.update(f.tableData);}});},loadform:function(f){var c="";var b=Ext.getCmp("windowValue").selectedHref;
if(!Ext.isEmpty(b)&&b!=null&&b!=undefined){if(b.indexOf("?")>-1){c=b.substring(b.indexOf("?")+1);}var i=this.getAllFieldValues();c=c+"&s_st_time="+i.fromDate+"&s_en_time="+i.toDate+"&s_st_hr="+i.fromHr+"&s_en_hr="+i.toHr+"&s_st_min="+i.fromMin+"&s_end_min="+i.toMin+"&fromStackMeasure=true";var h=Ext.getCmp("windowValue").selectedValue;
if(!Ext.isEmpty(h)){c=c+"&sdate="+h;}if(!Ext.isEmpty(f)){var g=f.id;var n=null;var l=null;if(!Ext.isEmpty(g)){if(g=="time"){if(!Ext.isEmpty(f.value)){c=c+"&time="+f.value;}}else{if(g=="sortByOrder"){var l=f.value;c=c+"&sortby="+l;var e=Ext.getCmp("time").value;c=c+"&time="+e;}}}}Ext.getCmp("measure").hide();
Ext.getCmp("threadname").hide();Ext.getCmp("west-region-container").hide();var k=this;var a=null;Ext.Ajax.request({url:"/final/monitor/ThreadDetails.jsp?"+c,success:function(p){var o=Ext.decode(p.responseText);var r=null;if(!Ext.isEmpty(o)&&!Ext.isEmpty(o.data)){for(var s=0;s<o.data.length;s++){var q=o.data[s].name;
if(!Ext.isEmpty(q)){if(q=="memtime"){var u=o.data[s].selectedValue;if(u==null){u="";}r=o.data[s].time;k.setComboOptionsInList("time",r,u);}else{if(q=="memsortname"){var u=o.data[s].selectedValue;if(u==null){u="";}r=o.data[s].sortByOrder;k.setComboOptionsInList("sortByOrder",r,u);}}}}var t=Ext.getCmp("threadResulPanel");
t.update(o.tableData);}}});}else{var i=this.getAllFieldValues();var m=ddLink;m=threadDetailLink;if(!Ext.isEmpty(m)&&m!=null&&m!=undefined&&m.indexOf("&host")==-1&&m.indexOf("&port")==-1){m=ddLink;}c=m+="&s_st_time="+i.fromDate+"&s_en_time="+i.toDate+"&s_st_hr="+i.fromHr+"&s_en_hr="+i.toHr+"&s_st_min="+i.fromMin+"&s_end_min="+i.toMin+"&flag=1&firsttime=true&"+"newWindow=true";
c=c.replace(/(measure=)[^\&]+/,"$1"+i.measurement);var j=i.description;if(Ext.isEmpty(i.description)){j="NONE";}c=c.replace(/(info=)[^\&]+/,"$1"+j);c=c.replace("measure","s_measure");if(!Ext.isEmpty(c)){if(c.indexOf("?")>-1){c=c.substring(c.indexOf("?")+1);}}if(!Ext.isEmpty(f)){var g=f.id;var n=null;
var l=null;if(!Ext.isEmpty(g)){if(g=="time"){if(!Ext.isEmpty(f.value)){c=c+"&time="+f.value;n=Ext.getCmp("measure").value;c=c.replace(/(s_measure=)[^\&]+/,"$1"+n);}}else{if(g=="measure"){if(!Ext.isEmpty(f.value)){var e=Ext.getCmp("time").value;c=c+"&time="+e;n=f.value;c=c.replace(/(s_measure=)[^\&]+/,"$1"+n);
}}else{if(g=="sortByOrder"){var l=f.value;c=c+"&sortby="+l;var e=Ext.getCmp("time").value;c=c+"&time="+e;var n=Ext.getCmp("measure").value;c=c.replace(/(s_measure=)[^\&]+/,"$1"+n);}else{if(g=="threadnameSelect"){var d=this.getThreadName().getValue();var e=Ext.getCmp("time").value;c=c+"&time="+e;var n=Ext.getCmp("measure").value;
c=c.replace(/(s_measure=)[^\&]+/,"$1"+n);c=c+"&selectedThreadName="+encodeURIComponent(d);}}}}if(!Ext.isEmpty(n)&&!Ext.isEmpty(g)&&g!="sortByOrder"){if(n=="Total_current_threads"){l="1";}else{if(n=="Blocked_threads"){l="8";}else{if(n=="Deadlock_threads"){l="8";}else{if(n=="Waiting_threads"){l="11";}else{if(n=="Timed_waiting_threads"){l="11";
}else{l="5";}}}}}c=c+"&sortby="+l;}}}var h=Ext.getCmp("windowValue").selectedValue;if(!Ext.isEmpty(h)){c=c+"&sdate="+h;}var k=this;var a=null;Ext.Ajax.request({url:"/final/monitor/ThreadDetails.jsp?"+c,success:function(s){var y=s.responseText;if(y!=null&&y!="undefined"&&y!=undefined&&y!=""){y=Ext.decode(s.responseText);
}var q=null;if(!Ext.isEmpty(y)&&!Ext.isEmpty(y.data)){var x=0;for(var t=0;t<y.data.length;t++){var o=y.data[t].name;if(!Ext.isEmpty(o)){if(o=="memtime"){var w=y.data[t].selectedvalue;if(w==null){w="";}q=y.data[t].time;k.setComboOptionsInList("time",q,w);}else{if(o=="Measurement"){var w=y.data[t].selectedvalue;
if(w==null){w="";}q=y.data[t].measure;k.setComboOptionsInList("measure",q,w);}else{if(o=="memsortname"){var w=y.data[t].selectedValue;if(w==null){w="";}q=y.data[t].sortByOrder;k.setComboOptionsInList("sortByOrder",q,w);}else{if(o=="threadname"){var v=Ext.getCmp("threadname");var w=y.data[t].selectedValue;
q=y.data[t].threadname;k.setComboOptionsInList("threadname",q,"");var p=[];p.push(w);v.setValue(p);}}}}}x++;}if(y.data.length==x){var r=Ext.getCmp("threadResulPanel");var u=Ext.getCmp("time").value;params="time="+u+"&details="+encodeURIComponent(w);Ext.Ajax.request({async:false,url:"/final/monitor/jvmThreads.jsp",params:params,method:"POST",success:function(z){var A=Ext.decode(z.responseText);
r.update(A.tableData);}});}}else{Ext.getCmp("windowValue").close();Ext.Msg.alert("Message","No Data Available");}}});}},setComboOptionsInList:function(d,b,a){var c=Ext.getCmp(d);c.getStore().loadRawData(b);c.suspendEvents(false);if(a==""){a=c.getStore().getAt(0).get("value");}c.setValue(a);c.resumeEvents();
},getAllFieldValues:function(){var e=this.getDetailedDiagnosisPanel().jsonData;var d=new Object();if(!Ext.isEmpty(this.getDescriptionCombo())){d.description=this.getDescriptionCombo().getValue();}d.measurement=this.getMeasurementCombo().getValue();d.measurementText=this.getMeasurementCombo().getValue();
d.timeline=this.getTimelineCombo().getValue();var c=this.getFromDate().getValue();if(!Ext.isEmpty(c)){d.fromDate=Ext.Date.format(c,"m/d/Y");}var b=this.getToDate().getValue();if(!Ext.isEmpty(b)){d.toDate=Ext.Date.format(b,"m/d/Y");}var a=new Date();var g=a.getHours();var f=a.getMinutes();a=Ext.Date.format(a,"m/d/Y");
d.fromHr=this.getFromHrCombo().getValue();d.fromMin=this.getFromMinCombo().getValue();d.toHr=this.getToHrCombo().getValue();d.toMin=this.getToMinCombo().getValue();return d;},});