public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager] gui: expose content-dirs property in storage edit/create
@ 2023-06-07 13:32 Leo Nunner
  2023-06-07 13:34 ` Leo Nunner
  0 siblings, 1 reply; 3+ messages in thread
From: Leo Nunner @ 2023-06-07 13:32 UTC (permalink / raw)
  To: pve-devel

Add a separate tab for the storage edit/create panels to set the
recently introduced "content-dirs" property which overrides the
default directory locations. Analogous to the API implementation,
the tab was added for Directory, CIFS and NFS storages.

Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
---
Changes since v3:
    - remove rootdir field
    - only allow setting snippets field for root@pam

 www/manager6/Makefile              |  1 +
 www/manager6/Toolkit.js            |  2 +
 www/manager6/panel/ContentDirs.js  | 91 ++++++++++++++++++++++++++++++
 www/manager6/storage/CIFSEdit.js   |  9 +++
 www/manager6/storage/CephFSEdit.js |  9 +++
 www/manager6/storage/DirEdit.js    |  9 +++
 www/manager6/storage/NFSEdit.js    |  9 +++
 7 files changed, 130 insertions(+)
 create mode 100644 www/manager6/panel/ContentDirs.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 71ab928ff..9fa016d6e 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -96,6 +96,7 @@ JSSRC= 							\
 	panel/GuestSummary.js				\
 	panel/TemplateStatusView.js			\
 	panel/MultiDiskEdit.js				\
+	panel/ContentDirs.js				\
 	tree/ResourceTree.js				\
 	tree/SnapshotTree.js				\
 	window/Backup.js				\
diff --git a/www/manager6/Toolkit.js b/www/manager6/Toolkit.js
index f69c376ad..0c801d453 100644
--- a/www/manager6/Toolkit.js
+++ b/www/manager6/Toolkit.js
@@ -15,6 +15,8 @@ Ext.apply(Ext.form.field.VTypes, {
     IP64AddressListMask: /[A-Fa-f0-9,:.; ]/,
     PciIdText: gettext('Example') + ': 0x8086',
     PciId: v => /^0x[0-9a-fA-F]{4}$/.test(v),
+    ContentDirText: gettext('Example') + ': custom/subdir/location',
+    ContentDir: v => /([^.]*(?:\.?[^.]+)+)/.test(v),
 });
 
 Ext.define('PVE.form.field.Display', {
diff --git a/www/manager6/panel/ContentDirs.js b/www/manager6/panel/ContentDirs.js
new file mode 100644
index 000000000..5168f4f21
--- /dev/null
+++ b/www/manager6/panel/ContentDirs.js
@@ -0,0 +1,91 @@
+Ext.define('PVE.panel.ContentDirsPanel', {
+    extend: 'Proxmox.panel.InputPanel',
+    xtype: 'pveContentDirsTab',
+    mixins: ['Proxmox.Mixin.CBind'],
+
+    onGetValues: function(values) {
+	let me = this;
+	let ret = me.values ?? {};
+	Object.keys(values || {}).forEach(function(name) {
+	    ret[name] = values[name];
+	});
+	return { "content-dirs": PVE.Parser.printPropertyString(ret) };
+    },
+
+    onSetValues: function(values) {
+	let me = this;
+	me.values = values?.["content-dirs"];
+	return me.values;
+    },
+
+    column1: [
+	{
+	    xtype: 'pmxDisplayEditField',
+	    name: 'vztmpl',
+	    fieldLabel: gettext('CT Template'),
+	    allowBlank: true,
+	    emptyText: "template/cache",
+	    vtype: "ContentDir",
+	    editable: true,
+	},
+	{
+	    xtype: 'pmxDisplayEditField',
+	    name: 'iso',
+	    fieldLabel: gettext('ISO Image'),
+	    allowBlank: true,
+	    emptyText: "template/iso",
+	    vtype: "ContentDir",
+	    editable: true,
+	},
+	{
+	    xtype: 'pmxDisplayEditField',
+	    name: 'snippets',
+	    fieldLabel: gettext('Snippets'),
+	    allowBlank: true,
+	    emptyText: "snippets",
+	    vtype: "ContentDir",
+	    editable: Proxmox.UserName === 'root@pam',
+	},
+    ],
+    column2: [
+	{
+	    xtype: 'pmxDisplayEditField',
+	    name: 'backup',
+	    fieldLabel: gettext('Backup Files'),
+	    allowBlank: true,
+	    emptyText: "dump",
+	    vtype: "ContentDir",
+	    cbind: {
+		editable: '{isCreate}',
+	    },
+	},
+	{
+	    xtype: 'pmxDisplayEditField',
+	    name: 'images',
+	    fieldLabel: gettext('Guest Volumes'),
+	    allowBlank: true,
+	    emptyText: "images",
+	    vtype: "ContentDir",
+	    cbind: {
+		editable: '{isCreate}',
+	    },
+	},
+    ],
+    columnT: [
+	{
+	    xtype: 'displayfield',
+	    userCls: 'pmx-hint',
+	    value: gettext('Editing overrides for existing storages might affect guests. Proceed with caution.'),
+	    cbind: {
+		hidden: '{isCreate}',
+	    },
+	},
+    ],
+    columnB: [
+	{
+	    xtype: 'displayfield',
+	    userCls: 'pmx-hint',
+	    value: gettext('Paths are relative to the mountpoint of the storage.'),
+	},
+    ],
+});
diff --git a/www/manager6/storage/CIFSEdit.js b/www/manager6/storage/CIFSEdit.js
index 8040bc858..0b19e6ce1 100644
--- a/www/manager6/storage/CIFSEdit.js
+++ b/www/manager6/storage/CIFSEdit.js
@@ -229,6 +229,15 @@ Ext.define('PVE.storage.CIFSInputPanel', {
 	    },
 	];
 
+	me.extraTabs = [
+	    {
+		xtype: 'pveContentDirsTab',
+		title: gettext("Content Directories"),
+		onlineHelp: me.onlineHelp,
+		isCreate: me.isCreate,
+	    },
+	];
+
 	me.callParent();
     },
 });
diff --git a/www/manager6/storage/CephFSEdit.js b/www/manager6/storage/CephFSEdit.js
index 6a95a00ae..7558a0528 100644
--- a/www/manager6/storage/CephFSEdit.js
+++ b/www/manager6/storage/CephFSEdit.js
@@ -129,6 +129,15 @@ Ext.define('PVE.storage.CephFSInputPanel', {
 	    },
 	];
 
+	me.extraTabs = [
+	    {
+		xtype: 'pveContentDirsTab',
+		title: gettext("Content Directories"),
+		onlineHelp: me.onlineHelp,
+		isCreate: me.isCreate,
+	    },
+	];
+
 	me.callParent();
     },
 });
diff --git a/www/manager6/storage/DirEdit.js b/www/manager6/storage/DirEdit.js
index 7e9ec44dd..d1ae46ccd 100644
--- a/www/manager6/storage/DirEdit.js
+++ b/www/manager6/storage/DirEdit.js
@@ -33,6 +33,15 @@ Ext.define('PVE.storage.DirInputPanel', {
 	    },
 	];
 
+	me.extraTabs = [
+	    {
+		xtype: 'pveContentDirsTab',
+		title: gettext("Content Directories"),
+		onlineHelp: me.onlineHelp,
+		isCreate: me.isCreate,
+	    },
+	];
+
 	me.callParent();
     },
 });
diff --git a/www/manager6/storage/NFSEdit.js b/www/manager6/storage/NFSEdit.js
index 202c7de08..13a17e3bb 100644
--- a/www/manager6/storage/NFSEdit.js
+++ b/www/manager6/storage/NFSEdit.js
@@ -160,6 +160,15 @@ Ext.define('PVE.storage.NFSInputPanel', {
 	    },
 	];
 
+	me.extraTabs = [
+	    {
+		xtype: 'pveContentDirsTab',
+		title: gettext("Content Directories"),
+		onlineHelp: me.onlineHelp,
+		isCreate: me.isCreate,
+	    },
+	];
+
 	me.callParent();
     },
 });
-- 
2.30.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH manager] gui: expose content-dirs property in storage edit/create
  2023-06-07 13:32 [pve-devel] [PATCH manager] gui: expose content-dirs property in storage edit/create Leo Nunner
@ 2023-06-07 13:34 ` Leo Nunner
  0 siblings, 0 replies; 3+ messages in thread
From: Leo Nunner @ 2023-06-07 13:34 UTC (permalink / raw)
  To: pve-devel

…this is v4 of this patch, forgot to put it in the subject prefix, sorry.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pve-devel] [PATCH manager] gui: expose content-dirs property in storage edit/create
@ 2023-02-02 11:32 Leo Nunner
  0 siblings, 0 replies; 3+ messages in thread
From: Leo Nunner @ 2023-02-02 11:32 UTC (permalink / raw)
  To: pve-devel

Add a separate tab for the storage edit/create panels to set the
recently introduced "content-dirs" property which overrides the
default directory locations. Analogous to the API implementation,
the tab was added for Directory, CIFS and NFS storages.

Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
---
RFC: something I noticed is that we actually return the parsed config
for "content-dirs" on GET /storage/{storage}. Should we maybe change
that so that it returns a property string instead, for consistency
reasons?

 www/manager6/storage/CIFSEdit.js |  8 +++
 www/manager6/storage/DirEdit.js  | 85 ++++++++++++++++++++++++++++++++
 www/manager6/storage/NFSEdit.js  |  8 +++
 3 files changed, 101 insertions(+)

diff --git a/www/manager6/storage/CIFSEdit.js b/www/manager6/storage/CIFSEdit.js
index 71415401..c909ccf2 100644
--- a/www/manager6/storage/CIFSEdit.js
+++ b/www/manager6/storage/CIFSEdit.js
@@ -218,6 +218,14 @@ Ext.define('PVE.storage.CIFSInputPanel', {
 	    },
 	];
 
+	me.extraTabs = [
+	    {
+		xtype: 'pveContentDirsTab',
+		title: gettext("Content Directories"),
+		onlineHelp: me.onlineHelp,
+	    },
+	];
+
 	me.callParent();
     },
 });
diff --git a/www/manager6/storage/DirEdit.js b/www/manager6/storage/DirEdit.js
index 7e9ec44d..3d036589 100644
--- a/www/manager6/storage/DirEdit.js
+++ b/www/manager6/storage/DirEdit.js
@@ -33,6 +33,91 @@ Ext.define('PVE.storage.DirInputPanel', {
 	    },
 	];
 
+	me.extraTabs = [
+	    {
+		xtype: 'pveContentDirsTab',
+		title: gettext("Content Directories"),
+		onlineHelp: me.onlineHelp,
+	    },
+	];
+
+	me.callParent();
+    },
+});
+
+Ext.define('PVE.panel.ContentDirsPanel', {
+    extend: 'Proxmox.panel.InputPanel',
+    xtype: 'pveContentDirsTab',
+
+    onGetValues: function(form) {
+	let str = PVE.Parser.printPropertyString(form);
+	let values = { "content-dirs": str };
+	return values;
+    },
+
+    onSetValues: function(values) {
+	return values?.["content-dirs"];
+    },
+
+    initComponent: function() {
+	let me = this;
+
+	me.column1 = [
+	    {
+		xtype: 'textfield',
+		name: 'images',
+		fieldLabel: gettext('Disk image'),
+		allowBlank: true,
+		emptyText: "/images/",
+	    },
+	    {
+		xtype: 'textfield',
+		name: 'iso',
+		fieldLabel: gettext('ISO image'),
+		allowBlank: true,
+		emptyText: "/template/iso/",
+	    },
+	    {
+		xtype: 'textfield',
+		name: 'vztmpl',
+		fieldLabel: gettext('CT template'),
+		allowBlank: true,
+		emptyText: "/template/cache/",
+	    },
+	];
+
+	me.column2 = [
+	    {
+		xtype: 'textfield',
+		name: 'backup',
+		fieldLabel: gettext('Backup files'),
+		allowBlank: true,
+		emptyText: "/dump/",
+	    },
+	    {
+		xtype: 'textfield',
+		name: 'rootdir',
+		fieldLabel: gettext('Container'),
+		allowBlank: true,
+		emptyText: "/private/",
+	    },
+	    {
+		xtype: 'textfield',
+		name: 'snippets',
+		fieldLabel: gettext('Snippets'),
+		allowBlank: true,
+		emptyText: "/snippets/",
+	    },
+	];
+
+	me.columnB = [
+	    {
+		xtype: 'displayfield',
+		userCls: 'pmx-hint',
+		value: gettext('Paths are relative to the mountpoint of the storage'),
+	    },
+	];
+
 	me.callParent();
     },
 });
diff --git a/www/manager6/storage/NFSEdit.js b/www/manager6/storage/NFSEdit.js
index 202c7de0..606e1c02 100644
--- a/www/manager6/storage/NFSEdit.js
+++ b/www/manager6/storage/NFSEdit.js
@@ -160,6 +160,14 @@ Ext.define('PVE.storage.NFSInputPanel', {
 	    },
 	];
 
+	me.extraTabs = [
+	    {
+		xtype: 'pveContentDirsTab',
+		title: gettext("Content Directories"),
+		onlineHelp: me.onlineHelp,
+	    },
+	];
+
 	me.callParent();
     },
 });
-- 
2.30.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-07 13:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-07 13:32 [pve-devel] [PATCH manager] gui: expose content-dirs property in storage edit/create Leo Nunner
2023-06-07 13:34 ` Leo Nunner
  -- strict thread matches above, loose matches on Subject: below --
2023-02-02 11:32 Leo Nunner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal