Ext.Msg.cls="adminAlert";Ext.define("ViewThreshold.controller.Main",{extend:"Ext.app.Controller",refs:[{selector:"threshview",ref:"threshview"},{selector:"print",ref:"print"},{selector:"downloadutils",ref:"downloadutils"}],init:function(){main=this;this.control({"threshview":{"afterrender":this.afterMainRender},'threshview combo[id="criteria"]':{"select":this.getDetails},'threshview combo[id="userOption"]':{"select":this.getDetails},'threshview combo[id="compTypeCombo"]':{"select":this.compTypeComboLoad},'threshview combo[id="compNameCombo"]':{"select":this.compNameComboLoad},'threshview combo[id="testCombo"]':{"select":this.testNameComboLoad},'threshview combo[id="threshTypeCombo"]':{"select":this.threshTypeComboLoad},'threshview button[id="submitBtn"]':{"click":this.updateData},'threshview button[id="saveBtn"]':{"click":this.savePdf},'threshview button[id="printBtn"]':{"click":this.printData},'threshview button[id="csvBtn"]':{"click":this.csvData}});
},getDetails:function(e){Ext.getCmp("saveBtn").setDisabled(true);Ext.getCmp("printBtn").setDisabled(true);Ext.getCmp("csvBtn").setDisabled(true);if(Ext.getCmp("resultPanel").isVisible()){Ext.getCmp("resultPanel").hide();}var d=Ext.getCmp("userOption");var h=Ext.getCmp("criteria");var c=Ext.getCmp("compTypeCombo");
var b=Ext.getCmp("compNameCombo");var a=Ext.getCmp("testCombo");var g=Ext.getCmp("threshTypeCombo");if(h.getValue()=="Component"||e.id=="criteria"){d.setValue("");}var f="criteria="+h.getValue()+"&userOption="+d.getValue();Ext.Ajax.request({url:"ViewThreshold/data/EgThreshDetailViewJson.jsp?"+f,method:"POST",timeout:120000,success:function(i){if(i.status==200&&!Ext.isEmpty(i.responseText)){publicJson=Ext.decode(i.responseText);
h.getStore().loadRawData(publicJson.viewByArr);h.setValue(publicJson.selectedCriteria);if(publicJson.selectedCriteria!="Component"){d.setFieldLabel(publicJson.specViewByTitle);d.getStore().loadRawData(publicJson.specViewByArr);d.setValue(publicJson.selectedUserOptionText);d.show();}else{d.hide();}Ext.getCmp("compTypeCombo").getStore().clearFilter(true);
Ext.getCmp("compTypeCombo").getStore().loadRawData(publicJson["threshCompTypeArr"]);Ext.getCmp("compNameCombo").getStore().clearFilter(true);Ext.getCmp("compNameCombo").getStore().loadRawData(publicJson["threshCompNameArr"]);Ext.getCmp("testCombo").getStore().clearFilter(true);Ext.getCmp("testCombo").getStore().loadRawData(publicJson["threshTestNameArr"]);
Ext.getCmp("threshTypeCombo").getStore().loadRawData(publicJson["threshTypeArr"]);Ext.getCmp("compTypeCombo").setValue(publicJson["threshCompTypeArr"][0].valueField);Ext.getCmp("compNameCombo").setValue(publicJson["threshCompNameArr"][0].valueField);Ext.getCmp("testCombo").setValue(publicJson["threshTestNameArr"][0].valueField);
Ext.getCmp("threshTypeCombo").setValue(publicJson["threshTypeArr"][0].valueField);}},failure:function(i,j){Ext.MessageBox.alert("Ajax Failed","Error in updating details");}});},afterMainRender:function(){Ext.getCmp("saveBtn").setDisabled(true);Ext.getCmp("printBtn").setDisabled(true);Ext.getCmp("csvBtn").setDisabled(true);
if(Ext.getCmp("resultPanel").isVisible()){Ext.getCmp("resultPanel").hide();}Ext.Ajax.request({url:"ViewThreshold/data/EgThreshDetailViewJson.jsp?reqfrom=navlink",method:"post",scope:this,success:function(c){var d=c.responseText;publicJson=Ext.decode(d);var b=Ext.getCmp("userOption");var e=Ext.getCmp("criteria");
e.getStore().loadRawData(publicJson["viewByArr"]);e.setValue(publicJson.selectedCriteria);if(publicJson.selectedCriteria!="Component"){b.getStore().loadRawData(publicJson.specViewByArr);b.setValue(publicJson.selectedUserOptionText);b.setFieldLabel(publicJson.specViewByTitle);b.show();}else{b.hide();}var a=publicJson["isSubmitDisabled"];
if(a){Ext.getCmp("submitBtn").setDisabled(true);}else{Ext.getCmp("submitBtn").setDisabled(false);}Ext.getCmp("compTypeCombo").getStore().clearFilter(true);Ext.getCmp("compTypeCombo").getStore().loadRawData(publicJson["threshCompTypeArr"]);Ext.getCmp("compNameCombo").getStore().clearFilter(true);Ext.getCmp("compNameCombo").getStore().loadRawData(publicJson["threshCompNameArr"]);
Ext.getCmp("testCombo").getStore().clearFilter(true);Ext.getCmp("testCombo").getStore().loadRawData(publicJson["threshTestNameArr"]);Ext.getCmp("threshTypeCombo").getStore().loadRawData(publicJson["threshTypeArr"]);Ext.getCmp("compTypeCombo").setValue(publicJson["threshCompTypeArr"][0].valueField);Ext.getCmp("compNameCombo").setValue(publicJson["threshCompNameArr"][0].valueField);
Ext.getCmp("testCombo").setValue(publicJson["threshTestNameArr"][0].valueField);Ext.getCmp("threshTypeCombo").setValue(publicJson["threshTypeArr"][0].valueField);if(!Ext.isEmpty(criteria)&&criteria.toLowerCase()!="component"){e.setValue(criteria);if(!Ext.isEmpty(userOption)){b.setValue(userOption);}if(Ext.isEmpty(compType)){Ext.getCmp("userOption").fireEvent("select",Ext.getCmp("userOption"));
}}if(!Ext.isEmpty(compType)){if(!Ext.isEmpty(criteria)){e.setValue(criteria);}if(!Ext.isEmpty(userOption)){b.setValue(userOption);b.show();}Ext.getCmp("compTypeCombo").setValue(compType);Ext.getCmp("compTypeCombo").fireEvent("select",Ext.getCmp("compTypeCombo"));}if(!Ext.isEmpty(comp)){Ext.getCmp("compNameCombo").setValue(comp);
Ext.getCmp("compNameCombo").fireEvent("select",Ext.getCmp("compNameCombo"));}if(!Ext.isEmpty(test)){Ext.getCmp("testCombo").setValue(test);Ext.getCmp("testCombo").fireEvent("select",Ext.getCmp("testCombo"));}if(!Ext.isEmpty(typeThresh)){Ext.getCmp("threshTypeCombo").setValue(typeThresh);Ext.getCmp("threshTypeCombo").fireEvent("select",Ext.getCmp("threshTypeCombo"));
}}});},compNameComboLoad:function(){Ext.getCmp("saveBtn").setDisabled(true);Ext.getCmp("printBtn").setDisabled(true);Ext.getCmp("csvBtn").setDisabled(true);if(Ext.getCmp("resultPanel").isVisible()){Ext.getCmp("resultPanel").hide();}var b=Ext.getCmp("compTypeCombo").getValue();var a=Ext.getCmp("compNameCombo").getValue();
var e=Ext.getCmp("criteria").getValue();var c=Ext.getCmp("userOption").getValue();var d="&criteria="+e+"&userOption="+c;if((b==null||b=="undefined"||b=="-1")){this.afterMainRender();}else{if((b!=null&&!Ext.isEmpty(b)&&b!="-1")&&(Ext.isEmpty(a)||a=="-1")){Ext.Ajax.request({url:"ViewThreshold/data/EgThreshDetailViewJson.jsp?eg_compType="+encodeURIComponent(b)+d,method:"post",scope:this,async:false,success:function(f){var g=f.responseText;
publicJson=Ext.decode(g);Ext.getCmp("compNameCombo").getStore().clearFilter(true);Ext.getCmp("compNameCombo").getStore().removeAll();Ext.getCmp("compNameCombo").getStore().loadRawData(publicJson["threshCompNameArr"]);Ext.getCmp("testCombo").getStore().clearFilter(true);Ext.getCmp("testCombo").getStore().removeAll();
Ext.getCmp("testCombo").getStore().loadRawData(publicJson["threshTestNameArr"]);Ext.getCmp("threshTypeCombo").getStore().removeAll();Ext.getCmp("threshTypeCombo").getStore().loadRawData(publicJson["threshTypeArr"]);Ext.getCmp("compNameCombo").setValue(publicJson["threshCompNameArr"][0].valueField);Ext.getCmp("testCombo").setValue(publicJson["threshTestNameArr"][0].valueField);
Ext.getCmp("threshTypeCombo").setValue(publicJson["threshTypeArr"][0].valueField);}});}else{Ext.Ajax.request({url:"ViewThreshold/data/EgThreshDetailViewJson.jsp?eg_compType="+encodeURIComponent(b)+"&eg_host="+encodeURIComponent(a)+d,method:"post",scope:this,async:false,success:function(f){var g=f.responseText;
publicJson=Ext.decode(g);Ext.getCmp("testCombo").getStore().clearFilter(true);Ext.getCmp("testCombo").getStore().removeAll();Ext.getCmp("testCombo").getStore().loadRawData(publicJson["threshTestNameArr"]);Ext.getCmp("threshTypeCombo").getStore().removeAll();Ext.getCmp("threshTypeCombo").getStore().loadRawData(publicJson["threshTypeArr"]);
Ext.getCmp("testCombo").setValue(publicJson["threshTestNameArr"][0].valueField);Ext.getCmp("testCombo").fireEvent("select",Ext.getCmp("testCombo"));}});}}},testNameComboLoad:function(){Ext.getCmp("saveBtn").setDisabled(true);Ext.getCmp("printBtn").setDisabled(true);Ext.getCmp("csvBtn").setDisabled(true);
if(Ext.getCmp("resultPanel").isVisible()){Ext.getCmp("resultPanel").hide();}var f=Ext.getCmp("criteria").getValue();var d=Ext.getCmp("userOption").getValue();var e="&criteria="+f+"&userOption="+d;var c=Ext.getCmp("compTypeCombo").getValue();var b=Ext.getCmp("compNameCombo").getValue();var a=Ext.getCmp("testCombo").getValue();
if(c==null||Ext.isEmpty(c)){this.afterMainRender();}else{if((c!=null&&!Ext.isEmpty(c)&&c!="-1")&&(Ext.isEmpty(b)||b=="-1")){Ext.Ajax.request({url:"ViewThreshold/data/EgThreshDetailViewJson.jsp?eg_compType="+encodeURIComponent(c)+e,method:"post",scope:this,async:false,success:function(g){var h=g.responseText;
publicJson=Ext.decode(h);Ext.getCmp("compNameCombo").getStore().clearFilter(true);Ext.getCmp("compNameCombo").getStore().removeAll();Ext.getCmp("compNameCombo").getStore().loadRawData(publicJson["threshCompNameArr"]);Ext.getCmp("testCombo").getStore().clearFilter(true);Ext.getCmp("testCombo").getStore().removeAll();
Ext.getCmp("testCombo").getStore().loadRawData(publicJson["threshTestNameArr"]);Ext.getCmp("threshTypeCombo").getStore().removeAll();Ext.getCmp("threshTypeCombo").getStore().loadRawData(publicJson["threshTypeArr"]);Ext.getCmp("compNameCombo").setValue(publicJson["threshCompNameArr"][0].valueField);Ext.getCmp("testCombo").setValue(publicJson["threshTestNameArr"][0].valueField);
Ext.getCmp("threshTypeCombo").setValue(publicJson["threshTypeArr"][0].valueField);}});}else{if((!Ext.isEmpty(c)&&c!="-1")&&(!Ext.isEmpty(b)&&b!="-1")&&(Ext.isEmpty(a)||a=="-1")){Ext.Ajax.request({url:"ViewThreshold/data/EgThreshDetailViewJson.jsp?eg_compType="+encodeURIComponent(c)+"&eg_host="+encodeURIComponent(b)+e,method:"post",scope:this,async:false,success:function(g){var h=g.responseText;
publicJson=Ext.decode(h);Ext.getCmp("testCombo").getStore().clearFilter(true);Ext.getCmp("testCombo").getStore().removeAll();Ext.getCmp("testCombo").getStore().loadRawData(publicJson["threshTestNameArr"]);Ext.getCmp("threshTypeCombo").getStore().removeAll();Ext.getCmp("threshTypeCombo").getStore().loadRawData(publicJson["threshTypeArr"]);
Ext.getCmp("testCombo").setValue(publicJson["threshTestNameArr"][0].valueField);Ext.getCmp("threshTypeCombo").setValue(publicJson["threshTypeArr"][0].valueField);}});}else{Ext.Ajax.request({url:"ViewThreshold/data/EgThreshDetailViewJson.jsp?eg_compType="+encodeURIComponent(c)+"&eg_host="+encodeURIComponent(b)+"&eg_test="+a+e,method:"post",scope:this,async:false,success:function(g){var h=g.responseText;
publicJson=Ext.decode(h);Ext.getCmp("threshTypeCombo").getStore().removeAll();Ext.getCmp("threshTypeCombo").getStore().loadRawData(publicJson["threshTypeArr"]);Ext.getCmp("threshTypeCombo").setValue(publicJson["threshTypeArr"][0].valueField);Ext.getCmp("threshTypeCombo").fireEvent("select",Ext.getCmp("threshTypeCombo"));
}});}}}},compTypeComboLoad:function(){Ext.getCmp("saveBtn").setDisabled(true);Ext.getCmp("printBtn").setDisabled(true);Ext.getCmp("csvBtn").setDisabled(true);if(Ext.getCmp("resultPanel").isVisible()){Ext.getCmp("resultPanel").hide();}var a=Ext.getCmp("compTypeCombo").getValue();if((a==null||a=="undefined"||a=="-1")){this.afterMainRender();
}else{if(a!=null&&a!="undefined"&&a!="-1"){var d=Ext.getCmp("criteria").getValue();var b=Ext.getCmp("userOption").getValue();var c="&criteria="+d+"&userOption="+b;Ext.Ajax.request({url:"ViewThreshold/data/EgThreshDetailViewJson.jsp?eg_compType="+encodeURIComponent(a)+c,method:"post",scope:this,async:false,success:function(f){var g=f.responseText;
publicJson=Ext.decode(g);var e=Ext.getCmp("userOption");var h=Ext.getCmp("criteria");h.getStore().loadRawData(publicJson["viewByArr"]);h.setValue(publicJson.selectedCriteria);if(publicJson.selectedCriteria!="Component"){e.getStore().loadRawData(publicJson.specViewByArr);e.setValue(publicJson.selectedUserOptionText);
e.setFieldLabel(publicJson.specViewByTitle);e.show();}else{e.hide();}Ext.getCmp("compNameCombo").getStore().clearFilter(true);Ext.getCmp("compNameCombo").getStore().removeAll();Ext.getCmp("compNameCombo").getStore().loadRawData(publicJson["threshCompNameArr"]);Ext.getCmp("compNameCombo").setValue(publicJson["threshCompNameArr"][0].valueField);
Ext.getCmp("compNameCombo").fireEvent("select",Ext.getCmp("compNameCombo"));}});}}},threshTypeComboLoad:function(){Ext.getCmp("saveBtn").setDisabled(true);Ext.getCmp("printBtn").setDisabled(true);Ext.getCmp("csvBtn").setDisabled(true);var c=Ext.getCmp("compTypeCombo").getValue();var b=Ext.getCmp("compNameCombo").getValue();
var a=Ext.getCmp("testCombo").getValue();var g=Ext.getCmp("threshTypeCombo").getValue();if(Ext.getCmp("resultPanel").isVisible()){Ext.getCmp("resultPanel").hide();}var f=Ext.getCmp("criteria").getValue();var d=Ext.getCmp("userOption").getValue();var e="&criteria="+f+"&userOption="+d;Ext.Ajax.request({url:"ViewThreshold/data/EgThreshDetailViewJson.jsp?eg_compType="+encodeURIComponent(c)+"&eg_host="+encodeURIComponent(b)+"&eg_test="+encodeURIComponent(a)+"&eg_threshType="+encodeURIComponent(g)+e,method:"post",scope:this,async:false,success:function(h){var i=h.responseText;
publicJson=Ext.decode(i);}});},updateData:function(d){var i=this;var h=Ext.getCmp("compTypeCombo").getValue();var e=Ext.getCmp("compNameCombo").getValue();var g=Ext.getCmp("testCombo").getValue();var l=Ext.getCmp("threshTypeCombo").getValue();var a="ViewThreshold/data/EgThreshDetailViewJson.jsp?";var c="true";
if(h=="-1"){Ext.Msg.show({title:pageName,msg:selCTypeMsg,buttons:Ext.Msg.OK,icon:"iconExclamation"});return;}else{if(e=="-1"){Ext.Msg.show({title:pageName,msg:selCNameMsg,buttons:Ext.Msg.OK,icon:"iconExclamation"});return;}else{if(g=="-1"){Ext.Msg.show({title:pageName,msg:selTNameMsg,buttons:Ext.Msg.OK,icon:"iconExclamation"});
return;}else{if(l=="-1"){Ext.Msg.show({title:pageName,msg:selTTypeMsg,buttons:Ext.Msg.OK,icon:"iconExclamation"});return;}}}}var k=Ext.getCmp("criteria").getValue();var b=Ext.getCmp("userOption").getValue();var f="&criteria="+k+"&userOption="+b;a=a+"fin=yes&onSubmit=true&eg_host="+encodeURIComponent(e)+"&eg_compType="+encodeURIComponent(h)+"&eg_threshType="+encodeURIComponent(l)+"&PDF="+c+"&eg_test="+encodeURIComponent(g)+"&fromCT=false"+f;
var j=Ext.getCmp("viewportId");myMask=new Ext.LoadMask(j,{msg:"Loading..."});myMask.show();Ext.Ajax.request({url:a,method:"POST",timeout:120000,scope:this,success:function(m){if(m.status==200&&!Ext.isEmpty(m.responseText)){var p=m.responseText;var o=Ext.decode(p);if(!Ext.isEmpty(o)){if(Ext.getCmp("resultPanel").isHidden()){Ext.getCmp("resultPanel").show();
Ext.getCmp("resultPanel").removeAll();}myMask.hide();var n=o["tableHtmlForm"];var q=o["isNoData"];if(!q){Ext.getCmp("saveBtn").setDisabled(false);Ext.getCmp("printBtn").setDisabled(false);Ext.getCmp("csvBtn").setDisabled(false);}Ext.getCmp("resultPanel").removeAll();Ext.getCmp("resultPanel").update(n);
Ext.getCmp("resultPanel").doLayout();}}}});},printData:function(){Ext.widget("print",{bodyStyle:{background:"#fff"}}).show();var a=Ext.select("#printContentDiv");a.set({src:"ViewThreshold/data/EgPrintThreshDetailView.jsp?print=printpage&com.eg.CSRF_NONCE="+csrfToken});},savePdf:function(){var b="/final/servlet/com.eg.EgPdfDownloadC?";
var a=Ext.widget("downloadutils");a.savePDF(b);},csvData:function(){var a="../servlet/com.eg.EgCSVController";window.location=a;}});