var rootComponentArray=null;var compLength="";var splitLen=50;var startcount="";Ext.define("segments.controller.Main",{extend:"Ext.app.Controller",views:["segments.view.Main","segments.view.SegmentsDashboard","segments.view.segmentUser","segments.view.ListPanel","segments.view.ListComponent"],stores:["segments.store.segmentUser"],refs:[{ref:"listPanel",selector:"listpanel"},{ref:"listPanelToolbar",selector:"listpanel>toolbar"},{ref:"optionalListPanel",selector:"optionallistpanel"},{ref:"optionalListPanelToolbar",selector:"optionallistpanel>toolbar"},{ref:"segmentsDashboard",selector:"segmentsdashboard"},{ref:"segmentsTreePanel",selector:"segmentstreepanel"},{ref:"main",selector:"main"},{ref:"segmentUser",selector:"segmentuser"},{ref:"listComponent",selector:"listcomponent"},{ref:"optionalListComponent",selector:"optionallistcomponent"},{ref:"listPanelTrigger",selector:"listpanel trigger"},{ref:"optionalListPanelTrigger",selector:"optionallistpanel trigger"},{ref:"configWindow",selector:"configwindow"},{ref:"topologyCombo",selector:"segmentstopology combo"},{ref:"componentsPanelCombo",selector:'dashboardgeneralmeasuresgridpanel[itemId="components"] combo'},{ref:"aggregatesPanelCombo",selector:'dashboardgeneralmeasuresaggregatepanel[itemId="aggregates"] combo'},{ref:"segmentTree",selector:"segmentstreepanel > panel"},{ref:"dashboardMaintainanceButton",selector:'tabbar > button[action="maintainance"]'}],init:function(){setInterval("execute()",refreshFrequency);
this.control({"listpanel trigger":{specialkey:this.segmentsSearchKeyPress,click:this.segmentsSearch},"optionallistpanel trigger":{specialkey:this.segmentsSearchKeyPress,click:this.segmentsSearch},"listpanel button[action=association]":{scope:this,click:this.displayListPanelAssociations},"listcomponent > container > button[action=servicedetail]":{scope:this,click:this.displaySegmentDetails},"optionallistcomponent > container > button[action=segmentdetail]":{scope:this,click:this.displaySegmentDetails},"optionallistpanel button[action=association]":{scope:this,click:this.displayOptionalListAssociations},"listpanel button[action=back]":{scope:this,click:this.backButtonHandler},"optionallistpanel button[action=back]":{scope:this,click:this.backButtonHandler},"segmentstreepanel":{beforerender:function(){if(requestParams.refresh!==true){Ext.state.Manager.clear("services-tree-panel-stateId");
}},beforeitemclick:this.renewSortState,expand:function(){window.parent.segmenttreeOpenval=true;},collapse:function(){window.parent.segmenttreeOpenval=false;}},"configwindow":{"render":this.itemset},"segmentstreepanel > panel":{afterrender:this.treeLoad,itemclick:this.treeItemClick},'segmentsdashboard button[id="iconMaximize"]':{"click":this.iconMaximize}});
},iconMaximize:function(){window.frames[0].openBigDiv();},segmentsSearchKeyPress:function(c,b){if(b.getKey()==b.ENTER){segmentSearchText=c.getValue();var a="/final/servlet/com.eg.EgMonitorController?from=segmentList&monCmd=segmentList&action=search&treeFlag=false&Go.x=0&Go.y=0&searchString="+encodeURIComponent(filterEncode(c.getValue()))+"&treeOpen="+!this.getSegmentsTreePanel().getCollapsed();
this.showResultData(a);}},segmentsSearch:function(b){segmentSearchText=b.getValue();var a="/final/servlet/com.eg.EgMonitorController?from=segmentList&monCmd=segmentList&action=search&treeFlag=false&Go.x=0&Go.y=0&searchString="+encodeURIComponent(filterEncode(b.getValue()))+"&treeOpen="+!this.getSegmentsTreePanel().getCollapsed();
this.showResultData(a);},treeItemClick:function(b,a,e,c,d){getDiv=0;gettingComponentDivId=0;scrollFlag=false;stopScroll();if(!Ext.isEmpty(a.raw.link)){var f=a.raw.link;if(!Ext.isEmpty(f)&&((f.indexOf("monCmd=segmentList")>-1)&&(f.indexOf("action=segment")>-1))){this.showResultData(f);}else{document.location=a.raw.link;
}}else{this.getSegmentsTreePanel().currentNode=a.raw.text;this.getSegmentTree().expandNode(a);this.displaySegmentDetails(b,a);}parent.parent.closeDiv();},treeLoad:function(f){var g=this.getSegmentsTreePanel().currentNode;if(!Ext.isEmpty(requestParams)&&requestParams.refresh=="true"){g=requestParams.selectedTreeNode;
this.getSegmentsTreePanel().currentNode=requestParams.selectedTreeNode;}if(!Ext.isEmpty(g)){var e;var b=f.getRootNode();if(b.raw.text===g){e=b;f.getSelectionModel().select(e);}else{e=b.findChild("text",g);f.getSelectionModel().select(e);}var a=e.getDepth();var d=e;for(var c=0;c<a;c++){if(d.isLeaf()){d.parentNode.expand();
}else{d.expand();}d=d.parentNode;}}},renewSortState:function(b,a){this.getSortRetainStore().getProxy().clear();},itemset:function(a,b){this.getConfigWindow().controllername=this.self.getName();},backButtonHandler:function(a){var b=requestParams.treeSession;var c="";b=(!Ext.isEmpty(b))?b:"";if(fromPage=="MyDashboard"){document.location=myDashboardBackUrl;
}else{if(b.indexOf("showDashboard")>0){c=b;}if(this.getSegmentUser()){window.history.go(0);return;}if(c.length>0){document.location=c;}else{if(!Ext.isEmpty(requestParams.refresh)&&requestParams.refresh=="true"){window.history.go(-2);}else{window.history.go(-1);}}}},displayListPanelAssociations:function(){this.getListPanel().removeAll();
Ext.Ajax.request({url:"/final/servlet/com.eg.EgMonitorController?monCmd=userSegments&selectNode=Segments&selectedParam=Segments&openNode=Segments&treeFlag=false&currentTab=association&transTab=null&setAssociate=&frompage=egTreeUsersegments",scope:this,timeout:280000,success:function(a){var c=a.responseText;
var b=Ext.decode(c);Ext.Element.select(".removeLineForTvMode").hide();Ext.getCmp("segmentlistpanelsearch").hide();if(Ext.getCmp("segmentlistpanelsearch-tb")!=null){Ext.getCmp("segmentlistpanelsearch-tb").hide();}if(Ext.getCmp("associationBtnId")!=null){Ext.getCmp("associationBtnId").hide();}if(Ext.getCmp("associationId")!=null){Ext.getCmp("associationId").hide();
}if(Ext.getCmp("separatorAssociationId")!=null){Ext.getCmp("separatorAssociationId").hide();}if(Ext.getCmp("backBtnSeparator")!=null){Ext.getCmp("backBtnSeparator").hide();}Ext.getCmp("segmentlistpanelbackbtn").show();if(!Ext.isEmpty(b.error)){this.getListPanel().add({xtype:"errorpanel",cls:"error-panel",margin:"10",flex:1,frame:true,imageCls:"iconInformation",padding:"0",style:{"text-align":"center"},errorMsg:b.error});
}else{this.getListPanel().setTitle("User and Segment Associations");this.getListPanelToolbar().hide();this.getListPanel().add({xtype:"segmentuser",screenLabels:b.screenLabels,data:b});}},failure:function(){}});},displayOptionalListAssociations:function(){this.getOptionalListPanel().removeAll();Ext.Ajax.request({url:"/final/servlet/com.eg.EgMonitorController?monCmd=userSegments&selectNode=Segments&selectedParam=Segments&openNode=Segments&treeFlag=false&currentTab=association&transTab=null&setAssociate=&frompage=egTreeUsersegments",scope:this,timeout:280000,success:function(a){var c=a.responseText;
var b=Ext.decode(c);Ext.getCmp("segmentlistpanelsearch").hide();if(Ext.getCmp("segmentlistpanelsearch-tb")!=null){Ext.getCmp("segmentlistpanelsearch-tb").hide();}if(Ext.getCmp("associationBtnId")!=null){Ext.getCmp("associationBtnId").hide();}if(Ext.getCmp("associationId")!=null){Ext.getCmp("associationId").hide();
}Ext.getCmp("segmentlistpanelbackbtn").show();if(!Ext.isEmpty(b.error)){tempContPanel.add({xtype:"errorpanel",cls:"error-panel",margin:"10",flex:1,frame:true,imageCls:"iconInformation",padding:"0",style:{"text-align":"center"},errorMsg:b.error});}else{this.getOptionalListPanel().setTitle("User and Segment Associations");
this.getOptionalListPanel().add({xtype:"segmentuser",screenLabels:b.screenLabels,data:b});}},failure:function(){}});},displaySegmentDetails:function(c,f){var d=null;var b=null;var h=null;var g=this.getCurrentListPanel();if(Ext.isEmpty(c)||c.getXType()=="treeview"){d=f.raw.text;b="system";h=f.raw.aggregateTab;
}else{if(c.getXType()=="button"){d=c.name;b="topology";h=c.aggregateTab;}}d=encodeURI(d);var e=this.getSegmentsTreePanel();var k=!e.getCollapsed();var a="&treeOpen="+k+"&openNode="+d;if(!Ext.isEmpty(g)){g.removeAll(true);var j=g.getDockedItems();if(!Ext.isEmpty(j)){for(i=0;i<j.length;i++){j[i].hide();
}}g.hide();if(!Ext.isEmpty(g.up("main").down("segmentsdashboard[id=segmentDashboardId]"))){g.up("main").down("segmentsdashboard[id=segmentDashboardId]").destroy();}g.up("main").add({xtype:"segmentsdashboard",treeUrl:a,currentTab:b,currentSegment:d,aggregateTab:h,region:"center",flex:4});}},displaySegmentDetailsFromAssociation:function(d){var c=this.getSegmentsTreePanel();
var b=!c.getCollapsed();var a=d.get("link")+"&treeOpen="+b;return a;},refresh:function(g){if(this.getConfigWindow()==undefined){var k=this.getCurrentListPanel();var o=this.getSegmentsDashboard();var e=this.getSegmentsTreePanel();var b=!e.getCollapsed();var d=null;if(!Ext.isEmpty(o)){var c=o.getActiveTab();
if(!Ext.isEmpty(c)){c=c.itemId;}var n="";if(!Ext.isEmpty(o.aggregateTab)){n=o.aggregateTab;}var a=o.currentTab;var h="",f="";if(!Ext.isEmpty(this.getComponentsPanelCombo())){h=this.getComponentsPanelCombo().value;}if(!Ext.isEmpty(this.getAggregatesPanelCombo())){f=this.getAggregatesPanelCombo().value;
}var m=o.currentSegment;var l="Segment";if(!Ext.isEmpty(this.getSegmentsTreePanel().currentNode)){l+="^"+this.getSegmentsTreePanel().currentNode;}compSelectedValue=h;var j=this;Ext.Ajax.request({url:"/final/servlet/com.eg.EgMonitorController?from=MainDashboard&monCmd=segmentList&action=segment",timeout:280000,success:function(t){var x=t.responseText;
var s=m;var q=q;var y=y;var r="";var w=j.getCurrentListPanel();var u=j.getSegmentsTreePanel();var A=!u.getCollapsed();var p="&treeOpen="+A;if(!Ext.isEmpty(u.currentNode)){p+="&openNode="+u.currentNode;}if(!Ext.isEmpty(w)){w.removeAll();var z=w.getDockedItems();if(!Ext.isEmpty(z)){for(i=0;i<z.length;i++){z[i].hide();
}}w.hide();j.refreshTree();if(Ext.isEmpty(q)){if(!Ext.isEmpty(c)){q=c;}}if(!Ext.isEmpty(w.up("main").down("segmentsdashboard[id=segmentDashboardId]"))){if(!Ext.isEmpty(q)&&q=="topology"){var v=w.up("main").down("segmentstopology");if(!Ext.isEmpty(v)){urlForRefresh=urlForRefresh1;v.loadTab(urlForRefresh);
}}else{if(!Ext.isEmpty(urlForRefresh)&&urlForRefresh.indexOf("Refreshing=true")<0){urlForRefresh=urlForRefresh+"&Refreshing=true";}if(!Ext.isEmpty(q)&&q=="aggregates"){w.up("main").down("segmentsdashboard[id=segmentDashboardId]").down("dashboardgeneralmeasuresaggregatepanel[itemId="+q+"]").loadTab(urlForRefresh,"segmentsAgg");
}else{if(!Ext.isEmpty(q)&&q=="system"){w.up("main").down("segmentsdashboard[id=segmentDashboardId]").down("dashboardgeneralmeasuresgridpanel[itemId="+q+"]").loadTab(urlForRefresh,"segmentsSys",Reftot,RefpageVal,ReftotalPageno);}else{if(!Ext.isEmpty(q)&&q=="components"){w.up("main").down("segmentsdashboard[id=segmentDashboardId]").down("dashboardgeneralmeasuresgridpanel[itemId="+q+"]").loadTab(urlForRefresh,"segmentsComp",Reftot,RefpageVal,ReftotalPageno);
}}}}}}},failure:function(){}});}else{if(!Ext.isEmpty(k)){if(k.getXType()=="listpanel"){d=this.getListPanelTrigger();}else{d=this.getOptionalListPanelTrigger();}this.refreshListPanel(g,k,d);}}d=null;delete d;k=null;delete k;o=null;delete o;e=null;delete e;b=null;delete b;}},refreshListPanel:function(d,c,b){var f=this.getSegmentsTreePanel();
var e=f.currentNode;var h=!f.getCollapsed();if(c.child("segmentuser")){if(c===this.getListPanel()){this.displayListPanelAssociations();}else{if(c===this.getOptionalListPanel()){this.displayOptionalListAssociations();}}this.refreshTree();}else{var g=b.value;var a=d+"&searchString="+g+"&treeOpen="+h+"&refresh=true&openNode="+e+"&action=search";
this.showResultData(a);g=null;delete g;}f=null;delete f;e=null;delete e;h=null;delete h;},showResultData:function(b){var c=this.getListPanel();if(Ext.isEmpty(c)){c=this.getOptionalListPanel();}var l=c;c=c.xtype;var p=this.getSegmentsDashboard();var h=Ext.getCmp("listPanelContents");var m=Ext.getCmp("segmentstreepanel");
var o="segments.view.ListComponent";if(!Ext.isEmpty(c)&&c=="optionallistpanel"){o="segments.view.OptionalListComponent";h=Ext.getCmp("componentPanel");}var k=Ext.getCmp("segmentDashboardId");if(!Ext.isEmpty(k)){k.destroy();}if(Ext.isEmpty(h)){Ext.Ajax.request({url:b,timeout:280000,success:function(r){var s=Ext.getCmp("segmentmain");
var q=Ext.getCmp("listpanel");if(!Ext.isEmpty(q)){s.remove(q);}var t=Ext.getCmp("optionallistpanel");if(!Ext.isEmpty(t)){s.remove(t);}var u={xtype:"listpanel",id:"listpanel",region:"center",flex:4,url:"/final/monitor/segments.jsp"};s.add(u);s=null;delete s;q=null;delete q;t=null;delete t;u=null;delete u;
},failure:function(){}});}else{if(!Ext.isEmpty(b)&&b.indexOf("searchString")<0){Ext.getCmp("segmentlistpanelsearch").setValue("");}else{var d=b.split("&");var e="";for(var f=0;f<d.length;f++){var a=d[f]+"&";if(!Ext.isEmpty(a)&&a.indexOf("action")>-1){var g=a.substring(0,a.indexOf("="));var n=a.substring(a.indexOf("=")+1,a.length);
a=g+"=search&";}e=e+a;}if(!Ext.isEmpty(e)){b=e;}d=null;delete d;}var j=this;Ext.Ajax.request({url:b,timeout:280000,success:function(q){var r=q.responseText;j.refreshTree();Ext.Ajax.request({url:"/final/monitor/segments.jsp",success:function(t){var w=t.responseText;var x=Ext.decode(w);rootComponentArray=x["RootItem"];
if(!Ext.isEmpty(rootComponentArray)){compLength=rootComponentArray.length;var z=h.items.items;h.removeAll();var v=j.getCurrentListPanel().getXType();var B=null;if(v=="listpanel"){B=j.getListPanel().getDockedItems();if(!Ext.isEmpty(B)){for(f=0;f<B.length;f++){if(f==1){B[f].show();}}}}getDiv=0;gettingComponentDivId=0;
stopScroll();Ext.suspendLayouts();if(compLength>splitLen){for(var A=0;A<splitLen;A++){var s=Ext.create(o,{rootComponent:rootComponentArray[A]});h.add(s);}isScroll=true;}else{for(var A=0;A<rootComponentArray.length;A++){var s=Ext.create(o,{rootComponent:rootComponentArray[A]});h.add(s);s=null;delete s;
}}Ext.resumeLayouts(true);if(o=="segments.view.ListComponent"){if(scrollFlag){pageScroll();}}if(o=="segments.view.OptionalListComponent"){if(scrollFlag){pageScroll();}}z=null;delete z;}else{var v=j.getCurrentListPanel().getXType();var B=null;if(!Ext.isEmpty(v)){if(v=="listpanel"){B=j.getListPanel().getDockedItems();
if(!Ext.isEmpty(B)){for(f=0;f<B.length;f++){if(f==1){B[f].hide();}}}}var z=h.items.items;for(var y=z.length-1;y>-1;y--){z[y].destroy();}h.removeAll();}var u="";if(strSkin=="Dark"){var u="#252525";}h.add({xtype:"errorpanel",cls:"error-panel",margin:"20% 0 auto 0",layout:"fit",width:"100%",height:Ext.getBody().getViewSize().height-80,scroll:false,autoScroll:false,border:false,frame:false,imageCls:"iconInformation",padding:"0",style:{"text-align":"center","background-color":u+"!important"},errorMsg:x.SearchNoListFoundText});
v=null;delete v;B=null;delete B;}w=null;delete w;x=null;delete x;}});r=null;Ext.destroy(r);},failure:function(){}});}c=null;delete c;l=null;delete l;p=null;delete p;m=null;delete m;k=null;delete k;},refreshTree:function(){var a=Ext.getCmp("segmentstreepanel");Ext.Ajax.request({url:"/final/monitor/segmentTree.jsp?tree=SegmentTreeModel&width=208&str=sessionID&node=Segment&treeTitle=Segments",method:"POST",timeout:280000,success:function(b,f){var g=b.responseText;
var d=Ext.decode(g);d["expanded"]=true;d["cls"]="list-tree-root-expand-collapse";var c=Ext.create("Ext.data.TreeStore",{id:"treestore",clearOnLoad:true,autoDestroy:true,root:d});var e=Ext.create("utilities.TreeScrollPanel",{store:c,cls:"treePanelDesign",margin:"8 0 0 8",border:true,autoDestroy:true,frame:true,scroll:false,autoScroll:true,iconCls:"segment22_GRAY",selModel:Ext.create("Ext.selection.TreeModel",{mode:"MULTI"}),title:"Segments",stateId:"services-tree-panel-stateId",rootVisible:true,useArrows:true,id:"select",});
a.add(e);},failure:function(){}});},getCurrentListPanel:function(){var a=null;if(!Ext.isEmpty(this.getListPanel())){a=this.getListPanel();}else{if(!Ext.isEmpty(this.getOptionalListPanel())){a=this.getOptionalListPanel();}}return a;},bulkDataLoad:function(c,b,a){var g=rootComponentArray;isScroll=false;
var f="",e="";if(a!=null&&a!=""&&a=="segments.view.ListComponent"){f=Ext.getCmp("listpanel");e=Ext.getCmp("listPanelContents");}else{f=Ext.getCmp("optionallistpanel");e=Ext.getCmp("componentPanel");}Ext.suspendLayouts();for(var d=c;d<b;d++){var h=Ext.create(a,{rootComponent:g[d]});e.add(h);}f.add(e);
Ext.resumeLayouts(true);if(b!=compLength&&b<compLength){isScroll=true;startcount=b;}else{rootComponentArray=null;delete rootComponentArray;compLength=null;startcount=null;}}});