From 8a73ef897a6fb7dc1feef31a4621f83bd3a94e21 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 16 Feb 2021 09:35:25 +0100 Subject: [PATCH] ui: tape/TapeInventory: add erase button to erase the selected tape Signed-off-by: Dominik Csapak --- www/tape/TapeInventory.js | 56 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/www/tape/TapeInventory.js b/www/tape/TapeInventory.js index 25dea1ba..ec10f5c9 100644 --- a/www/tape/TapeInventory.js +++ b/www/tape/TapeInventory.js @@ -33,6 +33,56 @@ Ext.define('PBS.TapeManagement.TapeInventory', { Ext.create('PBS.TapeManagement.LabelMediaWindow').show(); }, + erase: function() { + let me = this; + let view = me.getView(); + let selection = view.getSelection(); + if (!selection || selection.length < 1) { + return; + } + let label = selection[0].data['label-text']; + Ext.create('Proxmox.window.Edit', { + title: gettext('Erase'), + url: `/api2/extjs/tape/drive`, + showProgress: true, + submitUrl: function(url, values) { + let drive = values.drive; + delete values.drive; + return `${url}/${drive}/erase-media`; + }, + method: 'POST', + items: [ + { + xtype: 'displayfield', + cls: 'pmx-hint', + value: gettext('Make sure to insert the tape into the selected drive.'), + }, + { + xtype: 'pbsDriveSelector', + fieldLabel: gettext('Drive'), + name: 'drive', + }, + { + xtype: 'displayfield', + name: 'label-text', + value: label, + submitValue: true, + fieldLabel: gettext('Media'), + }, + { + xtype: 'proxmoxcheckbox', + fieldLabel: gettext('Fast Erase'), + name: 'fast', + }, + ], + listeners: { + destroy: function() { + me.reload(); + }, + }, + }).show(); + }, + moveToVault: function() { let me = this; let view = me.getView(); @@ -107,6 +157,12 @@ Ext.define('PBS.TapeManagement.TapeInventory', { handler: 'moveToVault', enableFn: (rec) => !rec.data.location.startsWith('online-'), }, + { + xtype: 'proxmoxButton', + text: gettext('Erase'), + disabled: true, + handler: 'erase', + }, ], columns: [