[pbs-devel] [PATCH proxmox-backup v2 05/15] ui: tape: add form fields
Dominik Csapak
d.csapak at proxmox.com
Thu Jan 28 12:59:45 CET 2021
this includes selectors for
* Allocation Policy
* Retention Policy
* Drives
* Changers
* Tape Device Paths
* Pools
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/Makefile | 6 +++
www/tape/form/AllocationSelector.js | 31 ++++++++++++
www/tape/form/ChangerSelector.js | 60 ++++++++++++++++++++++
www/tape/form/DriveSelector.js | 66 +++++++++++++++++++++++++
www/tape/form/PoolSelector.js | 44 +++++++++++++++++
www/tape/form/RetentionSelector.js | 26 ++++++++++
www/tape/form/TapeDevicePathSelector.js | 62 +++++++++++++++++++++++
7 files changed, 295 insertions(+)
create mode 100644 www/tape/form/AllocationSelector.js
create mode 100644 www/tape/form/ChangerSelector.js
create mode 100644 www/tape/form/DriveSelector.js
create mode 100644 www/tape/form/PoolSelector.js
create mode 100644 www/tape/form/RetentionSelector.js
create mode 100644 www/tape/form/TapeDevicePathSelector.js
diff --git a/www/Makefile b/www/Makefile
index c2d80c74..beea80bf 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -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
diff --git a/www/tape/form/AllocationSelector.js b/www/tape/form/AllocationSelector.js
new file mode 100644
index 00000000..ab56c00c
--- /dev/null
+++ b/www/tape/form/AllocationSelector.js
@@ -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',
+ },
+});
+
diff --git a/www/tape/form/ChangerSelector.js b/www/tape/form/ChangerSelector.js
new file mode 100644
index 00000000..cc07580c
--- /dev/null
+++ b/www/tape/form/ChangerSelector.js
@@ -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,
+ },
+ ],
+ },
+});
diff --git a/www/tape/form/DriveSelector.js b/www/tape/form/DriveSelector.js
new file mode 100644
index 00000000..333989a9
--- /dev/null
+++ b/www/tape/form/DriveSelector.js
@@ -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();
+ },
+});
+
diff --git a/www/tape/form/PoolSelector.js b/www/tape/form/PoolSelector.js
new file mode 100644
index 00000000..2a0f0bbb
--- /dev/null
+++ b/www/tape/form/PoolSelector.js
@@ -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',
+ },
+ ],
+ },
+});
+
diff --git a/www/tape/form/RetentionSelector.js b/www/tape/form/RetentionSelector.js
new file mode 100644
index 00000000..4c77d39e
--- /dev/null
+++ b/www/tape/form/RetentionSelector.js
@@ -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',
+ },
+});
+
diff --git a/www/tape/form/TapeDevicePathSelector.js b/www/tape/form/TapeDevicePathSelector.js
new file mode 100644
index 00000000..e458454d
--- /dev/null
+++ b/www/tape/form/TapeDevicePathSelector.js
@@ -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();
+ },
+});
--
2.20.1
More information about the pbs-devel
mailing list