Ext.define("EgViewUser.controller.Main",{extend:"Ext.app.Controller",requires:["EgViewUser.view.Main"],views:["Main"],refs:[{selector:"main",ref:"main"}],init:function(){appCnt=this;this.control({"main":{"afterrender":this.afterMainRender},'main button[id="backButton"]':{"click":this.goBack},'main combo[id="usertypes"]':{"select":this.changeUserCategory}});
},afterMainRender:function(){var a=new Ext.LoadMask(Ext.getBody(),{msg:"Loading..."});a.show();Ext.Ajax.request({url:"EgViewUser/data/EgViewUserJson.jsp",method:"POST",timeout:120000,success:function(b){a.hide();var e=b.responseText;publicJSON=Ext.decode(e);var d=publicJSON["isUsersCreated"];if(d!=false){var c={text:"Choose Organization / Organizational Unit / User",id:"-1",name:"-1",expanded:true,children:publicJSON["exportDataArr"]};
Ext.getCmp("unameTree").setRootNode(c);Ext.getCmp("unameTree").show();Ext.getCmp("emptyCont").hide();}else{Ext.getCmp("unameTree").hide();Ext.getCmp("emptyCont").show();}}});},changeUserCategory:function(){var a=Ext.getCmp("usertypes").getValue();var b=new Ext.LoadMask(Ext.getBody(),{msg:"Loading..."});
b.show();Ext.Ajax.request({url:"EgViewUser/data/EgViewUserJson.jsp",method:"POST",params:{"usertypes":a},timeout:120000,success:function(d){b.hide();var g=d.responseText;publicJSON=Ext.decode(g);var f=publicJSON["isUsersCreated"];if(f!=false){Ext.getCmp("searchbox").setDisabled(false);Ext.getCmp("nodeExpand").setDisabled(false);
Ext.getCmp("nodeCollapse").setDisabled(false);var e={text:"Choose Organization / Organizational Unit / User",id:"-1",name:"-1",expanded:true,children:publicJSON["exportDataArr"]};Ext.getCmp("unameTree").setRootNode(e);Ext.getCmp("unameTree").show();Ext.getCmp("emptyCont").hide();var c=Ext.getElementById("noDataFound");
if(c!=null&&c!=undefined){c.style.display="none";}}else{Ext.getCmp("unameTree").setRootNode({});if(a=="all"){Ext.getCmp("unameTree").hide();Ext.getCmp("emptyCont").show();}else{Ext.getCmp("searchbox").setDisabled(true);Ext.getCmp("nodeExpand").setDisabled(true);Ext.getCmp("nodeCollapse").setDisabled(true);
var c=Ext.getElementById("noDataFound");if(c==null||c===undefined){Ext.DomHelper.append(Ext.get(Ext.getCmp("unameTree").getView().id),{tag:"div",style:{"height":"95%","width":"100%","textAlign":"center","display":"table"},cls:"new-div-cls",id:"noDataFound",html:LoadAlert});}else{c.style.display="table";
}}}}});},goBack:function(){window.location.href=backHref;}});