FR.spaceQuota={store:new Ext.data.SimpleStore({fields:[{name:"id",type:"integer"},{name:"username"},{name:"name"},{name:"max"},{name:"maxNice"},{name:"used"},{name:"usedNice"},{name:"percent"}]}),sb:new Ext.ux.StatusBar({id:"my-status",defaultText:"&nbsp;"}),calculateAll:false};FR.spaceQuota.store.loadData(FR.users);FR.spaceQuota.grid=new Ext.grid.GridPanel({title:"Storage usage",store:FR.spaceQuota.store,disabled:FR.system.isFree||FR.system.isFreelancer,disabledMaskText:FR.T("Available in the %1 version").replace("%1",'<a href="https://filerun.com/get-enterprise" target="_blank">Enterprise FileRun</a>'),cls:"FREditForm",selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{selectionchange:function(sm){var r=sm.getSelected();if(!r){return}FR.spaceQuota.getQuota(r)}}}),cm:new Ext.grid.ColumnModel({defaults:{sortable:true},columns:[{header:"Id",width:50,dataIndex:"id",hidden:true},{header:"&nbsp;",width:42,sortable:false,menuDisabled:true,hideable:false,renderer:function(v,m,r){return'<img src="a/?uid='+r.data.id+'" class="basicAvatar" loading="lazy" />'}},{id:"uname",header:"Name",width:150,dataIndex:"name",hideable:false},{id:"usrname",header:"Username",width:150,dataIndex:"username",hideable:false},{header:"Quota",width:75,hideable:false,renderer:function(v,m,r){return r.data.maxNice},dataIndex:"max"},{header:"Used",width:75,hideable:false,renderer:function(v,m,r){if(r.data.max>0&&v>=r.data.max){return'<span style="color:red;">'+r.data.usedNice+"</span>"}else{return r.data.usedNice}},dataIndex:"used"},{header:"Usage",width:85,hideable:false,renderer:function(v,m,r){if(v>FR.highlightLimit){return'<span style="color:red;">'+v+"%</span>"}else{if(v){return v+"%"}else{return""}}},dataIndex:"percent"}]}),bbar:FR.spaceQuota.sb,listeners:{destroy:function(){Ext.Ajax.abort(FR.spaceQuota.ajaxReq);FR.spaceQuota=false}},tbar:{height:44,items:[{text:"Calculate all",iconCls:"fa-refresh",enableToggle:true,toggleHandler:function(btn,pressed){FR.spaceQuota.calculateAll=pressed;if(pressed){var data=FR.spaceQuota.store.data;if(data.length>0){FR.currentUID=0;FR.spaceQuota.getQuota(data.items[FR.currentUID])}}}}]}});FR.spaceQuota.getQuota=function(r){if(!FR.spaceQuota.sb){return false}FR.spaceQuota.sb.showBusy(FR.T('Calculating quota usage for "%1"...').replace("%1",r.data.name));this.ajaxReq=Ext.Ajax.request({url:FR.URLRoot+"/?module=cpanel&section=tools&page=space_quota&action=get&uid="+r.data.id,method:"GET",success:function(res){try{var rs=Ext.util.JSON.decode(res.responseText)}catch(er){FR.spaceQuota.sb.setStatus(FR.T("Server error"))}if(rs&&FR.spaceQuota){r.set("max",rs.max);r.set("maxNice",rs.maxNice);r.set("used",rs.used);r.set("usedNice",rs.usedNice);r.set("percent",rs.percent);r.commit();FR.spaceQuota.sb.clearStatus()}if(FR.spaceQuota.calculateAll){FR.currentUID++;var data=FR.spaceQuota.store.data;if(data.items[FR.currentUID]&&FR.spaceQuota){FR.spaceQuota.getQuota(data.items[FR.currentUID])}else{FR.spaceQuota.sb.clearStatus()}}}})};Ext.getCmp("appTab").add(FR.spaceQuota.grid);Ext.getCmp("appTab").doLayout();