1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
Ext.namespace('Zarafa.plugins.files.settings.ui');
/**
* @class Zarafa.plugins.files.settings.ui.FeatureQuotaInfoPanel
* @extends Ext.Panel
* @xtype filesplugin.featurequotainfopanel
*
* Will generate UI for {@link Zarafa.plugins.files.settings.ui.FeatureQuotaInfoContentPanel FeatureQuotaInfoContentPanel}.
*/
Zarafa.plugins.files.settings.ui.FeatureQuotaInfoPanel = Ext.extend(Ext.Panel, {
/**
* @cfg {Object} The current loaded account record.
*/
account: undefined,
/**
* @constructor
* @param {Object} config Configuration structure.
*/
constructor: function (config) {
config = config || {};
if (config.item) {
this.account = config.item;
}
Ext.applyIf(config, {
xtype : 'filesplugin.featurequotainfopanel',
items : this.createPanelItems(),
buttons : [{
text : dgettext('plugin_files', 'Reload'),
handler: this.doReload.createDelegate(this),
scope : this
}, {
text : dgettext('plugin_files', 'Close'),
handler: this.doClose,
scope : this
}]
});
Zarafa.plugins.files.settings.ui.FeatureQuotaInfoPanel.superclass.constructor.call(this, config);
this.doReload();
},
/**
* Close the dialog.
*/
doClose: function () {
this.dialog.close();
},
/**
* Reload the quota store.
*/
doReload: function () {
var responseHandler = new Zarafa.core.data.AbstractResponseHandler({
doGetquota: this.gotQuotaValues.createDelegate(this)
});
container.getRequest().singleRequest(
'filesaccountmodule',
'getquota',
{
accountId: this.account.get("id"),
folder : "/"
},
responseHandler
);
},
/**
* Function is called after we received the response object from the server.
* It sets the quota information in the form panel.
*
* @param {Object} response object from the server
*/
gotQuotaValues: function (response) {
if (!this.formPanel) {
return;
}
var used = parseInt(response["quota"][0].amount);
var available = parseInt(response["quota"][1].amount);
// Backend sometimes returns a negative value for available data, set it to zero.
if (used < 0 ) {
used = 0;
}
if (available < 0) {
available = 0;
}
this.formPanel.getForm().setValues([
{ id: 'usedField', value: Ext.util.Format.fileSize(used) },
{ id: 'availableField', value: Ext.util.Format.fileSize(available) },
{ id: 'totalField', value: Ext.util.Format.fileSize(available + used) }
]);
},
/**
* Function will create panel items for {@link Zarafa.plugins.files.settings.ui.FeatureQuotaInfoPanel FeatureQuotaInfoPanel}.
* @return {Array} array of items that should be added to panel.
* @private
*/
createPanelItems: function () {
return [{
xtype: 'form',
border: false,
ref: 'formPanel',
labelAlign: 'left',
items: [{
xtype : 'displayfield',
name : 'usedField',
fieldLabel: dgettext('plugin_files', 'Used'),
value : dgettext('plugin_files', 'Loading') + '…'
}, {
xtype : 'displayfield',
name : 'availableField',
fieldLabel: dgettext('plugin_files', 'Free'),
value : dgettext('plugin_files', 'Loading') + '…'
}, {
xtype : 'displayfield',
name : 'totalField',
fieldLabel: dgettext('plugin_files', 'Total'),
value : dgettext('plugin_files', 'Loading') + '…'
}]
}];
}
});
Ext.reg('filesplugin.featurequotainfopanel', Zarafa.plugins.files.settings.ui.FeatureQuotaInfoPanel);
|