Ext.define("microsoftDashboard.controller.Main",{extend:"Ext.app.Controller",requires:["microsoftDashboard.view.Main","microsoftDashboard.view.DashboardMenu","microsoftDashboard.view.office365.OverviewPage","microsoftDashboard.view.office365.ServiceHealthPage","microsoftDashboard.view.office365.LicenseUsagePage","microsoftDashboard.view.office365.UsersGroupsPage","microsoftDashboard.view.office365.ServiceUsagePage","microsoftDashboard.view.exchangeonline.OverviewPage","microsoftDashboard.view.exchangeonline.UserviewPage","microsoftDashboard.view.exchangeonline.MailTrafficPage","microsoftDashboard.view.exchangeonline.MailProtectPage","microsoftDashboard.view.exchangeonline.NonOwnerActivityPage","microsoftDashboard.view.sharepointonline.OverviewPage","microsoftDashboard.view.sharepointonline.UsagePage","microsoftDashboard.view.365AlarmDetailsDashboard.ContainerPage","microsoftDashboard.view.microsoftTeams.ServiceHealthPage","microsoftDashboard.view.microsoftTeams.CallSummaryPage","microsoftDashboard.view.microsoftTeams.UsersDevicesPage","microsoftDashboard.view.oneDrive.OverviewPage","microsoftDashboard.view.oneDrive.UsagePage",],refs:[{ref:"main",selector:"main"},{ref:"dashboardmenu",selector:"dashboardmenu"}],init:function(){timerId=window.setInterval("execute()",refreshFrequency);
this.control({"dashboardmenu":{viewready:this.menuOnLoad,itemclick:this.menuItemClick},'main button[id="backButton"]':{"click":this.goBack},});},goBack:function(){var e=requestParams.isFromHomepage;var d=requestParams.isFromMenu;var b=requestParams.isFromList;var c=requestParams.isFromMetrics;var a=requestParams.viewPageTitle;
if(e&&b&&!c){document.location="/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=MainDashboard&action=componentType&searchIndComps=true&viewId=components&viewTreeTitle=Component&componentType="+requestParams.dashboardCompType+"&fromPageView=Home&filterBy=Component&msDashboardLink=true&selectedState="+requestParams.selectedState+"&viewPageTitle="+a;
}else{if(b&&d&&!c){document.location="/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=MainDashboard&action=componentType&searchIndComps=true&viewId=components&viewTreeTitle=Component&componentType="+requestParams.dashboardCompType+"&fromMenu=true&filterBy=Component&msDashboardLink=true&selectedState="+requestParams.selectedState+"&viewPageTitle="+a;
}else{if(e&&c){document.location="/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewTreeTitle=Component&componentType="+requestParams.dashboardCompType+"&fromPageView=Home&msDashboardLink=true&selectedState="+requestParams.selectedState+"&viewPageTitle="+a;
}else{if(d&&c){document.location="/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewTreeTitle=Component&componentType="+requestParams.dashboardCompType+"&fromMenu=true&msDashboardLink=true&selectedState="+requestParams.selectedState+"&viewPageTitle="+a;
}else{if(e){document.location="/final/servlet/com.eg.EgMonitorController?monCmd=dashboard";}else{window.history.go(-1);}}}}}},menuItemClick:function(h,a,k,b,c,d){try{var g=a.get("id");if(g=="Unclickable_Sub_View"){return;}}catch(i){}var f=this,j=f.getMain().getComponent("microsoft_ground").getComponent("cardID");
requestParams.selectedTab=a.get("id");requestParams.dashboard=a.get("type");if(requestParams.isOldAgentCompName){setSession(requestParams.selectedTab,requestParams.dashboard,requestParams.dashboardCompType);}else{setSession(requestParams.selectedTab,requestParams.dashboard);}if(!Ext.isEmpty(j)){j.stopAnimation();
j.animate({duration:500,to:{"opacity":0},listeners:{afteranimate:function(){requestParams.selectedTab=a.get("id");requestParams.dashboard=a.get("type");f.addPage(a.get("id"),a.get("type"));}},scope:f.getMain()});}},menuOnLoad:function(e){var e=this.getDashboardmenu(),d=this.getDashboardmenu().el,c=this.getDashboardmenu().store,b=c.findRecord("type",requestParams.dashboard,0,false,true,true),a=c.indexOf(b);
this.addPage(requestParams.selectedTab,requestParams.dashboard);if(requestParams.isOldAgentCompName){setSession(requestParams.selectedTab,requestParams.dashboard,requestParams.dashboardCompType);}else{setSession(requestParams.selectedTab,requestParams.dashboard);}e.selectMenuonLoad(a,requestParams.selectedTab,requestParams.dashboard);
},updatePage:function(){var j=this;if(requestParams.selectedTab!=undefined&&requestParams.selectedTab!=null){var d=requestParams.selectedTab;var a=requestParams.dashboard;var b="";try{b=Ext.getCmp("serviceProvisionGrid_combo").getValue();}catch(g){b="";}var f=Ext.getCmp("dashTypeComId").getValue();var k=Ext.getCmp("dashTypeComId").getRawValue();
var c=Ext.getCmp("dashTypeComTypeId").getValue();var i="/final/servlet/com.eg.EgCommonDashboardController?isFrom=msdashboard&iniName=eg_msdashboard&userBased=true&fromMenu=true&showConfig=true&dashboard_name="+a+"&selectedTab="+d+"&time_line="+encodeURI(requestParams.time_line)+"&accountValue="+f+"&accountName="+k+"&isFromHomepage="+requestParams.isFromHomepage+"&isFromMenu="+requestParams.isFromMenu+"&isFromMetrics="+requestParams.isFromMetrics+"&selectedState="+requestParams.selectedState+"&isFromList="+requestParams.isFromList+"&eventDetails=true&isOldAgentCompName="+requestParams.isOldAgentCompName+"&compType="+c;
Ext.Ajax.request({url:i,method:"POST",scope:this,timeout:280000,success:function(l,n){var o=l.responseText;var m=Ext.decode(o);if(!Ext.isEmpty(m.loadViewDetails[0])){var e=m.loadViewDetails[0].state;var p=m.loadViewDetails[0].count;if(!Ext.isEmpty(e)){$("#All_Events_state").removeClass();$("#All_Events_state").addClass("stateCircle bar12_"+e);
}if(!Ext.isEmpty(p)){$("#All_Events_subtext").html("All Events ("+p+")");$("#All_Events_text").html("All Events ("+p+")");}}}});var h="/final/servlet/com.eg.EgCommonDashboardController?isFrom=msdashboard&iniName=eg_msdashboard&userBased=true&fromMenu=true&showConfig=true&dashboard_name="+a+"&selectedTab="+d+"&time_line="+encodeURI(requestParams.time_line)+"&comboTimeLine="+b+"&isRefresh=true&accountValue="+f+"&accountName="+k+"&isFromHomepage="+requestParams.isFromHomepage+"&isFromMenu="+requestParams.isFromMenu+"&isFromMetrics="+requestParams.isFromMetrics+"&selectedState="+requestParams.selectedState+"&isFromList="+requestParams.isFromList+"&isOldAgentCompName="+requestParams.isOldAgentCompName+"&compType="+c;
Ext.getBody().mask("Loading...");Ext.Ajax.request({url:h,method:"POST",scope:this,timeout:280000,success:function(e,m){var n=e.responseText;var l=Ext.decode(n);if(d!=null&&d==="overview_view"){j.updateOverviewPage(l);Ext.getBody().unmask();}else{if(d!=null&&d==="service_health_view"){j.updateServiceHealthPage(l);
Ext.getBody().unmask();}else{if(d!=null&&d==="license_usage_view"){j.updateLicenseUsagePage(l);Ext.getBody().unmask();}else{if(d!=null&&d==="users_group_view"){j.updateUsersGroupsPage(l);Ext.getBody().unmask();}else{if(d!=null&&d==="service_usage_view"){j.updateServiceUsagePage(l);Ext.getBody().unmask();
}else{if(d!=null&&d==="users_view"){j.updateUserViewPage(l);Ext.getBody().unmask();}else{if(d!=null&&d==="mail_traffic_view"){j.updateMailTrafficPage(l);Ext.getBody().unmask();}else{if(d!=null&&d==="mail_protection_view"){j.updateMailProtectionPage(l);Ext.getBody().unmask();}else{if(d!=null&&d==="non_owner_activities_view"){j.updateNonOwnerActivitiesPage(l);
Ext.getBody().unmask();}else{if(d!=null&&d==="usage_view"){j.updateUsagePage(l);Ext.getBody().unmask();}else{if(d!=null&&d==="All_Events"){j.updateallEventsPage(l);Ext.getBody().unmask();}else{if(d!=null&&d==="users_devices_view"){j.updateuserDevicesPage(l);Ext.getBody().unmask();}else{if(d!=null&&d==="call_quality_view"){j.updatecallQualityPage(l);
Ext.getBody().unmask();}}}}}}}}}}}}}Ext.getBody().unmask();},failure:function(){Ext.getBody().unmask();}});}},addPage:function(a,b){var h=this,c=Ext.getCmp("microsoft_ground");for(var e=0;e<Ext.getCmp("microsoft_ground").items.items[0].items.items.length;e++){Ext.destroy(c.items.items[0].items.items[e]);
}c.removeAll(true);window.clearInterval(timerId);timerId=window.setInterval("execute()",refreshFrequency);var f=Ext.getCmp("dashTypeComId").getValue();var j=Ext.getCmp("dashTypeComId").getRawValue();var d=Ext.getCmp("dashTypeComTypeId").getValue();var g="/final/servlet/com.eg.EgCommonDashboardController?isFrom=msdashboard&iniName=eg_msdashboard&userBased=true&fromMenu=true&showConfig=true&dashboard_name="+b+"&selectedTab="+a+"&time_line="+encodeURI(requestParams.time_line)+"&accountValue="+f+"&accountName="+j+"&isFromHomepage="+requestParams.isFromHomepage+"&isFromMenu="+requestParams.isFromMenu+"&isFromMetrics="+requestParams.isFromMetrics+"&selectedState="+requestParams.selectedState+"&isFromList="+requestParams.isFromList+"&isOldAgentCompName="+requestParams.isOldAgentCompName+"&compType="+d;
Ext.getBody().mask("Loading...");Ext.Ajax.request({url:g,method:"POST",scope:this,timeout:280000,success:function(i,l){var m=i.responseText;var k=Ext.decode(m);if(a!=null&&a==="overview_view"){h.addOverviewPage(k,c,b);Ext.getBody().unmask();}else{if(a!=null&&a==="service_health_view"){h.addServiceHealthPage(k,c,b);
Ext.getBody().unmask();}else{if(a!=null&&a==="license_usage_view"){h.addLicenseUsagePage(k,c,b);Ext.getBody().unmask();}else{if(a!=null&&a==="users_group_view"){h.addUsersGroupsPage(k,c,b);Ext.getBody().unmask();}else{if(a!=null&&a==="service_usage_view"){h.addServiceUsagePage(k,c,b);Ext.getBody().unmask();
}else{if(a!=null&&a==="users_view"){h.addUserViewPage(k,c,b);Ext.getBody().unmask();}else{if(a!=null&&a==="mail_traffic_view"){h.addMailTrafficPage(k,c,b);Ext.getBody().unmask();}else{if(a!=null&&a==="mail_protection_view"){h.addMailProtectionPage(k,c,b);Ext.getBody().unmask();}else{if(a!=null&&a==="non_owner_activities_view"){h.addNonOwnerActivitiesPage(k,c,b);
Ext.getBody().unmask();}else{if(a!=null&&a==="usage_view"){h.addUsagePage(k,c,b);Ext.getBody().unmask();}else{if(a!=null&&a==="All_Events"){h.addallEventsPage(k,c,b);Ext.getBody().unmask();}else{if(a!=null&&a==="users_devices_view"){h.adduserDevicesPage(k,c,b);Ext.getBody().unmask();}else{if(a!=null&&a==="call_quality_view"){h.addcallQualityPage(k,c,b);
Ext.getBody().unmask();}}}}}}}}}}}}}Ext.getBody().unmask();h.autoScrollTvMode("microsoft_ground");},failure:function(){Ext.getBody().unmask();}});},autoScrollTvMode:function(g){if(!Ext.isEmpty(window.parent.isTvMode)){$.fn.hasScrollBar=function(){return this.get(0).scrollHeight-40>this.height();};if(window.parent.isTvMode){var e=window.parent.Ext.getCmp("playBtn").ifScroll=true;
var j=Ext.get(g).dom.scrollHeight-Ext.get(g).dom.offsetHeight;var h=j*100;var d=j*70;var k=$("#"+g).hasScrollBar();var a=false;var i="";var c=function(){var m=window.parent.Ext.getCmp("tvmode").sliderAction;if(m=="pause"){Ext.get(g).getActiveAnimation().paused=false;a=true;}else{clearTimeout(i);Ext.get(g).getActiveAnimation().paused=true;
window.parent.Ext.getCmp("tvmode").sliderObj.pause();a=false;}};if(k){var f=Ext.get(g).getActiveAnimation().paused=true;window.parent.Ext.getCmp("tvmode").sliderObj.pause();Ext.get(g).scroll("b",h,{duration:d,listeners:{beforeanimate:function(n,m){isKioskModeScrollInProgress=true;},afteranimate:function(o,n,m){Ext.get(g).stopAnimation();
Ext.defer(function(){isKioskModeScrollInProgress=false;window.parent.Ext.getCmp("tvmode").sliderObj.play();if(!Ext.isEmpty(l)){l.destroy();}},1000);window.parent.Ext.getCmp("playBtn").ifScroll=false;}}},{scope:Ext.get(g)});}else{window.parent.Ext.getCmp("playBtn").ifScroll=false;window.parent.Ext.getCmp("tvmode").sliderObj.pause();
if(a==true){clearTimeout(i);window.parent.Ext.getCmp("tvmode").sliderObj.pause();}else{i=Ext.defer(function(){window.parent.Ext.getCmp("tvmode").sliderObj.play();},window.parent.Ext.getCmp("tvmode").getTimeFrequency);}}var l=new Ext.util.TaskRunner();var b=l.start({run:c,interval:1000});}}},addOverviewPage:function(c,b,e){var d=this,b=Ext.getCmp("microsoft_ground");
var a=e+".overviewpage";b.add({xtype:"cardItem",id:"cardID",listeners:{"afterrender":function(g){var f=this;f.add({xtype:a,id:"overviewpage",data:c.loadViewDetails});}}});b.doLayout();},updateOverviewPage:function(a){var b=this;Ext.getCmp("overviewpage").updatePage(a.loadViewDetails);},addServiceHealthPage:function(c,b,e){var d=this,b=Ext.getCmp("microsoft_ground");
var a=e+".servicehealthpage";b.add({xtype:"cardItem",id:"cardID",listeners:{"afterrender":function(g){var f=this;f.add({xtype:a,id:"servicehealthpage",data:c.loadViewDetails});}}});b.doLayout();},updateServiceHealthPage:function(a){var b=this;Ext.getCmp("servicehealthpage").updatePage(a.loadViewDetails);
},addLicenseUsagePage:function(c,b,e){var d=this,b=Ext.getCmp("microsoft_ground");var a=e+".licenseusagepage";b.add({xtype:"container",id:"cardID",layout:{type:"vbox",align:"stretch"},listeners:{"afterrender":function(g){var f=this;f.add({xtype:a,id:"licenseusagepage",data:c.loadViewDetails});}}});b.doLayout();
},updateLicenseUsagePage:function(a){var b=this;Ext.getCmp("licenseusagepage").updatePage(a.loadViewDetails);},addUsersGroupsPage:function(c,b,e){var d=this,b=Ext.getCmp("microsoft_ground");var a=e+".usersgroupspage";b.add({xtype:"cardItem",id:"cardID",listeners:{"afterrender":function(g){var f=this;
f.add({xtype:a,id:"usersgroupspage",data:c.loadViewDetails});}}});b.doLayout();},updateUsersGroupsPage:function(a){var b=this;Ext.getCmp("usersgroupspage").updatePage(a.loadViewDetails);},addServiceUsagePage:function(c,b,e){var d=this,b=Ext.getCmp("microsoft_ground");var a=e+".serviceusagepage";b.add({xtype:"cardItem",id:"cardID",listeners:{"afterrender":function(g){var f=this;
f.add({xtype:a,id:"serviceusagepage",data:c.loadViewDetails});}}});b.doLayout();},updateServiceUsagePage:function(a){var b=this;Ext.getCmp("serviceusagepage").updatePage(a.loadViewDetails);},addUserViewPage:function(c,b,e){var d=this,b=Ext.getCmp("microsoft_ground");var a=e+".userviewpage";b.add({xtype:"cardItem",id:"cardID",listeners:{"afterrender":function(g){var f=this;
f.add({xtype:a,id:"userviewpage",data:c.loadViewDetails});}}});b.doLayout();},updateUserViewPage:function(a){var b=this;Ext.getCmp("userviewpage").updatePage(a.loadViewDetails);},addMailTrafficPage:function(c,b,e){var d=this,b=Ext.getCmp("microsoft_ground");var a=e+".mailtrafficpage";b.add({xtype:"cardItem",id:"cardID",listeners:{"afterrender":function(g){var f=this;
f.add({xtype:a,id:"mailtrafficpage",data:c.loadViewDetails});}}});b.doLayout();},updateMailTrafficPage:function(a){var b=this;Ext.getCmp("mailtrafficpage").updatePage(a.loadViewDetails);},addMailProtectionPage:function(c,b,e){var d=this,b=Ext.getCmp("microsoft_ground");var a=e+".mailprotectpage";b.add({xtype:"cardItem",id:"cardID",listeners:{"afterrender":function(g){var f=this;
f.add({xtype:a,id:"mailprotectpage",data:c.loadViewDetails});}}});b.doLayout();},updateMailProtectionPage:function(a){var b=this;Ext.getCmp("mailprotectpage").updatePage(a.loadViewDetails);},addNonOwnerActivitiesPage:function(c,b,e){var d=this,b=Ext.getCmp("microsoft_ground");var a=e+".nonowneractivitiypage";
b.add({xtype:"cardItem",id:"cardID",listeners:{"afterrender":function(g){var f=this;f.add({xtype:a,id:"nonowneractivitiypage",data:c.loadViewDetails});}}});b.doLayout();},updateNonOwnerActivitiesPage:function(a){var b=this;Ext.getCmp("nonowneractivitiypage").updatePage(a.loadViewDetails);},addUsagePage:function(c,b,e){var d=this,b=Ext.getCmp("microsoft_ground");
var a=e+".usagepage";b.add({xtype:"cardItem",id:"cardID",listeners:{"afterrender":function(g){var f=this;f.add({xtype:a,id:"usagepage",data:c.loadViewDetails});}}});b.doLayout();},updateUsagePage:function(a){var b=this;Ext.getCmp("usagepage").updatePage(a.loadViewDetails);},addallEventsPage:function(c,b,e){var d=this,b=Ext.getCmp("microsoft_ground");
var a=e+".containerpage";b.add({xtype:"cardItem",id:"cardID",layout:{type:"vbox",align:"stretch"},listeners:{"afterrender":function(g){var f=this;f.add({xtype:a,flex:1,id:"containerpage",data:c.loadViewDetails});}}});b.doLayout();},updateallEventsPage:function(a){var b=this;Ext.getCmp("containerpage").updatePage(a.loadViewDetails);
},adduserDevicesPage:function(c,b,e){var d=this,b=Ext.getCmp("microsoft_ground");var a=e+".usersdevicespage";b.add({xtype:"cardItem",id:"cardID",listeners:{"afterrender":function(g){var f=this;f.add({xtype:a,id:"containerpage",data:c.loadViewDetails});}}});b.doLayout();},updateuserDevicesPage:function(a){var b=this;
Ext.getCmp("containerpage").updatePage(a.loadViewDetails);},addcallQualityPage:function(c,b,e){var d=this,b=Ext.getCmp("microsoft_ground");var a=e+".callsummarypage";b.add({xtype:"cardItem",id:"cardID",listeners:{"afterrender":function(g){var f=this;f.add({xtype:a,id:"containerpage",data:c.loadViewDetails});
}}});b.doLayout();},updatecallQualityPage:function(a){var b=this;Ext.getCmp("containerpage").updatePage(a.loadViewDetails);}});