]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/SyncWindow.js
1 Ext
.define('PVE.dc.SyncWindow', {
2 extend
: 'Ext.window.Window',
4 title
: gettext('Realm Sync'),
12 xclass
: 'Ext.app.ViewController',
16 validitychange: function(field
, valid
) {
18 me
.lookup('preview_btn').setDisabled(!valid
);
19 me
.lookup('sync_btn').setDisabled(!valid
);
23 click: function(btn
) {
24 if (btn
.reference
=== 'help_btn') return;
25 this.sync_realm(btn
.reference
=== 'preview_btn');
30 sync_realm: function(is_preview
) {
32 let view
= me
.getView();
33 let ipanel
= me
.lookup('ipanel');
34 let params
= ipanel
.getValues();
36 let vanished_opts
= [];
37 ['acl', 'entry', 'properties'].forEach((prop
) => {
38 if (params
[`remove-vanished-${prop}`]) {
39 vanished_opts
.push(prop
);
41 delete params
[`remove-vanished-${prop}`];
43 if (vanished_opts
.length
> 0) {
44 params
['remove-vanished'] = vanished_opts
.join(';');
46 params
['remove-vanished'] = 'none';
49 params
['dry-run'] = is_preview
? 1 : 0;
50 Proxmox
.Utils
.API2Request({
51 url
: `/access/domains/${view.realm}/sync`,
55 failure: function(response
) {
57 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
59 success: function(response
) {
61 Ext
.create('Proxmox.window.TaskViewer', {
62 upid
: response
.result
.data
,
92 xtype
: 'proxmoxKVComboBox',
94 fieldLabel
: gettext('Scope'),
96 emptyText
: gettext('No default available'),
100 ['users', gettext('Users')],
101 ['groups', gettext('Groups')],
102 ['both', gettext('Users and Groups')],
109 xtype
: 'proxmoxKVComboBox',
114 ['1', Proxmox
.Utils
.yesText
],
115 ['0', Proxmox
.Utils
.noText
],
118 fieldLabel
: gettext('Enable new'),
125 title
: gettext('Remove Vanished Options'),
128 xtype
: 'proxmoxcheckbox',
129 fieldLabel
: gettext('ACL'),
130 name
: 'remove-vanished-acl',
131 boxLabel
: gettext('Remove ACLs of vanished users and groups.'),
134 xtype
: 'proxmoxcheckbox',
135 fieldLabel
: gettext('Entry'),
136 name
: 'remove-vanished-entry',
137 boxLabel
: gettext('Remove vanished user and group entries.'),
140 xtype
: 'proxmoxcheckbox',
141 fieldLabel
: gettext('Properties'),
142 name
: 'remove-vanished-properties',
143 boxLabel
: gettext('Remove vanished properties from synced users.'),
148 xtype
: 'displayfield',
149 reference
: 'defaulthint',
150 value
: gettext('Default sync options can be set by editing the realm.'),
161 xtype
: 'proxmoxHelpButton',
162 reference
: 'help_btn',
163 onlineHelp
: 'pveum_ldap_sync',
168 text
: gettext('Preview'),
169 reference
: 'preview_btn',
172 text
: gettext('Sync'),
173 reference
: 'sync_btn',
177 initComponent: function() {
181 throw "no realm defined";
186 Proxmox
.Utils
.API2Request({
187 url
: `/access/domains/${me.realm}`,
190 failure: function(response
) {
191 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
194 success: function(response
) {
195 let default_options
= response
.result
.data
['sync-defaults-options'];
196 if (default_options
) {
197 let options
= PVE
.Parser
.parsePropertyString(default_options
);
198 if (options
['remove-vanished']) {
199 let opts
= options
['remove-vanished'].split(';');
200 for (const opt
of opts
) {
201 options
[`remove-vanished-${opt}`] = 1;
204 let ipanel
= me
.lookup('ipanel');
205 ipanel
.setValues(options
);
207 me
.lookup('defaulthint').setVisible(true);
210 // check validity for button state
211 me
.lookup('form').isValid();