Ext.define("AggregateComponent.controller.Main",{extend:"Ext.app.Controller",views:["Components","TestMeasures"],requires:["AggregateComponent.view.Components","AggregateComponent.view.TestMeasures"],refs:[{selector:"components",ref:"components"},{selector:"components #backButton",ref:"backbutton"},{selector:"components #homeBack",ref:"homeBack"},{selector:"testmeasures",ref:"testmeasures"}],init:function(){ctrler=this;
this.rowBodyTrSelector=".x-grid-rowbody-tr";this.rowBodyHiddenCls="x-grid-row-body-hidden";this.rowCollapsedCls="x-grid-row-collapsed";this.recordsExpanded={};this.isViewExpaned=false;this.isViewExpaned2=false;this.buildMainData();this.control({"components":{"afterrender":this.afterMainRender},'components combo[id="category"]':{"select":this.categorySelection},'components combo[id="compTypes"]':{"select":this.compTypeSelection},'components checkbox[id="activeCompType"]':{"change":this.showActiveCompTypes},'components trigger[id="searchBox"]':{"change":this.searchComponent},'components button[id="addNewButton"]':{"click":this.addNewComponent},'changeip button[id="backButton"]':{"click":this.goBack},'components button[id="showAll"]':{"click":this.showAllPreUsers},'components button[id="testsAndMeasures"]':{"click":this.showTestsAndMeasures},'testmeasures button[id="showAll_popup"]':{"click":this.showHideMeasures},"components #backButton":{"click":this.forwardURI},"components #homeBack":{"click":this.homeBack}});
},showTestsAndMeasures:function(b){var a=this;Ext.widget("window",{extend:"Ext.panel.Panel",title:publicJsonCopy.popupTitle,id:"userElementsWindow",width:750,scroll:false,autoScroll:false,height:400,padding:"5 10 10 10",border:false,closeAction:"destory",doClose:function(){this.destroy();},listeners:{afterrender:function(){a.updateTestMeasuresPopup();
}}}).show();},forwardURI:function(){var a=window.parent.reqfrom;var b=window.parent.username;if(a!=undefined&&a=="modifyuser"){if(b!=null&&b!=undefined){window.parent.location.href="/final/admin/EgChangeUserProfile.jsp?qctr=1&username="+encodeURIComponent(b);}else{window.parent.location.href="/final/admin/EgChangeUserProfile.jsp";
}}},updateTestMeasuresPopup:function(){var a=Ext.getCmp("userElementsWindow");a.removeAll();if(publicJsonCopy.compTypeSelected){a.add({xtype:"testmeasures"});Ext.getCmp("measuresGrid").getStore().loadRawData(publicJsonCopy.measuresGridDataList);Ext.getCmp("testmeasures").setTitle(publicJsonCopy.popupTitle);
Ext.getCmp("totalAggTests").update('<span class="f13-bold">&nbsp;'+publicJsonCopy.totalAggTests+"</span>");}else{var b="<div class='egFlexCenterByColumnWise' style='height:100%'><div class='iconExclamation'></div><div class='commonErrorMsgText' id='noCompAlrtDiv'>"+intnlLabel5+".</div></div>";var c={xtype:"container",height:"100%",html:b};
a.add(c);}},showHideMeasures:function(c){var a=Ext.getCmp("measuresGrid").getStore();if(c.status=="hidden"){c.status="shown";c.setText(intnlLabel13);for(var b=0;b<a.getCount();b++){this.expandRow(b,Ext.getCmp("measuresGrid"));}}else{c.status="hidden";c.setText(intnlLabel12);for(var b=0;b<a.getCount();
b++){this.collapseRow(b,Ext.getCmp("measuresGrid"));}}this.getTestmeasures().doLayout();},showAllPreUsers:function(c){var a=Ext.getCmp("componentListGrid").getStore();if(c.status=="hidden"){c.status="shown";c.setText(intnlLabel11);for(var b=0;b<a.getCount();b++){this.expandRow(b,Ext.getCmp("componentListGrid"));
}}else{c.status="hidden";c.setText(intnlLabel10);for(var b=0;b<a.getCount();b++){this.collapseRow(b,Ext.getCmp("componentListGrid"));}}this.getComponents().doLayout();},expandRow:function(c,a){var b=a.view.getNode(c);row=Ext.get(b);nextBd=Ext.get(row).down(this.rowBodyTrSelector);record=a.view.getRecord(b);
if(row.hasCls(this.rowCollapsedCls)){row.removeCls(this.rowCollapsedCls);nextBd.removeCls(this.rowBodyHiddenCls);this.recordsExpanded[record.internalId]=true;a.view.fireEvent("expandbody",b,record,nextBd.dom);}},collapseRow:function(c,a){var b=a.view.getNode(c);row=Ext.get(b);nextBd=Ext.get(row).down(this.rowBodyTrSelector);
record=a.view.getRecord(b);if(!row.hasCls(this.rowCollapsedCls)){row.addCls(this.rowCollapsedCls);nextBd.addCls(this.rowBodyHiddenCls);this.recordsExpanded[record.internalId]=false;a.view.fireEvent("collapsebody",b,record,nextBd.dom);}},nickTable:function(d){var a=d.split(",");var b="<table border='1' bordercolor='#E6EBF5' cellpadding='1' >";
for(var c=0;c<a.length;c++){b=b+"<tr><td height='20' width='500'>"+a[c]+"</td></tr>";}b=b+"</table>";return b;},buildMainData:function(){Ext.Ajax.request({url:"AggregateComponent/data/EgDispServerJson.jsp?",method:"POST",async:false,success:function(a){if(a.status==200&&!Ext.isEmpty(a.responseText)){var b=a.responseText;
publicJSON=Ext.decode(b);}}});},afterMainRender:function(){Ext.getCmp("category").getStore().clearFilter(true);Ext.getCmp("category").getStore().loadRawData(publicJSON["category"]);Ext.getCmp("category").setValue(publicJSON["selectedServerGroup"]);Ext.getCmp("compTypes").getStore().clearFilter(true);
Ext.getCmp("compTypes").getStore().loadRawData(publicJSON["componentTypes"]);Ext.getCmp("compTypes").setValue(publicJSON["selectedCompType"]);Ext.getCmp("activeCompType").setValue(publicJSON["showManagedCompTypes"]);Ext.getCmp("componentListGrid").hide();this.loadComps(categoryChosen,compTypeChosen);
var a=window.parent.reqfrom;if(a!=undefined&&a=="modifyuser"){this.getBackbutton().show();}else{this.getBackbutton().hide();if(showOverviewBackButton=="true"){Ext.getCmp("homeBack").show();}else{Ext.getCmp("homeBack").hide();}}},loadComps:function(c,e){c=encodeURIComponent(c);e=encodeURIComponent(e);
Ext.getCmp("category").setValue(c);Ext.getCmp("compTypes").setValue(e);var a="AggregateComponent/data/EgDispServerJson.jsp?&selectedServerGroup="+c+"&server="+e;this.getData(a);publicJsonCopy=jsonDataHolder;var b=jsonDataHolder.serversFound;var d=Ext.getCmp("componentListGrid");if(b){d.show();d.getStore().removeAll();
d.getStore().loadRawData(jsonDataHolder.components);}else{d.getStore().removeAll();Ext.get("noCompAlrtDiv").update(srcNotFnd);}if(e!="-1"){Ext.getCmp("searchBox").enable();Ext.getCmp("testsAndMeasures").enable();Ext.getCmp("showAll").enable();}else{Ext.getCmp("searchBox").disable();Ext.getCmp("testsAndMeasures").disable();
Ext.getCmp("showAll").disable();}},categorySelection:function(){var b=Ext.getCmp("category").getValue();b=encodeURIComponent(b);var f=Ext.getCmp("compTypes").getValue();f=encodeURIComponent(f);var e=Ext.getCmp("activeCompType").getValue();var a="AggregateComponent/data/EgDispServerJson.jsp?selectedServerGroup="+b+"&activeCompTypes="+e;
this.getData(a);var d=Ext.getCmp("compTypes").getStore();d.removeAll();d.clearFilter(true);d.loadRawData(jsonDataHolder.componentTypes);Ext.getCmp("compTypes").setValue("-1");var c=Ext.getCmp("componentListGrid");c.getStore().removeAll();c.hide();},compTypeSelection:function(){var e=Ext.getCmp("compTypes").getValue();
var c=Ext.getCmp("category").getValue();var d=Ext.getCmp("componentListGrid");if(e=="-1"){d.hide();return false;}c=encodeURIComponent(c);e=encodeURIComponent(e);var a="AggregateComponent/data/EgDispServerJson.jsp?&selectedServerGroup="+c+"&server="+e;this.getData(a);publicJsonCopy=jsonDataHolder;var b=jsonDataHolder.serversFound;
d.show();if(b){d.getStore().removeAll();d.getStore().loadRawData(jsonDataHolder.components);Ext.getCmp("showAll").enable();}else{d.getStore().removeAll();Ext.getCmp("showAll").disable();}if(e!="-1"){Ext.getCmp("searchBox").enable();Ext.getCmp("testsAndMeasures").enable();}else{Ext.getCmp("searchBox").disable();
Ext.getCmp("testsAndMeasures").disable();}},showActiveCompTypes:function(){var h=Ext.getCmp("activeCompType").getValue();var g=Ext.getCmp("compTypes").getValue();var d=Ext.getCmp("category").getValue();d=encodeURIComponent(d);g=encodeURIComponent(g);var a="AggregateComponent/data/EgDispServerJson.jsp?&selectedServerGroup="+d+"&server="+g+"&activeCompTypes="+h;
this.getData(a);var f=Ext.getCmp("compTypes").getStore();f.removeAll();f.clearFilter(true);f.loadRawData(jsonDataHolder.componentTypes);Ext.getCmp("compTypes").setValue(jsonDataHolder.selectedCompType);var b=Ext.getCmp("category").getStore();b.removeAll();b.clearFilter(true);b.loadRawData(jsonDataHolder.category);
Ext.getCmp("category").setValue(jsonDataHolder.selectedServerGroup);var c=jsonDataHolder.serversFound;var e=Ext.getCmp("componentListGrid");if(c){e.show();e.getStore().removeAll();e.getStore().loadRawData(jsonDataHolder.components);}else{e.getStore().removeAll();e.hide();}},searchComponent:function(){var g=Ext.getCmp("activeCompType").getValue();
var f=Ext.getCmp("compTypes").getValue();var d=Ext.getCmp("category").getValue();d=encodeURIComponent(d);f=encodeURIComponent(f);var a=Ext.getCmp("searchBox").getValue();a=encodeURIComponent(filterEncode(a));var b="AggregateComponent/data/EgDispServerJson.jsp?&selectedServerGroup="+d+"&server="+f+"&activeCompTypes="+g;
if(a!=""){b+="&searchStr="+a;}if(a==""||a.length==0){Ext.get("MyTrigger_0").setStyle("display","none");Ext.get("MyTrigger_1").setStyle("display","block");}else{Ext.get("MyTrigger_1").setStyle("display","none");Ext.get("MyTrigger_0").setStyle("display","block");}this.getData(b);var c=jsonDataHolder.serversFound;
var e=Ext.getCmp("componentListGrid");if(c){e.show();e.getStore().removeAll();e.getStore().loadRawData(jsonDataHolder.components);Ext.getCmp("showAll").enable();}else{e.getStore().removeAll();Ext.get("noCompAlrtDiv").update(srcNotFnd);Ext.getCmp("showAll").disable();}},getData:function(a){Ext.Ajax.request({url:a,method:"POST",async:false,success:function(b){var c=b.responseText;
jsonDataHolder=Ext.decode(c);}});},showActions:function(a,b,d,h,f){var g=a.getStore().getAt(h);var c=Ext.DomQuery.select(".x-action-col-icon",d);Ext.each(c,function(e){Ext.get(e).removeCls("x-hidden");});},hideActions:function(a,b,d,g,f){var c=Ext.DomQuery.select(".x-action-col-icon",d);Ext.each(c,function(e){Ext.get(e).addCls("x-hidden");
});},modifyComponent:function(c,h,b){var f=c.getStore().getAt(h);var d=f.get("Compname");if(d.indexOf(":")<0){d+=":NULL";}var g=Ext.getCmp("compTypes").getValue();g=encodeURIComponent(g);var e=Ext.getCmp("category").getValue();e=encodeURIComponent(e);var a="aggNewServer.jsp?isAggregateLink=false&server="+d+"&serverType="+g+"&modifyserver=true&siteSupport=false&treeViewSrc=null&serverGategory="+e+"&fromWizard="+fromWizard+"&compGlanceCompType="+compGlanceCompType+"&reqfrom="+reqfrom;
window.location.href=a;},unmanageComponent:function(b,f,a){var d=b.getStore().getAt(f);var c=d.get("Compname");if(c.indexOf(":")<0){c+=":NULL";}c=encodeURIComponent(c);var e=Ext.getCmp("compTypes").getValue();e=encodeURIComponent(e);parent.window.location.href="/final/admin/aggConfigEnv.jsp?srvtype="+e+"&component="+c+"&backButNeed=yes&reqfrom=EgDispServer&fromWizard="+fromWizard+"&compGlanceCompType="+compGlanceCompType;
},deleteComponent:function(a,h,i){var g=this;elemList="";var c=a.getStore().getAt(h);var e=c.get("Compname");if(e.indexOf(":")<0){e+=":NULL";}e=encodeURIComponent(e);compToDelete=e;var b=Ext.getCmp("compTypes").getValue();var f=b+":"+e;b=encodeURIComponent(b);var d="/final/admin/AggregateManageUnmanageComponents/data/EgdeleteserverpJson.jsp?performaction=true&refferalURL=AddComponent";
d+="&fmanagewithcomptype="+f+",&srvtype="+b+"&servertypes="+b+"&fmanage="+e+",";d+="&componentDetails=&funmanage="+"&fromAction=addmodify";var j=new Ext.LoadMask(Ext.getBody(),{msg:updating+"..."});j.show();Ext.Ajax.request({url:d,method:"POST",success:function(l){j.hide();var n=l.responseText;var m=Ext.decode(n);
if(m.requestStatus=="success"){var o=m.result;Ext.Msg.show({title:o.title,msg:alertMsg37,buttons:Ext.Msg.OK,width:400,icon:"iconInformation"});g.compTypeSelection();}else{var o=m.errors;var k=g.getErrorMessageTemplate(o);g.showResultWindow(o.title,k,"delete");}},failure:function(k){j.hide();}});},getErrorMessageTemplate:function(e){var d=this;
var a="";if(e.allow!=null&&e.allow!==undefined&&e.allow==true){a="";for(var c in e){if(c=="title"||c=="allow"){continue;}var b=e[c];a=a+b;}}else{a='<div class="x-table" style="width:90%"><table cellspacing="0" width="100%" cellpadding="5" border="1" align="center" class="x-grid-table" style="border:1px solid #c3c3c3;"><thead><tr class="x-grid-row"><th class="x-grid-cell"><div class="x-grid-cell-inner">'+pageTitle+"</div></th></tr></thead>";
for(var c in e){if(c=="title"){continue;}var b=e[c];a=a+'<tr class="x-grid-row"><td class="x-grid-cell x-grid-cell-first "><div class="x-form-display-field"><div class ="x-grid-cell-inner">'+b+"</div></div></td></tr>";}a=a+"</table></div>";}return a;},showResultWindow:function(d,a,c){var b=this;var e=false;
Ext.Msg.show({title:d,msg:a,buttons:Ext.Msg.YESNO,icon:"iconConfirmation",fn:function(f){if(f=="yes"){e=true;if(c!=null&&c!==undefined&&c=="delete"){b.delComponent(e);}}}});},delComponent:function(f){var d=this;var e=Ext.getCmp("compTypes").getValue();e=encodeURIComponent(e);var b=e+":"+compToDelete;
var c="/final/admin/AggregateManageUnmanageComponents/data/EgdeleteserverpJson.jsp?performaction=true&refferalURL=AddComponent";c+="&fmanagewithcomptype="+b+",&srvtype="+e+"&servertypes="+e+"&fmanage="+compToDelete+",";c+="&componentDetails=&funmanage=";if(f!=null&&f!==undefined&&f==true){c+="&isProceed="+f;
}var a=new Ext.LoadMask(Ext.getBody(),{msg:updating+"..."});a.show();Ext.Ajax.request({url:c,method:"POST",success:function(g){a.hide();var i=g.responseText;var h=Ext.decode(i);if(h.requestStatus=="success"){var j=h.result;Ext.Msg.show({title:j.title,width:450,msg:j.message1,buttons:Ext.Msg.OK,icon:"iconInformation"});
elemList=h.elemList;d.compTypeSelection();}},failure:function(g){a.hide();}});},viewAssociatedEntities:function(b){var a=this;Ext.widget("window",{extend:"Ext.panel.Panel",title:"associatedEntitiesTitle1",id:"assoEntitesWindow",width:"68%",bodyPadding:"10 10 10 10",height:350,modal:true,border:false,autoScroll:true,scroll:true,ghost:false,closeAction:"destory",doClose:function(){this.destroy();
},listeners:{afterrender:function(){a.updateEntityAssociationPage(b);}},items:[{xtype:"container",flex:1,id:"entityAssociationContainer",margin:10}]}).show();},updateEntityAssociationPage:function(e){console.log("action ",e);var d=this;var b=Ext.getCmp("compTypes").getValue();var f="AggregateManageUnmanageComponents/data/EgComponentGroupedSummary.jsp?date="+new Date().getTime()+"&fromWizard="+fromWizard+"&action="+e+"&srvtype="+b+"&comeFrom=addModify";
if(e!=null&&e!==undefined&&(e=="showMod"||e=="showDel")){f+="&elemList=true"+"&hiddenElemList="+encodeURIComponent(elemList);Ext.getCmp("assoEntitesWindow").setTitle(associatedEntitiesTitle2);}else{if(e!=null&&e!==undefined&&e=="delete"){Ext.getCmp("assoEntitesWindow").setTitle(associatedEntitiesTitle1);
var g=Ext.getCmp("compTypes").getValue();g=encodeURIComponent(g);var c=g+":"+compToDelete;f+="&fmanage="+compToDelete+"&fmanagewithcomptype="+c;}}var a=new Ext.LoadMask(Ext.getBody(),{msg:"Updating..."});a.show();Ext.Ajax.request({url:f,method:"POST",success:function(h){a.hide();var j=h.responseText;
var i=Ext.decode(j);d.updateResultPanel(i);},failure:function(h){a.hide();}});},updateResultPanel:function(a){var e=this;var c=Ext.getCmp("entityAssociationContainer");c.removeAll();var b=a["isElementsAssociated"];if(b!=undefined&&b==true){var d="<div>"+a.usersGridArr+"</div>";Ext.getCmp("entityAssociationContainer").update(d);
}else{var d='<div class = "iconInformation" style="margin:12% auto auto auto"></div><div>No components associated.</div>';var f={xtype:"component",width:"100%",border:false,style:{"text-align":"center"},html:d};c.add(f);}},addNewComponent:function(){var c=Ext.getCmp("compTypes").getValue();c=encodeURIComponent(c);
var b=Ext.getCmp("category").getValue();b=encodeURIComponent(b);if(c=="-1"){Ext.Msg.show({title:pageTitle,msg:alertMsg36,buttons:Ext.Msg.OK,icon:"iconExclamation"});return;}var a="/final/admin/aggNewServer.jsp?server=new&serverType="+c+"&from=addnew&isAggregateLink=false&treeViewSrc=null&serverGategory="+b+"&fromWizard="+fromWizard+"&compGlanceCompType="+compGlanceCompType+"&reqfrom="+reqfrom;
window.location.href=a;},homeBack:function(){parent.window.location.href="/final/admin/EgAdminOperations.jsp?fromWizard="+fromWizard;},goBack:function(){this.goBackFromIPChange(jsonDataHolder.hiddenVals.selCategory,jsonDataHolder.hiddenVals.servertype);},goBackFromIPChange:function(d,f){var a=Ext.getCmp("componentview");
a.removeAll();a.add({xtype:"components"});if(d==null||d==""){d="-1";}if(f==null||f==""){f="-1";}Ext.getCmp("category").setValue(d);Ext.getCmp("compTypes").setValue(f);d=encodeURIComponent(d);f=encodeURIComponent(f);var b="AggregateComponent/data/EgDispServerJson.jsp?&selectedServerGroup="+d+"&server="+f;
this.getData(b);var c=jsonDataHolder.serversFound;var e=Ext.getCmp("componentListGrid");if(c){e.show();e.getStore().removeAll();e.getStore().loadRawData(jsonDataHolder.components);}else{e.getStore().removeAll();Ext.get("noCompAlrtDiv").update(srcNotFnd);}if(f!="-1"){Ext.getCmp("searchBox").enable();Ext.getCmp("testsAndMeasures").enable();
}else{Ext.getCmp("searchBox").disable();Ext.getCmp("testsAndMeasures").disable();}}});