fix #759: save columns of resourceGrid

with this patch, the resourceGrid saves its state when
the columns are changed (resized, sorted, etc.)

also add a little reset button to the toolbar

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2016-04-20 09:35:19 +02:00 committed by Dietmar Maurer
parent 0be88ae197
commit df6345f9ba
3 changed files with 43 additions and 10 deletions

View File

@ -4,6 +4,8 @@ pve-manager (4.1-32) unstable; urgency=medium
* fix #143: add disk/mem percent sort
* fix #759: save columns of resourceGrid
-- Proxmox Support Team <support@proxmox.com> Wed, 20 Apr 2016 09:21:17 +0200
pve-manager (4.1-31) unstable; urgency=medium

View File

@ -350,3 +350,16 @@
.x-form-display-field-default {
min-height: 20px;
}
.x-button-reset:before {
font-size: 16px;
}
/* for resetcolumnsbutton */
.x-button-reset:after{
content: "\f0e7 ";
position: relative;
text-shadow: 0 0 2px #fff;
left: -3px;
top: 2px;
}

View File

@ -3,7 +3,14 @@ Ext.define('PVE.grid.ResourceGrid', {
alias: ['widget.pveResourceGrid'],
border: false,
saveCurrentState: function(){
var me = this;
me.saveState();
},
defaultSorter: {
property: 'type',
direction: 'ASC'
},
initComponent : function() {
var me = this;
@ -14,12 +21,7 @@ Ext.define('PVE.grid.ResourceGrid', {
var store = Ext.create('Ext.data.Store', {
model: 'PVEResources',
sorters: [
{
property : 'type',
direction: 'ASC'
}
],
sorters: me.defaultSorter,
proxy: { type: 'memory' }
});
@ -149,7 +151,21 @@ Ext.define('PVE.grid.ResourceGrid', {
Ext.apply(me, {
store: store,
stateful: true,
stateId: 'resourcegrid',
tbar: [
{
xtype: 'button',
itemId: 'resetbutton',
tooltip: gettext("Reset Columns"),
iconCls: 'fa fa-fw fa-columns x-button-reset',
handler: function(button, e, opts) {
var sp = Ext.state.Manager.getProvider();
me.getStore().sort(me.defaultSorter);
me.reconfigure(null, PVE.data.ResourceStore.defaultColums());
sp.clear(me.stateId);
}
},
'->',
gettext('Search') + ':', ' ',
{
@ -206,13 +222,15 @@ Ext.define('PVE.grid.ResourceGrid', {
},
destroy: function() {
rstore.un("load", load_cb);
}
},
columnschanged: 'saveCurrentState',
columnresize: 'saveCurrentState',
columnmove: 'saveCurrentState',
sortchange: 'saveCurrentState',
},
columns: coldef
});
me.callParent();
updateGrid();
rstore.on("load", load_cb);
}