ui: tape: add form fields

this includes selectors for
* Allocation Policy
* Retention Policy
* Drives
* Changers
* Tape Device Paths
* Pools

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

View File

@ -9,6 +9,12 @@ TAPE_UI_FILES=
ifdef TEST_TAPE_GUI
TAPE_UI_FILES= \
tape/form/AllocationSelector.js \
tape/form/ChangerSelector.js \
tape/form/DriveSelector.js \
tape/form/PoolSelector.js \
tape/form/RetentionSelector.js \
tape/form/TapeDevicePathSelector.js \
TapeManagement.js
endif

View File

@ -0,0 +1,31 @@
Ext.define('PBS.TapeManagement.AllocationStore', {
extend: 'Ext.data.Store',
alias: 'store.allocationCalendarEventStore',
field: ['value', 'text'],
data: [
{ value: 'continue', text: gettext('Continue') },
{ value: 'always', text: gettext('Always') },
{ value: '*:0/30', text: Ext.String.format(gettext("Every {0} minutes"), 30) },
{ value: 'hourly', text: gettext("Every hour") },
{ value: '0/2:00', text: gettext("Every two hours") },
{ value: '2,22:30', text: gettext("Every day") + " 02:30, 22:30" },
{ value: 'daily', text: gettext("Every day") + " 00:00" },
{ value: 'mon..fri', text: gettext("Monday to Friday") + " 00:00" },
{ value: 'mon..fri *:00', text: gettext("Monday to Friday") + ', ' + gettext("hourly") },
{ value: 'sat 18:15', text: gettext("Every Saturday") + " 18:15" },
{ value: 'monthly', text: gettext("Every first day of the Month") + " 00:00" },
{ value: 'sat *-1..7 02:00', text: gettext("Every first Saturday of the month") + " 02:00" },
{ value: 'yearly', text: gettext("First day of the year") + " 00:00" },
],
});
Ext.define('PBS.TapeManagement.AllocationSelector', {
extend: 'PBS.form.CalendarEvent',
alias: 'widget.pbsAllocationSelector',
store: {
type: 'allocationCalendarEventStore',
},
});

View File

@ -0,0 +1,60 @@
Ext.define('PBS.form.ChangerSelector', {
extend: 'Proxmox.form.ComboGrid',
alias: 'widget.pbsChangerSelector',
allowBlank: false,
displayField: 'name',
valueField: 'name',
value: null,
multiSelect: false,
store: {
proxy: {
type: 'proxmox',
url: '/api2/json/tape/changer',
},
autoLoad: true,
sorter: 'name',
},
listConfig: {
columns: [
{
text: gettext('Name'),
dataIndex: 'name',
sortable: true,
flex: 1,
renderer: Ext.String.htmlEncode,
},
{
text: gettext('Path'),
sortable: true,
dataIndex: 'path',
hidden: true,
flex: 1,
},
{
text: gettext('Vendor'),
dataIndex: 'vendor',
sortable: true,
flex: 1,
renderer: Ext.String.htmlEncode,
},
{
text: gettext('Model'),
dataIndex: 'model',
sortable: true,
flex: 1,
renderer: Ext.String.htmlEncode,
},
{
text: gettext('Serial'),
dataIndex: 'serial',
sortable: true,
flex: 1,
renderer: Ext.String.htmlEncode,
},
],
},
});

View File

@ -0,0 +1,66 @@
Ext.define('PBS.form.DriveSelector', {
extend: 'Proxmox.form.ComboGrid',
alias: 'widget.pbsDriveSelector',
allowBlank: false,
displayField: 'name',
valueField: 'name',
value: null,
store: {
proxy: {
type: 'proxmox',
url: '/api2/json/tape/drive',
},
autoLoad: true,
sorters: 'name',
},
listConfig: {
columns: [
{
text: gettext('Name'),
dataIndex: 'name',
sortable: true,
flex: 1,
renderer: Ext.String.htmlEncode,
},
{
text: gettext('Vendor'),
dataIndex: 'vendor',
sortable: true,
flex: 1,
renderer: Ext.String.htmlEncode,
},
{
text: gettext('Model'),
dataIndex: 'model',
sortable: true,
flex: 1,
renderer: Ext.String.htmlEncode,
},
{
text: gettext('Serial'),
dataIndex: 'serial',
sortable: true,
flex: 1,
renderer: Ext.String.htmlEncode,
},
],
},
initComponent: function() {
let me = this;
if (me.changer) {
me.store.proxy.extraParams = {
changer: me.changer,
};
} else {
me.store.proxy.extraParams = {};
}
me.callParent();
},
});

View File

@ -0,0 +1,44 @@
Ext.define('PBS.TapeManagement.PoolSelector', {
extend: 'Proxmox.form.ComboGrid',
alias: 'widget.pbsMediaPoolSelector',
allowBlank: false,
displayField: 'name',
valueField: 'name',
autoSelect: false,
store: {
proxy: {
type: 'proxmox',
url: '/api2/json/config/media-pool',
},
autoLoad: true,
sorters: 'name',
},
listConfig: {
columns: [
{
text: gettext('Name'),
dataIndex: 'name',
},
{
text: gettext('Drive'),
dataIndex: 'drive',
},
{
text: gettext('Allocation'),
dataIndex: 'allocation',
},
{
text: gettext('Retention'),
dataIndex: 'retention',
},
{
text: gettext('Encryption Fingerprint'),
dataIndex: 'encryption',
},
],
},
});

View File

@ -0,0 +1,26 @@
Ext.define('PBS.TapeManagement.RetentionStore', {
extend: 'Ext.data.Store',
alias: 'store.retentionCalendarEventStore',
field: ['value', 'text'],
data: [
{ value: 'overwrite', text: gettext('Overwrite') },
{ value: 'keep', text: gettext('Keep') },
{ value: '120 minutes', text: Ext.String.format(gettext("{0} minutes"), 120) },
{ value: '12 hours', text: Ext.String.format(gettext("{0} hours"), 12) },
{ value: '7 days', text: Ext.String.format(gettext("{0} days"), 7) },
{ value: '4 weeks', text: Ext.String.format(gettext("{0} weeks"), 4) },
{ value: '6 months', text: Ext.String.format(gettext("{0} months"), 6) },
{ value: '2 years', text: Ext.String.format(gettext("{0} years"), 2) },
],
});
Ext.define('PBS.TapeManagement.RetentionSelector', {
extend: 'PBS.form.CalendarEvent',
alias: 'widget.pbsRetentionSelector',
store: {
type: 'retentionCalendarEventStore',
},
});

View File

@ -0,0 +1,62 @@
Ext.define('PBS.form.TapeDevicePathSelector', {
extend: 'Proxmox.form.ComboGrid',
alias: 'widget.pbsTapeDevicePathSelector',
allowBlank: false,
displayField: 'path',
valueField: 'path',
// type can be 'drives' or 'changers'
type: 'drives',
listConfig: {
columns: [
{
text: gettext('Path'),
dataIndex: 'path',
sortable: true,
flex: 1,
renderer: Ext.String.htmlEncode,
},
{
text: gettext('Vendor'),
dataIndex: 'vendor',
sortable: true,
flex: 1,
renderer: Ext.String.htmlEncode,
},
{
text: gettext('Model'),
dataIndex: 'model',
sortable: true,
flex: 1,
renderer: Ext.String.htmlEncode,
},
{
text: gettext('Serial'),
dataIndex: 'serial',
sortable: true,
flex: 1,
renderer: Ext.String.htmlEncode,
},
],
},
initComponent: function() {
let me = this;
if (me.type !== 'drives' && me.type !== 'changers') {
throw `invalid type '${me.type}'`;
}
let url = `/api2/json/tape/scan-${me.type}`;
me.store = {
proxy: {
type: 'proxmox',
url,
},
autoLoad: true,
};
me.callParent();
},
});