var CONST_EmptyText_No_Cnfgrtn_Chngs_Found='<div class="egFlexCenterByColumnWise" style="height:98%"><div class="iconInformation"></div><div class="commonErrorMsgText">'+"No configuration changes found."+"</div></div>";var CONST_EmptyText_No_Data_Available='<div class="egFlexCenterByColumnWise" style="height:98%"><div class="iconInformation"></div><div class="commonErrorMsgText">'+"No data available"+"</div></div>";
Ext.define("ConfigMgmtHome.controller.Main",{extend:"Ext.app.Controller",views:["FormItems","OsBoxInfoChart","DaywiseChangesChart","ErrorContainer","configutilities.Tools","configutilities.PrintPreview","configutilities.SendMail"],refs:[{selector:"formitems",ref:"formitems"},{selector:"osboxinfochart",ref:"osboxinfochart"},{selector:"daywisechangeschart",ref:"daywisechangeschart"},{selector:"tools",ref:"tools"},{selector:"errorcontainer",ref:"errorcontainer"}],init:function(){thisCtrl=this;
me=this;this.control({"formitems":{"afterrender":this.afterMainRender},'formitems combo[id="ec_criteria"]':{"select":this.goTo},'formitems combo[id="ec_userOption"]':{"select":this.goTo},'formitems combo[id="ec_osOption"]':{"select":this.getOSwiseMachineStatus},'formitems combo[id="NHour"]':{"select":this.goToChangeSummary},'formitems combo[id="ec_os_sw"]':{"select":this.getTopNSoftwareInstalls},'formitems combo[id="ec_os_hf"]':{"select":this.getTopNHotfixInstalls},'formitems combo[id="Hour"]':{"select":this.goToChangesAtAGlance},'formitems combo[id="componentType"]':{"select":this.goToDaywiseChangeDistribution},'formitems combo[id="duration"]':{"select":this.goToDaywiseChangeDistribution},"tools":{"afterrender":this.loadTools},'tools button[id="saveBtn"]':{"click":this.saveAsPDF},'tools button[id="printBtn"]':{"click":this.printData},'tools button[id="mailBtn"]':{"click":this.sendMail},'tools button[id="scheduleBtn"]':{"click":this.setschedule}});
},afterMainRender:function(){var c=this;var b=Ext.getCmp("ec_userOption");var a=Ext.getCmp("ec_criteria");Ext.Ajax.request({url:config.urls.initialURL,params:queryString+"&needData=yes",method:"POST",async:false,success:function(d){if(d.status==200&&!Ext.isEmpty(d.responseText)){var e=d.responseText;
publicJSON=Ext.decode(e);hiddenFieldsKeys=publicJSON["hiddenFields"];a.getStore().loadRawData(publicJSON["viewByList"]);a.setValue(publicJSON.selectedEcOpt);if(publicJSON.selectedEcOpt!="Component"){b.getStore().loadRawData(publicJSON["specViewByList"]);b.setValue(publicJSON.selectedUserOption);b.setFieldLabel(publicJSON.specViewByTitle);
b.show();}else{b.hide();}if(publicJSON.hasRecords){Ext.getCmp("column1").show();Ext.getCmp("column2").show();c.getErrorcontainer().hide();c.syncConfigDataByMachine("");if(backButton!=""&&backButton!=null&&backButton!=undefined&&backButton=="true"){console.log("selectedMachinesOpt: "+selectedMachinesOpt);
c.syncConfigDataByMachine(selectedMachinesOpt);c.syncConfigDataByTopNSoftwareAvails("backButtonRender","SoftwareList_cf",selectedOsName_sw);c.syncConfigDataByTopNHotfixesAvails("backButtonRender","HotFix_cf",selectedOsName_hf);c.syncConfigDataByComponentTypeSummary(NHours_Summary);c.syncConfigDataByChangesAtAGlance("backButtonRender",NHours_Glance);
c.syncConfigDataByWeekChanges(componentType_dw,duration);}else{c.syncConfigDataByComponentTypeSummary();c.syncConfigDataByTopNSoftwareAvails("afterMainRender","SoftwareList_cf");c.syncConfigDataByTopNHotfixesAvails("afterMainRender","HotFix_cf");c.syncConfigDataByChangesAtAGlance("afterMainRender");c.syncConfigDataByWeekChanges();
}setInterval("thisCtrl.onRefresh()",120000);}else{Ext.getCmp("column1").hide();Ext.getCmp("column2").hide();c.getErrorcontainer().show();c.getErrorcontainer().update('<table border="0" height="360px" width="100%"><tr><td align=center valign=middle><img src="/final/images/spacer.gif" class="iconInformation" valign="middle" /><div class="commonErrorMsgText">'+publicJSON.errorText+".</div></td></tr></table>");
}var f=publicJSON["hasRecords"];if(!f){c.setToolsState();}delete publicJSON;}}});},syncConfigDataByMachine:function(b){var d="";var a=Ext.getCmp("ec_criteria").getValue();var f="";var c=this;if(a!="Component"){f=Ext.getCmp("ec_userOption").getValue();}var e=config.urls.servletURL;d="needData=yes&cmd=OswiseComponentStatus&ec_criteria="+a+"&ec_userOption="+encodeURIComponent(f);
if(b.length>0){if(b=="OS"){d=d+"&version=No";}else{if(b=="OSVersion"){d=d+"&version=Yes";}else{if(b=="NetworkDevices"){d=d+"&machines=NetworkDevices";}else{if(b=="Virutualization"){d=d+"&machines=Virutualization";}}}}}d=d+"&"+Math.random();Ext.Ajax.request({url:e,params:d,method:"POST",success:function(h){if(h.status==200&&!Ext.isEmpty(h.responseText)){var k=h.responseText;
var i=Ext.decode(k);var j=i.chartData;var g=i.errorText;Ext.getCmp("ec_osOption").getStore().removeAll();Ext.getCmp("machineCtn").setTitle('<a id="mouse" href="'+i.HeaderLink+'" target="main" class="eg_monlink">'+i.headerLinkText+"</a>");Ext.getCmp("ec_osOption").getStore().loadRawData(i.ecOSOptionArr);
Ext.getCmp("ec_osOption").setValue(i.SelectedEcOSOptionText);b=Ext.getCmp("ec_osOption").getValue();if(g!=null&&g!=undefined&&g!=""){Ext.getCmp("byMachineOSVersionGrid").hide();c.getOsboxinfochart().hide();Ext.getCmp("resultCntByMachine").removeAll();Ext.getCmp("resultCntByMachine").add({xtype:"errorcontainer",html:"<table border='0' width='100%' align='center' height='180px'><tr><td align='center' valign=middle><img src='/final/images/spacer.gif' class='iconInformation' valign='middle' /><div class='commonErrorMsgText'>"+g+"</div></td></tr></table>"});
}else{Ext.getCmp("resultCntByMachine").removeAll();c.getErrorcontainer().hide();if(b=="OS"||b==""){Ext.getCmp("byMachineOSVersionGrid").hide();if(j!=null&&j!=""&&j!=undefined){c.getOsboxinfochart().show();c.getOsboxinfochart().loadChart(i,c);}else{Ext.getCmp("byMachineOSVersionGrid").getView().emptyText=CONST_EmptyText_No_Cnfgrtn_Chngs_Found;
c.getOsboxinfochart().hide();}}else{if(b=="OSVersion"){c.getOsboxinfochart().hide();Ext.getCmp("byMachineOSVersionGrid").show();Ext.getCmp("displayMessage1").update('<div style="padding:2px;" class="font_bold11" align="center">'+i.gridTitle+"</div>");if(i.gridArr!=""&&i.gridArr!=null&&i.gridArr!=undefined){Ext.getCmp("byMachineOSVersionGrid").getStore().loadRawData(i.gridArr);
}else{Ext.getCmp("byMachineOSVersionGrid").getView().emptyText="<table border='0' width='100%' height='100px'><tr><td align=center valign=middle><img src='/final/images/spacer.gif' class='iconInformation' valign='middle' /><div class='commonErrorMsgText'>"+i.errorText+"</div></td></tr></table>";}}else{if(b=="NetworkDevices"){Ext.getCmp("byMachineOSVersionGrid").hide();
if(j!=null&&j!=""&&j!=undefined){c.getOsboxinfochart().show();c.getOsboxinfochart().loadChart(i,c);}else{Ext.getCmp("byMachineOSVersionGrid").getView().emptyText=CONST_EmptyText_No_Cnfgrtn_Chngs_Found;c.getOsboxinfochart().hide();}}else{if(b=="Virutualization"){Ext.getCmp("byMachineOSVersionGrid").hide();
if(j!=null&&j!=""&&j!=undefined){c.getOsboxinfochart().show();c.getOsboxinfochart().loadChart(i,c);}else{Ext.getCmp("byMachineOSVersionGrid").getView().emptyText=CONST_EmptyText_No_Cnfgrtn_Chngs_Found;c.getOsboxinfochart().hide();}}}}}}}}});},syncConfigDataByComponentTypeSummary:function(f){var c="";
var a=Ext.getCmp("ec_criteria").getValue();var e="";var b=this;if(a!="Component"){e=Ext.getCmp("ec_userOption").getValue();}var d=config.urls.servletURL;c="needData=yes&cmd=DashboardChangeSummary&ec_criteria="+a+"&ec_userOption="+encodeURIComponent(e);if(f!=null&&f!=undefined){c=c+"&NHour="+f;}c=c+"&"+Math.random();
Ext.Ajax.request({url:d,params:c,method:"POST",success:function(g){var h=Ext.decode(g.responseText);Ext.getCmp("NHour").getStore().removeAll();Ext.getCmp("NHour").getStore().loadRawData(h.timeLineArr);Ext.getCmp("NHour").setValue(h.selectedTime);if(h.gridTitle!=""&&h.gridTitle!=null&&h.gridTitle!=undefined){Ext.getCmp("changeSummaryGrid").setTitle('<span style="font-weight:500"><a id="mouse" href="'+h.HeaderLink+'" target="main" class="eg_monlink">'+h.HeaderText+"</a>"+"&nbsp;("+h.gridTitle+")</span>");
}else{Ext.getCmp("changeSummaryGrid").setTitle('<span style="font-weight:500"><a id="mouse" href="'+h.HeaderLink+'" target="main" class="eg_monlink">'+h.HeaderText+"</a></span>");}if(h.gridAr==""||h.gridAr==null||h.gridAr==undefined){Ext.getCmp("changeSummaryGrid").getView().emptyText=CONST_EmptyText_No_Cnfgrtn_Chngs_Found;
}Ext.getCmp("changeSummaryGrid").getStore().loadRawData(h.gridArr);delete h;},failure:function(){}});},syncConfigDataByTopNSoftwareAvails:function(h,b,c){var e="";var a=Ext.getCmp("ec_criteria").getValue();var g="";var d=this;if(a!="Component"){g=Ext.getCmp("ec_userOption").getValue();}var f=config.urls.servletURL;
e="needData=yes&cmd=TopNAvailability&ec_criteria="+a+"&ec_userOption="+encodeURIComponent(g);if(h!=null&&h!=""&&h!=undefined&&h.toLowerCase()!="aftermainrender"){if(c!=null&&c!=undefined){e=e+"&osName="+filterEncode(c);}}e=e+"&testName="+b+"&"+Math.random();Ext.Ajax.request({url:f,params:e,method:"POST",success:function(j){if(j.status==200&&!Ext.isEmpty(j.responseText)){var k=Ext.decode(j.responseText);
var i=Ext.getCmp("ec_os_sw");i.getStore().removeAll();i.getStore().loadRawData(k.ec_os);i.setValue(k.selectedEcOS);Ext.getCmp("sofwareInstallsGrid").setTitle('<span style="font-weight:500"><a id="mouse" href="'+k.HeaderLink+'" target="main" class="eg_monlink">'+k.HeaderText+"</a></span>");Ext.getCmp("headerText_sw").setValue('<span style="font-size:12px;font-weight:500">'+k.SystemLabel+"</span>");
if(k.TopNInstallsArr==""||k.TopNInstallsArr==null||k.TopNInstallsArr==undefined){Ext.getCmp("sofwareInstallsGrid").getView().emptyText=CONST_EmptyText_No_Data_Available;}Ext.getCmp("sofwareInstallsGrid").getStore().loadRawData(k.TopNInstallsArr);delete k;}},failure:function(){}});},syncConfigDataByTopNHotfixesAvails:function(h,b,c){var e="";
var a=Ext.getCmp("ec_criteria").getValue();var g="";var d=this;if(a!="Component"){g=Ext.getCmp("ec_userOption").getValue();}var f=config.urls.servletURL;e="needData=yes&cmd=TopNAvailability&ec_criteria="+a+"&ec_userOption="+encodeURIComponent(g);if(h!=null&&h!=""&&h!=undefined&&h.toLowerCase()!="aftermainrender"){if(c!=null&&c!=undefined){e=e+"&osName="+filterEncode(c);
}}e=e+"&testName="+b+"&"+Math.random();Ext.Ajax.request({url:f,params:e,method:"POST",success:function(j){if(j.status==200&&!Ext.isEmpty(j.responseText)){var k=Ext.decode(j.responseText);var i=Ext.getCmp("ec_os_hf");i.getStore().removeAll();i.getStore().loadRawData(k.ec_os);i.setValue(k.selectedEcOS);
Ext.getCmp("hotfixInstallsGrid").setTitle('<span style="font-weight:500"><a id="mouse" href="'+k.HeaderLink+'" target="main" class="eg_monlink">'+k.HeaderText+"</a></span>");Ext.getCmp("headerText_hf").setValue('<span style="font-size:12px;font-weight:500">'+k.SystemLabel+"</span>");if(k.TopNInstallsArr==""||k.TopNInstallsArr==null||k.TopNInstallsArr==undefined){Ext.getCmp("hotfixInstallsGrid").getView().emptyText=CONST_EmptyText_No_Data_Available;
}Ext.getCmp("hotfixInstallsGrid").getStore().loadRawData(k.TopNInstallsArr);delete k;}},failure:function(){}});},syncConfigDataByChangesAtAGlance:function(g,b){var d="";var c=this;var a=Ext.getCmp("ec_criteria").getValue();var f="";if(a!="Component"){f=Ext.getCmp("ec_userOption").getValue();}var e=config.urls.servletURL;
d="needData=yes&cmd=DashboardChangesAtAGlance&ec_criteria="+a+"&ec_userOption="+encodeURIComponent(f);if(g!=null&&g!=""&&g!=undefined&&g.toLowerCase()!="aftermainrender"){if(b!=""&&b!=null&&b!=undefined){d=d+"&NHour="+b;}}d=d+"&"+Math.random();Ext.Ajax.request({url:e,params:d,method:"POST",success:function(h){var i=Ext.decode(h.responseText);
var j=Ext.getCmp("Hour");j.getStore().removeAll();j.getStore().loadRawData(i.timeLineArr);j.setValue(i.selectedTime);if(i.gridTitle!=""&&i.gridTitle!=null&&i.gridTitle!=undefined){Ext.getCmp("changeAtAGlanceGrid").setTitle('<span style="font-weight:500"><a id="mouse" href="'+i.HeaderLink+'" target="main" class="eg_monlink">'+i.HeaderText+"</a>"+"&nbsp;("+i.gridTitle+")</span>");
}else{Ext.getCmp("changeAtAGlanceGrid").setTitle('<span style="font-weight:500"><a id="mouse" href="'+i.HeaderLink+'" target="main" class="eg_monlink">'+i.HeaderText+"</a></span>");}if(i.gridValues==""||i.gridValues==null||i.gridValues==undefined){Ext.getCmp("changeAtAGlanceGrid").getView().emptyText=CONST_EmptyText_No_Cnfgrtn_Chngs_Found;
}Ext.getCmp("changeAtAGlanceGrid").getStore().loadRawData(i.gridValues);delete i;},failure:function(){}});},syncConfigDataByWeekChanges:function(f,g){var c="";var a=Ext.getCmp("ec_criteria").getValue();var e="";var b=this;if(a!="Component"){e=Ext.getCmp("ec_userOption").getValue();}var d=config.urls.servletURL;
c="needJsonData=yes&cmd=DashboardDaywiseChangeDistribution&ec_criteria="+a+"&ec_userOption="+encodeURIComponent(e);if(f!=null&&f!=undefined){c=c+"&componentType="+filterEncode(f)+"&duration="+g;}c=c+"&"+Math.random();Ext.Ajax.request({url:d,params:c,method:"POST",success:function(h){var j=Ext.decode(h.responseText);
Ext.getCmp("changesovertime").setTitle('<a id="mouse" href="'+j.HeaderLink+'" target="main" class="eg_monlink">'+j.HeaderText+"</a>");var i=Ext.getCmp("componentType");i.getStore().removeAll();i.getStore().loadRawData(j.serverList);if(j.selectedServer!=null&&j.selectedServer!=""&&j.selectedServer!=undefined){i.setValue(j.selectedServer);
}else{i.setValue(j.serverList[0].valueField);}var k=Ext.getCmp("duration");k.getStore().removeAll();k.getStore().loadRawData(j.durationList);k.setValue(j.selectedDuration);Ext.getCmp("daywiseChartCnt").removeAll();Ext.getCmp("daywiseChartCnt").add({xtype:"daywisechangeschart"});b.getDaywisechangeschart().loadChart(j,b);
delete j;},failure:function(){}});},goTo:function(d){var e=d.getId();var c=this;var a=Ext.getCmp("ec_criteria").getValue();var b="";if(d.id=="ec_userOption"&&a!="Component"){b=Ext.getCmp("ec_userOption").getValue();}c.initConfigController(a,b,e);},initConfigController:function(e,c,h){var i="";var a=this.getHiddenFields(hiddenFieldsKeys);
var g=this;var d=config.urls.initialURL;i="ec_criteria="+e+"&"+a;if(c!=null&&c.length>0&&c!=undefined){i=i+"&ec_userOption="+c;}var b=Ext.getCmp("ec_criteria");var f=Ext.getCmp("ec_userOption");Ext.Ajax.request({url:d,params:i,method:"POST",success:function(j){publicJSON=Ext.decode(j.responseText);b.getStore().loadRawData(publicJSON["viewByList"]);
b.setValue(publicJSON.selectedEcOpt);if(publicJSON.selectedEcOpt!="Component"){f.getStore().loadRawData(publicJSON["specViewByList"]);f.setFieldLabel(publicJSON.specViewByTitle);if(h=="ec_criteria"){f.setValue(publicJSON["selectedUserOption"]);}f.show();}else{f.hide();}if(publicJSON.hasRecords){Ext.getCmp("column1").show();
Ext.getCmp("column2").show();g.getErrorcontainer().hide();g.syncConfigDataByMachine("");g.syncConfigDataByComponentTypeSummary();g.syncConfigDataByTopNSoftwareAvails("initConfigController","SoftwareList_cf");g.syncConfigDataByTopNHotfixesAvails("initConfigController","HotFix_cf");g.syncConfigDataByChangesAtAGlance("initConfigController");
g.syncConfigDataByWeekChanges();}else{Ext.getCmp("column1").hide();Ext.getCmp("column2").hide();g.getErrorcontainer().show();g.getErrorcontainer().update('<table border="0" height="360px" width="100%"><tr><td align=center valign=middle><img src="/final/images/spacer.gif" class="iconInformation" valign="middle" /><div class="commonErrorMsgText">'+publicJSON.errorText+".</div></td></tr></table>");
}delete publicJSON;},failure:function(){}});},getOSwiseMachineStatus:function(){var b=this;var a=Ext.getCmp("ec_osOption").getValue();if(a!=null&&a!=undefined){b.syncConfigDataByMachine(a);}},goToChangeSummary:function(){var b=this;var a=Ext.getCmp("NHour").getValue();if(a!=null&&a!=undefined){b.syncConfigDataByComponentTypeSummary(a);
}},getTopNSoftwareInstalls:function(){var b=this;var a=Ext.getCmp("ec_os_sw").getValue();if(a!=null&&a!=undefined){b.syncConfigDataByTopNSoftwareAvails("osChange","SoftwareList_cf",a);}},getTopNHotfixInstalls:function(){var b=this;var a=Ext.getCmp("ec_os_hf").getValue();if(a!=null&&a!=undefined){b.syncConfigDataByTopNHotfixesAvails("osChange","HotFix_cf",a);
}},goToChangesAtAGlance:function(){var a=this;var b=Ext.getCmp("Hour").getValue();if(b!=null&&b!=undefined){a.syncConfigDataByChangesAtAGlance("onchangeduration",b);}},goToDaywiseChangeDistribution:function(){var b=this;var a=Ext.getCmp("componentType").getValue();var c=Ext.getCmp("duration").getValue();
if(a!=null&&a!=undefined&&c!=null&&c!=undefined){b.syncConfigDataByWeekChanges(a,c);}},onRefresh:function(){var a=this;a.getOSwiseMachineStatus();a.getTopNSoftwareInstalls();a.getTopNHotfixInstalls();a.goToChangeSummary();a.goToChangesAtAGlance();a.goToDaywiseChangeDistribution();},getHiddenFields:function(b){var a="";
for(key in b){a+=key+"="+b[key]+"&";}return a;},loadTools:function(){var a=this;thisCtrl.getTools().loadIcon(true,true,true,false,true,true);},setToolsState:function(a){Ext.getCmp("toolbar").hide();Ext.getCmp("configDbId").hide();},printData:function(){var b=publicJSON.printQueryStr;Ext.widget("print",{title:config.title.mainPageTitle}).show();
var a=Ext.select("#printContentDiv");a.set({src:b});},saveAsPDF:function(){downloadAsPDF(config.urls.pdfURL);},sendMail:function(){Ext.widget("sendmail").show();},setschedule:function(){var a=publicJSON.schQueryStr;scheduleWindow(a);}});function doCloseWin(){Ext.getCmp("scheduleWin").destroy();}