Ext.define("ICTest.controller.AddPerfmonTestCtrlr",{extend:"Ext.app.Controller",views:["AddNewTest"],requires:["ICTest.view.AddNewTest"],refs:[{selector:"addnewtest",ref:"addnewtest"},{selector:"defaultthresholds",ref:"defaultthresholds"},],init:function(){perfmonCtrlr=this;this.control({"addnewtest":{"afterrender":this.afterMainRender}});
},afterMainRender:function(){},loadAddMeasureTab:function(f){var j=this;Ext.getCmp("addNewMeasure").show();Ext.Ajax.request({url:"ICTest/data/"+f,method:"POST",async:false,success:function(m){if(m.status==200&&!Ext.isEmpty(m.responseText)){var n=m.responseText;publicJSON=Ext.decode(n);}}});var e=publicJSON.measuresList;
var i=Ext.getCmp("addMeasureCntnr");i.removeAll();if(publicJSON.noMeasuresAdded){Ext.getCmp("noMeasureFnd").show();Ext.getCmp("generateCntnr").disable();Ext.getCmp("tab6Help").disable();}else{Ext.getCmp("noMeasureFnd").hide();for(var b=0;b<e.length;b++){var a=e[b];if(!(a.measureName=="Installed")){i.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,id:"dbSize"+b,value:a.databaseColumnSize,hidden:a.hideDatabaseColumnSize,},{xtype:"displayfield",id:"unitVal"+b,fieldLabel:unit,value:filterDecode(a.unit)},{xtype:"displayfield",fieldLabel:procMthd,id:"processMethodVal"+b,value:a.processMethod},{xtype:"displayfield",fieldLabel:convFact,id:"conFact"+b,value:a.conversionFactor,hidden:a.hideConversionFactor},{xtype:"displayfield",fieldLabel:alrmDispStr,id:"alarmDisp"+b,value:a.alarmDispString,hidden:a.hideAlarmDispStr},{xtype:"displayfield",fieldLabel:counterName,id:"contVal"+b,value:a.counterName,}]},{xtype:"container",layout:{type:"hbox",pack:"center"},defaults:{width:80},items:[{xtype:"button",cls:"button20",text:modifyTooltip,modifyURL:a.modifyURL,handler:function(){j.showModifyMeasure(this.modifyURL);
},margin:"5 0 10 0"},{xtype:"button",cls:"button20",text:deleteTooltip,deleteURL:a.deleteURL,measureName:a.measureName,handler:function(){j.deleteMeasure(this.deleteURL,this.measureName);},margin:"5 0 10 20"}]}]});var h=Ext.getCmp("dbSize"+b);var l=Ext.getCmp("unitVal"+b);var d=Ext.getCmp("processMethodVal"+b);
var g=Ext.getCmp("conFact"+b);var k=Ext.getCmp("alarmDisp"+b);var c=Ext.getCmp("contVal"+b);if(isConfigTest){h.hide();l.hide();d.hide();g.hide();k.hide();c.show();}}}}},showAddNewMeasure:function(){var d=this;Ext.create("Ext.window.Window",{padding:"3 10 10 10",title:newMeasDetail,width:500,id:"addPerfmonMeasureWindow",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(h){d.otherUnit("add");
}}}},{xtype:"textfield",cls:"textbox",fieldLabel:other,id:"otherunit",name:"otherunit",hidden:true,maxLength:64,enforceMaxLength:true},{xtype:"scrollcombo",cls:"dropdown",id:"process",name:"process",fieldLabel:procMthd,store:new Ext.data.Store({fields:["displayField","valueField"],data:[]}),displayField:"displayField",valueField:"valueField",queryMode:"local",editable:false,listeners:{select:{fn:function(h){d.processMethodChange("add");
}}}},{xtype:"scrollcombo",cls:"dropdown",id:"cFactor",name:"cFactor",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:"textfield",cls:"textbox",fieldLabel:counterName,id:"counter",name:"counter",maxLength:100,enforceMaxLength:true},{xtype:"button",cls:"button20",text:add,id:"addMeasureButton",width:80,listeners:{click:{fn:function(h){d.doAddNewMeasure();
}}},margin:"5 5 20 5"}]}).show();var f="";Ext.getCmp("index").setValue(publicJSON.measIndex);var g=Ext.getCmp("dbsize");var a=Ext.getCmp("alarmdescription");var b=Ext.getCmp("un");var e=Ext.getCmp("process");var c=Ext.getCmp("cFactor");if(isConfigTest){g.hide();a.hide();b.hide();e.hide();}else{g.show();
g.getStore().loadRawData(publicJSON.dbColSizeList);g.setValue("2");a.show();Ext.getCmp("process").getStore().loadRawData(publicJSON.processMethodList);f=publicJSON.selectedProcessMethod;Ext.getCmp("process").setValue(f);Ext.getCmp("un").getStore().loadRawData(publicJSON.unitsList);Ext.getCmp("un").setValue("-1");
}if(f=="UNALTERED"||f=="DIFFERENCE"){c.show();c.getStore().loadRawData(publicJSON.convFactorList);c.setValue(publicJSON.convFactorSelected);}else{c.hide();}},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.getStore().loadRawData(publicJSON.convFactorList);a.setValue(publicJSON.convFactorSelected);
}}if(b=="UNALTERED"||b=="DIFFERENCE"){a.show();a.enable();}else{a.hide();a.disable();}},doAddNewMeasure:function(){var i=this;var h=Ext.getCmp("test").getValue();var g=Ext.getCmp("index").getValue();var b=Ext.getCmp("measure").getValue();var j=Ext.getCmp("cFactor").getValue();var f=Ext.getCmp("dbsize").getValue();
var l=Ext.getCmp("otherunit").getValue();var k=Ext.getCmp("un").getValue();var d=Ext.getCmp("alarmdescription").getValue();var c=Ext.getCmp("process").getValue();var a=Ext.getCmp("counter").getValue();if(c==null&&isConfigTest){c="UNALTERED";j="1";}if(c!="UNALTERED"&&c!="DIFFERENCE"){j="none";}var e="ICTest/data/EgconfigperfmonmeasurepJson.jsp?add=add&test="+h+"&measure="+b+"&factor="+j+"&counter="+encodeURIComponent(filterEncode(a));
e+="&dbsize="+f+"&otherunit="+l+"&un="+encodeURIComponent(filterEncode(k))+"&alarmdescription="+encodeURIComponent(d)+"&index="+g+"&process="+c;if(!this.measureValidation(b,k,l,d,a)){return;}Ext.Ajax.request({url:e,method:"POST",async:false,success:function(m){if(m.status==200&&!Ext.isEmpty(m.responseText)){var n=m.responseText;
publicJSON=Ext.decode(n);}}});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(m){if(m=="yes"){Ext.getCmp("addPerfmonMeasureWindow").close();
var n=publicJSON.forwardURL;i.loadAddMeasureTab(n);i.showAddNewMeasure();}else{if(m=="no"){Ext.getCmp("addPerfmonMeasureWindow").close();var n=publicJSON.forwardURL;i.loadAddMeasureTab(n);Ext.getCmp("newtest").setActiveTab(4);}}}});}}},measureValidation:function(k,l,o,f,b){var i=this;var c=Ext.getCmp("measure");
var d=Ext.getCmp("alarmdescription");var m=Ext.getCmp("otherunit");var n=Ext.getCmp("counter");var p=new Array("other","none","null","all");var e=false;var j=true;var h=Ext.getCmp("type").getValue();if(h!=null&&h=="Configuration"){e=true;}if(!e){if(!i.checkSpecialChar(f,"~!@#$%^&*()|:,;'<>")){Ext.Msg.show({title:newMeasDetail,msg:splCharAlert,buttons:Ext.Msg.OK,icon:"iconExclamation"});
d.focus(true);return false;}if(isDouble=="false"){j=validateSingleByte(f);}}k=k.toUpperCase();if(k=="TRGT_HOST"||k=="PORT_NO"||k=="SITE_NAME"||k=="INFO"||k=="MSMT_HOST"||k=="MSMT_TIME"){Ext.Msg.show({title:newMeasDetail,msg:alertMsg14,buttons:Ext.Msg.OK,icon:"iconExclamation"});return false;}var a=k.charAt(0);
var g=!e?l:"NONE";if(!checkblank(k)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg15,buttons:Ext.Msg.OK,icon:"iconExclamation"});c.focus(true);return false;}else{if(!checkspace(k)){c.focus(true);return false;}else{if(!checkspecialnomess(k,"`~!@#$%^&*()+=-/?'\"]{}[\\|;:.,><")){Ext.Msg.show({title:newMeasDetail,msg:alertMsg3,buttons:Ext.Msg.OK,icon:"iconExclamation"});
c.focus(true);return false;}else{if(a>="0"&&a<="9"){Ext.Msg.show({title:newMeasDetail,msg:alertMsg16,buttons:Ext.Msg.OK,icon:"iconExclamation"});c.focus(true);return false;}else{if(a=="_"){Ext.Msg.show({title:newMeasDetail,msg:alertMsg17,buttons:Ext.Msg.OK,icon:"iconExclamation"});c.focus(true);return false;
}else{if(!validateSingleByte(k)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg18,buttons:Ext.Msg.OK,icon:"iconExclamation"});c.focus(true);return false;}else{if(g=="-1"){Ext.Msg.show({title:newMeasDetail,msg:alertMsg19,buttons:Ext.Msg.OK,icon:"iconExclamation"});return false;}else{if(!j){Ext.Msg.show({title:newMeasDetail,msg:alertMsg20,buttons:Ext.Msg.OK,icon:"iconExclamation"});
d.focus(true);return false;}else{if(g=="other"){if(!checkblank(o)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg21,buttons:Ext.Msg.OK,icon:"iconExclamation"});return false;}else{if(!checkspace(o)){m.focus(true);return false;}else{if(!checkspecialnomess(o,"`~!@#^&*()+=-?'\"]{}[\\|;:.,><")){Ext.Msg.show({title:newMeasDetail,msg:alertMsg3,buttons:Ext.Msg.OK,icon:"iconExclamation"});
m.focus(true);return false;}else{if(!checkKeywords(o,p)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg22,buttons:Ext.Msg.OK,icon:"iconExclamation"});m.focus(true);return false;}}}}}else{if(!checkblank(b)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg41,buttons:Ext.Msg.OK,icon:"iconExclamation"});n.focus(true);
return false;}else{if(!validateSingleByte(b)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg42,buttons:Ext.Msg.OK,icon:"iconExclamation"});n.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);}}});}}}});},generatePerfmonTest:function(){var c=Ext.getCmp("object");
var b=c.getValue();var j=Ext.getCmp("instances");var a=j.getValue();var k=Ext.getCmp("instances_neg");var i=k.getValue();if(!checkblank(b)){Ext.Msg.show({title:generate,msg:alertMsg75,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(l){if(l=="ok"){c.focus(true);}}});return;}else{if(!validateSingleByte(b)){Ext.Msg.show({title:generate,msg:alertMsg76,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(l){if(l=="ok"){c.focus(true);
}}});return;}else{if(!validateSingleByte(a)){Ext.Msg.show({title:generate,msg:alertMsg43,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(l){if(l=="ok"){j.focus(true);}}});return;}else{if(!validateSingleByte(i)){Ext.Msg.show({title:generate,msg:alertMsg44,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(l){if(l=="ok"){k.focus(true);
}}});return;}}}}var h=Ext.getCmp("test").getValue();var e="ICTest/data/EgconfigperfmonmeasurepJson.jsp?add=gen&test="+h+"&object="+b+"&instances="+a+"&instances_neg="+i;if(isConfigTest){var d=Ext.getCmp("dbSizeGen").getValue();var g=Ext.getCmp("isDescriptorBasedTestPerfmon").getValue();e+="&dbsize="+d+"&descVal="+g;
}Ext.Ajax.request({url:e,method:"POST",async:false,success:function(l){if(l.status==200&&!Ext.isEmpty(l.responseText)){var m=l.responseText;publicJSON=Ext.decode(m);}}});if(publicJSON.objectError){Ext.Msg.show({title:publicJSON.AlertTitle,msg:alertMsg83,buttons:Ext.Msg.OK,icon:"iconError",fn:function(l){if(l=="ok"){c.focus(true);
}}});}else{if(publicJSON.NonDescriptorObjError){Ext.Msg.show({title:publicJSON.AlertTitle,msg:alertMsg84,buttons:Ext.Msg.OK,icon:"iconError",fn:function(l){if(l=="ok"){c.focus(true);}}});}else{if(publicJSON.oldObjectName!=""){Ext.Msg.show({title:generate,msg:alertMsg30,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(l){if(l=="ok"){if(publicJSON.AlertType=="Error"){Ext.Msg.show({title:publicJSON.AlertTitle,msg:publicJSON.AlertMsg,buttons:Ext.Msg.OK,icon:"iconError"});
}else{if(publicJSON.AlertType=="Result"){Ext.Msg.show({title:publicJSON.AlertTitle,msg:publicJSON.AlertMsg,buttons:Ext.Msg.OK,icon:"iconInformation",fn:function(m){if(m=="ok"){window.location.href="/final/admin/EgUDTest.jsp";}}});}}}}});}}}if(!Ext.isEmpty(publicJSON.forwardURL)){this.getController("ICTest.controller.ThresholdCtrlr").init();
var f=Ext.getCmp("generateCntnr");f.removeAll();var e=publicJSON.forwardURL;qString="ICTest/data/"+e;f.add({xtype:"defaultthresholds"});}},showModifyMeasure:function(d){var c;Ext.Ajax.request({url:"ICTest/data/"+d+"&testType=Perfmon",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",{padding:"3 10 10 10",title:modMeas,width:500,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){perfmonCtrlr.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_process",name:"s_process",fieldLabel:procMthd,store:new Ext.data.Store({fields:["displayField","valueField"],data:[]}),displayField:"displayField",valueField:"valueField",queryMode:"local",editable:false,hidden:isConfigTest,listeners:{select:{fn:function(g){perfmonCtrlr.processMethodChange("modify");
}}}},{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:"textfield",cls:"textbox",fieldLabel:counterName,id:"s_counter",name:"s_counter",maxLength:100,enforceMaxLength:true,value:c.counterValue},{xtype:"button",cls:"button20",text:modifyTooltip,id:"modMeasureButton",width:80,margin:"5 5 20 5",listeners:{click:{fn:function(i){var h=Ext.getCmp("s_measure").getValue();
var l=Ext.getCmp("s_un").getValue();var n=Ext.getCmp("s_otherunit").getValue();var k=Ext.getCmp("alarmdescription").getValue();var g=Ext.getCmp("s_counter").getValue();if(!perfmonCtrlr.measureValidation(h,l,n,k,g)){return;}var m=Ext.getCmp("measureform").getForm();if(m.isValid()){var o=new Ext.LoadMask(Ext.getBody(),{msg:updating+"..."});
var j=encodeFieldParams(m);o.show();m.submit({method:"POST",params:j,success:function(p,r){o.hide();var q=r.response.responseText;var t=Ext.decode(q);if(t.AlertType=="Result"){var u=Ext.getCmp("test").getValue();var s="EgConfigPerfmonMeasureJson.jsp?test="+u;perfmonCtrlr.loadAddMeasureTab(s);Ext.Msg.show({title:t.AlertTitle,msg:t.AlertMsg,buttons:Ext.Msg.OK,icon:"iconInformation",fn:function(v){if(v=="ok"){Ext.getCmp("newtest").setActiveTab(3);
}}});}else{if(t.AlertType=="Error"){Ext.Msg.show({title:t.AlertTitle,msg:t.AlertMsg,buttons:Ext.Msg.OK,icon:"iconError",fn:function(v){if(v=="ok"){var x=Ext.getCmp("test").getValue();var w="EgConfigPerfmonMeasureJson.jsp?test="+x;perfmonCtrlr.loadAddMeasureTab(w);}}});}}}});}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);Ext.getCmp("s_process").getStore().loadRawData(c.processMethodList);
Ext.getCmp("s_process").setValue(c.selectedProcessMethod);var b=Ext.getCmp("s_factor");if(!c.hideConvFactor){b.show();b.getStore().loadRawData(c.convFactorList);b.setValue(c.convFactorSelected);}else{b.hide();}}else{Ext.getCmp("measureform").setHeight(100);Ext.getCmp("modScriptMeasureWindow").setHeight(150);
}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;}});