From 80a374908869ce6dd910e0c5cd9a2249368079cf Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Thu, 28 Jan 2021 12:59:46 +0100 Subject: [PATCH] ui: tape: add Edit Windows includes edit windows for * Drives * Changers * Media Pools * Labeling Media * Making new Tape Backups Signed-off-by: Dominik Csapak --- www/Makefile | 5 +++ www/tape/window/ChangerEdit.js | 50 ++++++++++++++++++++++ www/tape/window/DriveEdit.js | 77 ++++++++++++++++++++++++++++++++++ www/tape/window/LabelMedia.js | 47 +++++++++++++++++++++ www/tape/window/PoolEdit.js | 64 ++++++++++++++++++++++++++++ www/tape/window/TapeBackup.js | 43 +++++++++++++++++++ 6 files changed, 286 insertions(+) create mode 100644 www/tape/window/ChangerEdit.js create mode 100644 www/tape/window/DriveEdit.js create mode 100644 www/tape/window/LabelMedia.js create mode 100644 www/tape/window/PoolEdit.js create mode 100644 www/tape/window/TapeBackup.js diff --git a/www/Makefile b/www/Makefile index beea80bf..827633a3 100644 --- a/www/Makefile +++ b/www/Makefile @@ -15,6 +15,11 @@ TAPE_UI_FILES= \ tape/form/PoolSelector.js \ tape/form/RetentionSelector.js \ tape/form/TapeDevicePathSelector.js \ + tape/window/ChangerEdit.js \ + tape/window/DriveEdit.js \ + tape/window/LabelMedia.js \ + tape/window/PoolEdit.js \ + tape/window/TapeBackup.js \ TapeManagement.js endif diff --git a/www/tape/window/ChangerEdit.js b/www/tape/window/ChangerEdit.js new file mode 100644 index 00000000..bb166e50 --- /dev/null +++ b/www/tape/window/ChangerEdit.js @@ -0,0 +1,50 @@ +Ext.define('PBS.TapeManagement.ChangerEditWindow', { + extend: 'Proxmox.window.Edit', + alias: 'widget.pbsChangerEditWindow', + mixins: ['Proxmox.Mixin.CBind'], + + isCreate: true, + isAdd: true, + subject: gettext('Changer'), + cbindData: function(initialConfig) { + let me = this; + + let changerid = initialConfig.changerid; + let baseurl = '/api2/extjs/config/changer'; + + me.isCreate = !changerid; + me.url = changerid ? `${baseurl}/${encodeURIComponent(changerid)}` : baseurl; + me.method = changerid ? 'PUT' : 'POST'; + + return { }; + }, + + items: [ + { + fieldLabel: gettext('Name'), + name: 'name', + xtype: 'pmxDisplayEditField', + renderer: Ext.htmlEncode, + allowBlank: false, + cbind: { + editable: '{isCreate}', + }, + }, + { + fieldLabel: gettext('Path'), + xtype: 'pbsTapeDevicePathSelector', + type: 'changers', + name: 'path', + allowBlank: false, + }, + { + fieldLabel: gettext('Import-Export Slots'), + xtype: 'proxmoxtextfield', + name: 'export-slots', + cbind: { + deleteEmpty: '{!isCreate}', + }, + }, + ], +}); + diff --git a/www/tape/window/DriveEdit.js b/www/tape/window/DriveEdit.js new file mode 100644 index 00000000..5c3c8728 --- /dev/null +++ b/www/tape/window/DriveEdit.js @@ -0,0 +1,77 @@ +Ext.define('PBS.TapeManagement.DriveEditWindow', { + extend: 'Proxmox.window.Edit', + alias: 'widget.pbsDriveEditWindow', + mixins: ['Proxmox.Mixin.CBind'], + + isCreate: true, + isAdd: true, + subject: gettext('Drive'), + cbindData: function(initialConfig) { + let me = this; + + let driveid = initialConfig.driveid; + let baseurl = '/api2/extjs/config/drive'; + + me.isCreate = !driveid; + me.url = driveid ? `${baseurl}/${encodeURIComponent(driveid)}` : baseurl; + me.method = driveid ? 'PUT' : 'POST'; + + return { }; + }, + + items: [ + { + fieldLabel: gettext('Name'), + name: 'name', + xtype: 'pmxDisplayEditField', + renderer: Ext.htmlEncode, + allowBlank: false, + cbind: { + editable: '{isCreate}', + }, + }, + { + fieldLabel: gettext('Changer'), + xtype: 'pbsChangerSelector', + name: 'changer', + skipEmptyText: true, + allowBlank: true, + autoSelect: false, + emptyText: gettext('No Changer'), + cbind: { + deleteEmpty: '{!isCreate}', + }, + listeners: { + change: function(field, value) { + let disableSlotField = !value || value === ''; + console.log(value); + field + .up('window') + .down('field[name=changer-drivenum]') + .setDisabled(disableSlotField); + }, + }, + }, + { + fieldLabel: gettext('Changer Slot'), + xtype: 'proxmoxintegerfield', + name: 'changer-drivenum', + disabled: true, + allowBlank: true, + emptyText: '0', + minValue: 0, + maxValue: 8, + cbind: { + deleteEmpty: '{!isCreate}', + }, + }, + { + fieldLabel: gettext('Path'), + xtype: 'pbsTapeDevicePathSelector', + type: 'drives', + name: 'path', + allowBlank: false, + }, + ], +}); + diff --git a/www/tape/window/LabelMedia.js b/www/tape/window/LabelMedia.js new file mode 100644 index 00000000..ec7fca5d --- /dev/null +++ b/www/tape/window/LabelMedia.js @@ -0,0 +1,47 @@ +Ext.define('PBS.TapeManagement.LabelMediaWindow', { + extend: 'Proxmox.window.Edit', + alias: 'widget.pbsLabelMediaWindow', + mixins: ['Proxmox.Mixin.CBind'], + + isCreate: true, + isAdd: true, + title: gettext('Label Media'), + submitText: gettext('OK'), + + showProgress: true, + + items: [ + { + xtype: 'displayfield', + fieldLabel: gettext('Drive'), + cbind: { + value: '{driveid}', + }, + }, + { + fieldLabel: gettext('Label'), + name: 'label-text', + xtype: 'proxmoxtextfield', + allowBlank: false, + }, + { + xtype: 'pbsMediaPoolSelector', + fieldLabel: gettext('Media Pool'), + name: 'pool', + allowBlank: true, + skipEmptyText: true, + }, + ], + + initComponent: function() { + let me = this; + if (!me.driveid) { + throw "no driveid given"; + } + + let driveid = encodeURIComponent(me.driveid); + me.url = `/api2/extjs/tape/drive/${driveid}/label-media`; + me.callParent(); + }, +}); + diff --git a/www/tape/window/PoolEdit.js b/www/tape/window/PoolEdit.js new file mode 100644 index 00000000..c5148c9d --- /dev/null +++ b/www/tape/window/PoolEdit.js @@ -0,0 +1,64 @@ +Ext.define('PBS.TapeManagement.PoolEditWindow', { + extend: 'Proxmox.window.Edit', + alias: 'widget.pbsPoolEditWindow', + mixins: ['Proxmox.Mixin.CBind'], + + isCreate: true, + isAdd: true, + subject: gettext('Media Pool'), + cbindData: function(initialConfig) { + let me = this; + + let poolid = initialConfig.poolid; + let baseurl = '/api2/extjs/config/media-pool'; + + me.isCreate = !poolid; + me.url = poolid ? `${baseurl}/${encodeURIComponent(poolid)}` : baseurl; + me.method = poolid ? 'PUT' : 'POST'; + + return { }; + }, + + items: [ + { + fieldLabel: gettext('Name'), + name: 'name', + xtype: 'pmxDisplayEditField', + renderer: Ext.htmlEncode, + allowBlank: false, + cbind: { + editable: '{isCreate}', + }, + }, + { + fieldLabel: gettext('Drive'), + xtype: 'pbsDriveSelector', + name: 'drive', + allowBlank: false, + autoSelect: false, + }, + { + fieldLabel: gettext('Allocation'), + xtype: 'pbsAllocationSelector', + name: 'allocation', + skipEmptyText: true, + allowBlank: true, + autoSelect: false, + cbind: { + deleteEmpty: '{!isCreate}', + }, + }, + { + fieldLabel: gettext('Retention'), + xtype: 'pbsRetentionSelector', + name: 'retention', + skipEmptyText: true, + allowBlank: true, + autoSelect: false, + cbind: { + deleteEmpty: '{!isCreate}', + }, + }, + ], +}); + diff --git a/www/tape/window/TapeBackup.js b/www/tape/window/TapeBackup.js new file mode 100644 index 00000000..a3ceacdc --- /dev/null +++ b/www/tape/window/TapeBackup.js @@ -0,0 +1,43 @@ +Ext.define('PBS.TapeManagement.TapeBackupWindow', { + extend: 'Proxmox.window.Edit', + alias: 'pbsTapeBackupWindow', + + subject: gettext('Backup'), + url: '/api2/extjs/tape/backup', + method: 'POST', + showTaskViewer: true, + isCreate: true, + + items: [ + { + xtype: 'pbsDataStoreSelector', + fieldLabel: gettext('Datastore'), + name: 'store', + }, + { + xtype: 'pbsMediaPoolSelector', + fieldLabel: gettext('Media Pool'), + name: 'pool', + }, + { + xtype: 'proxmoxcheckbox', + name: 'export-media-set', + fieldLabel: gettext('Export Media Set'), + listeners: { + change: function(cb, value) { + let me = this; + let eject = me.up('window').down('proxmoxcheckbox[name=eject-media]'); + if (value) { + eject.setValue(false); + } + eject.setDisabled(!!value); + }, + }, + }, + { + xtype: 'proxmoxcheckbox', + name: 'eject-media', + fieldLabel: gettext('Eject Media'), + }, + ], +});