ui: tape/DriveStatus: add label/eject/catalog buttons

and enable them only if the status says that a tape is inserted.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-03-01 14:10:32 +01:00 committed by Dietmar Maurer
parent d938c9337a
commit 41f1132e0e
1 changed files with 94 additions and 0 deletions

View File

@ -15,6 +15,12 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
bodyPadding: 5, bodyPadding: 5,
viewModel: {
data: {
online: false,
},
},
controller: { controller: {
xclass: 'Ext.app.ViewController', xclass: 'Ext.app.ViewController',
@ -22,6 +28,63 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
let me = this; let me = this;
me.lookup('statusgrid').rstore.load(); me.lookup('statusgrid').rstore.load();
}, },
onLoad: function() {
let me = this;
let statusgrid = me.lookup('statusgrid');
let statusFlags = (statusgrid.getObjectValue('status') || "").split(/\s+|\s+/);
let online = statusFlags.indexOf('ONLINE') !== -1;
let vm = me.getViewModel();
vm.set('online', online);
},
labelMedia: function() {
let me = this;
Ext.create('PBS.TapeManagement.LabelMediaWindow', {
driveid: me.getView().drive,
}).show();
},
eject: function() {
let me = this;
let view = me.getView();
let driveid = view.drive;
PBS.Utils.driveCommand(driveid, 'eject-media', {
waitMsgTarget: view,
method: 'POST',
success: function(response) {
Ext.create('Proxmox.window.TaskProgress', {
upid: response.result.data,
taskDone: function() {
me.reload();
},
}).show();
},
});
},
catalog: function() {
let me = this;
let view = me.getView();
let drive = view.drive;
PBS.Utils.driveCommand(drive, 'catalog', {
waitMsgTarget: view,
method: 'POST',
success: function(response) {
Ext.create('Proxmox.window.TaskViewer', {
upid: response.result.data,
taskDone: function() {
me.reload();
},
}).show();
},
});
},
init: function(view) {
let me = this;
me.mon(me.lookup('statusgrid').getStore().rstore, 'load', 'onLoad');
},
}, },
listeners: { listeners: {
@ -34,6 +97,37 @@ Ext.define('PBS.TapeManagement.DriveStatus', {
handler: 'reload', handler: 'reload',
text: gettext('Reload'), text: gettext('Reload'),
}, },
'-',
{
text: gettext('Label Media'),
xtype: 'proxmoxButton',
handler: 'labelMedia',
iconCls: 'fa fa-barcode',
disabled: true,
bind: {
disabled: '{!online}',
},
},
{
text: gettext('Eject'),
xtype: 'proxmoxButton',
handler: 'ejectMedia',
iconCls: 'fa fa-eject',
disabled: true,
bind: {
disabled: '{!online}',
},
},
{
text: gettext('Catalog'),
xtype: 'proxmoxButton',
handler: 'catalog',
iconCls: 'fa fa-book',
disabled: true,
bind: {
disabled: '{!online}',
},
},
], ],
items: [ items: [