Ext.define("citrixDashboard.view.GeoMapDetails",{extend:"Ext.grid.Panel",requires:["Ext.grid.feature.RowBody"],padding:0,border:0,margin:"10px 5px 10px 5px",columnLines:false,alias:"widget.geomapdetails",title:"Countries",addInfo:true,ui:"plainGrid",id:"",jsonData:"",jsonData1:"",store:null,columns:null,initComponent:function(){var b=this;
var a=[];if(!Ext.isEmpty(b.jsonData)&&!Ext.isEmpty(b.jsonData.resultArray)){a=b.jsonData.resultArray;}b.store=Ext.create("Ext.data.Store",{storeId:"mapStore",fields:[{name:"m1",sortType:"asFloat"},{name:"m2",sortType:"asFloat"},"from","ctx_chartData","chartData","legendColor","test_name","measure_name"],data:a,sorters:[{property:"m1",direction:"DESC"}],proxy:{type:"memory",reader:{type:"json"}}});
if(!Ext.isEmpty(b.jsonData.ng_cols)&&b.jsonData.ng_cols!=undefined&&b.jsonData.ng_cols!=null){b.columns=b.jsonData.ng_cols;}else{b.columns=null;}if(!Ext.isEmpty(b.store.data.items)){var c=b.store.data.items;b.mon(b,"viewready",function(){b.loadChart(c);if(!Ext.isEmpty(b.jsonData.mapMode)&&b.jsonData.mapMode=="Region"){b.setTitle("Regions");
}else{if(!Ext.isEmpty(b.jsonData.mapMode)&&b.jsonData.mapMode=="City"){b.setTitle("Cities");}else{b.setTitle("Countries");}}},b);}b.mon(b,"sortchange",function(){b.loadChart(c);},b);b.mon(b,"resize",function(){b.loadChart(c);},b);this.callParent();},updateData:function(b,c){var a=this;topJson=c;if(!Ext.isEmpty(b.mapMode)&&b.mapMode=="Region"){a.setTitle("Regions");
}else{if(!Ext.isEmpty(b.mapMode)&&b.mapMode=="City"){a.setTitle("Cities");}else{a.setTitle("Countries");}}if(!Ext.isEmpty(b.ng_cols)&&b.ng_cols!=undefined&&b.ng_cols!=null){a.columns=b.ng_cols;}else{a.columns=null;}a.store.loadRawData(b.resultArray);if(!Ext.isEmpty(a.store.data.items)){var b=a.store.data.items;
a.loadChart(b,topJson);a.mon(a,"sortchange",function(){a.loadChart(b,topJson);},a);a.mon(a,"resize",function(){a.loadChart(b,topJson);},a);}},infoToolTip:function(a){var b=this;var c=Ext.create("Ext.tip.ToolTip",{anchor:"top",shadow:true,anchorOffset:25,mouseOffset:[0,0],target:Ext.fly(a),cls:"moreoptionstooltip",listeners:{hide:function(d){if(!Ext.isEmpty(d)){Ext.destroy(d);
}},render:function(d){Ext.EventManager.onWindowResize(function(e,f){d.hide();});}},getTargetXY:function(){var d=Ext.fly(a).getXY()[0];var e=Ext.fly(a).getXY()[1];return[d-c.anchorOffset-12,Ext.fly(a).getHeight()+e];},autoHide:false,anchorToTarget:true,width:210,padding:"10 2 10 10",style:"text-align:left",html:"<div class='t_b'><ol><li>Shows where Citrix users are coming from</li><li>Size of the geo-marker varies with the number of Citrix user sessions</li><li>State indicates the weighted value of HDX latency for users connecting from a location</li></ol></div>"});
c.show();return c;},addInfoIcon:function(a){var c=this;var b=Ext.get(c.header.getComponent(0).id).createChild({tag:"span",cls:a,style:"padding:5px 7px;margin-left:5px;cursor:pointer"},null,true);Ext.fly(b).addListener("click",function(){c.infoToolTip(b);});},loadChart:function(c,f){var h=this;if(c==undefined||c==null){return;
}try{var b;var g="";if(!Ext.isEmpty(f)&&f.length>0&&f[1].hasOwnProperty("Geo_Block_1_Value")){b=f[1].Geo_Block_1_Value[1];var j=Ext.getCmp("countryComboId").getRawValue();var a=Ext.getCmp("regionComboId").getValue();if(a!=null&&a.toLowerCase()!="allregion"){j=a;}}for(var d=0;d<c.length;d++){if(!Ext.isEmpty(b)){g="loadView('"+b.changeTabView+"','"+c[d].get("m2")+"','"+c[d].data.from+" - "+j+"','"+c[d].data.test_name+"','"+c[d].data.measure_name+"','"+b.linkurl+"','true')";
$("#geo_mapbar"+d+"IdText").attr("onclick",g);$("#geo_mapbar"+d+"Id").attr("onclick",g);}$("#geo_mapbar"+d+"Id").highcharts(h.chartConfig(c[d].data.ctx_chartData,c[d].data.m2));}}catch(e){return;}},chartConfig:function(e,f){var a=[];for(var c=e.DataSet.length-1;c>=0;c--){a.push(e.DataSet[c]);}var d=this,b={chart:{type:"bar",backgroundColor:"transparent",height:8,padding:0,margin:0},title:"",exporting:{enabled:false},credits:{enabled:false},tooltip:{enabled:false},yAxis:{gridLineWidth:0,max:f,endOnTick:false,labels:{enabled:false},lineColor:"transparent",tickLength:0,minorGridLineWidth:0},xAxis:{gridLineWidth:0,labels:{enabled:false},lineColor:"transparent",tickLength:0,minorGridLineWidth:0},legend:{enabled:false,reversed:true},plotOptions:{series:{stacking:"normal",},bar:{borderWidth:0,dataLabels:{enabled:false},series:{borderColor:"transparent"}}},series:a};
return b;},features:[{ftype:"rowbody",getAdditionalData:function(e,i,f,j){var b=this.view.headerCt,a=b.getColumnCount();var g=this.grid.fullJson;if(!Ext.isEmpty(g)&&g.length>0&&g[1].hasOwnProperty("Geo_Block_1_Value")){var d=g[1].Geo_Block_1_Value[1];if(!Ext.isEmpty(d)&&d.title.toLowerCase()=="unique users"){var h=Ext.getCmp("countryComboId").getRawValue();
var c=Ext.getCmp("regionComboId").getValue();if(c!=null&&c.toLowerCase()!="allregion"){h=c;}h=f.data.from+" - "+h;return{rowBody:"<div onclick=\"loadView('"+d.changeTabView+"','"+f.get("m2")+"','"+h+"','"+f.get("test_name")+"','"+f.get("measure_name")+"','"+d.linkurl+'\',\'true\')" style="cursor:pointer;margin:0px 0px 5px 0px" id="geo_mapbar'+i+'IdText">'+f.get("from")+"</div><div onclick=\"loadView('"+d.changeTabView+"','"+f.get("m2")+"','"+h+"','"+f.get("test_name")+"','"+f.get("measure_name")+"','"+d.linkurl+'\',\'true\')" style="cursor:pointer;"  id="geo_mapbar'+i+'Id"  class="mapdetail_chart">'+f.get("ctx_chartData")+"</div>",rowBodyCls:"plainGrid-body-cls",rowBodyColspan:a};
}}else{return{rowBody:'<div style="margin:0px 0px 5px 0px">'+f.get("from")+'</div><div id="geo_mapbar'+i+'Id"  class="mapdetail_chart">'+f.get("ctx_chartData")+"</div>",rowBodyCls:"plainGrid-body-cls",rowBodyColspan:a};}}}]});