Ext.define("ICTest.controller.AddSnmpTestCtrlr",{extend:"Ext.app.Controller",views:["AddNewTest"],requires:["ICTest.view.AddNewTest"],refs:[{selector:"addnewtest",ref:"addnewtest"},{selector:"defaultthresholds",ref:"defaultthresholds"},],init:function(){snmpCtrlr=this;this.control({"addnewtest":{"afterrender":this.afterMainRender},'addnewtest combo[id="elements"]':{"select":this.elementsSelection},'addnewtest button[id="elmtMib"]':{"click":this.showElementMibTree},'addnewtest button[id="statusMib"]':{"click":this.showElementStatusTree}});
},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 c=0;c<e.length;c++){var b=e[c];if(!(b.measureName=="Installed")){i.add({xtype:"fieldset",title:"<b>"+b.measureIndex+". "+b.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"+c,value:b.databaseColumnSize,hidden:b.hideDatabaseColumnSize},{xtype:"displayfield",id:"unitVal"+c,fieldLabel:unit,value:filterDecode(b.unit)},{xtype:"displayfield",fieldLabel:procMthd,id:"processMethodVal"+c,value:b.processMethod},{xtype:"displayfield",fieldLabel:convFact,id:"conFact"+c,value:b.conversionFactor,hidden:b.hideConversionFactor},{xtype:"displayfield",fieldLabel:alrmDispStr,id:"alarmDisp"+c,value:b.alarmDispString,hidden:b.hideAlarmDispStr},{xtype:"displayfield",fieldLabel:objOID,id:"objId"+c,value:b.objectOID,}]},{xtype:"container",layout:{type:"hbox",pack:"center"},defaults:{width:80},items:[{xtype:"button",cls:"button20",text:modifyTooltip,modifyURL:b.modifyURL,handler:function(){j.showModifyMeasure(this.modifyURL);
},margin:"5 0 10 0"},{xtype:"button",cls:"button20",text:deleteTooltip,deleteURL:b.deleteURL,measureName:b.measureName,handler:function(){j.deleteMeasure(this.deleteURL,this.measureName);},margin:"5 0 10 20"}]}]});var h=Ext.getCmp("dbSize"+c);var l=Ext.getCmp("unitVal"+c);var d=Ext.getCmp("processMethodVal"+c);
var g=Ext.getCmp("conFact"+c);var k=Ext.getCmp("alarmDisp"+c);var a=Ext.getCmp("objId"+c);if(isConfigTest){h.hide();l.hide();d.hide();g.hide();k.hide();a.show();}}}}},showAddNewMeasure:function(){var h=this;var g=Ext.getCmp("test").getValue();var f="EgConfigSnmpMeasureJson.jsp?test="+g;h.loadAddMeasureTab(f);
selMibFile="";selElmtFile="";selStusFile="";oidFldName="";elmtFldName="";stusFldName="";Ext.create("Ext.window.Window",{title:newMeasDetail,width:500,id:"addSnmpMeasureWindow",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(j){h.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(j){h.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:"container",layout:{type:"hbox",pack:"start",align:"center"},defaults:{labelSeparator:"",labelWidth:200},items:[{xtype:"textfield",cls:"textbox",fieldLabel:objOID,id:"oid",name:"oid",maxLength:100,width:380,enforceMaxLength:true},{xtype:"button",iconCls:"iconTree",border:0,style:{"background":"none"},listeners:{el:{click:function(){h.showMibTree("config","ObjectOID");
}}}}]},{xtype:"button",cls:"button20",text:add,id:"addMeasureButton",width:80,listeners:{click:{fn:function(j){h.doAddNewMeasure();}}},margin:"5 5 20 5"}]}).show();Ext.getCmp("index").setValue(publicJSON.measIndex);var e=Ext.getCmp("dbsize");var b=Ext.getCmp("alarmdescription");var i=Ext.getCmp("process");
var c=Ext.getCmp("un");var a="";if(isConfigTest){e.hide();b.hide();i.hide();c.hide();}else{e.show();e.getStore().loadRawData(publicJSON.dbColSizeList);e.setValue("2");b.show();Ext.getCmp("process").getStore().loadRawData(publicJSON.processMethodList);a=publicJSON.selectedProcessMethod;Ext.getCmp("process").setValue(a);
Ext.getCmp("un").getStore().loadRawData(publicJSON.unitsList);Ext.getCmp("un").setValue("-1");}var d=Ext.getCmp("cFactor");if(a=="UNALTERED"||a=="DIFFERENCE"){d.show();d.getStore().loadRawData(publicJSON.convFactorList);d.setValue(publicJSON.convFactorSelected);}else{d.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 a=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 b=Ext.getCmp("process").getValue();var c=Ext.getCmp("oid").getValue();
if(b==null&&isConfigTest){b="UNALTERED";j="1";}if(b!="UNALTERED"&&b!="DIFFERENCE"){j="none";}var e="ICTest/data/EgconfigsnmpmeasurepJson.jsp?add=add&test="+h+"&measure="+a+"&factor="+j+"&oid="+c;e+="&dbsize="+f+"&otherunit="+l+"&un="+encodeURIComponent(filterEncode(k))+"&alarmdescription="+encodeURIComponent(d)+"&index="+g+"&process="+b;
e+="&fileName="+selMibFile+"&oid_fieldName="+oidFldName;if(!this.measureValidation(a,k,l,d,c)){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",fn:function(m){if(m=="ok"){Ext.getCmp("addSnmpMeasureWindow").close();
i.showAddNewMeasure();}}});}else{if(publicJSON.AlertType=="Result"){Ext.getCmp("generateCntnr").enable();Ext.getCmp("tab6Help").enable();Ext.Msg.show({title:publicJSON.AlertTitle,msg:publicJSON.AlertMsg+". "+alertMsg80,buttons:Ext.Msg.YESNO,icon:"iconInformation",closable:false,fn:function(m){if(m=="yes"){Ext.getCmp("addSnmpMeasureWindow").close();
var n=publicJSON.forwardURL;i.loadAddMeasureTab(n);i.showAddNewMeasure();}else{if(m=="no"){Ext.getCmp("addSnmpMeasureWindow").close();var n=publicJSON.forwardURL;i.loadAddMeasureTab(n);Ext.getCmp("newtest").setActiveTab(4);}}}});}}},measureValidation:function(l,m,o,e,f){var j=this;var b=Ext.getCmp("measure");
var c=Ext.getCmp("alarmdescription");var n=Ext.getCmp("otherunit");var g=Ext.getCmp("oid");var p=new Array("other","none","null","all");var d=false;var k=true;var i=Ext.getCmp("type").getValue();if(i!=null&&i=="Configuration"){d=true;}if(!d){if(!j.checkSpecialChar(e,"~!@#$%^&*()|:,;'<>")){Ext.Msg.show({title:newMeasDetail,msg:splCharAlert,buttons:Ext.Msg.OK,icon:"iconExclamation"});
c.focus(true);return false;}if(isDouble=="false"){k=validateSingleByte(e);}}l=l.toUpperCase();if(l=="TRGT_HOST"||l=="PORT_NO"||l=="SITE_NAME"||l=="INFO"||l=="MSMT_HOST"||l=="MSMT_TIME"){Ext.Msg.show({title:newMeasDetail,msg:alertMsg14,buttons:Ext.Msg.OK,icon:"iconExclamation"});return false;}var a=l.charAt(0);
var h=!d?m:"NONE";if(!checkblank(l)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg15,buttons:Ext.Msg.OK,icon:"iconExclamation"});b.focus(true);return false;}else{if(!checkspace(l)){b.focus(true);return false;}else{if(!checkspecialnomess(l,"`~!@#$%^&*()+=-/?'\"]{}[\\|;:.,><")){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(l)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg18,buttons:Ext.Msg.OK,icon:"iconExclamation"});b.focus(true);return false;}else{if(h=="-1"){Ext.Msg.show({title:newMeasDetail,msg:alertMsg19,buttons:Ext.Msg.OK,icon:"iconExclamation"});return false;}else{if(!k){Ext.Msg.show({title:newMeasDetail,msg:alertMsg20,buttons:Ext.Msg.OK,icon:"iconExclamation"});
c.focus(true);return false;}else{if(h=="other"){if(!checkblank(o)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg21,buttons:Ext.Msg.OK,icon:"iconExclamation"});return false;}else{if(!checkspace(o)){n.focus(true);return false;}else{if(!checkspecialnomess(o,"`~!@#^&*()+=-?'\"]{}[\\|;:.,><")){Ext.Msg.show({title:newMeasDetail,msg:alertMsg3,buttons:Ext.Msg.OK,icon:"iconExclamation"});
n.focus(true);return false;}else{if(!checkKeywords(o,p)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg22,buttons:Ext.Msg.OK,icon:"iconExclamation"});n.focus(true);return false;}}}}}else{if(!checkblank(f)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg46,buttons:Ext.Msg.OK,icon:"iconExclamation"});g.focus(true);
return false;}else{if(!checkspecialnomess(f,"`~!@#$%^&*()+=-_?'\"]{}[\\|;:,><")){Ext.Msg.show({title:newMeasDetail,msg:alertMsg3,buttons:Ext.Msg.OK,icon:"iconExclamation"});g.focus(true);return false;}else{if(checkAlpha(f)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg47,buttons:Ext.Msg.OK,icon:"iconExclamation"});
g.focus(true);return false;}else{if(!validateSingleByte(f)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg48,buttons:Ext.Msg.OK,icon:"iconExclamation"});g.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);}}});}}}});},elementsSelection:function(){var e=Ext.getCmp("elements").getValue();
var c=Ext.getCmp("multiGroup");var d=Ext.getCmp("dbSizeGen");var a=false;var f="";var b=Ext.getCmp("type").getValue();if(b!=null&&b=="Configuration"){a=true;}if(e=="Single Element"){c.hide();c.disable();d.setWidth(450);if(a){f=Ext.getCmp("isDescriptorBasedTestSnmp");descFielLabelObj=Ext.getCmp("descCheckBox");
f.hide();descFielLabelObj.hide();}}else{if(e=="Multiple Elements"){c.show();c.enable();d.setWidth(450);if(a){f=Ext.getCmp("isDescriptorBasedTestSnmp");descFielLabelObj=Ext.getCmp("descCheckBox");f.show();descFielLabelObj.show();f.setValue(true);f.setReadOnly(true);}}}},generateSnmpTest:function(){var f=Ext.getCmp("elements").getValue();
var g="";var m="";var k="";var n="";if(f=="Multiple Elements"){var h=Ext.getCmp("elementOid");g=h.getValue();var d=Ext.getCmp("validOid");m=d.getValue();var l=Ext.getCmp("validValue");k=l.getValue();var a=Ext.getCmp("rediscPeriod");n=a.getValue();if(!checkblank(g)){Ext.Msg.show({title:generate,msg:alertMsg49,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(o){if(o=="ok"){h.focus(true);
}}});return;}else{if(!checkspecialnomess(g,"`~!@#$%^&*()+=-_?'\"]{}[\\|;:,><")){Ext.Msg.show({title:generate,msg:alertMsg3,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(o){if(o=="ok"){h.focus(true);}}});return;}else{if(checkAlpha(g)){Ext.Msg.show({title:generate,msg:alertMsg47,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(o){if(o=="ok"){h.focus(true);
}}});return;}else{if(!validateSingleByte(g)){Ext.Msg.show({title:generate,msg:alertMsg50,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(o){if(o=="ok"){h.focus(true);}}});return;}else{if(!validateSingleByte(m)){Ext.Msg.show({title:generate,msg:alertMsg51,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(o){if(o=="ok"){d.focus(true);
}}});return;}else{if(!validateSingleByte(k)){Ext.Msg.show({title:generate,msg:alertMsg52,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(o){if(o=="ok"){d.focus(true);}}});return;}else{if(!checkblank(n)){Ext.Msg.show({title:generate,msg:alertMsg53,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(o){if(o=="ok"){a.focus(true);
}}});return;}else{if(!checkspecialnomess(n,"`~!@#$%^&*()+=-_?'\"]{}[\\|;.:,><")){Ext.Msg.show({title:generate,msg:alertMsg3,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(o){if(o=="ok"){a.focus(true);}}});return;}else{if(checkAlpha(n)){Ext.Msg.show({title:generate,msg:alertMsg47,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(o){if(o=="ok"){a.focus(true);
}}});return;}else{if(n==0){Ext.Msg.show({title:generate,msg:alertMsg54,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(o){if(o=="ok"){a.focus(true);}}});return;}else{if(!validateSingleByte(n)){Ext.Msg.show({title:generate,msg:alertMsg55,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(o){if(o=="ok"){a.focus(true);
}}});return;}}}}}}}}}}}if(publicJSON.snmpElement!=null&&publicJSON.snmpElement!=""&&publicJSON.snmpElement!=undefined){alert(alertMsg30);}}var j=Ext.getCmp("test").getValue();var c="ICTest/data/EgconfigsnmpmeasurepJson.jsp?add=gen&test="+j+"&elementOid="+g+"&validOid="+m+"&validValue="+k;c+="&rediscPeriod="+n+"&element_fileName="+selElmtFile+"&status_fileName="+selStusFile+"&element_fieldName="+elmtFldName+"&status_fieldName="+stusFldName;
if(isConfigTest){var b=Ext.getCmp("dbSizeGen").getValue();var i=Ext.getCmp("isDescriptorBasedTestSnmp").getValue();c+="&dbsize="+b+"&descVal="+i;}Ext.Ajax.request({url:c,method:"POST",async:false,success:function(o){if(o.status==200&&!Ext.isEmpty(o.responseText)){var p=o.responseText;publicJSON=Ext.decode(p);
}}});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(o){if(o=="ok"){window.location.href="/final/admin/EgUDTest.jsp";
}}});}}if(!Ext.isEmpty(publicJSON.forwardURL)){this.getController("ICTest.controller.ThresholdCtrlr").init();var e=Ext.getCmp("generateCntnr");e.removeAll();var c=publicJSON.forwardURL;qString="ICTest/data/"+c;e.add({xtype:"defaultthresholds"});}},showModifyMeasure:function(d){var c;Ext.Ajax.request({url:"ICTest/data/"+d+"&testType=Snmp",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,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){snmpCtrlr.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){snmpCtrlr.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:"container",layout:{type:"hbox",pack:"center",align:"center"},defaults:{labelSeparator:"",margin:5,},items:[{xtype:"textfield",cls:"textbox",fieldLabel:objOID,id:"s_oid",name:"s_oid",maxLength:100,enforceMaxLength:true,value:c.oidValue,labelWidth:200,width:370},{xtype:"button",iconCls:"iconTree",border:0,style:{"background":"none"},listeners:{el:{click:function(){snmpCtrlr.showMibTree("config","ObjectOID","modify",c.oidValue,c.hiddens.fileName);
}}}}]},{xtype:"button",cls:"button20",text:modifyTooltip,id:"modMeasureButton",width:80,margin:"5 5 20 5",listeners:{click:{fn:function(h){var g=Ext.getCmp("s_measure").getValue();var n=Ext.getCmp("s_otherunit").getValue();var k=Ext.getCmp("s_un").getValue();var j=Ext.getCmp("alarmdescription").getValue();
var i=Ext.getCmp("s_oid").getValue();if(!snmpCtrlr.measureValidation(g,k,n,j,i)){return;}var l=Ext.getCmp("measureform").getForm();if(l.isValid()){var o=new Ext.LoadMask(Ext.getBody(),{msg:updating+"..."});var m=encodeFieldParams(l);o.show();l.submit({method:"POST",params:m,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="EgConfigSnmpMeasureJson.jsp?test="+u;snmpCtrlr.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="EgConfigSnmpMeasureJson.jsp?test="+x;snmpCtrlr.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]});}},showMibTree:function(g,f,c,a,e){var d="showMibFilesJson.jsp?from="+g+"&fieldName="+f;if(isModifyTest){c="modify";}if(e==null||e==""||e=="undefined"){e="-1";}if(c!=null&&c=="modify"){if(snmpElmtIDFile==""){snmpElmtIDFile=publicJSON.hiddens.element_fileName;
}if(snmpElmtStatusFile==""){snmpElmtStatusFile=publicJSON.hiddens.status_fileName;}if(f=="ObjectOID"){d+="&fileList="+e+"&OID="+a;}else{if(f=="ElementOID"){d+="&fileList="+snmpElmtIDFile+"&OID="+snmpElmtID;}else{if(f=="StatusOID"){d+="&fileList="+snmpElmtStatusFile+"&OID="+snmpElmtStatus;}}}}Ext.Ajax.request({url:"ICTest/data/"+d,method:"POST",async:false,success:function(h){if(h.status==200&&!Ext.isEmpty(h.responseText)){var i=h.responseText;
publicJSON=Ext.decode(i);}}});var b=this;Ext.create("Ext.window.Window",{title:modMeas,height:478,width:800,id:"mibWindow",layout:{type:"hbox",pack:"center",align:"stretch"},listeners:{close:function(){Ext.Ajax.request({url:"ICTest/data/ictesthelpJson.jsp?selectTab=addMeasureTab&testType=Snmp",method:"POST"});
}},dockedItems:[{dock:"bottom",layout:{type:"hbox",pack:"center"},border:false,padding:"10 0 7 0",items:[{xtype:"button",text:"OK",id:"ok",name:"ok",width:80,cls:"quickMenuWhiteButton",listeners:{el:{click:function(){var i=Ext.getCmp("objOid").getValue();if(f=="ObjectOID"){var h=Ext.getCmp("modScriptMeasureWindow");
if(h!=undefined||h!=null){Ext.getCmp("s_oid").setValue(i);var k=Ext.getCmp("measureform").getForm().findField("fileName").getValue();var j=Ext.getCmp("fileList").getValue();if(j!=null&&k!==j){Ext.getCmp("measureform").getForm().findField("fileName").setValue(j);}}else{Ext.getCmp("oid").setValue(i);}}else{if(f=="ElementOID"){Ext.getCmp("elementOid").setValue(i);
}else{if(f=="StatusOID"){Ext.getCmp("validOid").setValue(i);}}}Ext.getCmp("mibWindow").close();}}}}]}],items:[{xtype:"container",border:true,cls:"border-theme",layout:{type:"vbox",align:"stretch"},flex:0.5,margin:"5 0 5 5",items:[{xtype:"fieldcontainer",layout:"column",margin:5,items:[{xtype:"scrollcombo",cls:"dropdown",id:"fileList",name:"fileList",fieldLabel:mibFiles,store:new Ext.data.Store({fields:["displayField","valueField"],data:[]}),displayField:"displayField",valueField:"valueField",queryMode:"local",labelSeparator:"",editable:false,labelWidth:60,listeners:{select:{fn:function(h){b.mibFileSelection(g,f,c,true);
}}},columnWidth:0.9},{xtype:"button",iconCls:"iconUpload",columnWidth:0.1,border:0,style:{"background":"none"},tooltip:"Upload",margin:"0 0 0 10",listeners:{click:{fn:function(){b.uploadMibFile(g,f);}}},}]},{xtype:"fieldcontainer",id:"treepanalCntnr",layout:{type:"vbox",align:"stretch"},cls:"border-theme",margin:"0 5 5 5",flex:1},{xtype:"textfield",cls:"textbox",fieldLabel:"OID",id:"objOid",labelSeparator:"",labelWidth:60,margin:"0 5 5 5"}]},{xtype:"container",border:true,cls:"border-theme",flex:0.5,layout:{type:"hbox",align:"stretch"},margin:"5 5 5 5",items:[{xtype:"container",id:"displayFieldCntnr",layout:{type:"vbox",align:"stretch"},defaults:{labelSeparator:"",labelAlign:"top",readOnly:true},flex:1,hidden:true,items:[{xtype:"textfield",cls:"textbox",fieldLabel:"Name",id:"name",margin:"9 5 5 5"},{xtype:"textarea",fieldLabel:"Fullname",cls:"text-area",id:"fullname",margin:"5 5 5 5"},{xtype:"fieldcontainer",layout:"column",defaults:{labelSeparator:"",columnWidth:0.5,labelAlign:"top",readOnly:true},margin:"5 5 5 5",items:[{xtype:"textfield",cls:"textbox",fieldLabel:"Access",id:"access"},{xtype:"textfield",cls:"textbox",fieldLabel:"Syntax",id:"syntax",margin:"0 0 0 5"}]},{xtype:"fieldcontainer",layout:"column",defaults:{labelSeparator:"",columnWidth:0.33,labelAlign:"top",readOnly:true},margin:"5 5 5 5",items:[{xtype:"textfield",cls:"textbox",fieldLabel:"Status",id:"status",columnWidth:0.34},{xtype:"textfield",cls:"textbox",fieldLabel:"IsIndexNode",id:"isIndexNode",margin:"0 0 0 5"},{xtype:"textfield",cls:"textbox",fieldLabel:"IsV2Trap",id:"isV2Trap",margin:"0 0 0 5"}]},{xtype:"textarea",cls:"text-area",fieldLabel:"Description",id:"description",margin:"5 5 5 5",rows:6}]}]}]}).show();
Ext.getCmp("fileList").getStore().loadRawData(publicJSON.mibFilesList);if(c!=null&&c=="modify"){if(f=="ElementOID"){if(snmpElmtIDFile==null||snmpElmtIDFile==undefined||snmpElmtIDFile==""){Ext.getCmp("fileList").setValue("-1");}else{Ext.getCmp("fileList").setValue(snmpElmtIDFile);b.mibFileSelection(g,f,c,false);
}}else{if(f=="StatusOID"){if(snmpElmtStatusFile==null||snmpElmtStatusFile==undefined||snmpElmtStatusFile==""){Ext.getCmp("fileList").setValue("-1");}else{Ext.getCmp("fileList").setValue(snmpElmtStatusFile);b.mibFileSelection(g,f,c,false);}}else{Ext.getCmp("fileList").setValue(publicJSON.hiddens.fileName);
b.mibFileSelection(g,f,c,false);}}}else{Ext.getCmp("fileList").setValue("-1");}},uploadMibFile:function(c,b){var a=this;Ext.widget("window",{title:fileUpload,width:350,height:150,id:"file",name:"file",resizable:"false",items:[{xtype:"form",id:"uploadform",name:"uploadform",url:"../servlet/com.eg.EgUploadServlet",height:150,items:[{xtype:"fileuploadfield",cls:"fileupload",id:"file1",name:"file1",labelSeparator:"",emptyText:noFileSel,fieldLabel:file2Upload,labelAlign:"top",width:290,buttonText:"Browse",margin:"15 0 0 15",},{xtype:"button",text:upload,id:"upload",name:"upload",action:"upload",cls:"button20",align:"center",margin:"15 0 0 140",handler:function(g,j){var i=Ext.getCmp("uploadform").getForm().findField("file1").getValue();
var l=i.lastIndexOf("fakepath");if(l>0){i=i.substring(l+9);}var f="";var h=i.lastIndexOf(".");if(h>0){f=i.substring(h);}f=f.toLowerCase();var k=true;if(!validateSingleByte(i)){Ext.Msg.show({title:fileUpload,msg:alertMsg23,buttons:Ext.Msg.OK,icon:"iconExclamation"});Ext.getCmp("file1").focus(true);k=false;
}else{if(i==""){Ext.Msg.show({title:fileUpload,msg:alertMsg24,buttons:Ext.Msg.OK,icon:"iconExclamation"});Ext.getCmp("file1").focus(true);k=false;}else{if(f!=".txt"&&f!=".mib"){Ext.Msg.show({title:fileUpload,msg:alertMsg74,buttons:Ext.Msg.OK,icon:"iconExclamation"});Ext.getCmp("file1").focus(true);k=false;
}}}if(!k){return false;}else{if(publicJSON.existingFiles.indexOf(i)!=-1){Ext.Msg.show({title:fileUpload,msg:alertMsg73,buttons:Ext.Msg.OKCANCEL,icon:"iconConfirmation",fn:function(m){if(m=="ok"){var e=Ext.getCmp("uploadform").getForm();if(e.isValid()){e.submit({method:"POST",success:function(n,p){var o=p.response.responseText;
var q=Ext.decode(o);if(!Ext.isEmpty(q.uploadStatus)&&q.uploadStatus=="true"){g.up(".window").close();Ext.Msg.show({title:fileUpload,msg:alertMsg82,buttons:Ext.Msg.OK,icon:"iconInformation",fn:function(r){if(r=="ok"){Ext.getCmp("mibWindow").close();a.showMibTree(c,b);}}});}else{Ext.Msg.show({title:fileUpload,msg:q.statusMsg,buttons:Ext.Msg.OK,icon:"iconInformation",fn:function(r){if(r=="ok"){}}});
}},failure:function(n,o){Ext.Msg.alert(fileUpload,"Not able to upload the selected MIB file. Please try again");}});}else{}}else{g.up(".window").close();}}});}else{var d=Ext.getCmp("uploadform").getForm();if(d.isValid()){d.submit({method:"POST",success:function(e,n){var m=n.response.responseText;var o=Ext.decode(m);
if(!Ext.isEmpty(o.uploadStatus)&&o.uploadStatus=="true"){g.up(".window").close();Ext.Msg.show({title:fileUpload,msg:alertMsg82,buttons:Ext.Msg.OK,icon:"iconInformation",fn:function(p){if(p=="ok"){Ext.getCmp("mibWindow").close();a.showMibTree(c,b);}}});}else{Ext.Msg.show({title:fileUpload,msg:o.statusMsg,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(p){if(p=="ok"){}}});
}},failure:function(e,m){Ext.Msg.alert(fileUpload,"Not able to upload the selected MIB file. Please try again");}});}else{}}}}}],listeners:{afterrender:function(){var d=Ext.getCmp("uploadform");d.add({xtype:"hidden",name:"uploadMIB",value:"true"});d.add({xtype:"hidden",name:"fromMIBBrowser",value:"true"});
d.add({xtype:"hidden",name:"comeFrom",value:"icMIB"});},}}]}).show();},mibFileSelection:function(j,k,f,c){var e="";var i=false;var h=Ext.getCmp("fileList").getValue();if(k=="ElementOID"){selElmtFile=h;elmtFldName=k;}else{if(k=="StatusOID"){selStusFile=h;stusFldName=k;}else{selMibFile=h;oidFldName=k;}}var a="mibTree.jsp?MibFileName="+h+"&fieldName="+k+"&from="+j+"&expanded="+i;
if(f=="modify"){var g=publicJSON.hiddens.fileName;var b=publicJSON.oidValue;e=b;if(c){g=h;b="";}else{i=true;Ext.getCmp("fileList").setValue(g);}a="mibTree.jsp?MibFileName="+g+"&fieldName="+k+"&from="+j+"&oid="+b+"&expanded="+i;}if(h!="-1"){var d=Ext.create("Ext.data.TreeStore",{fields:[{name:"text",type:"string"},{name:"leaf",type:"boolean"},{name:"expanded",defaultValue:true},{name:"id",type:"string"},{name:"name",type:"string"},{name:"fullName",type:"string"},{name:"syntax",type:"string"},{name:"access",type:"string"},{name:"status",type:"string"},{name:"isIndexNode",type:"boolean"},{name:"isV2Trap",type:"boolean"},{name:"description",type:"string"},]});
Ext.Ajax.request({url:a,success:function(m){var q=Ext.decode(m.responseText);if(q.jsonarray==null||q.jsonarray.length>0){d.setRootNode({text:"MIB Tree",id:"",iconCls:"iconTree",expandable:false,children:q.jsonarray});Ext.getCmp("treepanalCntnr").show();Ext.getCmp("displayFieldCntnr").show();Ext.getCmp("objOid").show();
Ext.getCmp("treepanalCntnr").removeAll();var p=Ext.create("Ext.tree.Panel",{flex:1,rootVisible:true,cls:"treePanelDesign",animate:false,store:d,listeners:{itemclick:function(s,r){if(r.get("id")!=""){Ext.getCmp("objOid").setValue(r.get("id"));Ext.getCmp("name").setValue(r.get("name"));Ext.getCmp("fullname").setValue(r.get("fullName"));
Ext.getCmp("syntax").setValue(r.get("syntax"));Ext.getCmp("access").setValue(r.get("access"));Ext.getCmp("status").setValue(r.get("status"));Ext.getCmp("isIndexNode").setValue(r.get("isIndexNode"));Ext.getCmp("isV2Trap").setValue(r.get("isV2Trap"));Ext.getCmp("description").setValue(r.get("description"));
}}}});Ext.getCmp("treepanalCntnr").add(p);if(e!=""){if(c){Ext.getCmp("objOid").setValue("");Ext.getCmp("name").setValue("");Ext.getCmp("fullname").setValue("");Ext.getCmp("syntax").setValue("");Ext.getCmp("access").setValue("");Ext.getCmp("status").setValue("");Ext.getCmp("isIndexNode").setValue("");
Ext.getCmp("isV2Trap").setValue("");Ext.getCmp("description").setValue("");}else{var l=p.getStore().getNodeById(e);p.getSelectionModel().select(l);d.getRootNode().cascadeBy(function(s){var r=s.raw.id;if(r==e){Ext.getCmp("objOid").setValue(s.raw.id);Ext.getCmp("name").setValue(s.raw.name);Ext.getCmp("fullname").setValue(s.raw.fullName);
Ext.getCmp("syntax").setValue(s.raw.syntax);Ext.getCmp("access").setValue(s.raw.access);Ext.getCmp("status").setValue(s.raw.status);Ext.getCmp("isIndexNode").setValue(s.raw.isIndexNode);Ext.getCmp("isV2Trap").setValue(s.raw.isV2Trap);Ext.getCmp("description").setValue(s.raw.description);}});}}}else{var n="Invalid MIB file";
if(!Ext.isEmpty(q.validMsg)){n=q.validMsg;}Ext.getCmp("treepanalCntnr").show();Ext.getCmp("treepanalCntnr").removeAll();var o=Ext.create("Ext.container.Container",{html:"<table align='center'><tr height=150><td valign='bottom' align='center'><div class='iconInformation'/></td></tr><tr><td valign='top' align='center'>"+n+"</td></tr></table>",});
Ext.getCmp("objOid").setValue("");Ext.getCmp("treepanalCntnr").add(o);Ext.getCmp("displayFieldCntnr").hide();}}});}else{Ext.getCmp("objOid").hide();Ext.getCmp("treepanalCntnr").hide();Ext.getCmp("displayFieldCntnr").hide();}},showElementMibTree:function(){var a="";if(isModifyTest){a="modify";}this.showMibTree("config","ElementOID",a);
},showElementStatusTree:function(){var a="";if(isModifyTest){a="modify";}this.showMibTree("config","StatusOID",a);},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;}});