From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 4/4] ui: add Realm Sync panel
Date: Mon, 4 Apr 2022 10:54:16 +0200 [thread overview]
Message-ID: <20220404085416.1761268-6-d.csapak@proxmox.com> (raw)
In-Reply-To: <20220404085416.1761268-1-d.csapak@proxmox.com>
a typical CRUD panel for adding/editing/removing realm sync jobs
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
www/manager6/Makefile | 1 +
www/manager6/dc/Config.js | 7 +
www/manager6/dc/RealmSyncJob.js | 315 ++++++++++++++++++++++++++++++++
3 files changed, 323 insertions(+)
create mode 100644 www/manager6/dc/RealmSyncJob.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index e6e01bd1..7fcdb563 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -159,6 +159,7 @@ JSSRC= \
dc/UserEdit.js \
dc/UserView.js \
dc/MetricServerView.js \
+ dc/RealmSyncJob.js \
lxc/CmdMenu.js \
lxc/Config.js \
lxc/CreateWizard.js \
diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js
index 9c54b19d..1f92cb0e 100644
--- a/www/manager6/dc/Config.js
+++ b/www/manager6/dc/Config.js
@@ -140,6 +140,13 @@ Ext.define('PVE.dc.Config', {
iconCls: 'fa fa-address-book-o',
itemId: 'domains',
},
+ {
+ xtype: 'pveRealmSyncJobView',
+ title: gettext('Realm Sync'),
+ groups: ['permissions'],
+ iconCls: 'fa fa-refresh',
+ itemId: 'realmsyncjobs',
+ },
{
xtype: 'pveHAStatus',
title: 'HA',
diff --git a/www/manager6/dc/RealmSyncJob.js b/www/manager6/dc/RealmSyncJob.js
new file mode 100644
index 00000000..4ac61745
--- /dev/null
+++ b/www/manager6/dc/RealmSyncJob.js
@@ -0,0 +1,315 @@
+Ext.define('PVE.dc.RealmSyncJobView', {
+ extend: 'Ext.grid.Panel',
+ alias: 'widget.pveRealmSyncJobView',
+
+ stateful: true,
+ stateId: 'grid-realmsyncjobs',
+
+ controller: {
+ xclass: 'Ext.app.ViewController',
+
+ addRealmSyncJob: function(button) {
+ let me = this;
+ Ext.create(`PVE.dc.RealmSyncJobEdit`, {
+ autoShow: true,
+ listeners: {
+ destroy: () => me.reload(),
+ },
+ });
+ },
+
+ editRealmSyncJob: function() {
+ let me = this;
+ let view = me.getView();
+ let selection = view.getSelection();
+ if (!selection || selection.length < 1) {
+ return;
+ }
+
+ Ext.create(`PVE.dc.RealmSyncJobEdit`, {
+ jobid: selection[0].data.id,
+ autoShow: true,
+ listeners: {
+ destroy: () => me.reload(),
+ },
+ });
+ },
+
+ reload: function() {
+ this.getView().getStore().load();
+ },
+ },
+
+ store: {
+ autoLoad: true,
+ id: 'metricservers',
+ proxy: {
+ type: 'proxmox',
+ url: '/api2/json/access/domainsyncjobs',
+ },
+ },
+
+ columns: [
+ {
+ header: gettext('Enabled'),
+ width: 80,
+ dataIndex: 'enabled',
+ xtype: 'checkcolumn',
+ sortable: true,
+ disabled: true,
+ disabledCls: 'x-item-enabled',
+ stopSelection: false,
+ },
+ {
+ text: gettext('Name'),
+ flex: 1,
+ dataIndex: 'id',
+ },
+ {
+ header: gettext('Node'),
+ width: 100,
+ sortable: true,
+ dataIndex: 'node',
+ renderer: function(value) {
+ if (value) {
+ return value;
+ }
+ return gettext('Any');
+ },
+ },
+ {
+ text: gettext('Realm'),
+ width: 200,
+ dataIndex: 'realm',
+ },
+ {
+ header: gettext('Schedule'),
+ width: 150,
+ dataIndex: 'schedule',
+ },
+ {
+ text: gettext('Next Run'),
+ dataIndex: 'next-run',
+ width: 150,
+ renderer: PVE.Utils.render_next_event,
+ },
+ {
+ header: gettext('Comment'),
+ dataIndex: 'comment',
+ renderer: Ext.htmlEncode,
+ sorter: (a, b) => (a.data.comment || '').localeCompare(b.data.comment || ''),
+ flex: 1,
+ },
+ ],
+
+ tbar: [
+ {
+ text: gettext('Add'),
+ handler: 'addRealmSyncJob',
+ },
+ {
+ text: gettext('Edit'),
+ xtype: 'proxmoxButton',
+ handler: 'editRealmSyncJob',
+ disabled: true,
+ },
+ {
+ xtype: 'proxmoxStdRemoveButton',
+ baseurl: `/api2/extjs/access/domainsyncjobs`,
+ callback: 'reload',
+ },
+ ],
+
+ listeners: {
+ itemdblclick: 'editRealmSyncJob',
+ },
+
+ initComponent: function() {
+ var me = this;
+
+ me.callParent();
+
+ Proxmox.Utils.monStoreErrors(me, me.getStore());
+ },
+});
+
+Ext.define('PVE.dc.RealmSyncJobEdit', {
+ extend: 'Proxmox.window.Edit',
+ mixins: ['Proxmox.Mixin.CBind'],
+
+ subject: gettext('Realm Sync Job'),
+ onlineHelp: 'pveum_ldap_sync',
+
+ // don't focus the schedule field on edit
+ defaultFocus: 'field[name=id]',
+
+ cbindData: function() {
+ let me = this;
+ me.isCreate = !me.jobid;
+ me.jobid = me.jobid || "";
+ me.url = `/api2/extjs/access/domainsyncjobs/${me.jobid}`;
+ me.method = me.isCreate ? 'POST' : 'PUT';
+ if (!me.isCreate) {
+ me.subject = `${me.subject}: ${me.jobid}`;
+ }
+ return {};
+ },
+
+ submitUrl: function(url, values) {
+ return this.isCreate ? `${url}/${values.id}` : url;
+ },
+
+ items: [
+ {
+ xtype: 'inputpanel',
+
+ onGetValues: function(values) {
+ let me = this;
+
+ let vanished_opts = [];
+ ['acl', 'entry', 'properties'].forEach((prop) => {
+ if (values[`remove-vanished-${prop}`]) {
+ vanished_opts.push(prop);
+ }
+ delete values[`remove-vanished-${prop}`];
+ });
+
+ values['remove-vanished'] = vanished_opts.join(';');
+ PVE.Utils.delete_if_default(values, 'remove-vanished', '');
+
+ if (me.isCreate) {
+ delete values.delete; // on create we cannot delete values
+ }
+
+ return values;
+ },
+
+ column1: [
+ {
+ xtype: 'pmxDisplayEditField',
+ name: 'id',
+ fieldLabel: gettext('Name'),
+ allowBlank: false,
+ cbind: {
+ editable: '{isCreate}',
+ value: '{jobid}',
+ },
+ },
+ {
+ xtype: 'pveCalendarEvent',
+ fieldLabel: gettext('Schedule'),
+ allowBlank: false,
+ name: 'schedule',
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ fieldLabel: gettext('Enable'),
+ name: 'enabled',
+ uncheckedValue: 0,
+ defaultValue: 1,
+ checked: true,
+ },
+ ],
+
+ column2: [
+ {
+ xtype: 'pmxDisplayEditField',
+ editConfig: {
+ xtype: 'pmxRealmComboBox',
+ },
+ cbind: {
+ editable: '{isCreate}',
+ },
+ fieldLabel: gettext('Realm'),
+ name: 'realm',
+ },
+ {
+ xtype: 'proxmoxKVComboBox',
+ name: 'scope',
+ fieldLabel: gettext('Scope'),
+ value: '',
+ emptyText: gettext('No default available'),
+ deleteEmpty: false,
+ allowBlank: false,
+ comboItems: [
+ ['users', gettext('Users')],
+ ['groups', gettext('Groups')],
+ ['both', gettext('Users and Groups')],
+ ],
+ },
+ {
+ xtype: 'proxmoxKVComboBox',
+ value: '1',
+ deleteEmpty: false,
+ allowBlank: false,
+ comboItems: [
+ ['1', Proxmox.Utils.yesText],
+ ['0', Proxmox.Utils.noText],
+ ],
+ name: 'enable-new',
+ fieldLabel: gettext('Enable new'),
+ },
+ ],
+
+ columnB: [
+ {
+ xtype: 'proxmoxtextfield',
+ name: 'comment',
+ fieldLabel: gettext('Comment'),
+ cbind: {
+ deleteEmpty: '{!isCreate}',
+ },
+ },
+ {
+ xtype: 'displayfield',
+ value: gettext('Remove Vanished'),
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ fieldLabel: gettext('ACL'),
+ name: 'remove-vanished-acl',
+ boxLabel: gettext('Remove ACLs of users and groups which are not in the sync response.'),
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ fieldLabel: gettext('Entry'),
+ name: 'remove-vanished-entry',
+ boxLabel: gettext('Remove users and groups that are not in the sync response.'),
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ fieldLabel: gettext('Properties'),
+ name: 'remove-vanished-properties',
+ boxLabel: gettext('Remove user-properties that are not in the sync response.'),
+ },
+ {
+ xtype: 'displayfield',
+ reference: 'defaulthint',
+ value: gettext('Default sync options can be set by editing the realm.'),
+ userCls: 'pmx-hint',
+ hidden: true,
+ },
+ ],
+ },
+ ],
+
+ initComponent: function() {
+ let me = this;
+ me.callParent();
+ if (me.jobid) {
+ me.load({
+ success: function(response, options) {
+ let values = response.result.data;
+
+ if (values['remove-vanished']) {
+ let opts = values['remove-vanished'].split(';');
+ for (const opt of opts) {
+ values[`remove-vanished-${opt}`] = 1;
+ }
+ }
+ me.down('inputpanel').setValues(values);
+ },
+ });
+ }
+ },
+});
--
2.30.2
prev parent reply other threads:[~2022-04-04 8:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-04 8:54 [pve-devel] [PATCH access-control/manager] add realm sync jobs Dominik Csapak
2022-04-04 8:54 ` [pve-devel] [PATCH access-control 1/1] add realmsync plugin for jobs and CRUD api for domainsync-jobs Dominik Csapak
2022-11-07 17:05 ` Thomas Lamprecht
2022-11-08 8:20 ` Dominik Csapak
2022-11-08 9:24 ` Thomas Lamprecht
2022-11-08 10:36 ` Wolfgang Bumiller
2022-04-04 8:54 ` [pve-devel] [PATCH manager 1/4] Jobs: provide id and schedule to the job Dominik Csapak
2022-11-07 16:14 ` [pve-devel] applied: " Thomas Lamprecht
2022-04-04 8:54 ` [pve-devel] [PATCH manager 2/4] Jobs/Plugin: remove 'vzdump' from id description Dominik Csapak
2022-11-07 16:14 ` [pve-devel] applied: " Thomas Lamprecht
2022-04-04 8:54 ` [pve-devel] [PATCH manager 3/4] Jobs: add RealmSync Plugin and register it Dominik Csapak
2022-11-07 16:14 ` [pve-devel] applied: " Thomas Lamprecht
2022-11-07 16:15 ` Thomas Lamprecht
2022-04-04 8:54 ` Dominik Csapak [this message]
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=20220404085416.1761268-6-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.