From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id EDC796BED4
 for <pbs-devel@lists.proxmox.com>; Thu, 28 Jan 2021 13:00:06 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 690762D343
 for <pbs-devel@lists.proxmox.com>; Thu, 28 Jan 2021 13:00:05 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 02A9E2D242
 for <pbs-devel@lists.proxmox.com>; Thu, 28 Jan 2021 12:59:58 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C17ED4614E
 for <pbs-devel@lists.proxmox.com>; Thu, 28 Jan 2021 12:59:57 +0100 (CET)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Thu, 28 Jan 2021 12:59:45 +0100
Message-Id: <20210128115955.23136-6-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20210128115955.23136-1-d.csapak@proxmox.com>
References: <20210128115955.23136-1-d.csapak@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.245 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [me.store]
Subject: [pbs-devel] [PATCH proxmox-backup v2 05/15] ui: tape: add form
 fields
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Thu, 28 Jan 2021 12:00:07 -0000

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

Signed-off-by: Dominik Csapak <d.csapak@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