Ext.define("ICTest.controller.DatasetController",{extend:"Ext.app.Controller",views:["AddNewDSN"],requires:["ICTest.view.AddNewDSN","ICTest.view.RESTHeaderGrid","ICTest.view.RESTParamsGrid","ICTest.view.RESTBodyUrlEncodedGrid","ICTest.view.RESTDataGrid","utilities.TreeScrollPanel","ICTest.view.RESTGenerate","ICTest.view.RESTMeasureMappingGrid"],refs:[{selector:"addnewdsn",ref:"addnewdsn"},{selector:"RESTParamsGrid",ref:"RESTParamsGrid"},{selector:"RESTHeaderGrid",ref:"RESTHeaderGrid"},{selector:"RESTBodyUrlEncodedGrid",ref:"RESTBodyUrlEncodedGrid"},{selector:"restgenerate",ref:"restgenerate"},{selector:"restMeasureMappingGrid",ref:"restMeasureMappingGrid"},],init:function(){if(Ext.isEmpty(datasetCtrlr)){datasetCtrlr=this;
}this.control({'addnewdsn combo[id="restHttpMethod"]':{"select":this.restHttpMethodChange},'addnewdsn checkbox[id="User_Authentication_Required"]':{"change":this.enableUserAuthenticationSettings},'addnewdsn checkbox[id="Header_Required"]':{"change":this.enableHeaderRequiredSettings},'addnewdsn checkbox[id="params_Required"]':{"change":this.enableParamsRequiredSettings},'addnewdsn button[id="addHeader"]':{"click":this.addHeader},'addnewdsn button[id="rest_header"]':{"click":this.addBasicAuth},'addnewdsn button[id="addParam"]':{"click":this.addParam},'restgenerate button[id="addParam"]':{"click":this.addMeasureInternalValueConfiguration},'addnewdsn radiogroup[id="body_type"]':{"change":this.body_typeSettings},'addnewdsn button[id="addBody_urlencoded"]':{"click":this.addBody_urlencoded},'addnewdsn button[id="getData"]':{"click":this.saveRESTDSN},'restgenerate checkbox[id="DescriptorRequired"]':{"change":this.enableDescriptorDataRestFldSelection},'restgenerate button[id="generate"]':{"click":this.generateRESTTest}});
},selectFields:function(){var C=this;var w=Ext.getCmp("test").getValue();var v="EgConfigRESTMeasureJson.jsp?test="+w;Ext.Ajax.request({url:"ICTest/data/"+v,method:"POST",async:false,success:function(d){if(d.status==200&&!Ext.isEmpty(d.responseText)){var i=d.responseText;publicJSON=Ext.decode(i);}}});
var B=Ext.getCmp("restDataConfigurationWindow");var q=false;var r="";var b=[];var p="";var m="";var e=document.getElementsByClassName("messageCheckbox");var o="";if(B!=null&&B.hasOwnProperty("dataTypeMapping")){o=B.dataTypeMapping;}var n=0;var A=false;var u=[];var j=[];var z=Ext.getCmp("restDataGrid");
var m=z.dataFieldParentNode;var x=[];var a=0;if(!Ext.isEmpty(z)&&z.hasOwnProperty("selectedDataFieldsMap")){selectedDataFieldsMap=z.selectedDataFieldsMap;selectedFldsMapping=selectedDataFieldsMap;if(!Ext.isEmpty(selectedDataFieldsMap)){for(var y in selectedDataFieldsMap){var l=y;a++;if(l!=null&&l==m){continue;
}var f=selectedDataFieldsMap[y];for(var c in f){var k=f[c];u.push(k+"|^|"+l);}}publicJSON.restFldMap=selectedDataFieldsMap;}}for(var t=0;e[t];++t){if(e[t].checked){var k=e[t].value;if(o!=null&&o.hasOwnProperty(k)){var g=o[e[t].value];if(Ext.isEmpty(g)||(g!=null&&g!="Number")){A=true;j.push(k+"|^|"+m);
u.push(k+"|^|"+m);}else{u.push(k+"|^|"+m);}if(!Ext.isEmpty(g)){r+="^_^"+k+"^:^"+g;}else{r+="^_^"+k+"^:^String";}}n++;}}if(Ext.isEmpty(u)){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["selectFieldsAlert"],buttons:Ext.MessageBox.OK});return;}if(r!=null&&r.indexOf("^_^")>-1){r=r.substring(r.indexOf("^_^")+3,r.length);
}var B=Ext.getCmp("restDataConfigurationWindow");var s=Ext.getCmp("restTreePnl");if(!Ext.isEmpty(s)){Ext.getCmp("restTreePnl").hide();var h=[];h.push({xtype:"restgenerate",id:"restGenCont",padding:"0 10 0 0",selectedMetrics:u,descriptorFields:j,dataFieldParentNode:m,multipleNodes:(a>1?true:false),isSelectedFieldsHasTextBasedValues:A});
B.add({xtype:"container",autoScroll:true,layout:{type:"vbox",align:"stretch"},flex:1,margin:"0 0 10 10",id:"apiConfigFields",ui:"newTreePanelWithLines hideFolder DsTreePanel",cls:"x-tree-arrows",name:"restTreePnl",flex:1,items:h});}Ext.get("restApiBackbtn").show();},enableDescriptorDataRestFldSelection:function(a){if(a.checked){Ext.getCmp("descriptorDataRestFld").show();
}else{Ext.getCmp("descriptorDataRestFld").hide();}},validateCheckboxSelection:function(g,f,a,c){var d=g.getValue();var e=document.getElementsByClassName("messageCheckbox");if(d){for(var b=0;e[b];++b){if(!e[b].checked){e[b].disable();}}}else{for(var b=0;e[b];++b){e[b].enable();}}},restPreviewBtn:function(){var c=Ext.getCmp("restDataConfigurationWindow");
var d=Ext.getCmp("restTreePnl");var b=Ext.getCmp("restGenCont");if(!Ext.isEmpty(b)){Ext.getCmp("apiConfigFields").hide();}c.remove("apiConfigFields");Ext.getCmp("restPreviewBtnBox").hide();var a=Ext.get("restApiBackbtn");a.setVisibilityMode(Ext.Element.DISPLAY);a.hide();Ext.getCmp("restTreePnl").show();
},loadDatasetconfigWindow:function(){try{var b=Ext.widget("addnewdsn",{});b.show();}catch(a){console.log("cex",a);}},restHttpMethodChange:function(){var c=Ext.getCmp("restHttpMethod").getValue();if(c!=""&&c=="GET"){Ext.getCmp("body_type").hide();Ext.getCmp("rawJsonBody").hide();Ext.getCmp("body_urlencoded_key").hide();
Ext.getCmp("body_urlencoded_value").hide();Ext.getCmp("addBody_urlencoded").hide();Ext.getCmp("bodyUrlEncodedGrid").hide();}if(c!=""&&c=="POST"){Ext.getCmp("body_type").show();var a=Ext.getCmp("body_type");var d=a.getChecked();var b=d[0].inputValue;if(b!=null&&b=="x-www-form-urlencoded"){Ext.getCmp("rawJsonBody").hide();
Ext.getCmp("body_urlencoded_key").show();Ext.getCmp("body_urlencoded_value").show();Ext.getCmp("addBody_urlencoded").show();Ext.getCmp("bodyUrlEncodedGrid").show();}else{Ext.getCmp("rawJsonBody").show();Ext.getCmp("body_urlencoded_key").hide();Ext.getCmp("body_urlencoded_value").hide();Ext.getCmp("addBody_urlencoded").hide();
Ext.getCmp("bodyUrlEncodedGrid").hide();}}},enableUserAuthenticationSettings:function(a){if(a.checked){Ext.getCmp("rest_username").show();Ext.getCmp("rest_password").show();Ext.getCmp("rest_header").show();}else{Ext.getCmp("rest_username").hide();Ext.getCmp("rest_password").hide();Ext.getCmp("rest_header").hide();
}},enableHeaderRequiredSettings:function(a){if(a.checked){Ext.getCmp("key").show();Ext.getCmp("value").show();Ext.getCmp("addHeader").show();Ext.getCmp("header_grid").show();}else{Ext.getCmp("key").hide();Ext.getCmp("value").hide();Ext.getCmp("addHeader").hide();Ext.getCmp("header_grid").hide();}},enableParamsRequiredSettings:function(a){if(a.checked){Ext.getCmp("param_key").show();
Ext.getCmp("param_value").show();Ext.getCmp("addParam").show();Ext.getCmp("param_grid").show();}else{Ext.getCmp("param_key").hide();Ext.getCmp("param_value").hide();Ext.getCmp("addParam").hide();Ext.getCmp("param_grid").hide();}},body_typeSettings:function(a){var c=a.getChecked();var b=c[0].inputValue;
if(b!=null&&b=="x-www-form-urlencoded"){Ext.getCmp("rawJsonBody").hide();Ext.getCmp("body_urlencoded_key").show();Ext.getCmp("body_urlencoded_value").show();Ext.getCmp("addBody_urlencoded").show();Ext.getCmp("bodyUrlEncodedGrid").show();}else{Ext.getCmp("rawJsonBody").show();Ext.getCmp("body_urlencoded_key").hide();
Ext.getCmp("body_urlencoded_value").hide();Ext.getCmp("addBody_urlencoded").hide();Ext.getCmp("bodyUrlEncodedGrid").hide();}},basicAuthForm:function(){var b=Ext.getCmp("rest_username");var a=Ext.getCmp("rest_password");var d=b.getValue();var f=a.getValue();var e='="@()!^;?><:,';if(d==null||d==""){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["basicAuth_username_alert"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}if(f==null||f==""){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["basicAuth_password_alert"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}if(d!=""||d!=null){for(var c=0;c<d.length;c++){check_char=e.indexOf(d.charAt(c));if(check_char>=0){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:d+" "+screenLabelsObj["invalidHTTPHeaderAlert"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}}}return true;},addBasicAuth:function(){var a=this.basicAuthForm();if(a){var i=Ext.getCmp("rest_username");var e=Ext.getCmp("rest_password");var h=i.getValue();var g=e.getValue();var c=btoa(h+":"+g);var b=this.getRESTHeaderGrid();var d=b.getStore();var f=[];f.push({key:"Authorization",value:"Basic "+c});
d.add(f);b.doLayout();i.reset();e.reset();Ext.getCmp("key").show();Ext.getCmp("value").show();Ext.getCmp("addHeader").show();Ext.getCmp("header_grid").show();}},addHeader:function(){var d=Ext.getCmp("key");var c=Ext.getCmp("value");var e=d.getValue();var g=c.getValue();var b=this.headerValForm();if(b){var h=this.getRESTHeaderGrid();
var f=h.getStore();var a=[];a.push({key:e,value:g});f.add(a);h.doLayout();d.reset();c.reset();}},addReqParamValidateForm:function(){var b=Ext.getCmp("param_key");var a=Ext.getCmp("param_value");var c=b.getValue();var d=a.getValue();if(c==null||c==""){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["paramNameAlert"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}if(d==null||d==""){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["paramValueAlert"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}return true;},addParam:function(){var b=this.addReqParamValidateForm();if(b){var d=Ext.getCmp("param_key");var c=Ext.getCmp("param_value");
var e=d.getValue();var g=c.getValue();var h=this.getRESTParamsGrid();var f=h.getStore();var a=[];a.push({key:e,value:g});f.add(a);h.doLayout();d.reset();c.reset();}},headerValForm:function(){var b=Ext.getCmp("key");var a=Ext.getCmp("value");var d=b.getValue();var f=a.getValue();var e='="@()!^;?><:,';
if(d==null||d==""){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["headerParamAlert"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}if(f==null||f==""){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["headerValueAlert"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}if(d!=""||d!=null){for(var c=0;c<d.length;c++){check_char=e.indexOf(d.charAt(c));if(check_char>=0){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:d+" "+screenLabelsObj["invalidHTTPHeaderAlert"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}}}return true;},addBody_urlencoded:function(){var b=this.bodyValForm();
if(b){var d=Ext.getCmp("body_urlencoded_key");var c=Ext.getCmp("body_urlencoded_value");var e=d.getValue();var g=c.getValue();var b=true;if(e!=null&&e!=""&&g!=null&&g!=""){var h=this.getRESTBodyUrlEncodedGrid();var f=h.getStore();var a=[];a.push({key:e,value:g});f.add(a);h.doLayout();d.reset();c.reset();
}}},bodyValForm:function(){var b=Ext.getCmp("body_urlencoded_key");var a=Ext.getCmp("body_urlencoded_value");var c=b.getValue();var d=a.getValue();if(c==null||c==""){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["bodyParamAlert"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}if(d==null||d==""){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["bodyParamValueAlert"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}return true;},getData:function(c){var a=this.valForm();if(!a){return;}var b=Ext.getCmp("restdsnname");this.getResponseForRestURL(c,b,false);
},getResponseForRestURL:function(G,t,V){var O=Ext.getCmp("dsnSettingspopup");var R="";if(t!=null&&t.id=="restdsnname"){R=t.getValue();}G.setDisabled(true);var E=this;var C=Ext.getCmp("restdsnname");var z=C.getValue();var w=Ext.getCmp("urltextbox");var e=w.getValue();var B=Ext.getCmp("restPortNo").getValue();
var D=Ext.getCmp("restHttpMethod").getValue();var g=Ext.getCmp("body_type");var p=g.getChecked();var s=p[0].inputValue;var Q=Ext.getCmp("rawJsonBody");var c=Q.getValue();var j="";var M=this.getRESTBodyUrlEncodedGrid();var L=M.getStore();var m="";var h="";if(D=="POST"){h=s;if(s!=null&&s=="x-www-form-urlencoded"){var y=M.getStore().getCount();
for(var S=0;S<y;S++){var r=M.getStore().getAt(S).get("key");var I=M.getStore().getAt(S).get("value");var k=r+"$!$"+I;m=m+"!^!"+k;}if(m!=null&&m.indexOf("!^!")==0){m=m.substring(3);}}else{if(c!=null&&c!=""){var l=JSON.parse(c);j=JSON.stringify(l);}}}var f=this.getRESTHeaderGrid();var u=f.getStore();var K="";
var F=f.getStore().getCount();for(var S=0;S<F;S++){var r=f.getStore().getAt(S).get("key");var I=f.getStore().getAt(S).get("value");var b=r+"$!$"+I;K=K+"!^!"+b;}var q=Ext.getCmp("User_Authentication_Required");if(q.checked){var H=Ext.getCmp("rest_username").getValue();var A=Ext.getCmp("rest_password").getValue();
var o=btoa(H+":"+A);var T="Authorization"+"$!$"+"Basic "+o;K=K+"!^!"+T;}if(K!=null&&K.indexOf("!^!")==0){K=K.substring(3);}var n=this.getRESTParamsGrid();var U=n.getStore();var N="";var J=U.getCount();for(var S=0;S<J;S++){var d=U.getAt(S).get("key");var v=U.getAt(S).get("value");var a=d+"="+v;N=N+"&"+a;
}if(N!=null&&N.indexOf("&")==0){N=N.substring(1);}if(N!=null&&N!=""){if(e!=null&&e.indexOf("?")>=0){e=e.substring(0,e.indexOf("?"));}e=e+"?"+N;w.setValue(e);}var P="action=loadDataForConfigWindow&restDSNName="+encodeURIComponent(filterEncode(z))+"&restWS_URL="+encodeURIComponent(filterEncode(e))+"&restWS_Port="+encodeURIComponent(B)+"&httpMethod="+encodeURIComponent(D)+"&configuredHeaders="+encodeURIComponent(filterEncode(K))+"&selectedBodyType="+encodeURIComponent(filterEncode(h))+"&rawJsonBody="+encodeURIComponent(filterEncode(j))+"&configuredBodyUrlEncoded="+encodeURIComponent(filterEncode(m));
var x=new Ext.LoadMask(Ext.getBody(),{msg:restDataLoadingMsg+"..."});x.show();Ext.Ajax.request({url:"/final/admin/ICTest/data/EgAddRESTTestp.jsp",method:"POST",params:P,scope:this,success:function(X){var ab=X.responseText;if(ab!=null&&ab!=""){var Z=Ext.decode(ab);O=Ext.getCmp("dsnSettingspopup");var W={};
W["expanded"]="true";W["children"]=Z["jsonkeys"]["restTree"];O.remove("restTreePnl");Ext.EventManager.removeAll("restTreePnl");O.remove("restfieldmappingpnl");Ext.EventManager.removeAll("restfieldmappingpnl");var ac=Ext.getCmp("dsnConfigCont").hide();var Y={};var i=Ext.getCmp("restPreviewBtnBox");i.show();
G.setDisabled(false);if(!Ext.isEmpty(W.children)){var aa=new Array();aa.push({xtype:"treescrollPanel",rootVisible:false,width:"100 px",height:300,ui:"newTreePanelWithLines",id:"treeP",store:Ext.create("Ext.data.TreeStore",{root:W}),restTreeNodeData:Z["jsonkeys"]["restTreeNodeData"],restTreeNodeFields:Z["jsonkeys"]["resTreeNodefields"],listeners:{select:function(ao,ae,ah,ad){var au=[];
var af=Ext.getCmp("saveFldsBtn");var ap=Z["jsonkeys"]["restGrid"][ae.raw.jPath];var aj=ap["gridCols"];var at=ap["gridData"];var ar=[];var av=[];var ai=[];for(var aw in aj){var am=aj[aw].toString();av.push({name:am,type:"string"});var aq=0.14;var an="",ak="";if(V){an="<span class='newFont_normal11 DsWrapText' style='display:block;' data-qtip='"+am+"'><label class='dsCustomCheckBox' style='margin: -2px 7px 0 0px;display: block;float: left;width:16px'><input id='checkbox' type='checkbox' name='header' class='messageCheckbox' value='"+am+"' ><span class='labelCheckBOx'></span></label></span>";
ak="x-grid-checkheader-editor";}else{an="<span class='newFont_normal11 DsWrapText' style='display:block;' data-qtip='"+am+"'>"+am+"</span>";}ar.push({header:an,dataIndex:am,sortable:false,flex:1,tdCls:"DsWrapText",cls:ak,renderer:function(aB,ay,ax,aD,aA,az,aC){var aB='<span class="newFont_normal11 DsWrapText"  data-qtip="'+aB+'">'+aB+"</span>";
return aB;}});}var ag=Ext.getCmp("restDataGrid");ag.getStore().removeAll();var al=Ext.create("Ext.data.Store",{fields:av,data:at});ag.reconfigure(al,ar);ag.dataFieldParentNode=ae.raw.jPath;O.dataTypeMapping=ap["dataTypeMapping"];ag.show();ag.view.refresh();}}});aa.push({xtype:"RESTDataGrid",flex:2.35,padding:0,cls:"restGridPreview",tdCls:"DsWrapText",margin:0,id:"restDataGrid",hidden:false});
O.add({xtype:"panel",title:'<span class="font_bold11">Data Field Configuration</span>',autoScroll:true,layout:{type:"hbox",align:"stretch"},margin:"0 15 0 20",id:"restTreePnl",ui:"newTreePanelWithLines hideFolder DsTreePanel",cls:"x-tree-arrows",name:"restTreePnl",flex:1,items:aa,dockedItems:[{xtype:"toolbar",dock:"bottom",items:["->",{xtype:"button",id:"createDSN",name:"createDSN",margin:"20 0 0 0",width:106,height:27,cls:"button20 restBgButton",text:'<span class="newFont_normal14" style="color:#ffffff;line-height:26px;">Save DSN</span>',tooltip:"click here to Add",},"->"]}]});
}else{O.add({xtype:"container",id:"restEmptyGrid",flex:1,html:'<div style="height:100%;width:100%;display:table"><div class="msgFont" style="display:table-cell;vertical-align:middle"> <div class="iconExclamation" style="margin:0px auto"></div><div style="text-align:center">No Data Available!</div></div></div>'});
}x.hide();}},failure:function(i,W){x.hide();}});},dsnBackBtn:function(){var a=Ext.getCmp("restTreePnl");if(!Ext.isEmpty(a)){a.hide();}},valForm:function(){var b=Ext.getCmp("restdsnname");var q=Ext.getCmp("urltextbox");var n=Ext.getCmp("rawJsonBody");var l=n.getValue();var h=b.getValue();var d=q.getValue();
var a='%&+="?#:$!^~';var c='="@()!^;?><:,';var p=/^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/;var f=this.getRESTHeaderGrid();var k=f.getStore();var o="";var g=f.getStore().getCount();if(h==""||h==null){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["emptyDSNAlertMsg"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}if(h!=""||h!=null){for(var s=0;s<h.length;s++){check_char=a.indexOf(h.charAt(s));if(check_char>=0){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["specialCharsDSNAlertMsg"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}}}if(d==""||d==null){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["emptyRESTURLAlertMsg"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}if(g>0){for(var s=0;s<g;s++){var u=f.getStore().getAt(s).get("key");if(u!=""||u!=null){for(var r=0;r<u.length;r++){check_char=c.indexOf(u.charAt(r));if(check_char>=0){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:u+" "+screenLabelsObj["invalidHTTPKeyAlertMsg"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});
return false;}}}}}if(l!=""&&l!=null){try{var m=JSON.parse(l);}catch(t){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["invalidJSONyAlertMsg"],buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return false;}}return true;},saveRESTDSN:function(v){var D=this;var Q=this.valForm();
if(Q){v.setDisabled(true);var u=Ext.getCmp("dsnListCont");var B=Ext.getCmp("restdsnname");var x=B.getValue();var b=Ext.getCmp("urltextbox");var e=b.getValue();var z=Ext.getCmp("restPortNo").getValue();var C=Ext.getCmp("restHttpMethod").getValue();var M=Ext.getCmp("dsnSettingspopup");var g=Ext.getCmp("body_type");
var o=g.getChecked();var s=o[0].inputValue;var O=Ext.getCmp("rawJsonBody");var d=O.getValue();var j="";var K=this.getRESTBodyUrlEncodedGrid();var J=K.getStore();var n="";var h="";if(C=="POST"){h=s;if(s!=null&&s=="x-www-form-urlencoded"){var w=K.getStore().getCount();for(var P=0;P<w;P++){var q=K.getStore().getAt(P).get("key");
var H=K.getStore().getAt(P).get("value");var k=q+"$!$"+H;n=n+"!^!"+k;}if(n!=null&&n.indexOf("!^!")==0){n=n.substring(3);}}else{if(d!=null&&d!=""){var m=JSON.parse(d);j=JSON.stringify(m);}}}var f=this.getRESTHeaderGrid();var t=f.getStore();var I="";var F=f.getStore().getCount();for(var P=0;P<F;P++){var q=f.getStore().getAt(P).get("key");
var H=f.getStore().getAt(P).get("value");var c=q+"$!$"+H;I=I+"!^!"+c;}var l="";var p=Ext.getCmp("User_Authentication_Required");if(p.checked){var G=Ext.getCmp("rest_username").getValue();var y=Ext.getCmp("rest_password").getValue();if(!Ext.isEmpty(G)&&!Ext.isEmpty(y)){l="&basicAuth_Username="+encodeURIComponent(G)+"&basicAuth_pwd="+encodeURIComponent(y);
}}if(I!=null&&I.indexOf("!^!")==0){I=I.substring(3);}var L="";var p=Ext.getCmp("params_Required");if(p.checked){var A=this.getRESTParamsGrid();var E=A.getStore();var I="";var F=E.getCount();for(var P=0;P<F;P++){var q=E.getAt(P).get("key");var H=E.getAt(P).get("value");var r=q+"$!$"+H;L=L+"!^!"+r;}if(L!=null&&L.indexOf("!^!")==0){L=L.substring(3);
}}e=D.filterEncode(e);I=D.filterEncode(I);j=D.filterEncode(j);n=D.filterEncode(n);var a=Ext.getCmp("test").getValue();var N="restDSNName="+encodeURIComponent(filterEncode(x))+"&restWS_URL="+encodeURIComponent(filterEncode(e))+"&restWS_Port="+encodeURIComponent(z)+"&httpMethod="+encodeURIComponent(C)+"&action=saveRESTDSN&configuredHeaders="+encodeURIComponent(filterEncode(I))+"&selectedBodyType="+encodeURIComponent(h)+"&rawJsonBody="+encodeURIComponent(filterEncode(j))+"&configuredBodyUrlEncoded="+encodeURIComponent(filterEncode(n))+"&test="+encodeURIComponent(a);
if(!Ext.isEmpty(L)){L=D.filterEncode(L);N=N+"&configuredParams="+encodeURIComponent(L);}if(!Ext.isEmpty(l)){l=D.filterEncode(l);N=N+l;}Ext.Msg.show({title:pageTitle1,msg:screenLabelsObj["validateAPIConfiguration"],buttons:Ext.Msg.YESNO,icon:"iconConfirmation",fn:function(i){if(i==="yes"){N=N+"&validateRESTResponse=yes";
D.updateDSNConfiguration(N,v,x,true);}else{D.updateDSNConfiguration(N,v,x,false);}}});}},updateDSNConfiguration:function(h,d,f,e){try{var b=plsWait;var c=screenLabelsObj["restAPISaveMsg"];if(e){b=restValidateLoadingMsg;c=screenLabelsObj["restAPIValidateSaveMsg"];}var a=new Ext.LoadMask(Ext.getBody(),{msg:b+"..."});
a.show();Ext.Ajax.request({url:"/final/admin/ICTest/data/EgAddRESTTestp.jsp",method:"POST",params:h,scope:this,success:function(i){Ext.getCmp("getData").enable();var m=i.responseText;if(m!=null&&m!=""){var j=Ext.decode(m);var l=Ext.getCmp("datasetconfiguration");a.hide();d.setDisabled(false);if(!Ext.isEmpty(j)){var k=j["errorMsg"];
if(!Ext.isEmpty(k)&&k!="-"){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["connectFailureMsg"],buttons:Ext.MessageBox.OK,});return;}else{l.removeAll();var o=Ext.getCmp("dsnSettingspopup");o.close();Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:c,buttons:Ext.MessageBox.OK,});
}var n=[];var p=j["dsnConfigDetailsArr"];l.add({xtype:"panel",flex:1,layout:{type:"vbox",align:"stretch"}},{xtype:"dataview",margin:"10 10 10 10",store:Ext.data.Store({fields:["displayName","key","value","childTabHeaders"],data:p}),jsonData:p,itemSelector:"div.thumb-wrap",tpl:new Ext.XTemplate('<div class="newTable">','<table border="1"  width="100%">','<tr ><th colspan="2" class="Ictesttableheader" >','<div  style="display:inline-block; margin: 3px 0 0 0;">'+screenLabelsObj["API_Configuration"]+"</div>",'<div style="float:right;" ><a href="javascript:void(0)" class="iconModify" style="display:inline-block;" onclick="javascript:editAPIConfiguration(this,\''+f+'\',true)"  title="'+screenLabelsObj["Edit_API_Tooltip"]+'"><img src="/final/images/Light/edit.png"/></a>',"</div>","</th>","</tr>",'<tpl for=".">',"<tpl if=\"key==='ConfiguredHeaders' || key==='ConfiguredBodyUrlEncoded' || key==='configuredParams'\" >","<tr>","<td>{displayName} </td>","<td>",'<table border="0" align="left" width="100%">',"<tr>",'<tpl for="childTabHeaders">','<th class="table_head" style="border-top:0px;padding:4px;padding-left:10px !important;text-align: start;">',"{headerName}","</th>","</tpl>","</tr>",'<tpl for="value">',"<tr>",'<td class="font_bold12" style="width:25%;padding:6px 10px 5px 10px">',"{childTabKey}","</td>",'<td class="font_bold12" style="width:25%;padding:6px 10px 5px 10px">',"{childTabValue}","</td>","</tr>","</tpl>","</table>","</td>","</tr>","<tpl else>","<tr>","<td>{key} </td>","<td>{value} </td>","</tr>","</tpl>","</tpl>","</table>","</div>")});
l.doLayout();}}else{a.hide();Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["connectFailureMsg"],buttons:Ext.MessageBox.OK,});}},failure:function(){d.setDisabled(false);a.hide();}});}catch(g){console.log("cp---->",g);}},setMeasureRESTField:function(){var j=Ext.getCmp("dsnListCont");
var c=Ext.getCmp("dsnSettingspopup");var f=Ext.getCmp("restdatafld");var a=false;if(Ext.isEmpty(f)){f=Ext.getCmp("descriptorDataRestFld");a=true;}var h="";var l=[];var d="";var k="";var n=document.getElementsByClassName("messageCheckbox");var g="";if(c!=null&&c.hasOwnProperty("dataTypeMapping")){g=c.dataTypeMapping;
}var m=0;var q=false;var p=false;for(var e=0;n[e];++e){if(n[e].checked){if(m>0){q=true;break;}var b=n[e].value;d=d+","+b;if(g!=null&&g.hasOwnProperty(b)){var o=g[n[e].value];if(!a&&(o!=null&&o!="Number")){p=true;}if(!Ext.isEmpty(o)){h+="^_^"+b+"^:^"+o;}else{h+="^_^"+b+"^:^String";}}m++;}}if(d!=null&&d.indexOf(",")==0){d=d.substring(1);
}if(q){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["selectOneFieldAlert"],buttons:Ext.MessageBox.OK});return;}if(d==null||d==""){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["selectFieldsAlert"],buttons:Ext.MessageBox.OK});return;}if(h!=null&&h.indexOf("^_^")>-1){h=h.substring(h.indexOf("^_^")+3,h.length);
}k=f.dataFieldParentNode;f.setValue(d);f.dataFieldParentNode=k;if(!Ext.isEmpty(h)){f.dataFieldMapping=h;}c.close();},loadDatasetTab:function(){isRESTTestType=true;var a=Ext.getCmp("test").getValue();var b="action=loadDSNConfiguration&test="+encodeURIComponent(a);Ext.Ajax.request({url:"/final/admin/ICTest/data/EgAddRESTTestp.jsp",method:"POST",params:b,scope:this,success:function(f){var d=f.responseText;
if(d!=null&&d!=""){var k=Ext.decode(d);var l=Ext.getCmp("datasetconfiguration");if(!Ext.isEmpty(k)){l.removeAll();var h=k["errorMsg"];if(h!=null&&h=="-"){var i=k["dsnArr"];var j=[];for(var e in i){var g=i[e];var c=g["configDetails"];l.add({xtype:"panel",flex:1,layout:{type:"vbox",align:"stretch"}},{xtype:"dataview",margin:"10 10 10 10",store:Ext.data.Store({fields:["displayName","key","value","childTabHeaders"],data:c}),jsonData:c,itemSelector:"div.thumb-wrap",tpl:new Ext.XTemplate('<div class="newTable">','<table border="1"  width="100%">','<tr ><th colspan="2" class="Ictesttableheader" >','<div  style="display:inline-block; margin: 3px 0 0 0;">'+screenLabelsObj["API_Configuration"]+"</div>",'<div style="float:right;" ><a href="javascript:void(0);" class="" style="display:inline-block;" onclick="javascript:editAPIConfiguration(this,\''+g["dsnName"]+'\',true)" title="'+screenLabelsObj["Edit_API_Tooltip"]+'"><img src="/final/images/Light/edit.png" /></a>',"</div>","</th>","</tr>",'<tpl for=".">',"<tpl if=\"key==='ConfiguredHeaders' || key==='ConfiguredBodyUrlEncoded' || key==='configuredParams'\" >","<tr>","<td>{displayName}</td>","<td>",'<table border="0" align="left" width="100%">',"<tr>",'<tpl for="childTabHeaders">','<th class="table_head" style="border-top:0px;padding:4px;padding-left:10px !important;text-align: start;">',"{headerName}","</th>","</tpl>","</tr>",'<tpl for="value">',"<tr>",'<td class="font_bold12" style="width:25%;padding:6px 10px 5px 10px">',"{childTabKey}","</td>",'<td class="font_bold12" style="width:25%;padding:6px 10px 5px 10px">',"{childTabValue}","</td>","</tr>","</tpl>","</table>","</td>","</tr>","<tpl else>","<tr>","<td>{key} </td>","<td>{value} </td>","</tr>","</tpl>","</tpl>","</table>","</div>")});
}}else{l.add({xtype:"panel",flex:1,layout:{type:"vbox",align:"stretch"},dockedItems:[{dock:"top",layout:{type:"hbox",pack:"end"},border:false,padding:5,items:[{xtype:"button",cls:"button20",id:"configuredatasets",text:"Configure API",handler:function(){datasetCtrlr.loadDatasetconfigWindow();}}]}]},{xtype:"fieldset",title:screenLabelsObj["API_Configuration"],collapsible:false,style:{"box-shadow":"none","background":"none"},margin:"0 20 5 20",defaults:{labelAlign:"top",labelSeparator:""},items:{xtype:"container",height:200,html:'<table width="100%" height="100%" style="margin:0% auto"><tr><td align="center" valign="middle"><div class="iconExclamation"></div><div styel="margin:10px auto">Please configure REST API</div></td></tr></table>',}});
}l.doLayout();}}}});},editDSN:function(b,a){return editDSN(b,a,false);},editDSN:function(f,d,c){var b=Ext.getCmp("test").getValue();var e="action=modifyDSNConfiguration&restDSNName="+encodeURIComponent(d)+"&test="+encodeURIComponent(b);var a=new Ext.LoadMask(Ext.getBody(),{msg:restConfigLoadingMsg+"..."});
a.show();Ext.Ajax.request({url:"/final/admin/ICTest/data/EgAddRESTTestp.jsp",method:"POST",params:e,scope:this,success:function(g){var C=g.responseText;if(C!=null&&C!=""){var l=Ext.decode(C);if(!Ext.isEmpty(l)){try{var i=Ext.widget("addnewdsn",{});i.show();var r=Ext.getCmp("restdsnname");r.setValue(l["restDSNName"]);
if(c){r.disable();}else{r.show();}var G=Ext.getCmp("dsnSettingspopup");var B=Ext.getCmp("urltextbox");var j=Ext.getCmp("restHttpMethod");var n=Ext.getCmp("tabPanelBox");var z=Ext.getCmp("addNewDS");B.setValue(l["dsnConfigDetails"]["URL"]);j.setValue(l["dsnConfigDetails"]["HTTP Method"]);var x=l["dsnConfigDetails"]["ConfiguredHeaders"];
var p=l["dsnConfigDetails"]["configuredParams"];var k=l["dsnConfigDetails"]["configuredBodyUrlEncoded"];var u=l["dsnConfigDetails"]["RawJsonBody"];var q=l["dsnConfigDetails"]["DataFieldParentNode"];if(!Ext.isEmpty(x)){var A=Ext.getCmp("Header_Required");A.suspendEvents(false);var o=Ext.getCmp("header_grid");
var s=o.getStore();s.removeAll();s.add(x);o.doLayout();Ext.getCmp("key").show();Ext.getCmp("value").show();Ext.getCmp("addHeader").show();Ext.getCmp("header_grid").show();A.setValue(true);A.resumeEvents();}else{var A=Ext.getCmp("Header_Required");A.suspendEvents(false);Ext.getCmp("key").hide();Ext.getCmp("value").hide();
Ext.getCmp("addHeader").hide();Ext.getCmp("header_grid").hide();var o=Ext.getCmp("header_grid");var s=o.getStore();s.removeAll();A.setValue(false);A.resumeEvents();}if(!Ext.isEmpty(p)){var A=Ext.getCmp("params_Required");A.suspendEvents(false);var o=Ext.getCmp("param_grid");var s=o.getStore();s.removeAll();
s.add(p);o.doLayout();Ext.getCmp("key").show();Ext.getCmp("value").show();Ext.getCmp("addHeader").show();Ext.getCmp("param_grid").show();A.setValue(true);A.resumeEvents();}else{var A=Ext.getCmp("params_Required");A.suspendEvents(false);Ext.getCmp("param_key").hide();Ext.getCmp("param_value").hide();Ext.getCmp("addParam").hide();
Ext.getCmp("param_grid").hide();var o=Ext.getCmp("param_grid");var s=o.getStore();s.removeAll();A.setValue(false);A.resumeEvents();}if(l["dsnConfigDetails"]["HTTP Method"]!=""&&l["dsnConfigDetails"]["HTTP Method"]=="POST"){var F=Ext.getCmp("body_type");F.show();var v=F.getChecked();var y=l["dsnConfigDetails"]["SelectedBodyType"];
if(y!=null&&y=="x-www-form-urlencoded"){var m=Ext.getCmp("body_type");m.suspendEvents(false);m.setValue({body_name:y});m.show();m.resumeEvents();m=null;delete m;Ext.getCmp("rawJsonBody").hide();Ext.getCmp("body_urlencoded_key").show();Ext.getCmp("body_urlencoded_value").show();Ext.getCmp("addBody_urlencoded").show();
Ext.getCmp("bodyUrlEncodedGrid").show();if(k!=null){var E=Ext.getCmp("bodyUrlEncodedGrid");var D=E.getStore();D.removeAll();D.add(k);E.doLayout();}}else{var m=Ext.getCmp("body_type");m.suspendEvents(false);m.setValue({body_name:y});m.show();m.resumeEvents();m=null;delete m;var t=Ext.getCmp("rawJsonBody");
t.show();if(u!=null&&u!=""){var h=JSON.stringify(u,undefined,2);t.setValue(h);}Ext.getCmp("body_urlencoded_key").hide();Ext.getCmp("body_urlencoded_value").hide();Ext.getCmp("addBody_urlencoded").hide();Ext.getCmp("bodyUrlEncodedGrid").hide();}}else{Ext.getCmp("body_type").hide();Ext.getCmp("body_urlencoded_key").hide();
Ext.getCmp("body_urlencoded_value").hide();Ext.getCmp("addBody_urlencoded").hide();Ext.getCmp("bodyUrlEncodedGrid").hide();var t=Ext.getCmp("rawJsonBody");t.reset();t.hide();var o=Ext.getCmp("bodyUrlEncodedGrid");var s=o.getStore();s.removeAll();}Ext.getCmp("getData").setText(btnText2);a.hide();}catch(w){a.hide();
console.log("cex ",w);}}}else{a.hide();}},failure:function(g,h){a.hide();}});},addRESTDataFields:function(c,e){var b=Ext.getCmp("test").getValue();var d="action=modifyDSNConfiguration&loadDataGrid=yes&restDSNName="+encodeURIComponent(filterEncode(c))+"&test="+encodeURIComponent(b);e.setDisabled(true);
Ext.create("Ext.window.Window",{id:"restDataConfigurationWindow",name:"restDataConfigurationWindow",width:900,modal:true,border:false,frame:false,title:'<div><span id="restApiBackbtn"></span>Metrics Configuration</div>',ui:"newPopupWindow widgetOptionsWindowHeader",resizable:false,autoShow:false,ghost:false,padding:"0 0 0 0",autoScroll:true,scroll:true,header:{height:48,padding:"0 20",margin:0},layout:{type:"vbox",align:"stretch"},ui:"newPopupWindow widgetOptionsWindowHeader",cls:"myDashboardwindow",height:560,scroll:true,autoScroll:true,closeAction:"destroy",listeners:{show:function(g){if(this.modal){var h=Ext.dom.Query.select(".x-mask");
var f=Ext.fly(h[h.length-1]);f.addCls("windowModal");}},hide:function(g){if(this.modal){var h=Ext.dom.Query.select(".x-mask");var f=Ext.fly(h[h.length-1]);f.removeCls("windowModal");}},afterrender:function(){Ext.EventManager.onWindowResize(function(){var f=this;f.center();},this);}}}).show();var a=new Ext.LoadMask(Ext.getBody(),{msg:restDataLoadingMsg+"...",id:"restDataLoadingMask"});
a.show();Ext.Ajax.request({url:"/final/admin/ICTest/data/EgAddRESTTestp.jsp",method:"POST",params:d,scope:this,success:function(g){var A=g.responseText;if(A!=null&&A!=""){var k=Ext.decode(A);if(!Ext.isEmpty(k)){try{e.setDisabled(false);var H=Ext.getCmp("restDataConfigurationWindow");H.removeAll();var t="";
if(publicJSON!=null&&publicJSON.hasOwnProperty("measureParentNode")){if(!Ext.isEmpty(publicJSON.measureParentNode)){t=publicJSON.measureParentNode;}}var F={};F["expanded"]="true";F["children"]=k["jsonkeys"]["restTree"];H.remove("restTreePnl");Ext.EventManager.removeAll("restTreePnl");H.remove("restfieldmappingpnl");
Ext.EventManager.removeAll("restfieldmappingpnl");var l=new Array();l.push({xtype:"treescrollPanel",rootVisible:false,flex:1,ui:"newTreePanelWithLines",id:"treeP",store:Ext.create("Ext.data.TreeStore",{root:F}),restTreeNodeData:k["jsonkeys"]["restTreeNodeData"],restTreeNodeFields:k["jsonkeys"]["resTreeNodefields"],listeners:{afterrender:function(){if(publicJSON!=null&&publicJSON.hasOwnProperty("restFldMap")){if(!Ext.isEmpty(publicJSON.restFldMap)){var K=Ext.getCmp("restDataGrid");
K.selectedDataFieldsMap=publicJSON.restFldMap;}}var i=this.getStore().getNodeById(t);this.getSelectionModel().select(i);},select:function(ac,O,S,M){var ah=[];var U=Ext.getCmp("restDataGrid");var Y=U.dataFieldParentNode;var R=Ext.getCmp("saveFldsBtn");var ad=k["jsonkeys"]["restGrid"][O.raw.jPath];var V=ad["gridCols"];
var ag=ad["gridData"];var af=[];var aj=[];var T=[];for(var ak in V){var aa=V[ak].toString();aj.push({name:aa,type:"string"});af.push({header:"<span class='newFont_normal11  DsWrapText' style='display:block ;' data-qtip='"+aa+"'><label class='dsCustomCheckBox' style=' margin: -2px 7px 0 0px;display: block;float: left;width:16px' ><input id='datacolumncheckbox' type='checkbox' name='datacolumncheckbox' class='messageCheckbox' value='"+aa+"' ><span class='labelCheckBOx'></span></label>"+aa+"</span>",dataIndex:aa,sortable:false,tdCls:"DsWrapText",cls:"x-grid-checkheader-editor",renderer:function(ao,al,i,aq,an,am,ap){var ao='<span class="newFont_normal11 DsWrapText" data-qtip="'+ao+'">'+ao+"</span>";
return ao;}});}H.dataTypeMapping=ad["dataTypeMapping"];var ab=[];if(!Ext.isEmpty(U)&&U.hasOwnProperty("dataFieldParentNode")){var N=document.getElementsByClassName("messageCheckbox");var ai=k["jsonkeys"]["restGrid"][Y].dataTypeMapping;for(var ae=0;N[ae];++ae){if(N[ae].checked==true){var W=N[ae].value;
if(ai!=null&&ai.hasOwnProperty(W)){var P=ai[W];if(Ext.isEmpty(P)||(P!=null&&P!="Number")){}else{ab.push(N[ae].value);}}}}var Q={};if(U!=null&&U.hasOwnProperty("selectedDataFieldsMap")){Q=U.selectedDataFieldsMap;}if(!Ext.isEmpty(ab)){Q[Y]=ab;U.selectedDataFieldsMap=Q;}}U.getStore().removeAll();var Z=Ext.create("Ext.data.Store",{fields:aj,data:ag});
U.reconfigure(Z,af);U.dataFieldParentNode=O.raw.jPath;if(publicJSON!=null&&publicJSON.hasOwnProperty("restFldMap")){if(!Ext.isEmpty(publicJSON.restFldMap)&&publicJSON.restFldMap.hasOwnProperty(U.dataFieldParentNode)){var L="";var K=false;if(publicJSON!=null&&publicJSON.hasOwnProperty("descriptorNode")){if(!Ext.isEmpty(publicJSON.descriptorNode)){L=publicJSON.descriptorNode;
K=true;}}var X=[];X=publicJSON.restFldMap[U.dataFieldParentNode];if(!Ext.isEmpty(X)){var N=document.getElementsByClassName("messageCheckbox");for(var ae=0;N[ae];++ae){var S=X.indexOf(N[ae].value);if(S>-1){N[ae].checked=true;}else{if(K&&L.indexOf(N[ae].value)>-1){N[ae].checked=true;}}}}}}else{if(U!=null&&U.hasOwnProperty("selectedDataFieldsMap")){if(!Ext.isEmpty(U.selectedDataFieldsMap)&&U.selectedDataFieldsMap.hasOwnProperty(U.dataFieldParentNode)){var X=[];
X=U.selectedDataFieldsMap[U.dataFieldParentNode];if(!Ext.isEmpty(X)){var N=document.getElementsByClassName("messageCheckbox");for(var ae=0;N[ae];++ae){var S=X.indexOf(N[ae].value);if(S>-1){N[ae].checked=true;}}}}}}U.show();U.view.refresh();}}});l.push({xtype:"RESTDataGrid",flex:2.35,padding:0,margin:0,cls:"restGridPreview",id:"restDataGrid",hidden:false,isGridLoaded:false,listeners:{"reconfigure":function(i){if(i.isGridLoaded==false){i.isGridLoaded=true;
}}}});Ext.create("Ext.Button",{html:"",icon:"../images/"+strSkin+"/apiBackbtn.png",renderTo:Ext.get("restApiBackbtn"),id:"restPreviewBtn",style:{"background":"none"},scale:"medium",border:0,buttonId:"restPreviewBtn",handler:function(){datasetCtrlr.restPreviewBtn();}});H.add({xtype:"container",layout:{type:"hbox",},id:"restPreviewBtnBox",hidden:true,items:[]});
H.add({xtype:"panel",title:'<span class="font_bold11">'+screenLabelsObj["dataFieldConfig"]+"</span>",autoScroll:true,layout:{type:"hbox",align:"stretch"},margin:"10 15 0 20",id:"restTreePnl",ui:"newTreePanelWithLines hideFolder DsTreePanel",cls:"x-tree-arrows",name:"restTreePnl",flex:1,items:l,dockedItems:[{xtype:"toolbar",dock:"bottom",items:["->",{xtype:"button",id:"saveFldsBtn",name:"saveFldsBtn",margin:"20 0 0 0",style:{"border":"none"},padding:0,width:106,height:27,text:'<span class="newFont_normal14" style="color:#ffffff;line-height:24px;">'+screenLabelsObj["nextLbl"]+"</span>",tooltip:"click here to Add",cls:"button20 restBgButton",handler:function(){datasetCtrlr.selectFields();
}},"->"]}]});if(t!=null){var r=k["jsonkeys"];if(r.hasOwnProperty("restGrid")&&k["jsonkeys"]["restGrid"].hasOwnProperty(t)){var E=[];var m=Ext.getCmp("saveFldsBtn");var z=k["jsonkeys"]["restGrid"][t];var q=z["gridCols"];var D=z["gridData"];var C=[];var I=[];var p=[];for(var J in q){var y=q[J].toString();
I.push({name:y,type:"string"});var u=y;var v=y;if(u!=null&&u.indexOf(" ")>-1){u=u.replace(" ","_bs_");v=v.replace("_bs_"," ");}C.push({header:"<span class='newFont_normal11  DsWrapText' data-qtip='"+v+"' style='display:block;'><label class='dsCustomCheckBox' style=' margin: -2px 7px 0 0px;display: block;float: left;width:16px'   ><input id='datacolumncheckbox' type='checkbox' name='datacolumncheckbox' class='messageCheckbox' value='"+u+"' ><span class='labelCheckBOx'></span></label>"+v+"</span>",dataIndex:y,sortable:false,tdCls:"DsWrapText",cls:"x-grid-checkheader-editor",renderer:function(N,K,i,P,M,L,O){var N='<span class="newFont_normal11 DsWrapText" data-qtip="'+N+'">'+N+"</span>";
return N;}});}var o=Ext.getCmp("restDataGrid");o.getStore().removeAll();var x=Ext.create("Ext.data.Store",{fields:I,data:D});o.reconfigure(x,C);o.dataFieldParentNode=t;H.dataTypeMapping=z["dataTypeMapping"];o.show();o.view.fireEvent("resize",o.view);var j=document.getElementsByClassName("messageCheckbox");
var s=publicJSON["selectedRestFieldList"];var h="";var f=false;if(publicJSON!=null&&publicJSON.hasOwnProperty("descriptorNode")){if(!Ext.isEmpty(publicJSON.descriptorNode)){h=publicJSON.descriptorNode;f=true;}}for(var B=0;j[B];++B){var n=s.indexOf(j[B].value);if(n>-1){j[B].checked=true;}else{if(f&&h.indexOf(j[B].value)>-1){j[B].checked=true;
}}}datasetCtrlr.selectFields();if(f){var G=Ext.getCmp("DescriptorRequired");if(!Ext.isEmpty(G)){G.setValue(true);}}Ext.defer(function(){},1000);}else{a.hide();}}else{a.hide();}}catch(w){a.hide();console.log("cex",w);}}}}});},loadAddMeasureTab:function(f){var j=this;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();Ext.getCmp("addNewMeasure").hide();Ext.getCmp("configureMetricsBtn").show();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: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:screenLabelsObj["APIDataFieldLbl"],id:"restTreeId"+c,value:b.restdatafld,}]},{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("restTreeId"+c);if(isConfigTest){h.hide();l.hide();d.hide();g.hide();k.hide();a.show();}}}}},showConfigDescriptorPopup:function(){if(Ext.isEmpty(datasetCtrlr)){datasetCtrlr=this.getController("ICTest.controller.DatasetController");
}var a="EgConfigRESTMeasureJson.jsp?test="+test;datasetCtrlr.loadAddMeasureTab(a);datasetCtrlr.addRESTDataFields(publicJSON["restDSNName"],this);},showAddNewMeasure:function(){var h=this;var g=Ext.getCmp("test").getValue();var f="EgConfigRESTMeasureJson.jsp?test="+g;h.loadAddMeasureTab(f);selMibFile="";
selElmtFile="";selStusFile="";oidFldName="";elmtFldName="";stusFldName="";Ext.create("Ext.window.Window",{title:newMeasDetail,width:500,id:"addRESTMeasureWindow",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:"API Data Field",id:"restdatafld",name:"restdatafld",maxLength:100,width:380,enforceMaxLength:true},{xtype:"button",iconCls:"iconUrlTree",border:0,style:{"background":"none"},listeners:{"click":function(j){datasetCtrlr.addRESTDataFields(publicJSON["restDSNName"],j);
}}}]},{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 p=Ext.getCmp("otherunit").getValue();var m=Ext.getCmp("un").getValue();var d=Ext.getCmp("alarmdescription").getValue();var b=Ext.getCmp("process").getValue();var c=Ext.getCmp("restdatafld").getValue();
var n=Ext.getCmp("restdatafld").dataFieldParentNode;var o=i.filterEncode(c);var l=i.filterEncode(oidFldName);var k=i.filterEncode(n);if(b==null&&isConfigTest){b="UNALTERED";j="1";}if(b!="UNALTERED"&&b!="DIFFERENCE"){j="none";}var e="ICTest/data/EgconfigrestmeasurepJson.jsp?add=add&test="+h+"&measure="+filterEncode(a)+"&factor="+j+"&restdatafld="+encodeURIComponent(filterEncode(o));
e+="&dbsize="+f+"&otherunit="+encodeURIComponent(filterEncode(p))+"&un="+encodeURIComponent(filterEncode(m))+"&alarmdescription="+encodeURIComponent(filterEncode(d))+"&index="+g+"&process="+b;e+="&fileName="+selMibFile+"&oid_fieldName="+encodeURIComponent(filterEncode(oidFldName))+"&restParentNode="+encodeURIComponent(filterEncode(k));
if(!this.measureValidation(a,m,p,d,c)){return;}Ext.Ajax.request({url:e,method:"POST",async:false,success:function(q){if(q.status==200&&!Ext.isEmpty(q.responseText)){var r=q.responseText;publicJSON=Ext.decode(r);}}});if(publicJSON.AlertType=="Error"){Ext.Msg.show({title:error+": "+publicJSON.AlertTitle,msg:publicJSON.AlertMsg,buttons:Ext.Msg.OK,icon:"iconError",fn:function(q){if(q=="ok"){Ext.getCmp("addRESTMeasureWindow").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(q){if(q=="yes"){Ext.getCmp("addRESTMeasureWindow").close();
var r=publicJSON.forwardURL;i.loadAddMeasureTab(r);i.showAddNewMeasure();}else{if(q=="no"){Ext.getCmp("addRESTMeasureWindow").close();var r=publicJSON.forwardURL;i.loadAddMeasureTab(r);Ext.getCmp("newtest").setActiveTab(3);}}}});}}},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 h=Ext.getCmp("restdatafld");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 g=!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(g=="-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(g=="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:alertMsg85,buttons:Ext.Msg.OK,icon:"iconExclamation"});h.focus(true);
return false;}else{if(!validateSingleByte(f)){Ext.Msg.show({title:newMeasDetail,msg:alertMsg48,buttons:Ext.Msg.OK,icon:"iconExclamation"});h.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);}}});}}}});},generateRESTTest:function(){var w=this;
var v=Ext.getCmp("DescriptorRequired");var h="",l="";if(!Ext.isEmpty(v)){l=v.getValue();if(l==true){h=Ext.getCmp("descriptorDataRestFld").getValue();if(!checkblank(h)){Ext.Msg.show({title:generate,msg:alertMsg49,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(i){if(i=="ok"){eleOidObj.focus(true);
}}});return;}else{if(!validateSingleByte(h)){Ext.Msg.show({title:generate,msg:alertMsg50,buttons:Ext.Msg.OK,icon:"iconExclamation",fn:function(i){if(i=="ok"){eleOidObj.focus(true);}}});return;}}}}var j=Ext.getCmp("measureInternalValueMappingGrid");var s=Ext.getCmp("test").getValue();var e=Ext.getCmp("restGenCont").dataFieldParentNode;
var a=Ext.getCmp("restGenCont").selectedMetrics;var c=Ext.getCmp("restGenCont").selectedFldsMapping;var p="";for(var o in a){p=p+","+a[o];}if(p!=null&&p.indexOf(",")==0){p=p.substring(1);}h=w.filterEncode(h);p=w.filterEncode(p);e=w.filterEncode(e);var d="";if(!Ext.isEmpty(j)){var k=j.getStore().getCount();
for(var q=0;q<k;q++){var x=j.getStore().getAt(q).get("key");var n=j.getStore().getAt(q).get("value");for(var b in a){var g=a[b];if(g!=null&&g.indexOf("|^|")>-1){g=g.substring(0,g.indexOf("|^|"));}var u=g+":"+x+"$!$"+n;d=d+"!^!"+u;}}}var r="ICTest/data/EgconfigrestmeasurepJson.jsp";var t="add=gen&test="+s+"&descriptorbasedtest="+l+"&selDescRestFldVal="+encodeURIComponent(h)+"&restParentNode="+encodeURIComponent(e)+"&selectedMetrics="+encodeURIComponent(p);
if(!Ext.isEmpty(d)){if(d.indexOf("!^!")==0){d=d.substring(3);}d=w.filterEncode(d);t=t+"&configuredMeasIntVals="+encodeURIComponent(d);}Ext.Ajax.request({url:r,method:"POST",params:t,async:false,success:function(i){if(i.status==200&&!Ext.isEmpty(i.responseText)){var m=i.responseText;publicJSON=Ext.decode(m);
}}});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(i){if(i=="ok"){window.location.href="/final/admin/EgUDTest.jsp";
}}});}}if(!Ext.isEmpty(publicJSON.forwardURL)){this.getController("ICTest.controller.ThresholdCtrlr").init();var f=Ext.getCmp("restDataConfigurationWindow");f.removeAll();var r=publicJSON.forwardURL;qString="ICTest/data/"+r;f.add({xtype:"defaultthresholds"});}},showModifyMeasure:function(d){var c;Ext.Ajax.request({url:"ICTest/data/"+d+"&testType=REST",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){datasetCtrlr.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){datasetCtrlr.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:"API Measure Field",id:"restdatafld",name:"restdatafld",maxLength:100,enforceMaxLength:true,hidden:true,value:c.restDataFld,dataFieldParentNode:c.restParentNodeDataField,labelWidth:200,width:370}]},{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 o=Ext.getCmp("s_otherunit").getValue();var m=Ext.getCmp("s_un").getValue();var k=Ext.getCmp("alarmdescription").getValue();var i=Ext.getCmp("restdatafld").getValue();if(!datasetCtrlr.measureValidation(g,m,o,k,i)){return;}var n=Ext.getCmp("measureform").getForm();if(n.isValid()){var p=new Ext.LoadMask(Ext.getBody(),{msg:updating+"..."});
var l=encodeFieldParams(n);p.show();var j=Ext.getCmp("restdatafld");if(!Ext.isEmpty(j)){l+="&restParentNode"+"="+encodeURIComponent(filterEncode(Ext.getCmp("restdatafld").dataFieldParentNode));}if(!Ext.isEmpty(i)){l+="&restdatafld"+"="+encodeURIComponent(filterEncode(i));}n.submit({params:l,method:"POST",success:function(q,s){p.hide();
var r=s.response.responseText;var u=Ext.decode(r);if(u.AlertType=="Result"){var v=Ext.getCmp("test").getValue();var t="EgConfigRESTMeasureJson.jsp?test="+v;datasetCtrlr.loadAddMeasureTab(t);Ext.Msg.show({title:u.AlertTitle,msg:u.AlertMsg,buttons:Ext.Msg.OK,icon:"iconInformation",fn:function(w){if(w=="ok"){Ext.getCmp("newtest").setActiveTab(3);
}}});}else{if(u.AlertType=="Error"){Ext.Msg.show({title:u.AlertTitle,msg:u.AlertMsg,buttons:Ext.Msg.OK,icon:"iconError",fn:function(w){if(w=="ok"){var y=Ext.getCmp("test").getValue();var x="EgConfigRESTMeasureJson.jsp?test="+y;datasetCtrlr.loadAddMeasureTab(x);}}});}}}});}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:filterEncode(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;},filterEncode:function(i){var d=["[","]","(",")","=","%","'","&"];var c=["|lsbr|","|rsbr|","|lbr|","|rbr|","|eq|","|per|","|squot|","|ampsnd|"];try{if(i!=null&&i!=undefined&&!Ext.isEmpty(i)){for(var b in d){var f=d[b];var g=c[b];do{i=i.replace(f,g);}while(i.indexOf(f)>-1);
}}}catch(h){}return i;},addMeasureInternalValueConfiguration:function(h){var b=this.addReqParamValidateForm();if(b){var k=Ext.getCmp("param_key");var f=Ext.getCmp("param_value");var j=k.getValue();var i=f.getValue();var d=this.getRestMeasureMappingGrid();var e=d.getStore();var g=[];if(!Ext.isEmpty(e)){var a=e.findRecord("key",j,0,false,true,true);
var c=e.indexOf(a);if(c>-1){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["MeasureIntValueExist"],buttons:Ext.MessageBox.OK,icon:"iconExclamation"});return false;}}if(!Ext.isEmpty(i)){i=i.trim();}if(!Ext.isNumeric(i)){Ext.Msg.show({title:screenLabelsObj["DSNTitle"],msg:screenLabelsObj["validNumericvalueMsg"],buttons:Ext.MessageBox.OK,icon:"iconExclamation"});
return false;}g.push({key:j,value:i});e.add(g);d.doLayout();k.reset();f.reset();}}});