Ext.define("MyDashBoard.view.AddExternalMetrics",{extend:"Ext.container.Container",alias:"widget.addexternalmetrics",requires:["utilities.CustomGrid","utilities.ScrollCombo","utilities.CommonPanel"],layout:{type:"vbox",align:"stretch"},flex:1,cls:"myDashboardwindow",ui:"newPopupWindow widgetOptionsWindowHeader",closeAction:"destroy",widgetID:"",widgetType:"",id:"externalMetricsView",dataFieldsComboIdArr:[],widgetSettingsJsonArr:[],isKpi:false,Kpicount:0,totalKpiCount:0,kpiBlckId:null,initComponent:function(){var a={};
a["activityChart"]=[343,230];a["areaChart"]=[343,230];a["BarChart"]=[427,230];a["combinationChart"]=[427,248];a["CombinedTimelineChart"]=[427,230];a["ddTable"]=[427,248];a["dialChart"]=[259,248];a["digitalChart"]=[280,248];a["geomap"]=[427,248];a["health"]=[343,248];a["heatMapChart"]=[424,230];a["liveMeasuresBox"]=[343,248];
a["networkhealth"]=[427,248];a["news"]=[427,248];a["pieChart"]=[343,230];a["servicehealth"]=[427,248];a["table"]=[427,230];a["tierhealth"]=[427,248];a["TimelineChart"]=[427,230];a["TopNAnalysis"]=[339,203];a["TopologyWidget"]=[427,248];a["TrendGraph"]=[427,248];a["vmAlarmsWidget"]=[427,248];a["weather"]=[343,248];
this.widgetPreviewDimensions=a;this.createExternalWidgetConfigLayout();this.callParent();},createExternalWidgetConfigLayout:function(){var i=this;var h={xtype:"fieldset",cls:"configWinFieldsetNew",ui:"newFieldSetHeader",collapsible:false,style:{"box-shadow":"none","background":"none"},layout:{type:"hbox",align:"stretch"},padding:"5 0 10 0",bodyPadding:"0 0 0 0",margin:"0 0  0  0",defaults:{labelAlign:"top",labelSeparator:""},items:{xtype:"panel",layout:{type:"column",align:"stretch",pack:"start"},flex:1,margin:"0 10px 0 10px",defaults:{labelAlign:"top",labelSeparator:""},id:"widgetChartAttrsCont",name:"widgetChartAttrsCont",width:100,defaults:{labelAlign:"top",margin:"10 10 10px 0px",labelSeparator:""},}};
var e=false;var a="";var f=Ext.getCmp(i.widgetID);if(!Ext.isEmpty(f)){e=f.isChart;isTopNChart=f.isTopNChart;a=f.title;}var c=280;if(i.widgetType!=null&&(i.widgetType=="dialChart"||i.widgetType=="digitalChart")){c=200;}var g=false;if(i!=null&&i.action=="editWidget"){g=true;}var j=400;var b=250;var d=this.widgetPreviewDimensions[i.widgetType];
if(!Ext.isEmpty(d)){j=d[0];b=d[1];}this.items={xtype:"form",layout:{type:"vbox",align:"stretch"},id:"externalWidgetConfigForm",name:"externalWidgetConfigForm",itemId:"externalConfigForm",cls:"form",flex:1,fullscreen:true,scroll:true,autoScroll:true,border:false,padding:"0 0",items:{xtype:"panel",id:"configSettings",cls:"configSettingsWindow",flex:1,scroll:true,autoScroll:true,border:true,bodyPadding:"10 10 0 10",layout:{type:"vbox",align:"stretch"},defaults:{labelAlign:"top",labelSeparator:""},margin:"0 0 0 0",items:[{xtype:"panel",margin:"0 0 0 0",padding:"0 0 10 0",layout:{type:"hbox",pack:"center",},items:[{xtype:"previewcontiner",margin:"4 20 4 10",width:j,height:b,isConfigured:g,items:[{xtype:"portlet",flex:1,width:j-23,height:b-23,id:i.widgetID+"_previewImage",title:a,ui:"newGraphPanel",cls:"previewImage",margin:"0 0 0 0",isChart:e,isTopNChart:false,showMoreDataOption:false,isPreviewMode:true}]},{xtype:"container",width:350,cls:"widget_config_form",layout:{type:"column"},id:"controllerSetting",disabledCls:"my-disabled-panel",disabled:(i.action=="addWidget"?true:false),defaults:{labelAlign:"top",columnWidth:1,labelSeparator:""},margin:"0 0 0 0",padding:"0 0 0 0"}]},h]},listeners:{"afterrender":function(){}}};
},onRender:function(){var h=this;var f=this.widgetType;var d=this.widgetID;var a=d;if(this.isKpi){a=this.kpiBlckId+"_"+a;}else{a=this.widgetID;}var b=Ext.getCmp("dashboardLayoutObj").profileName;var c=Ext.getCmp("externalMetricsView");var g="DSNName="+encodeURIComponent("")+"&action=loadWidgetOptions"+"&widgetId="+encodeURIComponent(a)+"&dashboardName="+encodeURIComponent(b)+"&selectedWidgetType="+encodeURIComponent(f);
var e=myDashApp.getController("WidgetConfigurationController").getWidgetConfigurationWindowObj();Ext.Ajax.request({url:"/final/servlet/com.eg.RESTIntegrationController",method:"POST",params:g,scope:this,success:function(j){var E=j.responseText;if(E!=null&&E!=""){var q=Ext.decode(E);var G=Ext.getCmp("widgetChartAttrsCont");
if(!Ext.isEmpty(q)&&q.hasOwnProperty("widgetAttrsJson")){var C=q["widgetAttrsJson"]["widgetAttrsOptions"];var u=q["widgetAttrsJson"]["widgetSettingsOptions"];var l=q["widgetAttrsJson"]["selectedWidgetAttrValsJson"];var k=[];var v=[];if(q.hasOwnProperty("dataFieldsOpts")){k=q["dataFieldsOpts"];}if(q.hasOwnProperty("dataSourceFldsArr")){v=q["dataSourceFldsArr"];
}if(!Ext.isEmpty(u)){h.widgetSettingsJsonArr=u;var H=Ext.getCmp("controllerSetting");H.add(e.createSettingsCtrls(u));if(f=="digitalChart"){var o="/final/images/"+strSkin+"/listViewWidgetDefault.png";o=q["widgetAttrsJson"]["selectedImg"];if(Ext.isEmpty(o)){o="/final/images/"+strSkin+"/listViewWidgetDefault.png";
}if(o!=null&&o!=""){if(o.indexOf(":")>0&&o.startsWith("Default")){o=o.substring(o.indexOf(":")+1);var z=Ext.getCmp("digitalChartImgCont");z.iconClass=o;if(o.indexOf("_")>-1){o=o.substring(0,o.lastIndexOf("_")+1)+"32";}z.update('<div id="customUserDefinedImgDefault" class="userDefinedImgDefault" style="padding:5px"><div id="dashboardImageIcon"  class= "'+o+'" width="32px" height="32px" border="0px"/><div class="settingOver"></div></div>');
z.doComponentLayout();Ext.defer(function(){z.setImageTriggerEvents(z);},100);}else{var z=Ext.getCmp("digitalChartImgCont");if(!Ext.isEmpty(z)){z.update('<div id="customUserDefinedImgDefault" class="userDefinedImgDefault" style="padding:5px"><img id="dashboardImageIcon"  src="'+o+'" width="100%" height="100%" border="0px"/><div class="settingOver"></div></div>');
z.doComponentLayout();Ext.defer(function(){z.setImageTriggerEvents(z);},100);}}}}}if(!Ext.isEmpty(C)){G.removeAll();var B=[];var i=k[0];var n="";if(!Ext.isEmpty(i)&&i.hasOwnProperty("valueField")){n=i["valueField"];}var r=[];for(var w in C){var m=C[w];var D=m["displayField"];var A=m["valueField"];var s=m["UI_Control"];
var x="";if(!Ext.isEmpty(m)&&m.hasOwnProperty("selectedVal")){x=m["selectedVal"];}else{x=n;if(A!=null&&A=="Measure_Data"){x="type";}if(A!=null&&A=="Data_Source"){x="-1";}}r.push(A);if(s!=null&&s=="combo"){if(A!=null&&A=="Data_Source"){B.push({xtype:"combo",width:294,margin:10,cls:"dropdown",fieldLabel:D,id:A,name:A,store:Ext.create("Ext.data.Store",{fields:["displayField","valueField"],data:v}),editable:true,forceSelection:true,displayField:"displayField",valueField:"valueField",queryMode:"local",value:x});
}else{if(A!=null&&A=="Measure_Data"){B.push({xtype:"combo",cls:"dropdown",fieldLabel:D,id:A,name:A,width:294,margin:10,store:Ext.create("Ext.data.Store",{fields:["displayField","valueField"],data:[{displayField:"Please choose aggregate type",valueField:"type"},{displayField:"Sum",valueField:"Sum"},{displayField:"Average",valueField:"Average"},{displayField:"Count",valueField:"Count"},{displayField:"Minimum",valueField:"Minimum"},{displayField:"Maximum",valueField:"Maximum"},]}),editable:true,forceSelection:true,displayField:"displayField",valueField:"valueField",queryMode:"local",value:x});
}else{var p=[];if(m!=null&&m.hasOwnProperty("options")){p=m["options"];}if(Ext.isEmpty(p)){p=k;}B.push({xtype:"combo",cls:"dropdown",fieldLabel:D,id:A,name:A,width:295,margin:10,store:Ext.create("Ext.data.Store",{fields:["displayField","valueField"],data:p}),editable:true,forceSelection:true,displayField:"displayField",valueField:"valueField",queryMode:"local",value:x});
}}}else{if(s!=null&&s=="multiselect"){var p=[];if(m!=null&&m.hasOwnProperty("options")){p=m["options"];}if(Ext.isEmpty(p)){p=k;}B.push({xtype:"container",items:[{xtype:"box",margin:"0 0 0px 15px",padding:"0 0 3px 0",html:'<span class="newFont_normal12">'+D+"</span>",},{xtype:"container",layout:{type:"vbox",align:"stretch"},width:280,cls:"darkbox",margin:"-4 5 0 0",height:135,id:A+"MultiSelectOuterBox",items:[{xtype:"trigger",margin:"5",id:A+"SearchTextBox",name:A+"SearchTextBox",width:228,cls:"whitedropdown_search",emptyText:"Search",controltStoreObj:null,valLbl:A,listeners:{"change":function(P,O,K,L){var M=this;
var J=M.controltStoreObj;if(J==null){var I=this.valLbl;M.controltStoreObj=Ext.getCmp(I).getStore();J=M.controltStoreObj;}if(O=="*"){J.clearFilter();}else{if(O.lastIndexOf("*")==(O.length-1)){O=O.substr(0,(O.length-1));}J.clearFilter();if(O){var N=new RegExp(Ext.String.escapeRegex(O),"i");J.filter({filterFn:function(Q){return N.test(Q.get("displayField"));
}});}P.focus();}}}},{xtype:"multiselect",width:280,height:95,margin:"0 0 0px 15px",border:1,autoScroll:true,scroll:true,displayField:"displayField",baseCls:"egmultiselect",multiSelect:true,id:A,name:A,store:Ext.create("Ext.data.Store",{fields:["displayField","valueField"],data:p}),value:x,valueField:"valueField",queryMode:"local"}]}]});
}}}if(f!=null&&(f=="TimelineChart"||f=="areaChart")){if(B!=null&&B.length==4){var t=[];var y=[];y.push(B[0]);y.push(B[1]);var F={xtype:"container",layout:{type:"vbox",align:"strecth"},margin:"25 0 0 0",items:y};t.push(F);t.push(B[2]);t.push(B[3]);G.add(t);}else{G.add(B);}}else{G.add(B);}G.show();}this.dataFieldsComboIdArr=r;
}}}});Ext.getCmp("doneButton").enable();this.callParent();}});