From 3657fa1ff3bf61cf0b8a0995a56c586ce4a734e2 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Thu, 11 Jan 2024 11:40:36 +0100 Subject: [PATCH] ui: tape: add remove media button this only removes media from the inventory, it does not touch the data Signed-off-by: Dominik Csapak --- www/Makefile | 1 + www/tape/TapeInventory.js | 27 ++++++++++++ www/tape/window/MediaRemoveWindow.js | 66 ++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 www/tape/window/MediaRemoveWindow.js diff --git a/www/Makefile b/www/Makefile index be7e27ab..c2755ac8 100644 --- a/www/Makefile +++ b/www/Makefile @@ -21,6 +21,7 @@ TAPE_UI_FILES= \ tape/window/Erase.js \ tape/window/EncryptionEdit.js \ tape/window/LabelMedia.js \ + tape/window/MediaRemoveWindow.js \ tape/window/PoolEdit.js \ tape/window/TapeBackup.js \ tape/window/TapeBackupJob.js \ diff --git a/www/tape/TapeInventory.js b/www/tape/TapeInventory.js index dba36dac..3039a95a 100644 --- a/www/tape/TapeInventory.js +++ b/www/tape/TapeInventory.js @@ -60,6 +60,27 @@ Ext.define('PBS.TapeManagement.TapeInventory', { }).show(); }, + remove: function() { + let me = this; + let view = me.getView(); + let selection = view.getSelection(); + if (!selection || selection.length < 1) { + return; + } + let uuid = selection[0].data.uuid; + let label = selection[0].data['label-text']; + Ext.create('PBS.TapeManagement.MediaRemoveWindow', { + uuid, + label, + autoShow: true, + listeners: { + destroy: function() { + me.reload(); + }, + }, + }); + }, + moveToVault: function() { let me = this; let view = me.getView(); @@ -206,6 +227,12 @@ Ext.define('PBS.TapeManagement.TapeInventory', { disabled: true, handler: 'format', }, + { + xtype: 'proxmoxButton', + text: gettext('Remove'), + disabled: true, + handler: 'remove', + }, ], features: [ diff --git a/www/tape/window/MediaRemoveWindow.js b/www/tape/window/MediaRemoveWindow.js new file mode 100644 index 00000000..0eb3d6be --- /dev/null +++ b/www/tape/window/MediaRemoveWindow.js @@ -0,0 +1,66 @@ +Ext.define('PBS.TapeManagement.MediaRemoveWindow', { + extend: 'Proxmox.window.Edit', + mixins: ['Proxmox.Mixin.CBind'], + + uuid: undefined, + label: undefined, + + cbindData: function(config) { + let me = this; + return { + uuid: me.uuid, + warning: Ext.String.format(gettext("Are you sure you want to remove tape '{0}' ?"), me.label), + }; + }, + + title: gettext('Remove Media'), + url: `/api2/extjs/tape/media/destroy`, + + layout: 'hbox', + width: 400, + method: 'GET', + isCreate: true, + submitText: gettext('Ok'), + items: [ + { + xtype: 'container', + padding: 0, + layout: { + type: 'hbox', + align: 'stretch', + }, + items: [ + { + xtype: 'component', + cls: [Ext.baseCSSPrefix + 'message-box-icon', + Ext.baseCSSPrefix + 'message-box-warning', + Ext.baseCSSPrefix + 'dlg-icon'], + }, + { + xtype: 'container', + flex: 1, + items: [ + { + xtype: 'displayfield', + cbind: { + value: '{warning}', + }, + }, + { + xtype: 'hidden', + name: 'uuid', + cbind: { + value: '{uuid}', + }, + }, + { + xtype: 'proxmoxcheckbox', + fieldLabel: gettext('Force'), + name: 'force', + }, + ], + }, + ], + }, + ], +});