opens a window with the parameters for the sync and two buttons:
'preview' and 'sync'

both open the taskviewer, but the 'preview' one sets the 'no-write'
parameter so that it does not get written out to the user.cfg

Signed-off-by: Dominik Csapak <d.csa...@proxmox.com>
---
 www/manager6/Makefile         |   1 +
 www/manager6/dc/AuthView.js   |  21 ++++++
 www/manager6/dc/SyncWindow.js | 125 ++++++++++++++++++++++++++++++++++
 3 files changed, 147 insertions(+)
 create mode 100644 www/manager6/dc/SyncWindow.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index a06d349c..67f81b20 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -232,6 +232,7 @@ JSSRC=                                                      
\
        dc/RoleView.js                                  \
        dc/RoleEdit.js                                  \
        dc/ACLView.js                                   \
+       dc/SyncWindow.js                                \
        dc/AuthView.js                                  \
        dc/AuthEditBase.js                              \
        dc/AuthEditAD.js                                \
diff --git a/www/manager6/dc/AuthView.js b/www/manager6/dc/AuthView.js
index a2486fef..3e5a8517 100644
--- a/www/manager6/dc/AuthView.js
+++ b/www/manager6/dc/AuthView.js
@@ -73,6 +73,19 @@ Ext.define('PVE.dc.AuthView', {
        me.openEditWindow(rec.data.type, rec.data.realm);
     },
 
+    open_sync_window: function() {
+       let me = this;
+       let rec = me.getSelection()[0];
+       if (!rec) {
+           return;
+       }
+       Ext.create('PVE.dc.SyncWindow', {
+           realm: rec.data.realm,
+           listeners: {
+               destroy: () => me.reload(),
+           },
+       }).show();
+    },
 
     initComponent: function() {
        var me = this;
@@ -107,6 +120,14 @@ Ext.define('PVE.dc.AuthView', {
                    enableFn: (rec) => PVE.Utils.authSchema[rec.data.type].add,
                    callback: () => me.reload(),
                },
+               '-',
+               {
+                   xtype: 'proxmoxButton',
+                   text: gettext('Sync'),
+                   disabled: true,
+                   enableFn: (rec) => 
Boolean(PVE.Utils.authSchema[rec.data.type].syncipanel),
+                   handler: () => me.open_sync_window(),
+               },
            ],
            listeners: {
                activate: () => me.reload(),
diff --git a/www/manager6/dc/SyncWindow.js b/www/manager6/dc/SyncWindow.js
new file mode 100644
index 00000000..21d4fbfb
--- /dev/null
+++ b/www/manager6/dc/SyncWindow.js
@@ -0,0 +1,125 @@
+Ext.define('PVE.dc.SyncWindow', {
+    extend: 'Ext.window.Window',
+
+    title: gettext('Realm Sync'),
+
+    bodyPadding: 10,
+    modal: true,
+    resizable: false,
+
+    sync_realm: function(is_preview) {
+       let me = this;
+       let ipanel = me.down('inputpanel');
+       let params = ipanel.getValues();
+       params['no-write'] = is_preview ? 1 : 0;
+       Proxmox.Utils.API2Request({
+           url: `/access/domains/${me.realm}/sync`,
+           waitMsgTarget: me,
+           method: 'POST',
+           params,
+           failure: function(response) {
+               me.show();
+               Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+           },
+           success: function(response) {
+               me.hide();
+               Ext.create('Proxmox.window.TaskViewer', {
+                   upid: response.result.data,
+                   listeners: {
+                       destroy: function() {
+                           me.close();
+                       },
+                   },
+               }).show();
+           },
+       });
+    },
+
+    items: [
+       {
+           xtype: 'inputpanel',
+           column1: [
+               {
+                   xtype: 'proxmoxKVComboBox',
+                   name: 'scope',
+                   fieldLabel: gettext('Scope'),
+                   value: '__default__',
+                   deleteEmpty: false,
+                   comboItems: [
+                       ['__default__', Proxmox.Utils.defaultText],
+                       ['users', gettext('Users')],
+                       ['groups', gettext('Groups')],
+                       ['both', gettext('Users and Groups')],
+                   ],
+               },
+               {
+                   xtype: 'proxmoxKVComboBox',
+                   value: '__default__',
+                   deleteEmpty: false,
+                   comboItems: [
+                       ['__default__', Proxmox.Utils.defaultText],
+                       ['1', Proxmox.Utils.yesText],
+                       ['0', Proxmox.Utils.noText],
+                   ],
+                   name: 'full',
+                   fieldLabel: gettext('Full'),
+               },
+           ],
+
+           column2: [
+               {
+                   xtype: 'proxmoxKVComboBox',
+                   value: '__default__',
+                   deleteEmpty: false,
+                   comboItems: [
+                       [
+                           '__default__',
+                           Ext.String.format(
+                                             gettext("{0} ({1})"),
+                                             Proxmox.Utils.yesText,
+                                             Proxmox.Utils.defaultText,
+                           ),
+                       ],
+                       ['1', Proxmox.Utils.yesText],
+                       ['0', Proxmox.Utils.noText],
+                   ],
+                   name: 'enable-new',
+                   fieldLabel: gettext('Enable new'),
+               },
+               {
+                   xtype: 'proxmoxKVComboBox',
+                   value: '__default__',
+                   deleteEmpty: false,
+                   comboItems: [
+                       ['__default__', Proxmox.Utils.defaultText],
+                       ['1', Proxmox.Utils.yesText],
+                       ['0', Proxmox.Utils.noText],
+                   ],
+                   name: 'purge',
+                   fieldLabel: gettext('Purge'),
+               },
+           ],
+       },
+    ],
+
+    buttons: [
+       {
+           text: gettext('Preview'),
+           handler: function() { this.up('window').sync_realm(true); },
+       },
+       {
+           text: gettext('Sync'),
+           handler: function() { this.up('window').sync_realm(false); },
+       },
+    ],
+
+    initComponent: function() {
+       let me = this;
+
+       if (!me.realm) {
+           throw "no realm defined";
+       }
+
+       me.callParent();
+    },
+});
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to