add owner to group and snapshot listings

while touching it, make columns and tbar in DataStoreContent.js
declarative members and remove the (now) unnecessary initComponent

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-05-29 15:09:01 +02:00 committed by Dietmar Maurer
parent 86e432b0b8
commit 04b0ca8b59
3 changed files with 63 additions and 60 deletions

View File

@ -130,8 +130,8 @@ fn list_groups(
let group = info.backup_dir.group(); let group = info.backup_dir.group();
let list_all = (user_privs & PRIV_DATASTORE_AUDIT) != 0; let list_all = (user_privs & PRIV_DATASTORE_AUDIT) != 0;
if !list_all {
let owner = datastore.get_owner(group)?; let owner = datastore.get_owner(group)?;
if !list_all {
if owner != username { continue; } if owner != username { continue; }
} }
@ -141,6 +141,7 @@ fn list_groups(
last_backup: info.backup_dir.backup_time().timestamp(), last_backup: info.backup_dir.backup_time().timestamp(),
backup_count: list.len() as u64, backup_count: list.len() as u64,
files: info.files.clone(), files: info.files.clone(),
owner: Some(owner),
}; };
groups.push(result_item); groups.push(result_item);
} }
@ -329,8 +330,9 @@ pub fn list_snapshots (
} }
let list_all = (user_privs & PRIV_DATASTORE_AUDIT) != 0; let list_all = (user_privs & PRIV_DATASTORE_AUDIT) != 0;
if !list_all {
let owner = datastore.get_owner(group)?; let owner = datastore.get_owner(group)?;
if !list_all {
if owner != username { continue; } if owner != username { continue; }
} }
@ -340,6 +342,7 @@ pub fn list_snapshots (
backup_time: info.backup_dir.backup_time().timestamp(), backup_time: info.backup_dir.backup_time().timestamp(),
files: info.files, files: info.files,
size: None, size: None,
owner: Some(owner),
}; };
if let Ok(index) = read_backup_index(&datastore, &info.backup_dir) { if let Ok(index) = read_backup_index(&datastore, &info.backup_dir) {

View File

@ -388,6 +388,9 @@ pub struct GroupListItem {
pub backup_count: u64, pub backup_count: u64,
/// List of contained archive files. /// List of contained archive files.
pub files: Vec<String>, pub files: Vec<String>,
/// The owner of group
#[serde(skip_serializing_if="Option::is_none")]
pub owner: Option<String>,
} }
#[api( #[api(
@ -420,6 +423,9 @@ pub struct SnapshotListItem {
/// Overall snapshot size (sum of all archive sizes). /// Overall snapshot size (sum of all archive sizes).
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub size: Option<u64>, pub size: Option<u64>,
/// The owner of the snapshots group
#[serde(skip_serializing_if="Option::is_none")]
pub owner: Option<String>,
} }
#[api( #[api(

View File

@ -9,6 +9,7 @@ Ext.define('pbs-data-store-snapshots', {
dateFormat: 'timestamp' dateFormat: 'timestamp'
}, },
'files', 'files',
'owner',
{ name: 'size', type: 'int' }, { name: 'size', type: 'int' },
] ]
}); });
@ -125,6 +126,7 @@ Ext.define('PBS.DataStoreContent', {
group["backup-time"] = last_backup; group["backup-time"] = last_backup;
group.files = item.files; group.files = item.files;
group.size = item.size; group.size = item.size;
group.owner = item.owner;
} }
} }
group.count = group.children.length; group.count = group.children.length;
@ -157,21 +159,6 @@ Ext.define('PBS.DataStoreContent', {
} }
}, },
initComponent: function() {
var me = this;
var sm = Ext.create('Ext.selection.RowModel', {});
var prune_btn = new Proxmox.button.Button({
text: gettext('Prune'),
disabled: true,
selModel: sm,
enableFn: function(record) { return !record.data.leaf; },
handler: 'onPrune',
});
Ext.apply(me, {
selModel: sm,
columns: [ columns: [
{ {
xtype: 'treecolumn', xtype: 'treecolumn',
@ -200,12 +187,17 @@ Ext.define('PBS.DataStoreContent', {
sortable: true, sortable: true,
dataIndex: 'count', dataIndex: 'count',
}, },
{
header: gettext("Owner"),
sortable: true,
dataIndex: 'owner',
},
{ {
header: gettext("Files"), header: gettext("Files"),
sortable: false, sortable: false,
dataIndex: 'files', dataIndex: 'files',
flex: 2 flex: 2
} },
], ],
tbar: [ tbar: [
@ -214,10 +206,12 @@ Ext.define('PBS.DataStoreContent', {
iconCls: 'fa fa-refresh', iconCls: 'fa fa-refresh',
handler: 'reload', handler: 'reload',
}, },
prune_btn {
xtype: 'proxmoxButton',
text: gettext('Prune'),
disabled: true,
enableFn: function(record) { return !record.data.leaf; },
handler: 'onPrune',
}
], ],
});
me.callParent();
},
}); });