public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/4] ui: add GroupSelector
Date: Mon, 22 Nov 2021 15:20:21 +0100	[thread overview]
Message-ID: <20211122142024.913238-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20211122142024.913238-1-d.csapak@proxmox.com>

to select either a local or remote group from a datastore

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/Makefile              |  1 +
 www/form/GroupSelector.js | 83 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 www/form/GroupSelector.js

diff --git a/www/Makefile b/www/Makefile
index 616c3e12..c975387c 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -42,6 +42,7 @@ JSSRC=							\
 	form/DataStoreSelector.js			\
 	form/CalendarEvent.js				\
 	form/PermissionPathSelector.js			\
+	form/GroupSelector.js				\
 	data/RunningTasksStore.js			\
 	button/TaskButton.js				\
 	config/UserView.js				\
diff --git a/www/form/GroupSelector.js b/www/form/GroupSelector.js
new file mode 100644
index 00000000..1e6c1bd4
--- /dev/null
+++ b/www/form/GroupSelector.js
@@ -0,0 +1,83 @@
+Ext.define('pbs-groups', {
+    extend: 'Ext.data.Model',
+    fields: [
+	'backup-type',
+	'backup-id',
+	{
+	    name: 'group',
+	    type: 'string',
+	    convert: function(value, record) {
+		if (record.data['backup-type'] && record.data['backup-id']) {
+		    return `${record.data['backup-type']}/${record.data['backup-id']}`;
+		}
+		return value;
+	    },
+	},
+    ],
+    proxy: {
+	type: 'proxmox',
+    },
+});
+
+Ext.define('PBS.form.GroupSelector', {
+    extend: 'Proxmox.form.ComboGrid',
+    alias: 'widget.pbsGroupSelector',
+
+    allowBlank: false,
+    autoSelect: false,
+    notFoundIsValid: true,
+    editable: true,
+    valueField: 'group',
+    displayField: 'group',
+
+    reload: function() {
+	let me = this;
+	if (!me.isDisabled()) {
+	    let value = me.getValue();
+	    me.getStore().load({
+		callback: function() {
+		    me.setValue(value);
+		},
+	    });
+	}
+    },
+
+    setLocalDatastore: function(datastore) {
+	let me = this;
+	me.getStore().getProxy().setUrl(`/api2/json/admin/datastore/${datastore}/groups`);
+	me.reload();
+    },
+
+    setRemoteDatastore: function(remote, datastore) {
+	let me = this;
+	me.getStore().getProxy().setUrl(`/api2/json/config/remote/${remote}/scan/${datastore}/groups`);
+	me.reload();
+    },
+
+    store: {
+	sorters: 'group',
+	model: 'pbs-groups',
+    },
+
+    listConfig: {
+	columns: [
+	    {
+		header: gettext('Group'),
+		sortable: true,
+		dataIndex: 'group',
+		renderer: Ext.String.htmlEncode,
+		flex: 1,
+	    },
+	],
+    },
+
+    initComponent: function() {
+	let me = this;
+	me.callParent();
+	if (me.remote && me.datastore) {
+	    me.setRemoteDatastore(me.remote, me.datastore);
+	} else if (me.datastore) {
+	    me.setLocalDatastore(me.datastore);
+	}
+    },
+});
-- 
2.30.2





  reply	other threads:[~2021-11-22 14:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22 14:20 [pbs-devel] [PATCH proxmox-backup 0/4] ui for group-filters Dominik Csapak
2021-11-22 14:20 ` Dominik Csapak [this message]
2021-11-22 14:20 ` [pbs-devel] [PATCH proxmox-backup 2/4] ui: add GroupFilter form field(container) Dominik Csapak
2021-11-22 14:20 ` [pbs-devel] [PATCH proxmox-backup 3/4] ui: tape/BackupJobEdit: add second tab with group filters Dominik Csapak
2021-11-22 14:20 ` [pbs-devel] [PATCH proxmox-backup 4/4] ui: SyncJobEdit: " Dominik Csapak
2021-11-24  9:04 ` [pbs-devel] [PATCH proxmox-backup 0/4] ui for group-filters Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211122142024.913238-2-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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