Ext.define("CompositeTest.controller.AddTestCtrlr",{extend:"Ext.app.Controller",views:["AddNewTest"],requires:["CompositeTest.view.AddNewTest","CompositeTest.view.Description","Ext.ux.form.MultiSelectSI"],refs:[{selector:"addnewtest",ref:"addnewtest"},{selector:"compositetestgenerate",ref:"compositetestgenerate"},{selector:"addhelp",ref:"addhelp"},{selector:"defaultthresholds",ref:"defaultthresholds"}],init:function(){addctrler=this;
this.buildMainData();this.control({"addnewtest":{"afterrender":this.afterMainRender},'addnewtest scrollcombo[id="componentType"]':{"select":this.componentTypeChanged},'addnewtest scrollcombo[id="weightageName"]':{"select":this.weightageTypeChanged},'addnewtest button[id="add"]':{"click":this.addTest},'addnewtest button[id="addNewMeasure"]':{"click":this.showAddMeasure},'addnewtest button[id="backButton"]':{"click":this.goBack},'addnewtest component[id="reporterLogoIMG_enable"]':{"click":this.showWeightagePopupWindow},'addnewtest component[id="reporterLogoIMG_disable"]':{"click":this.showWeightagePopupWindow}});
},showWeightagePopupWindow:function(){Ext.widget("description_window").show();},buildMainData:function(){Ext.Ajax.request({url:"CompositeTest/data/EgAddTestJson.jsp",method:"POST",async:false,success:function(a){if(a.status==200&&!Ext.isEmpty(a.responseText)){var b=a.responseText;publicJSON=Ext.decode(b);
}}});},tabchange:function(b){previousCompType=null;forbiddenMessage=null;var a=b.getActiveTab().id;if(a=="addtest"){Ext.Ajax.request({url:"CompositeTest/data/alertJson.jsp?selectTab="+a,method:"POST",async:false,success:function(c){if(c.status==200&&!Ext.isEmpty(c.responseText)){var d=c.responseText;
tempJson=Ext.decode(d);if(!Ext.isEmpty(tempJson.s_compType)){previousCompType=tempJson.s_compType;forbiddenMessage=tempJson.forbiddenMessage;}}}});}},afterMainRender:function(){var a=this;Ext.getCmp("componentType").getStore().clearFilter(true);Ext.getCmp("componentType").getStore().suspendEvents(true);
Ext.getCmp("componentType").getStore().loadRawData(publicJSON.compTypes);Ext.getCmp("componentType").getStore().resumeEvents();Ext.getCmp("componentType").select(Ext.getCmp("componentType").getStore().getAt(0));Ext.getCmp("allowedId").hide();Ext.getCmp("add").hide();Ext.getCmp("addBtnContainer").hide();
Ext.getCmp("common_page_desc").update('<center><img src="/final/images/spacer.gif" class="iconAdminInfo" valign="middle" style="margin-right:2px"/>&nbsp'+addPageDesc+".</center>");},goBack:function(){Ext.Ajax.request({url:"CompositeTest/data/LookForChanges.jsp",method:"POST",async:false,success:function(a){if(a.status==200&&!Ext.isEmpty(a.responseText)){var b=a.responseText;
tempJson=Ext.decode(b);if(tempJson.alertUser){Ext.Msg.show({title:pageTitle1,msg:confirmBackBtn,closable:false,buttons:Ext.Msg.YESNO,icon:"iconInformation",width:300,fn:function(c){if(c=="yes"){window.location.href="/final/admin/compositeTest.jsp";}}});}else{window.location.href="/final/admin/compositeTest.jsp";
}}}});},componentTypeChanged:function(){var e=Ext.getCmp("add");var c=Ext.getCmp("addBtnContainer");var a=Ext.getCmp("allowedId");var d=Ext.getCmp("testForInfos");var f=Ext.getCmp("componentType").getValue();if(f==null||f=="-1"){a.hide();e.hide();c.hide();d.hide();return;}var b=Ext.getCmp("allowedId").getValue().is_info_based_test;
var h=Ext.getCmp("testForInfos").getValue();var i={"compType":f};var g="testForInfos.jsp";Ext.Ajax.request({url:"CompositeTest/data/"+g,method:"POST",params:i,async:false,success:function(j){if(j.status==200&&!Ext.isEmpty(j.responseText)){var k=j.responseText;test_for_infos_json=Ext.decode(k);Ext.getCmp("testForInfos").getStore().clearFilter(true);
Ext.getCmp("testForInfos").getStore().suspendEvents(true);Ext.getCmp("testForInfos").getStore().loadRawData(test_for_infos_json.individual_tests);Ext.getCmp("testForInfos").getStore().resumeEvents();Ext.getCmp("testForInfos").setValue(test_for_infos_json.selectedTest);}}});a.show();e.show();c.show();
if(b=="true"){d.show();}else{d.hide();}},layerNameChanged:function(){var d=Ext.getCmp("confirmationContainer");var c=Ext.getCmp("generateButton");var a=Ext.getCmp("generateButtonContainer");var b=Ext.getCmp("layerName").getValue();if(b==null||b=="-1"){d.setVisible(false);Ext.getCmp("associated_comptypes").setVisible(false);
Ext.getCmp("associatedCompTypesContainer").setVisible(false);c.hide();a.hide();}else{Ext.Ajax.request({url:"CompositeTest/data/lookForCompTypes.jsp?layer="+b+"&lastSelection="+Ext.getCmp("testforId").getValue().testfor,method:"POST",async:false,success:function(f){if(f.status==200&&!Ext.isEmpty(f.responseText)){var h=Ext.decode(f.responseText);
if(genJSON.is_predefined_test){c.hide();a.hide();}else{c.show();a.show();}d.setVisible(true);var g=Ext.getCmp("testforId");g.setVisible(true);if(h.lastSelection=="yes"){g.items.items[0].setValue(true);Ext.getCmp("associated_comptypes").setVisible(true);Ext.getCmp("associatedCompTypesContainer").setVisible(true);
}else{g.items.items[1].setValue(true);Ext.getCmp("associated_comptypes").setVisible(false);Ext.getCmp("associatedCompTypesContainer").setVisible(false);}fromAssociatedComponentsFound=false;toAssociatedComponentsFound=false;Ext.getCmp("associated_comptypes").fromField.store.removeAll();Ext.getCmp("associated_comptypes").toField.store.removeAll();
if(h.associatedComponentsFound){fromAssociatedComponentsFound=true;var i=Ext.getCmp("associated_comptypes").fromField;i.store.add(h["associatedComponents"]);fromStore=h["associatedComponents"];}if(h.availableComponentsFound){toAssociatedComponentsFound=true;var e=Ext.getCmp("associated_comptypes").toField;
e.store.add(h["availableComponents"]);toStore=h["availableComponents"];}}}});}},weightageTypeChanged:function(){var a=Ext.getCmp("weightageName").getValue();if(a==null||a=="SystemDefined"){Ext.getCmp("reporterLogoIMG_enable").show();Ext.getCmp("reporterLogoIMG_disable").hide();Ext.getCmp("alaramKeyContainer").hide();
Ext.getCmp("alaramSupportContainer").hide();}else{Ext.getCmp("reporterLogoIMG_enable").hide();Ext.getCmp("reporterLogoIMG_disable").show();Ext.getCmp("alaramKeyContainer").show();Ext.getCmp("alaramSupportContainer").show();}},addTest:function(){var f=this;if(!this.validate()){return;}isModifyTest=false;
if(testTabLoad){this.testModifyAlone();return;}var h=Ext.getCmp("test_display_name").getValue();var b=Ext.getCmp("componentType").getValue();var c=Ext.getCmp("componentType").getRawValue();if(b==null||b=="-1"){Ext.Msg.show({title:pageTitle1,msg:compTypeAlert,buttons:Ext.Msg.OK});return;}var d="-1";var a=Ext.getCmp("allowedId").getValue().is_info_based_test;
if(a=="true"){d=Ext.getCmp("testForInfos").getValue();if(d==null||d=="-1"){Ext.Msg.show({title:pageTitle1,msg:message2,buttons:Ext.Msg.OK});return;}}var g=Ext.getCmp("cx_test_description").getValue();var i={"display_name":filterEncode(h),"compType":b,"operation":"addTest","purpose_of_test":filterEncode(g),"descriptor_based":a,"selected_master_test":d};
var e="EgaddtestpJson.jsp?add=test";Ext.Ajax.request({url:"CompositeTest/data/"+e,method:"POST",params:i,async:false,success:function(j){if(j.status==200&&!Ext.isEmpty(j.responseText)){var k=j.responseText;publicJSON=Ext.decode(k);}}});if(publicJSON.AlertType=="Error"){Ext.Msg.show({title:pageTitle1,msg:publicJSON.AlertMsg,buttons:Ext.Msg.OK,icon:"iconError"});
}else{if(publicJSON.AlertType=="COULD_NOT_CREATE_TEST"){Ext.Msg.show({title:pageTitle1,msg:publicJSON.AlertMsg,buttons:Ext.Msg.OK,icon:"iconError"});}else{if(publicJSON.AlertType=="Result"){Ext.getCmp("test").setValue(publicJSON.newCompTestName);if(publicJSON.isNewTestEntry){Ext.getCmp("addMeasureTab").enable();
Ext.getCmp("newtest").setActiveTab(1);}else{Ext.Msg.show({title:pageTitle1,msg:publicJSON.AlertMsg,closable:false,buttons:Ext.Msg.OK,icon:"iconInformation",width:300,fn:function(j){if(j=="ok"){Ext.getCmp("addMeasureTab").enable();Ext.getCmp("newtest").setActiveTab(1);}}});}}}}},validate:function(){var a=Ext.getCmp("cx_test_description");
var b=Ext.getCmp("test_display_name");if(!checkblank(b.getValue())){Ext.Msg.show({title:pageTitle1,msg:testDisplayAlert,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){b.focus(true);}});return false;}else{if(!checkblank(a.getValue())){Ext.Msg.show({title:pageTitle1,msg:testDescriptionAlert,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){b.focus(true);
}});return false;}else{if(!this.checkSpecialChar(b.getValue(),"~!@#$%^&*()|:,;'<>={}[]?/\"")){Ext.Msg.show({title:pageTitle1,msg:splCharAlert1,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){b.focus(true);}});return false;}else{if(!this.checkSpecialChar(a.getValue(),"~!@#$%^&*()|:,;'<>={}[]?/\"")){Ext.Msg.show({title:pageTitle1,msg:splCharAlert2,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){a.focus(true);
}});return false;}}}}return true;},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;},weightageValidation:function(){key_minor=Ext.getCmp("alarmKeyMin").getValue().toString().toLowerCase();
key_major=Ext.getCmp("alarmKeyMaj").getValue().toString().toLowerCase();if(key_minor==null||key_minor.length==0){Ext.Msg.show({title:pageTitle1,msg:weightageAlert1,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyMin").focus(true);}});return false;}else{if(key_minor.indexOf(" ")>-1){Ext.Msg.show({title:pageTitle1,msg:weightageAlert2,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyMin").focus(true);
}});return false;}else{if(key_major==null||key_major.length==0){Ext.Msg.show({title:pageTitle1,msg:weightageAlert3,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyMaj").focus(true);}});return false;}else{if(key_major.indexOf(" ")>-1){Ext.Msg.show({title:pageTitle1,msg:weightageAlert4,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyMaj").focus(true);
}});return false;}else{if(key_minor!="none"&&isNaN(key_minor)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert5,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyMin").focus(true);}});return false;}else{if(key_minor!="none"&&!isNaN(key_minor)&&key_minor.indexOf(".")>-1){Ext.Msg.show({title:pageTitle1,msg:weightageAlert6,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyMin").focus(true);
}});return false;}else{if(key_major!="none"&&isNaN(key_major)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert7,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyMaj").focus(true);}});return false;}else{if(key_major!="none"&&!isNaN(key_major)&&key_major.indexOf(".")>-1){Ext.Msg.show({title:pageTitle1,msg:weightageAlert8,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyMaj").focus(true);
}});return false;}}}}}}}}key_normal=Ext.getCmp("alarmKeyN").getValue().toString().toLowerCase();key_critical=Ext.getCmp("alarmKeyCri").getValue().toString().toLowerCase();if(key_minor=="none"&&key_major=="none"){if(parseInt(key_critical)>=parseInt(key_normal)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert9,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyCri").focus(true);
}});return false;}}else{if(key_minor!="none"&&key_major=="none"){if(parseInt(key_minor)>=parseInt(key_normal)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert10,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyMin").focus();}});return false;}else{if(parseInt(key_critical)>parseInt(key_minor)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert11,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyCri").focus();
}});return false;}}}else{if(key_minor=="none"&&key_major!="none"){if(parseInt(key_major)>=parseInt(key_normal)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert12,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyMaj").focus(true);}});return false;}else{if(parseInt(key_critical)>parseInt(key_major)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert13,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyCri").focus(true);
}});return false;}}}else{if(key_minor!="none"&&key_major!="none"){if(parseInt(key_normal)>parseInt(key_minor)){if(parseInt(key_minor)>=parseInt(key_major)){if(parseInt(key_major)>=parseInt(key_critical)){}else{Ext.Msg.show({title:pageTitle1,msg:weightageAlert14,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyCri").focus(true);
}});return false;}}else{Ext.Msg.show({title:pageTitle1,msg:weightageAlert15,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyMaj").focus(true);}});return false;}}else{Ext.Msg.show({title:pageTitle1,msg:weightageAlert16,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmKeyMin").focus(true);
}});return false;}}}}}support_minor=Ext.getCmp("alarmSupMin").getValue().toString().toLowerCase();support_major=Ext.getCmp("alarmSupMaj").getValue().toString().toLowerCase();if(support_minor==null||support_minor.length==0){Ext.Msg.show({title:pageTitle1,msg:weightageAlert17,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupMin").focus(true);
}});return false;}else{if(support_minor.indexOf(" ")>-1){Ext.Msg.show({title:pageTitle1,msg:weightageAlert18,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupMin").focus(true);}});return false;}else{if(support_major==null||support_major.length==0){Ext.Msg.show({title:pageTitle1,msg:weightageAlert19,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupMaj").focus(true);
}});return false;}else{if(support_major.indexOf(" ")>-1){Ext.Msg.show({title:pageTitle1,msg:weightageAlert20,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupMaj").focus(true);}});return false;}else{if(support_minor!="none"&&isNaN(support_minor)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert21,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupMin").focus(true);
}});return false;}else{if(support_minor!="none"&&!isNaN(support_minor)&&support_minor.indexOf(".")>-1){Ext.Msg.show({title:pageTitle1,msg:weightageAlert22,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupMin").focus(true);}});return false;}else{if(support_major!="none"&&isNaN(support_major)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert23,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupMaj").focus(true);
}});return false;}else{if(support_major!="none"&&!isNaN(support_major)&&support_major.indexOf(".")>-1){Ext.Msg.show({title:pageTitle1,msg:weightageAlert24,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupMaj").focus(true);}});return false;}}}}}}}}support_normal=Ext.getCmp("alarmSupN").getValue().toString().toLowerCase();
support_critical=Ext.getCmp("alarmSupCri").getValue().toString().toLowerCase();if(support_minor=="none"&&support_major=="none"){if(parseInt(support_critical)>=parseInt(support_normal)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert25,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupCri").focus(true);
}});return false;}}else{if(support_minor!="none"&&support_major=="none"){if(parseInt(support_minor)>=parseInt(support_normal)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert26,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupMin").focus(true);}});return false;}else{if(parseInt(support_critical)>parseInt(support_minor)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert27,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupCri").focus(true);
}});return false;}}}else{if(support_minor=="none"&&support_major!="none"){if(parseInt(support_major)>=parseInt(support_normal)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert28,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupMaj").focus(true);}});return false;}else{if(parseInt(support_critical)>parseInt(support_major)){Ext.Msg.show({title:pageTitle1,msg:weightageAlert29,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupCri").focus(true);
}});return false;}}}else{if(support_minor!="none"&&support_major!="none"){if(parseInt(support_normal)>parseInt(support_minor)){if(parseInt(support_minor)>=parseInt(support_major)){if(parseInt(support_major)>=parseInt(support_critical)){return true;}else{Ext.Msg.show({title:pageTitle1,msg:weightageAlert30,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupCri").focus(true);
}});return false;}}else{Ext.Msg.show({title:pageTitle1,msg:weightageAlert31,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupMaj").focus(true);}});return false;}}else{Ext.Msg.show({title:pageTitle1,msg:weightageAlert32,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupMin").focus(true);
}});return false;}}}}}if(key_normal!=support_normal){Ext.Msg.show({title:pageTitle1,msg:weightageAlert33,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(){Ext.getCmp("alarmSupN").focus(true);}});return false;}return true;},loadMeasureTab:function(){var a=this;var c=Ext.getCmp("test").getValue();
var b="EgConfigMeasureJson.jsp?test="+c;compTestCtrlr=this.getController("CompositeTest.controller.MeasureWindowController");compTestCtrlr.init();compTestCtrlr.loadAddMeasureTab(b);},showAddMeasure:function(){operationCompMeasure="addCompMeasure";compTestCtrlr=this.getController("CompositeTest.controller.MeasureWindowController");
compTestCtrlr.loadPopup();},loadGenerateTab:function(){var b=this;var d=Ext.getCmp("test").getValue();var a=(d.indexOf("_")==d.lastIndexOf("_"));var c=Ext.getCmp("generateCntnr");c.removeAll();c.add({xtype:"container",layout:{type:"vbox",pack:"center",align:"center"},margin:10,items:[{xtype:"container",id:"dp_container_generate",layout:{type:"hbox",pack:"center"},hidden:false,cls:"formOuter",padding:10,width:800,defaultType:"displayfield",defaults:{labelAlign:"top",labelSeparator:"",width:250,margin:5},items:[{fieldLabel:"<b>"+test_name_label+"</b>",value:"-",id:"dp_testname_generate_tab"},{fieldLabel:"<b>"+compTypeDesc+"</b>",value:"-",id:"dp_comptype_generate_tab"},{fieldLabel:"<b>"+descbased+"</b>",value:"-",id:"dp_descriptor_generate_tab"}]}]},{xtype:"container",layout:{type:"vbox",pack:"center",align:"center"},margin:10,items:[{xtype:"container",cls:"formOuter",padding:10,width:800,layout:{type:"hbox",pack:"center"},defaults:{labelAlign:"top",labelSeparator:"",margin:5,width:250},items:[{xtype:"scrollcombo",id:"layerName",name:"layerName",hidden:false,fieldLabel:layerLabel,store:new Ext.data.Store({fields:["displayField","valueField"],data:[]}),displayField:"displayField",valueField:"valueField",queryMode:"local",editable:false,listeners:{select:function(){b.layerNameChanged();
}}},{xtype:"fieldcontainer",layout:"column",fieldLabel:weightageLabel,columnWidth:0.25,items:[{xtype:"scrollcombo",id:"weightageName",name:"weightageName",hidden:false,store:new Ext.data.Store({fields:["displayField","valueField"],data:[]}),displayField:"displayField",valueField:"valueField",queryMode:"local",editable:false,columnWidth:0.9,listeners:{select:function(){b.weightageTypeChanged();
}}},{xtype:"component",id:"reporterLogoIMG_enable",name:"reporterLogoIMG_enable",html:'<center><div class="iconUpload" style="cursor:pointer;margin-top: -3px" border="0" width="20" height="18" title="Click here to see weightage" onclick="addctrler.showWeightagePopupWindow()"></center>',columnWidth:0.1,margin:"8 0 0 2",hidden:false},{xtype:"component",id:"reporterLogoIMG_disable",name:"reporterLogoIMG_disable",html:'<center><div class="iconUploadDisabled" style="margin-top: -3px" border="0" width="20" height="18"></center>',columnWidth:0.1,margin:"8 0 0 2",hidden:true}]}]}]},{xtype:"container",layout:{type:"vbox",pack:"center",align:"center"},margin:10,items:[{xtype:"fieldset",width:800,title:alaramKeyMeasure,id:"alaramKeyContainer",name:"alaramKeyContainer",layout:{type:"hbox",pack:"center"},defaults:{labelSeparator:"",labelAlign:"top",margin:10},items:[{xtype:"numberfield",cls:"textbox",name:"alarmKeyN",id:"alarmKeyN",fieldLabel:alarmKeyNor,allowBlank:false,minValue:keyNormal_default,value:keyNormal_default,allowDecimals:false,hideTrigger:true,keyNavEnabled:false,mouseWheelEnabled:false},{xtype:"textfield",cls:"textbox",name:"alarmKeyMin",id:"alarmKeyMin",value:keyMinor_default,fieldLabel:alarmKeyMin,allowBlank:false},{xtype:"textfield",cls:"textbox",name:"alarmKeyMaj",id:"alarmKeyMaj",value:keyMajor_default,fieldLabel:alarmKeyMaj,allowBlank:false},{xtype:"numberfield",cls:"textbox",name:"alarmKeyCri",id:"alarmKeyCri",fieldLabel:alarmKeyCritical,allowBlank:false,minValue:keyCritical_default,value:keyCritical_default,allowDecimals:false,hideTrigger:true,keyNavEnabled:false,mouseWheelEnabled:false}]},{xtype:"fieldset",width:800,title:alaramSupportMeasure,id:"alaramSupportContainer",name:"alaramSupportContainer",layout:{type:"hbox",pack:"center"},defaults:{labelSeparator:"",labelAlign:"top",margin:10},items:[{xtype:"numberfield",cls:"textbox",fieldLabel:alarmKeyNor,id:"alarmSupN",allowBlank:false,minValue:supportNormal_default,value:supportNormal_default,allowDecimals:false,hideTrigger:true,keyNavEnabled:false,mouseWheelEnabled:false},{xtype:"textfield",cls:"textbox",name:"alarmSupMin",id:"alarmSupMin",fieldLabel:alarmKeyMin,allowBlank:false,value:supportMinor_default},{xtype:"textfield",cls:"textbox",name:"alarmSupMaj",id:"alarmSupMaj",fieldLabel:alarmKeyMaj,allowBlank:false,value:supportMajor_default},{xtype:"numberfield",cls:"textbox",name:"alarmSupCri",id:"alarmSupCri",fieldLabel:alarmKeyCritical,allowBlank:false,minValue:supportCritical_default,value:supportCritical_default,allowDecimals:false,hideTrigger:true,keyNavEnabled:false,mouseWheelEnabled:false}]}]},{xtype:"container",id:"confirmationContainer",layout:{type:"vbox",pack:"center",align:"center"},margin:10,items:[{xtype:"container",layout:{type:"vbox",pack:"center",align:"center"},defaults:{labelSeparator:"",margin:5,width:500,labelWidth:350},items:[{xtype:"radiogroup",fieldLabel:autoAssociateLabel,columns:2,cls:"radiobt",id:"testforId",listeners:{click:{element:"el",fn:function(e){if(Ext.getCmp(this.id).getValue().testfor=="yes"){Ext.getCmp("associated_comptypes").setVisible(true);
Ext.getCmp("associatedCompTypesContainer").setVisible(true);}else{Ext.getCmp("associated_comptypes").setVisible(false);Ext.getCmp("associatedCompTypesContainer").setVisible(false);}}}},items:[{boxLabel:yes,name:"testfor",id:"managedcomponents",inputValue:"yes",},{boxLabel:no,name:"testfor",id:"allcomponents",inputValue:"no",checked:true}]}]}]},{xtype:"container",layout:{type:"hbox",pack:"center",align:"center"},items:[{xtype:"container",cls:"formOuter",padding:10,width:800,id:"associatedCompTypesContainer",layout:{type:"hbox",pack:"center",align:"center"},hidden:true,margin:"0 10 20 10",items:[{xtype:"itemselector",name:"associated_comptypes",fieldName:"associated_comptypes",id:"associated_comptypes",cls:"multiselect",hidden:true,buttons:["add","remove"],buttonsText:{add:"Disassociate",remove:"Associate"},store:new Ext.data.Store({fields:["displayField","valueField"],data:[]}),displayField:"displayField",valueField:"valueField",msgTarget:"side",height:250,width:700,fromTitle:associatedCompTypesDesc,toTitle:availableCompTypesDesc,onAddBtnClick:function(){var f=this,e=f.getSelections(f.fromField.boundList);
f.moveRec(true,e);f.toField.boundList.getSelectionModel().select(e);},onRemoveBtnClick:function(){var f=this,e=f.getSelections(f.toField.boundList);f.moveRec(false,e);f.fromField.boundList.getSelectionModel().select(e);},onItemDblClick:function(e,f){this.moveRec(e===this.fromField.boundList,f);},syncValue:function(){var e=this;
e.mixins.field.setValue.call(e,e.setupValue(e.toField.store.getRange()));}},{xtype:"multiselectSi",title:associatedCompTypesDesc,cls:"multiselect",id:"defaultAssociatedComponents",name:"defaultAssociatedComponents",displayField:"displayField",valueField:"valueField",autoScroll:true,scroll:false,hidden:true,height:250,width:420,store:new Ext.data.Store({fields:["displayField","valueField"],data:[]})}]}]});
genJSON=null;Ext.Ajax.request({url:"CompositeTest/data/generateTestJson.jsp",method:"POST",async:false,success:function(i){if(i.status==200&&!Ext.isEmpty(i.responseText)){var g=i.responseText;genJSON=Ext.decode(g);showModifyTestAlert=genJSON.modifyTestAlert;var h=Ext.getCmp("layerName");h.getStore().loadRawData(genJSON.layers);
h.select(genJSON.selectedLayer);defaultCompType=genJSON.defaultCompType;var j=Ext.getCmp("confirmationContainer");j.setVisible(false);var f=Ext.getCmp("generateButton");var n=Ext.getCmp("generateButtonContainer");f.hide();n.hide();if(genJSON.selectedLayer!="-1"){j.setVisible(true);f.show();n.show();Ext.getCmp("confirmationContainer").setVisible(true);
var l=Ext.getCmp("testforId");l.setVisible(true);if(genJSON.multipleCompTypesAreAssociated){l.items.items[0].setValue(true);if(genJSON.is_predefined_test){Ext.getCmp("defaultAssociatedComponents").setVisible(true);Ext.getCmp("associated_comptypes").setVisible(false);}else{Ext.getCmp("associated_comptypes").setVisible(true);
Ext.getCmp("defaultAssociatedComponents").setVisible(false);}Ext.getCmp("associatedCompTypesContainer").setVisible(true);}else{l.items.items[1].setValue(true);if(genJSON.is_predefined_test){Ext.getCmp("defaultAssociatedComponents").setVisible(true);Ext.getCmp("associatedCompTypesContainer").setVisible(true);
}else{Ext.getCmp("defaultAssociatedComponents").setVisible(false);Ext.getCmp("associatedCompTypesContainer").setVisible(false);}Ext.getCmp("associated_comptypes").setVisible(false);}if(genJSON.is_predefined_test){l.setVisible(false);l.items.items[0].setValue(true);l.items.items[0].setDisabled(true);l.items.items[1].setDisabled(true);
}fromAssociatedComponentsFound=false;toAssociatedComponentsFound=false;Ext.getCmp("associated_comptypes").fromField.store.removeAll();Ext.getCmp("associated_comptypes").toField.store.removeAll();if(genJSON.associatedComponentsFound){fromAssociatedComponentsFound=true;var e=Ext.getCmp("associated_comptypes").fromField;
e.store.add(genJSON["associatedComponents"]);fromStore=genJSON["associatedComponents"];if(genJSON.is_predefined_test){Ext.getCmp("defaultAssociatedComponents").clearValue();Ext.getCmp("defaultAssociatedComponents").getStore().loadRawData(genJSON["associatedComponents"]);}}if(genJSON.availableComponentsFound){toAssociatedComponentsFound=true;
var k=Ext.getCmp("associated_comptypes").toField;k.store.add(genJSON["availableComponents"]);toStore=genJSON["availableComponents"];}}Ext.getCmp("dp_testname_generate_tab").setValue(genJSON.test_desc_generate_tab);Ext.getCmp("dp_comptype_generate_tab").setValue(genJSON.type_desc_generate_tab);Ext.getCmp("dp_descriptor_generate_tab").setValue(genJSON.descriptor_generate_tab);
var m=Ext.getCmp("weightageName");m.getStore().loadRawData(genJSON.weightageTypes);m.select(genJSON.selectedWeightageType);b.weightageTypeChanged();if(genJSON.selectedWeightageType=="CustomDefined"){Ext.getCmp("alarmKeyN").setValue(genJSON.keyNormal);Ext.getCmp("alarmKeyMin").setValue(genJSON.keyMinor);
Ext.getCmp("alarmKeyMaj").setValue(genJSON.keyMajor);Ext.getCmp("alarmKeyCri").setValue(genJSON.keyCritical);Ext.getCmp("alarmSupN").setValue(genJSON.supportNormal);Ext.getCmp("alarmSupMin").setValue(genJSON.supportMinor);Ext.getCmp("alarmSupMaj").setValue(genJSON.supportMajor);Ext.getCmp("alarmSupCri").setValue(genJSON.supportCritical);
}if(genJSON.isModifyTest){Ext.getCmp("generateButton").setText(update);}else{Ext.getCmp("generateButton").setText(generate);}}}});},generateCompTest:function(r){var u=Ext.getCmp("layerName").getValue();if(u==null||u=="-1"){Ext.Msg.show({title:pageTitle1,msg:layerAlert,buttons:Ext.Msg.OK});return;}if(!this.weightageValidation()){return;
}var h="";if(Ext.getCmp("testforId").getValue().testfor=="yes"){var n=Ext.getCmp("associated_comptypes");var j=n.fromField.store;for(var l=0;l<n.fromField.store.getCount();l++){var b=j.getAt(l).get("valueField");h+=","+b.trim();}if(h.length>0){h=h.substring(1);}if(h.length==0){Ext.Msg.show({title:pageTitle1,msg:cannotMsg,buttons:Ext.Msg.OK,icon:"iconInformation"});
Ext.getCmp("associated_comptypes").fromField.store.removeAll();Ext.getCmp("associated_comptypes").toField.store.removeAll();if(fromAssociatedComponentsFound){var i=Ext.getCmp("associated_comptypes").fromField;i.store.add(fromStore);}if(toAssociatedComponentsFound){var t=Ext.getCmp("associated_comptypes").toField;
t.store.add(toStore);}return;}}if(h.length==0){h=defaultCompType;}var a=Ext.getCmp("weightageName").getValue();var c=keyNormal_default;var o=keyMinor_default;var g=keyMajor_default;var k=keyCritical_default;var e=supportNormal_default;var f=supportMinor_default;var s=supportMajor_default;var p=supportCritical_default;
if(a=="CustomDefined"){c=Ext.getCmp("alarmKeyN").getValue();o=Ext.getCmp("alarmKeyMin").getValue();g=Ext.getCmp("alarmKeyMaj").getValue();k=Ext.getCmp("alarmKeyCri").getValue();e=Ext.getCmp("alarmSupN").getValue();f=Ext.getCmp("alarmSupMin").getValue();s=Ext.getCmp("alarmSupMaj").getValue();p=Ext.getCmp("alarmSupCri").getValue();
}var q=generateTest;if(genJSON.isModifyOperationNow){q=confrmMsg;if(genJSON.showModifyTestAlert||(genJSON.selectedLayer!=Ext.getCmp("layerName").getValue())){q=regenerateTest;}}var d="Key:"+c+":"+o+":"+g+":"+k+"#Sup:"+e+":"+f+":"+s+":"+p;Ext.Msg.show({title:pageTitle1,msg:q,closable:false,icon:"iconInformation",buttons:Ext.Msg.YESNO,fn:function(m){if(m=="yes"){Ext.Ajax.request({url:"CompositeTest/data/generateTestp.jsp?compTest="+r,method:"POST",params:{"layer":u,"weightageName":a,"weightageStr":d,"newly_associated_comp_types":h},async:false,success:function(v){if(v.status==200&&!Ext.isEmpty(v.responseText)){var w=v.responseText;
publicJSON=Ext.decode(w);Ext.Msg.show({title:pageTitle1,msg:publicJSON.operationResultMessage,closable:false,icon:"iconInformation",buttons:Ext.Msg.OK,fn:function(x){if(!publicJSON.isFailure&&x=="ok"){window.location.href="/final/admin/compositeTest.jsp";}}});}}});}}});},postURL:function(a){Ext.Ajax.request({url:"CompositeTest/data/"+a,method:"POST",async:false,success:function(b){if(b.status==200&&!Ext.isEmpty(b.responseText)){var c=b.responseText;
publicJSON=Ext.decode(c);}}});},loadTestTab:function(){var a=Ext.getCmp("test");var b=a.getValue();if(b!=null&&b!=""){testTabLoad=true;a.setReadOnly(true);Ext.getCmp("add").setText(updateTooltip);}},testModifyAlone:function(){var f=this;if(!this.validate()){return;}var e=Ext.getCmp("test").getValue();
var h=Ext.getCmp("test_display_name").getValue();var b=Ext.getCmp("componentType").getValue();if(b==null||b=="-1"){Ext.Msg.show({title:pageTitle1,msg:compTypeAlert,buttons:Ext.Msg.OK});return;}else{if(previousCompType!=null&&previousCompType!=b){Ext.Msg.show({title:pageTitle1,msg:forbiddenMessage,buttons:Ext.Msg.OK});
return;}}var g=Ext.getCmp("cx_test_description").getValue();var a=Ext.getCmp("allowedId").getValue().is_info_based_test;var c="-1";if(a=="true"){c=Ext.getCmp("testForInfos").getValue();if(c==null||c=="-1"){Ext.Msg.show({title:pageTitle1,msg:message2,buttons:Ext.Msg.OK});return;}}var i={"display_name":encodeURIComponent(h),"compType":b,"operation":"modifyTest","purpose_of_test":encodeURIComponent(g),"descriptor_based":a,"selected_master_test":c};
var d="EgaddtestpJson.jsp?add=test&test="+e;Ext.Ajax.request({url:"CompositeTest/data/"+d,method:"POST",params:i,async:false,success:function(j){if(j.status==200&&!Ext.isEmpty(j.responseText)){var k=j.responseText;publicJSON=Ext.decode(k);}}});if(publicJSON.AlertType=="Error"){Ext.Msg.show({title:pageTitle1,msg:publicJSON.AlertMsg,buttons:Ext.Msg.OK,icon:"iconError"});
}else{if(publicJSON.AlertType=="Result"){Ext.Msg.show({title:pageTitle1,msg:publicJSON.AlertMsg,closable:false,icon:"iconInformation",buttons:Ext.Msg.OK,fn:function(j){if(j=="ok"){Ext.getCmp("addMeasureTab").enable();Ext.getCmp("newtest").setActiveTab(1);}}});}}}});