ui: tape/TapeRestore: add MediaSetSelector

when no uuid/mediaset is given.
we change a bit how we use the uuid by moving it into the viewmodel
(instead of a simple property on the view) so that we can always
use the selected one

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-05-26 15:48:07 +02:00 committed by Thomas Lamprecht
parent d455270fa1
commit 0732de361a
1 changed files with 43 additions and 2 deletions

View File

@ -14,6 +14,10 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', {
showTaskViewer: true, showTaskViewer: true,
isCreate: true, isCreate: true,
mediaset: undefined,
prefilter: undefined,
uuid: undefined,
cbindData: function(config) { cbindData: function(config) {
let me = this; let me = this;
if (me.prefilter !== undefined) { if (me.prefilter !== undefined) {
@ -27,6 +31,7 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', {
viewModel: { viewModel: {
data: { data: {
uuid: "",
singleDatastore: true, singleDatastore: true,
}, },
formulas: { formulas: {
@ -43,6 +48,13 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', {
return panel.query('[isFormField]').every(field => field.isValid()); return panel.query('[isFormField]').every(field => field.isValid());
}, },
changeMediaSet: function(field, value) {
let me = this;
let vm = me.getViewModel();
vm.set('uuid', value);
me.updateSnapshots();
},
checkValidity: function() { checkValidity: function() {
let me = this; let me = this;
@ -203,10 +215,12 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', {
let me = this; let me = this;
let view = me.getView(); let view = me.getView();
let grid = me.lookup('snapshotGrid'); let grid = me.lookup('snapshotGrid');
let vm = me.getViewModel();
let uuid = vm.get('uuid');
Proxmox.Utils.API2Request({ Proxmox.Utils.API2Request({
waitMsgTarget: view, waitMsgTarget: view,
url: `/tape/media/content?media-set=${view.uuid}`, url: `/tape/media/content?media-set=${uuid}`,
success: function(response, opt) { success: function(response, opt) {
let datastores = {}; let datastores = {};
for (const content of response.result.data) { for (const content of response.result.data) {
@ -229,6 +243,13 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', {
}); });
}, },
init: function(view) {
let me = this;
let vm = me.getViewModel();
vm.set('uuid', view.uuid);
},
control: { control: {
'[isFormField]': { '[isFormField]': {
change: 'checkValidity', change: 'checkValidity',
@ -283,11 +304,29 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', {
}, },
column1: [ column1: [
{
xtype: 'pbsMediaSetSelector',
fieldLabel: gettext('Media-Set'),
width: 350,
submitValue: false,
bind: {
value: '{uuid}',
},
cbind: {
hidden: '{uuid}',
disabled: '{uuid}',
},
listeners: {
change: 'changeMediaSet',
},
},
{ {
xtype: 'displayfield', xtype: 'displayfield',
fieldLabel: gettext('Media-Set'), fieldLabel: gettext('Media-Set'),
cbind: { cbind: {
value: '{mediaset}', value: '{mediaset}',
hidden: '{!uuid}',
disabled: '{!uuid}',
}, },
}, },
], ],
@ -298,8 +337,10 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', {
fieldLabel: gettext('Media-Set UUID'), fieldLabel: gettext('Media-Set UUID'),
name: 'media-set', name: 'media-set',
submitValue: true, submitValue: true,
cbind: { bind: {
value: '{uuid}', value: '{uuid}',
hidden: '{!uuid}',
disabled: '{!uuid}',
}, },
}, },
], ],