ui: tape: add Edit Windows

includes edit windows for
* Drives
* Changers
* Media Pools
* Labeling Media
* Making new Tape Backups

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-01-28 12:59:46 +01:00 committed by Dietmar Maurer
parent c72fdb53ae
commit 80a3749088
6 changed files with 286 additions and 0 deletions

View File

@ -15,6 +15,11 @@ TAPE_UI_FILES= \
tape/form/PoolSelector.js \ tape/form/PoolSelector.js \
tape/form/RetentionSelector.js \ tape/form/RetentionSelector.js \
tape/form/TapeDevicePathSelector.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 TapeManagement.js
endif endif

View File

@ -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}',
},
},
],
});

View File

@ -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,
},
],
});

View File

@ -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();
},
});

View File

@ -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}',
},
},
],
});

View File

@ -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'),
},
],
});