[pve-devel] [PATCH manager 6/6] ui: dc/Auth: add sync button

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Apr 27 12:15:01 CEST 2020


On 4/9/20 4:10 PM, Dominik Csapak wrote:
> 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.csapak at 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


Works OK, after the s/no-write/dry-run/ fix which was required to a change to
the API patch coming after you sent this one - obviously.

Some UX changes I'd like to see though, mainly regarding the default sync options.
I'd like to have their values visible in the Realm Sync window and ideally, if a
non-optional property is not set in the default-sync-options we should require that
one.

For display the value(s) of the default-sync-options for this realm we could either
add another section at the top of the window, having all set fields there (or a
"emptyText"-like "No default-sync-option set", if none).

An alternative could be to show it after the "Default". Oh, and the "Enable new"
default entry "Yes (Default)" can be really confusing, because if one set the
sync-options to "do not enable new" this would do the opposite the user got told.

> 
> 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'),

maybe add a tooltip here, something like:

    tooltip: gettext('Preview the changes made through a sync'),

?

> +	    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();
> +    },
> +});
> 





More information about the pve-devel mailing list