create and use BackupView

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2020-11-13 14:16:25 +01:00 committed by Thomas Lamprecht
parent 13d7dfccee
commit 1665b8402c
4 changed files with 82 additions and 49 deletions

View File

@ -234,6 +234,7 @@ JSSRC= \
sdn/zones/SimpleEdit.js \
sdn/zones/VlanEdit.js \
sdn/zones/VxlanEdit.js \
storage/BackupView.js \
storage/Base.js \
storage/Browser.js \
storage/CIFSEdit.js \

View File

@ -0,0 +1,80 @@
Ext.define('PVE.storage.BackupView', {
extend: 'PVE.storage.ContentView',
alias: 'widget.pveStorageBackupView',
stateful: true,
stateId: 'grid-storage-content-backup',
initComponent: function() {
var me = this;
var nodename = me.nodename = me.pveSelNode.data.node;
if (!nodename) {
throw "no node name specified";
}
var storage = me.storage = me.pveSelNode.data.storage;
if (!storage) {
throw "no storage ID specified";
}
me.content = 'backup';
var sm = me.sm = Ext.create('Ext.selection.RowModel', {});
var reload = function() {
me.store.load();
};
me.tbar = [
{
xtype: 'proxmoxButton',
text: gettext('Restore'),
selModel: sm,
disabled: true,
enableFn: function(rec) {
return rec && rec.data.content === 'backup';
},
handler: function(b, e, rec) {
var vmtype;
if (PVE.Utils.volume_is_qemu_backup(rec.data.volid, rec.data.format)) {
vmtype = 'qemu';
} else if (PVE.Utils.volume_is_lxc_backup(rec.data.volid, rec.data.format)) {
vmtype = 'lxc';
} else {
return;
}
var win = Ext.create('PVE.window.Restore', {
nodename: nodename,
volid: rec.data.volid,
volidText: PVE.Utils.render_storage_content(rec.data.volid, {}, rec),
vmtype: vmtype
});
win.show();
win.on('destroy', reload);
}
},
{
xtype: 'proxmoxButton',
text: gettext('Show Configuration'),
disabled: true,
selModel: sm,
enableFn: function(rec) {
return rec && rec.data.content === 'backup';
},
handler: function(b,e,rec) {
var win = Ext.create('PVE.window.BackupConfig', {
volume: rec.data.volid,
pveSelNode: me.pveSelNode
});
win.show();
}
},
];
me.callParent();
},
});

View File

@ -51,13 +51,10 @@ Ext.define('PVE.storage.Browser', {
if (contents.includes('backup')) {
items.push({
xtype: 'pveStorageContentView',
xtype: 'pveStorageBackupView',
title: gettext('Backups'),
iconCls: 'fa fa-floppy-o',
itemId: 'contentBackup',
content: 'backup',
stateful: true,
stateId: 'grid-storage-content-backup',
});
}
if (contents.includes('images')) {

View File

@ -344,53 +344,8 @@ Ext.define('PVE.storage.ContentView', {
me.tbar.push(uploadButton);
}
me.tbar.push(
{
xtype: 'proxmoxButton',
text: gettext('Restore'),
selModel: sm,
disabled: true,
enableFn: function(rec) {
return rec && rec.data.content === 'backup';
},
handler: function(b, e, rec) {
var vmtype;
if (PVE.Utils.volume_is_qemu_backup(rec.data.volid, rec.data.format)) {
vmtype = 'qemu';
} else if (PVE.Utils.volume_is_lxc_backup(rec.data.volid, rec.data.format)) {
vmtype = 'lxc';
} else {
return;
}
var win = Ext.create('PVE.window.Restore', {
nodename: nodename,
volid: rec.data.volid,
volidText: PVE.Utils.render_storage_content(rec.data.volid, {}, rec),
vmtype: vmtype
});
win.show();
win.on('destroy', reload);
}
},
removeButton,
imageRemoveButton,
{
xtype: 'proxmoxButton',
text: gettext('Show Configuration'),
disabled: true,
selModel: sm,
enableFn: function(rec) {
return rec && rec.data.content === 'backup';
},
handler: function(b,e,rec) {
var win = Ext.create('PVE.window.BackupConfig', {
volume: rec.data.volid,
pveSelNode: me.pveSelNode
});
win.show();
}
},
'->',
gettext('Search') + ':', ' ',
{