Ext.define("utilities.ErUtils",{alias:"widget.erutils",isHighChartFlag:null,savePDF:function(b){var d=Ext.MessageBox.progress({title:typeof downloadingText!=="undefined"?downloadingText:"Downloading",value:5,width:350,increment:15,closable:true,progressText:typeof connectingText!=="undefined"?'<div style="text-align:center; margin:5px;">'+connectingText+".. </div>":"Connecting..",wait:true,waitConfig:{interval:200},msg:(typeof downloadingText!="undefined"&&typeof waitText!=="undefined")?"<b>"+downloadingText+"..."+waitText+"</b>":"<b>Downloading ... Please wait.</b>",scope:this,handler:function(){this.updateText("Done!");
}});var c=Ext.query("#pdfIframe");var a;if(!Ext.isEmpty(window["appConstants"])){a=appConstants.er_RmDispName;}else{a=er_RmDispName;}if(Ext.isEmpty(c)){Ext.DomHelper.append(document.body,{tag:"iframe",frameBorder:0,width:0,height:0,css:"display:none;visibility:hidden;height:1px;",src:b+"&er_RmDispName="+a,id:"pdfIframe"});
}else{Ext.select("#pdfIframe").set({src:b+"&er_RmDispName="+a});}Ext.Ajax.request({url:"/final/reporter/ErPdfSaveStatus.jsp",scope:this,timeout:60000000,success:function(e){var g=e.responseText;var f=Ext.decode(g);if(!Ext.isEmpty(f)){var h=f.downloadStatus;if(h=="done"){d.hide();}}},failure:function(){}});
},saveSchedule:function(a){document.location=a;},firebackbuttonaction:function(m){try{if(window["reportLastAccessedURL"]!=undefined&&(reportLastAccessedURL.indexOf("ErApplicationReport.jsp")>-1||reportLastAccessedURL.indexOf("SegmentTemplate.jsp")>-1||reportLastAccessedURL.indexOf("ZoneTemplate.jsp")>-1||reportLastAccessedURL.indexOf("ServiceTemplate.jsp")>-1)){parent.appConstants.appObj.getController(parent.appConstants.appController).homeFireBack(reportLastAccessedURL);
}else{var j=Ext.getCmp("ID").getValue();var b=j;var a=m+"?"+b;var q=b;var c=q.split("&");var n=document.createElement("form");n.type="hidden";n.name="backButtonForm";for(var f=0;f<c.length;f++){if(c[f]!=null&&c[f].indexOf("=")>-1){var p=c[f].substring(0,c[f].indexOf("="));var h=c[f].substring(c[f].indexOf("=")+1);
var g=document.getElementById(p);if(g==null){var o=document.createElement("SELECT");if(p!=null&&!p==""){o.setAttribute("name",p);o.setAttribute("id",p);o.setAttribute("MULTIPLE","true");o.style.display="none";theOption=document.createElement("OPTION");theOption.setAttribute("value",h);o.appendChild(theOption);
n.appendChild(o);}}else{if(g!=null&&g.name=="backButtonForm"){theOption=document.createElement("OPTION");theOption.setAttribute("value",h);g.appendChild(theOption);}else{var o=document.createElement("SELECT");if(p!=null&&!p==""){o.setAttribute("name",p);o.setAttribute("id",p);o.setAttribute("MULTIPLE","true");
o.style.display="none";theOption=document.createElement("OPTION");theOption.setAttribute("value",h);o.appendChild(theOption);n.appendChild(o);}}}}}for(var f=0;f<n.elements.length;f++){if((n.elements[f].type=="select-multiple"||n.elements[f].type=="select-one")&&n.elements[f].form.name=="backButtonForm"){for(var d=0;
d<n.elements[f].length;d++){n.elements[f].options[d].selected=true;}}}n.action=m;n.method="POST";document.body.appendChild(n);n.submit();}}catch(l){alert("An error has occurred: "+l.message);}return true;},filterComboStore:function(h,j,b){var c=h.getValue().toLowerCase();if(Ext.isEmpty(c)){j.getStore().loadRawData(b);
j.setValue(b[0]["valueField"]);}else{var e=false;var g=new Ext.data.Store({fields:["displayField","valueField"],data:[]});for(var f=0;f<b.length;f++){var d=b[f]["valueField"].toLowerCase();var a=b[f]["displayField"].toLowerCase();if(a.indexOf(c)>-1){e=true;g.add({"displayField":b[f]["displayField"],"valueField":b[f]["valueField"]});
}}if(e){j.getStore().removeAll();for(var f=0;f<g.getCount();f++){var a=g.getAt(f);j.getStore().add(a);}j.setValue(g.getAt(0).get("valueField"));}else{j.getStore().removeAll();j.getStore().add({"displayField":"Not Applicable!","valueField":"-1"});j.setValue("-1");}}h.focus();},expandMultiComboButton:function(a,b,c){c.setDisabled(true);
Ext.create("Ext.window.Window",{width:400,border:false,frame:false,modal:true,ghost:false,header:false,id:"expandWindow",ui:"newPopupWindow withBorderShadow",listeners:{show:function(e){if(this.modal){var f=Ext.dom.Query.select(".x-mask");for(var g=0;g<f.length;g++){var d=Ext.fly(f[g]);}d.addCls("windowModalNoBg");
}},hide:function(e){var f=Ext.dom.Query.select(".x-mask");if(this.modal){var d=Ext.fly(f[0]);d.removeCls("windowModalNoBg");}},afterrender:function(){Ext.EventManager.onWindowResize(function(){var d=this;d.center();},this);}},doClose:function(){var d=this;c.setDisabled(false);if(d.hidden){d.fireEvent("close",d);
if(d.closeAction=="destroy"){this.destroy();}}else{d.hide(d.animateTarget,d.doClose,d);}},buttonAlign:"center",items:[{xtype:"panel",title:b,layout:{type:"vbox",pack:"center",align:"stretch"},buttonAlign:"center",ui:"newFormFieldsInPopup",items:[{xtype:"multiselect",width:"100%",height:237,margin:"0 10 0 10",layout:"fit",border:0,autoScroll:false,scroll:false,labelAlign:"left",baseCls:"egmultiselect",multiSelect:true,id:"componentsClone",name:"componentsClone",store:a.getStore(),value:a.getValue(),displayField:"displayField",valueField:"valueField",queryMode:"local"},{xtype:"container",layout:{type:"hbox",pack:"center"},items:[{xtype:"button",text:typeof selectTxt!=="undefined"?selectTxt:"Select",id:"expand",margin:"10 10 10 10",ui:"newButtonSmall",name:"expand",handler:function(){if(Ext.getCmp("componentsClone").getValue()!=""){a.setValue(Ext.getCmp("componentsClone").getValue());
c.setDisabled(false);Ext.getCmp("expandWindow").destroy();}else{Ext.MessageBox.show({title:typeof alert_text!=="undefined"?alert_text:"Alert",msg:typeof componentMsg!=="undefined"?componentMsg:"Please Choose a Component",buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.WARNING});return;}}}]}],tools:[{xtype:"button",iconCls:"iconCloseNew",listeners:{afterrender:function(){Ext.create("Ext.tip.ToolTip",{target:this.id,anchor:"top",cls:"yellowTip",trackMouse:true,html:(typeof close!=="undefined"&&typeof close!=="function")?close:"Close"});
},click:function(){Ext.getCmp("expandWindow").doClose();}},style:{background:"none",border:"0px"}}]}],}).show();},getDateDiff_ms:function(f,i,a,d,g){var e=f.indexOf(" ");var h=1;var c=1000*60*60;if(e>0){var k=parseInt(f.substring(0,e));var j=f.substring(e+1).toLowerCase();if(j.indexOf("hour")>-1){h=k*c;
}else{if(j.indexOf("day")>-1){h=k*(24*c);}else{if(j.indexOf("week")>-1){h=k*(7*24*c);}else{if(j.indexOf("mon")>-1){var l=new Date(i.getFullYear(),i.getMonth()+1,0);var b=l.getDate();h=k*(b*24*c);}}}}}else{i.setHours(d);a.setHours(g);h=a.getTime()-i.getTime();}return h;},toggleGraphCombo:function(f,k,a,c,g,d){console.log("reporterTimeline----"+f);
if(f=="Any"&&!Ext.isEmpty(Ext.getCmp("goBtn"))){Ext.getCmp("goBtn").show();}var e=false;var b=new Array();b.push("ErReporterMenu");b.push("ErComparison");b.push("ErCompareTest");b.push("ErCapacityCumulationReport");b.push("ErCapacityCorrelationReport");b.push("ErCapacityPredictionReport");b.push("ErEsxGuestReport");
b.push("ErVirtualClusterReport");b.push("ErVmGuestStatusReport");b.push("ErThinClientUserReport");b.push("ErVirtualDataCenter");b.push("ErMeasureDrillDown");b.push("ErVmMeasureDrillDown");b.push("ErCtxUserGraph");for(var l in b){if(requestPageURL.indexOf(b[l])>-1){e=true;break;}}if(e&&f!=null){var i=this.getDateDiff_ms(f,k,a,c,g);
var h;if(Ext.get("TimelineReportType")!=null){if(!Ext.getCmp("TimelineReportType").isHidden()){h=Ext.getCmp("TimelineReportType").getValue();}}if(Ext.get("er_graphType")!=null){if(!Ext.getCmp("er_graphType").isHidden()){h=Ext.getCmp("er_graphType").getValue();}}if(Ext.get("er_rtype")!=null){if(!Ext.getCmp("er_rtype").isHidden()){h=Ext.getCmp("er_rtype").getValue();
}}if(Ext.get("graphtype")!=null){if(!Ext.getCmp("graphtype").isHidden()){h=Ext.getCmp("graphtype").getValue();}}console.log("diff_ms----"+i);if(i<=maxTimelineDiff_ms){this.isHighChartFlag=true;if(h=="Summary"||h=="distribution"||h=="Distribution"||h=="Yes"){d.show();}else{d.setValue("2D");d.hide();}}else{this.isHighChartFlag=false;
var j;if(Ext.get("er_type")!=null){j=Ext.getCmp("er_type").getValue();}if(Ext.get("reportTypeCombo")!=null){j=Ext.getCmp("reportTypeCombo").getValue();}if(j=="No"){d.hide();}else{d.setValue("2D");d.show();}}}},updatePieChart:function(h,f,p,n,q,m,k,d,w,o){var l="";if((w["needmarginTop"]!="undefined"||w["needmarginTop"]!=undefined)&&w["needmarginTop"]=="Yes"){l='<table cellpadding="0" cellspacing="0" border="0" style="margin:30px 10px 10px 10px">';
}else{l='<table cellpadding="0" cellspacing="0" border="0" style="margin:10px">';}l+="<tr>";if(!$.isArray(f)){var e=f[q];var r=f[p];var u=f[n];for(var y in e){var j=e[y];var c=r[y];var b=u[y];if(b!=null&&b.indexOf("openInNewWin")>-1){b=b.substring(b.indexOf("(")+1,b.length-1);}if(((t+1)%4)==0){l+="</tr><tr>";
}l+='<td><div style="background-color:#'+c+';width:8px;height:8px;border-radius:4px;">&nbsp;</div></td>';l+='<td style="padding:5px;" class="font_normal10"><a href="javascript:void(0);" onClick="javascript:openInNewWin(\''+b+"');\">"+j+"</a></td>";}}else{for(var t=0;t<f.length;t++){if(((t+1)%4)==0){l+="</tr><tr>";
}var a=f[t][p];if(a.indexOf("#")<0){a="#"+a;}l+='<td><div style="background-color:'+a+';width:6px;height:6px;border-radius:3px;">&nbsp;</div></td>';l+='<td style="padding:5px;" class="font_normal10"><a href="javascript:void(0);" onClick="javascript:openInNewWin(\''+f[t][n]+"');\">"+f[t][q]+"</a></td>";
}}l+="</tr>";l+="</table>";var s;s+="</table>";var x;if(o.id!="undefined"&&o.id!=undefined){x=o.id+"piegraphdiv";}else{x="piegraphdiv";}if(m!=undefined&&m!=""){s='<div style="padding:10px;" align="center"><div class="font_normal12" style="text-align:center;height:30px;">'+m+'</div><div id="'+x+'" height="300px" style="padding:5px 0px 0px 0px"></div><div>'+l+"</div></div>";
}else{s='<div style="padding-top:15px;" align="center"><div id="'+x+'" height="300px"></div><div>'+l+"</div></div>";}o.update(s);if(h.toLowerCase()=="fusionchart"){if(FusionCharts("piechartid")){FusionCharts("piechartid").dispose();}var g=new FusionCharts(d,"piechartid","100%","100%","0","1");g.setDataXML(k);
g.setTransparent(true);g.render(x);}else{if(h.toLowerCase()=="highchart"){var v={};v=jQuery.extend(true,{},getHighChartsBarInstance(x,highChartPieHeight,highChartPieWidth),v);v.setData(w,"<%=currentDateFormat%>","");v.drawChart();}}},updatePieChart_builder:function(l,f,r,p,t,o,m,d,B,q){var F;if(q.id!="undefined"&&q.id!=undefined){F=q.id+"piegraphdiv";
}else{F="piegraphdiv";}var e=f[t];var v=f[r];var x=B["DataSet"];var z=highChartPieHeight;var u="flex";var c=false;var s="egFlexLeftByColumnWise";if(e!=undefined&&e.length>0){var j=e.length;if(j<6){c=true;}if(j>2){u="grid";s="egFlexCenterByColumnWise";}}var n='<div class="'+s+'" style="height:'+z+"px;overflow:auto;display:"+u+'">';
n+='<div style="padding:2px">';var a=false;if(x!=null&&x.length>0){var C=x[0].data;var y=0;for(var E in e){var k=e[E];var b=v[E];var D=C[E].percentVal;if(D==undefined){D=C[E].y;}var h=C[E].url;if(y>0&&((y+1)%1)==0){n+='</div><div style="padding:2px">';}n+='<table><tr><td><div style="background-color:#'+b+';width:6px;height:6px;border-radius:3px;">&nbsp;</div></td>';
if(h!=null&&h!=undefined&&h!=""&&h!="undefined"){n+='<td style="padding:2px 10px;" class="font_normal11"><a href="javascript:void(0);" onclick="javascript:linkURL(\''+h+"');\">"+k+'</a></td><td class="font_normal11">'+D+"</td>";}else{if(c){n+='<td style="padding:0px 10px 0px 5px;" class="newFont_bold15">'+D+"</td>";
n+='</tr><tr><td></td><td style="padding:0px 5px;" class="newFont_normal11">'+k+"</td></tr></table>";}else{n+='<td wrap style="padding:2px 10px;word-break:break-all" class="font_normal11" width="75%">'+k+'</td><td wrap class="font_normal11" width="25%">'+D+"</td>";}}y++;}a=true;}n+="</div>";n+="</div>";
var w='<table cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse:collapse;">';if(a){if(f.LegendPosition!=undefined&&f.LegendPosition!=" "&&f.LegendPosition!=null&&f.LegendPosition=="bottom"){w+='<tr><td id="'+F+'" width="60%"></td></tr><tr><td width="100%"  align="center" >'+n+"</td></tr></table>";
}else{w+='<tr><td id="'+F+'" width="70%"></td><td width="30%"  style="height:'+z+'px">'+n+"</td></tr></table>";}}else{w+='<tr><td id="'+F+'" width="100%"></td></tr></table>';}q.update(w);if(l.toLowerCase()=="fusionchart"){if(FusionCharts("piechartid")){FusionCharts("piechartid").dispose();}var g=new FusionCharts(d,"piechartid","100%","100%","0","1");
g.setDataXML(m);g.setTransparent(true);g.render(F);}else{if(l.toLowerCase()=="highchart"){var A={};A=jQuery.extend(true,{},getHighChartsBarInstance(F,highChartPieHeight,highChartPieWidth),A);A.setData(B,"<%=currentDateFormat%>","");A.drawChart();}}},updateDistributedPieChart:function(d,y,k,g,q,o,r,n,l,e,x,p){var m='<table cellpadding="0" cellspacing="0" border="0" style="margin:0px;">';
m+="<tr>";if(!$.isArray(g)){var f=g[r];var s=g[q];var v=g[o];for(var A in f){var j=f[A];var c=s[A];var b=v[A];if(b!=null&&b.indexOf("openInNewWin")>-1){b=b.substring(b.indexOf("(")+1,b.length-1);}if(((u+1)%4)==0){m+="</tr><tr>";}b=b+"&widgetIdInfo="+d+"&graphIndex="+y;m+='<td><div style="background-color:#'+c+';width:6px;height:6px;border-radius:3px;">&nbsp;</div></td>';
m+='<td style="padding:5px;" class="font_normal10"><a href="javascript:void(0);" onClick="javascript:openInNewWin(\''+b+"');\">"+j+"</a></td>";}}else{for(var u=0;u<g.length;u++){if(((u+1)%4)==0){m+="</tr><tr>";}var a=g[u][q];if(a.indexOf("#")<0){a="#"+a;}m+='<td><div style="background-color:'+a+';width:6px;height:6px;border-radius:3px;">&nbsp;</div></td>';
m+='<td style="padding:5px;" class="font_normal10"><a href="javascript:void(0);" onClick="javascript:openInNewWin(\''+g[u][o]+"');\">"+g[u][r]+"</a></td>";}}m+="</tr>";m+="</table>";var t;var z;if(p.id!="undefined"&&p.id!=undefined){z=p.id+"piegraphdiv";}else{z="piegraphdiv";}if(n!=undefined&&n!=""){t='<div style="padding:10px;" align="center"><div class="font_normal12" style="text-align:center;height:30px;">'+n+'</div><div id="'+z+'" height="300px"></div><div>'+m+"</div></div>";
}else{t='<table cellspacing="0" cellpadding="0" border="0" width="100%" height="100%" style="border-collapse:collapse;">';t+='<tr><td id="'+z+'" width="70%"></td><td width="30%">'+m+"</td></tr>";t+="</table>";}p.update(t);if(k.toLowerCase()=="fusionchart"){if(FusionCharts("piechartid")){FusionCharts("piechartid").dispose();
}var h=new FusionCharts(e,"piechartid","100%","100%","0","1");h.setDataXML(l);h.setTransparent(true);h.render(z);}else{if(k.toLowerCase()=="highchart"){var w={};w=jQuery.extend(true,{},getHighChartsBarInstance(z,highChartPieHeight,highChartPieWidth),w);w.setData(x,"<%=currentDateFormat%>","");w.drawChart();
}}},updateColumnChart:function(h,d,e,k,j,f,b,c){var i;if(c.id!="undefined"){i=c.id+"topgraphdiv";}else{i="topgraphdiv";}var g;g='<div style="padding:0px;"><div class="font_normal12" style="text-align:center;">'+d+'</div><div id="'+i+'" ></div></div>';c.update(g);var a={};a=jQuery.extend(true,{},getColumnInstance(i,f,b),a);
a.setData(j,"<%=currentDateFormat%>","");a.drawChart();},updateBarChart:function(h,d,e,k,j,f,b,c){var i;if(c.id!="undefined"){i=c.id+"topgraphdiv";}else{i="topgraphdiv";}var g;if(d!=undefined&&d!=""){g='<div style="padding:10px;"><div class="font_normal12" style="text-align:center;height:30px;">'+d+'</div><div id="'+i+'" height="300px"></div></div>';
}else{g='<div id="'+i+'" height="300px"></div>';}if(h.toLowerCase()=="fusionchart"){c.add({xtype:"container",html:g,listeners:{boxready:function(){if(FusionCharts("barchartid")){FusionCharts("barchartid").dispose();}var l=new FusionCharts(k,"barchartid","80%",f,"0","1");l.setDataXML(e);l.setTransparent(true);
l.render(i);}}});}else{if(h.toLowerCase()=="highchart"){c.add({xtype:"container",html:g});var a={};a=jQuery.extend(true,{},getHighChartsBarInstance(i,f,b),a);a.setData(j,"<%=currentDateFormat%>","");a.drawChart();}}},updateCombineBarChart:function(h,d,e,k,j,f,b,c){var i;if(c.id!="undefined"){i=c.id+"topgraphdiv";
}else{i="topgraphdiv";}var g;if(d!=undefined&&d!=""){g='<div style="padding:10px;"><div class="font_normal12" style="text-align:center;height:30px;">'+d+'</div><div id="'+i+'" height="300px"></div></div>';}else{g='<div id="'+i+'" height="300px"></div>';}if(h.toLowerCase()=="fusionchart"){c.add({xtype:"container",html:g,listeners:{boxready:function(){if(FusionCharts("barchartid")){FusionCharts("barchartid").dispose();
}var l=new FusionCharts(k,"barchartid","80%",f,"0","1");l.setDataXML(e);l.setTransparent(true);l.render(i);}}});}else{if(h.toLowerCase()=="highchart"){c.add({xtype:"container",html:g});var a={};a=jQuery.extend(true,{},getHighChartsBarInstance_combine(i,f,b),a);a.setData(j,"<%=currentDateFormat%>","");
a.drawChart();}}},specialCharEncode:function(i){var d=["[","]","(",")","=","%"," ","\\",";","?","&","-","*","#","|","'","@","_","{","}"," ",">","<",":","/"];var c=["eGlsbreG","eGrsbreG","eGlbreG","eGrbreG","eGeqeG","eGpereG","eGspaceG","eGbkSleG","eGsemieG","eGquestioneG","eGandeG","eGhypheneG","eGstareG","eGHasheG","eGPipeeG","eGApposeG","eGatG","eGundereG","eGlflowereG","eGrflowereG","eGspaceeG","eGgreG","eGleeG","eGcoloneG","eGfslasheG"];
try{if(i!=null&&i!=undefined){i=i.toString();for(var b in d){var f=d[b];var g=c[b];do{i=i.replace(f,g);}while(i.indexOf(f)>-1);}i=encodeURIComponent(i);}}catch(h){console.log(h);}return i;},specialCharDecode:function(i){var d=["eGlsbreG","eGrsbreG","eGlbreG","eGrbreG","eGeqeG","eGpereG","eGspaceG","eGbkSleG","eGsemieG","eGquestioneG","eGandeG","eGhypheneG","eGstareG","eGHasheG","eGPipeeG","eGApposeG","eGatG","eGundereG","eGlflowereG","eGrflowereG","eGspaceeG","eGgreG","eGleeG","eGcoloneG","eGfslasheG"];
var c=["[","]","(",")","=","%"," ","\\",";","?","&","-","*","#","|","'","@","_","{","}"," ",">","<",":","/"];try{if(i!=null&&i!=undefined){i=i.toString();i=decodeURIComponent(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){console.log(h);}return i;}});
