Ext.define("ICTest.controller.AddCustomTestCtrlr",{extend:"Ext.app.Controller",views:["AddNewTest"],requires:["ICTest.view.AddNewTest"],refs:[{selector:"addnewtest",ref:"addnewtest"},{selector:"defaultthresholds",ref:"defaultthresholds"}],init:function(){customCtrlr=this;this.control({"addnewtest":{"afterrender":this.afterMainRender},});
},afterMainRender:function(){},loadAddMeasureTab:function(f){var d=this;Ext.getCmp("addNewMeasure").show();Ext.Ajax.request({url:"ICTest/data/"+f,method:"POST",async:false,success:function(i){if(i.status==200&&!Ext.isEmpty(i.responseText)){var j=i.responseText;publicJSON=Ext.decode(j);}}});var h=publicJSON.measuresList;
var g=Ext.getCmp("addMeasureCntnr");g.removeAll();if(publicJSON.noMeasuresAdded){Ext.getCmp("noMeasureFnd").show();Ext.getCmp("generateCntnr").disable();Ext.getCmp("tab6Help").disable();}else{Ext.getCmp("noMeasureFnd").hide();for(var e=0;e<h.length;e++){var a=h[e];if(!(a.measureName=="Installed")){g.add({xtype:"fieldset",title:"<b>"+a.measureIndex+". "+a.measureName+"</b>",width:500,items:[{xtype:"container",layout:{type:"vbox",align:"left",pack:"center"},defaults:{labelSeparator:" ",margin:5,labelWidth:200},items:[{xtype:"displayfield",fieldLabel:dbColSize,value:a.databaseColumnSize,hidden:isConfigTest},{xtype:"displayfield",fieldLabel:unit,value:filterDecode(a.unit),hidden:isConfigTest},{xtype:"displayfield",fieldLabel:convFact,value:a.conversionFactor,hidden:a.hideConversionFactor,id:"conFact"+e},{xtype:"displayfield",fieldLabel:alrmDispStr,value:a.alarmDispString,hidden:a.hideAlarmDispStr,id:"alarmDisp"+e}]},{xtype:"container",layout:{type:"hbox",pack:"center"},defaults:{width:80,},items:[{xtype:"button",cls:"button20",text:modifyTooltip,modifyURL:a.modifyURL,handler:function(){d.showModifyMeasure(this.modifyURL);
},margin:"5 0 10 0"},{xtype:"button",cls:"button20",text:deleteTooltip,deleteURL:a.deleteURL,measureName:a.measureName,handler:function(){d.deleteMeasure(this.deleteURL,this.measureName);},margin:"5 0 10 20"}]}]});var c=Ext.getCmp("conFact"+e);var b=Ext.getCmp("alarmDisp"+e);if(isConfigTest){c.hide();
b.hide();}}}}addctrler.tabHelp();},showAddNewMeasure:function(){var c=this;Ext.create("Ext.window.Window",{title:newMeasDetail,width:500,padding:"3 10 10 10",id:"addMeasureWindow",layout:{type:"vbox",pack:"start",align:"center"},defaults:{labelSeparator:"",margin:5,width:400,labelWidth:200},modal:true,resizable:false,items:[{xtype:"textfield",cls:"textbox",fieldLabel:measIdx,id:"index",name:"index",margin:"10 5 0 5"},{xtype:"textfield",cls:"textbox",fieldLabel:measName,id:"measure",name:"measure",maxLength:24,enforceMaxLength:true},{xtype:"scrollcombo",cls:"dropdown",id:"dbsize",name:"dbsize",fieldLabel:dbColSize,store:new Ext.data.Store({fields:["displayField","valueField"],data:[]}),displayField:"displayField",valueField:"valueField",queryMode:"local",editable:false},{xtype:"scrollcombo",cls:"dropdown",id:"un",name:"un",fieldLabel:unit,store:new Ext.data.Store({fields:["displayField","valueField"],data:[]}),displayField:"displayField",valueField:"valueField",queryMode:"local",listeners:{select:{fn:function(f){c.otherUnit("add");
}}}},{xtype:"textfield",cls:"textbox",fieldLabel:other,id:"otherunit",name:"otherunit",hidden:true,maxLength:64,enforceMaxLength:true},{xtype:"scrollcombo",cls:"dropdown",id:"cFactor",name:"cFactor",listConfig:{maxHeight:150},fieldLabel:convFact,store:new Ext.data.Store({fields:["displayField","valueField"],data:[]}),displayField:"displayField",valueField:"valueField",queryMode:"local",editable:false},{xtype:"textfield",cls:"textbox",fieldLabel:alrmDispStr,id:"alarmdescription",name:"alarmdescription",maxLength:75,enforceMaxLength:true},{xtype:"button",cls:"button20",text:add,id:"addMeasureButton",width:80,listeners:{click:{fn:function(f){c.doAddNewMeasure();
}}},margin:"5 5 20 5"}]}).show();Ext.getCmp("index").setValue(publicJSON.measIndex);var e=Ext.getCmp("dbsize");var b=Ext.getCmp("un");var d=Ext.getCmp("cFactor");var a=Ext.getCmp("alarmdescription");if(isConfigTest){e.hide();b.hide();d.hide();a.hide();}else{e.show();e.getStore().loadRawData(publicJSON.dbColSizeList);
e.setValue("2");b.show();b.getStore().loadRawData(publicJSON.unitsList);b.setValue("-1");d.show();d.getStore().loadRawData(publicJSON.convFactorList);d.setValue(publicJSON.convFactorSelected);a.show();}},otherUnit:function(c){var a=Ext.getCmp("un");var b=Ext.getCmp("otherunit");if(c=="modify"){a=Ext.getCmp("s_un");
b=Ext.getCmp("s_otherunit");}if(a.getValue()=="other"){b.show();b.enable();}else{b.hide();b.disable();}},processMethodChange:function(c){var b;var a;if(c=="add"){b=Ext.getCmp("process").getValue();a=Ext.getCmp("cFactor");}else{if(c=="modify"){b=Ext.getCmp("s_process").getValue();a=Ext.getCmp("s_factor");
a.setValue(publicJSON.convFactorSelected);}}if(b=="UNALTERED"||b=="DIFFERENCE"){a.show();a.enable();}else{a.hide();a.disable();}},doAddNewMeasure:function(){var g=this;var f=Ext.getCmp("test").getValue();var e=Ext.getCmp("index").getValue();var a=Ext.getCmp("measure").getValue();var h=Ext.getCmp("cFactor").getValue();
var d=Ext.getCmp("dbsize").getValue();var j=Ext.getCmp("otherunit").getValue();var i=Ext.getCmp("un").getValue();var b=Ext.getCmp("alarmdescription").getValue();var c="ICTest/data/EgconfigtestmeasurepJson.jsp?add=add&test="+f+"&measure="+a+"&factor="+h;c+="&dbsize="+d+"&otherunit="+j+"&un="+encodeURIComponent(filterEncode(i))+"&alarmdescription="+encodeURIComponent(b)+"&index="+e;
if(!this.measureValidation(a,i,j,b)){return;}Ext.Ajax.request({url:c,method:"POST",async:false,success:function(k){if(k.status==200&&!Ext.isEmpty(k.responseText)){var l=k.responseText;publicJSON=Ext.decode(l);}}});if(publicJSON.AlertType=="Error"){Ext.Msg.show({title:error+": "+publicJSON.AlertTitle,msg:publicJSON.AlertMsg,buttons:Ext.Msg.OK,icon:"iconError"});
}else{if(publicJSON.AlertType=="Result"){Ext.getCmp("generateCntnr").enable();Ext.getCmp("tab6Help").enable();Ext.Msg.show({title:publicJSON.AlertTitle,msg:publicJSON.AlertMsg+". "+alertMsg80,closable:false,buttons:Ext.Msg.YESNO,icon:"iconInformation",fn:function(k){if(k=="yes"){Ext.getCmp("addMeasureWindow").close();
var l=publicJSON.forwardURL;g.loadAddMeasureTab(l);g.showAddNewMeasure();}else{if(k=="no"){Ext.getCmp("addMeasureWindow").close();var l=publicJSON.forwardURL;g.loadAddMeasureTab(l);Ext.getCmp("newtest").setActiveTab(4);}}}});}}addctrler.tabHelp();},measureValidation:function(j,k,m,e){var h=this;var b=Ext.getCmp("measure");
var c=Ext.getCmp("alarmdescription");var l=Ext.getCmp("otherunit");var n=new Array("other","none","null","all");var d=false;var i=true;var g=Ext.getCmp("type").getValue();if(g!=null&&g=="Configuration"){d=true;}if(!d){if(!h.checkSpecialChar(e,"~!@#$%^&*()|:,;'<>")){Ext.Msg.show({title:newMeasDetail,msg:splCharAlert,buttons:Ext.Msg.OK,icon:"iconExclamation"});
c.focus(true);return false;}if(isDouble=="false"){i=validateSingleByte(e);}}j=j.toUpperCase();if(j=="TRGT_HOST"||j=="PORT_NO"||j=="SITE_NAME"||j=="INFO"||j=="MSMT_HOST"||j=="MSMT_TIME"){Ext.Msg.show({title:newMeasDetail,msg:alertMsg14,buttons:Ext.Msg.OK,icon:"iconExclamation"});return false;}var a=j.charAt(0);
var f=!d?k:"NONE";if(!checkblank(j)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg15,buttons:Ext.Msg.OK,icon:"iconExclamation"});b.focus(true);return false;}else{if(!checkspaceForExtjs(j)){Ext.Msg.show({title:newMeasDetail,msg:_checkblank+" "+valIn+" "+measName,buttons:Ext.Msg.OK,icon:"iconExclamation"});
b.focus(true);return false;}else{if(!checkspecialnomess(j,"`~!@#$%^&*()+=-/?'\"]{}[\\|;:.,><")){Ext.Msg.show({title:newMeasDetail,msg:alertMsg3,buttons:Ext.Msg.OK,icon:"iconExclamation"});b.focus(true);return false;}else{if(a>="0"&&a<="9"){Ext.Msg.show({title:newMeasDetail,msg:alertMsg16,buttons:Ext.Msg.OK,icon:"iconExclamation"});
b.focus(true);return false;}else{if(a=="_"){Ext.Msg.show({title:newMeasDetail,msg:alertMsg17,buttons:Ext.Msg.OK,icon:"iconExclamation"});b.focus(true);return false;}else{if(!validateSingleByte(j)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg18,buttons:Ext.Msg.OK,icon:"iconExclamation"});b.focus(true);
return false;}else{if(f=="-1"){Ext.Msg.show({title:newMeasDetail,msg:alertMsg19,buttons:Ext.Msg.OK,icon:"iconExclamation"});return false;}else{if(!i){Ext.Msg.show({title:newMeasDetail,msg:alertMsg20,buttons:Ext.Msg.OK,icon:"iconExclamation"});c.focus(true);return false;}else{if(f=="other"){if(!checkblank(m)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg21,buttons:Ext.Msg.OK,icon:"iconExclamation"});
l.focus(true);return false;}else{if(!checkspaceForExtjs(m)){Ext.Msg.show({title:newMeasDetail,msg:_checkblank+" "+valIn+" "+other,buttons:Ext.Msg.OK,icon:"iconExclamation"});l.focus(true);return false;}else{if(!checkspecialnomess(m,"`~!@#^&*()+=-?'\"]{}[\\|;:.,><")){Ext.Msg.show({title:newMeasDetail,msg:alertMsg3,buttons:Ext.Msg.OK,icon:"iconExclamation"});
l.focus(true);return false;}else{if(!checkKeywords(m,n)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg22,buttons:Ext.Msg.OK,icon:"iconExclamation"});l.focus(true);return false;}}}}}}}}}}}}}return true;},deleteMeasure:function(c,b){var a=this;Ext.Msg.show({title:addMeasure,msg:alertMsg45+" '"+b+"'?",buttons:Ext.Msg.OKCANCEL,icon:"iconConfirmation",fn:function(d){if(d=="ok"){Ext.Ajax.request({url:"ICTest/data/"+c,method:"POST",async:false,success:function(e){if(e.status==200&&!Ext.isEmpty(e.responseText)){var f=e.responseText;
publicJSON=Ext.decode(f);}}});if(publicJSON.AlertType=="Result"){Ext.Msg.show({title:publicJSON.AlertTitle,msg:publicJSON.AlertMsg,buttons:Ext.Msg.OK,icon:"iconInformation",fn:function(e){if(e=="ok"){Ext.getCmp("addMeasureTab").enable();var f=publicJSON.forwardURL;a.loadAddMeasureTab(f);}}});}}}});},generateCustomTest:function(){var i=this;
var f=Ext.getCmp("test").getValue();var j=Ext.getCmp("path");var m=j.getValue();if(!checkblank(m)){Ext.Msg.show({title:generate,msg:alertMsg26,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(n){if(n=="ok"){j.focus(true);}}});return;}else{if(!checkspaceForExtjs(m)){Ext.Msg.show({title:generate,msg:_checkblank+" "+valIn+" "+classFile,buttons:Ext.Msg.OK,icon:"iconExclamation"});
j.focus(true);return;}else{if(!checkspecialnomess(m,'*?"<>|')){Ext.Msg.show({title:generate,msg:alertMsg3,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(n){if(n=="ok"){j.focus(true);}}});return;}else{if(m.indexOf(".class")>-1&&m.indexOf(f)==-1){Ext.Msg.show({title:generate,msg:alertMsg27,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(n){if(n=="ok"){j.focus(true);
}}});return;}else{if(m.indexOf("_ex.class")!=(m.length-"_ex.class".length)){Ext.Msg.show({title:generate,msg:alertMsg28,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(n){if(n=="ok"){j.focus(true);}}});return;}}}}}var a=Ext.getCmp("loadLib").getValue();var l=Ext.getCmp("lib");var g=l.getValue();
if(a){if(!checkblank(g)){Ext.Msg.show({title:generate,msg:alertMsg29,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(n){if(n=="ok"){l.focus(true);}}});return;}else{if(!checkspaceForExtjs(g)){Ext.Msg.show({title:generate,msg:_checkblank+" "+valIn+" "+libFile,buttons:Ext.Msg.OK,icon:"iconExclamation"});
l.focus(true);return;}else{if(!checkspecialnomess(g,"`!@#%^&*()+=?'\"]}[{|;><")){Ext.Msg.show({title:generate,msg:alertMsg3,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(n){if(n=="ok"){l.focus(true);}}});return;}}}}if(publicJSON.oldClass!=""){alert(alertMsg30);}var h="no";var e="no";var k="no";
if(Ext.getCmp("ddForMeasure").getValue()){k="yes";}if(Ext.getCmp("loadPath").getValue()){h="yes";}if(a){e="yes";}var c="ICTest/data/EgconfigtestmeasurepJson.jsp?add=gen&test="+f+"&path="+m+"&lib="+g;c+="&loadPath="+h+"&loadLib="+e;if(isConfigTest){var b=Ext.getCmp("dbSizeGen").getValue();c+="&dbsize="+b;
if(Ext.getCmp("isDescriptorBasedTest").getValue()){c+="&isDescriptorBasedTest=yes";}else{c+="&isDescriptorBasedTest=no";}}else{c+="&ddForMeasure="+k;}Ext.Ajax.request({url:c,method:"POST",async:false,success:function(n){if(n.status==200&&!Ext.isEmpty(n.responseText)){var o=n.responseText;publicJSON=Ext.decode(o);
}}});if(publicJSON.AlertType=="Error"){Ext.Msg.show({title:publicJSON.AlertTitle,msg:publicJSON.AlertMsg,buttons:Ext.Msg.OK,icon:"iconError",fn:function(n){if(n=="ok"){Ext.getCmp("addMeasureTab").enable();var o=publicJSON.forwardURL;if(o!=null&&o!=""){i.loadAddMeasureTab(o);}}}});}else{if(publicJSON.AlertType=="Result"){Ext.Msg.show({title:publicJSON.AlertTitle,msg:publicJSON.AlertMsg,buttons:Ext.Msg.OK,icon:"iconInformation",fn:function(n){if(n=="ok"){window.location.href="/final/admin/EgUDTest.jsp";
}}});}}if(!Ext.isEmpty(publicJSON.forwardURL)){if(k=="yes"){Ext.getCmp("newtest").child("#tab5DD").tab.show();Ext.getCmp("newtest").setActiveTab(4);}else{this.getController("ICTest.controller.ThresholdCtrlr").init();var d=Ext.getCmp("generateCntnr");d.removeAll();var c=publicJSON.forwardURL;qString="ICTest/data/"+c;
d.add({xtype:"defaultthresholds"});}}},showModifyMeasure:function(d){var c;Ext.Ajax.request({url:"ICTest/data/"+d+"&testType=Custom",method:"POST",async:false,success:function(g){if(g.status==200&&!Ext.isEmpty(g.responseText)){var h=g.responseText;c=Ext.decode(h);}}});Ext.create("Ext.window.Window",{title:modMeas,width:500,padding:"3 10 10 10",id:"modScriptMeasureWindow",modal:true,resizable:false,items:[{xtype:"form",id:"measureform",name:"measureform",url:"ICTest/data/EgmodifymeasurespJson.jsp",width:500,layout:{type:"vbox",pack:"start",align:"center"},defaults:{labelSeparator:"",margin:5,width:400,labelWidth:200},items:[{xtype:"textfield",cls:"textbox",fieldLabel:measName,id:"s_measure",name:"s_measure",maxLength:24,enforceMaxLength:true,value:c.measureName,margin:"10 5 0 5"},{xtype:"scrollcombo",cls:"dropdown",id:"s_dbsize",name:"s_dbsize",fieldLabel:dbColSize,store:new Ext.data.Store({fields:["displayField","valueField"],data:[]}),displayField:"displayField",valueField:"valueField",queryMode:"local",editable:false,hidden:isConfigTest},{xtype:"scrollcombo",cls:"dropdown",id:"s_un",name:"s_un",fieldLabel:unit,store:new Ext.data.Store({fields:["displayField","valueField"],data:[]}),displayField:"displayField",valueField:"valueField",queryMode:"local",hidden:isConfigTest,listeners:{select:{fn:function(g){customCtrlr.otherUnit("modify");
}}}},{xtype:"textfield",cls:"textbox",fieldLabel:other,id:"s_otherunit",name:"s_otherunit",hidden:true,maxLength:64,enforceMaxLength:true,},{xtype:"scrollcombo",cls:"dropdown",id:"s_factor",name:"s_factor",fieldLabel:convFact,store:new Ext.data.Store({fields:["displayField","valueField"],data:[]}),displayField:"displayField",valueField:"valueField",queryMode:"local",editable:false,hidden:isConfigTest},{xtype:"textfield",cls:"textbox",fieldLabel:alrmDispStr,id:"alarmdescription",name:"alarmdescription",maxLength:75,enforceMaxLength:true,value:c.alarmDispStrValue,hidden:isConfigTest},{xtype:"button",cls:"button20",text:modifyTooltip,id:"modMeasureButton",width:80,margin:"5 5 20 5",listeners:{click:{fn:function(n){var l=Ext.getCmp("s_measure").getValue();
var m=Ext.getCmp("s_un").getValue();var k=Ext.getCmp("s_otherunit").getValue();var j=Ext.getCmp("alarmdescription").getValue();if(!customCtrlr.measureValidation(l,m,k,j)){return;}var i=Ext.getCmp("measureform").getForm();if(i.isValid()){var h=encodeFieldParams(i);var g=new Ext.LoadMask(Ext.getBody(),{msg:updating+"..."});
g.show();i.submit({method:"POST",params:h,success:function(o,q){g.hide();var p=q.response.responseText;var s=Ext.decode(p);if(s.AlertType=="Result"){var t=Ext.getCmp("test").getValue();var r="EgConfigTestMeasureJson.jsp?test="+t;customCtrlr.loadAddMeasureTab(r);Ext.Msg.show({title:s.AlertTitle,msg:s.AlertMsg,buttons:Ext.Msg.OK,icon:"iconInformation",fn:function(u){if(u=="ok"){Ext.getCmp("newtest").setActiveTab(3);
}}});}else{if(s.AlertType=="Error"){Ext.Msg.show({title:s.AlertTitle,msg:s.AlertMsg,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(u){if(u=="ok"){var w=Ext.getCmp("test").getValue();var v="EgConfigTestMeasureJson.jsp?test="+w;customCtrlr.loadAddMeasureTab(v);}}});}}}});}Ext.getCmp("modScriptMeasureWindow").close();
}}}},{xtype:"container",id:"hiddenContnr",hidden:true}]}]}).show();if(!isConfigTest){Ext.getCmp("s_dbsize").getStore().loadRawData(c.dbColSizeList);Ext.getCmp("s_dbsize").setValue(c.dbColSizeSelected);Ext.getCmp("s_un").getStore().loadRawData(c.unitsList);Ext.getCmp("s_un").setValue(c.unitSelected);if(!c.hideConvFactor){var b=Ext.getCmp("s_factor");
b.show();b.getStore().loadRawData(c.convFactorList);b.setValue(c.convFactorSelected);}}else{Ext.getCmp("measureform").setHeight(100);Ext.getCmp("modScriptMeasureWindow").setHeight(100);}var a=c.hiddens;var e=Ext.getCmp("hiddenContnr");e.removeAll();for(var f in a){e.add({xtype:"hidden",name:f,value:a[f]});
}},checkSpecialChar:function(c,b){if(typeof(c)=="object"){obj_val=c.value;}else{obj_val=c;}for(var a=0;a<obj_val.length;a++){check_char=b.indexOf(obj_val.charAt(a));if(check_char>=0){return false;}}return true;}});