]>
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(';');
47 params
['dry-run'] = is_preview
? 1 : 0;
48 Proxmox
.Utils
.API2Request({
49 url
: `/access/domains/${view.realm}/sync`,
53 failure: function(response
) {
55 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
57 success: function(response
) {
59 Ext
.create('Proxmox.window.TaskViewer', {
60 upid
: response
.result
.data
,
90 xtype
: 'proxmoxKVComboBox',
92 fieldLabel
: gettext('Scope'),
94 emptyText
: gettext('No default available'),
98 ['users', gettext('Users')],
99 ['groups', gettext('Groups')],
100 ['both', gettext('Users and Groups')],
107 xtype
: 'proxmoxKVComboBox',
112 ['1', Proxmox
.Utils
.yesText
],
113 ['0', Proxmox
.Utils
.noText
],
116 fieldLabel
: gettext('Enable new'),
123 title
: gettext('Remove Vanished Options'),
126 xtype
: 'proxmoxcheckbox',
127 fieldLabel
: gettext('ACL'),
128 name
: 'remove-vanished-acl',
129 boxLabel
: gettext('Remove ACLs of vanished users and groups.'),
132 xtype
: 'proxmoxcheckbox',
133 fieldLabel
: gettext('Entry'),
134 name
: 'remove-vanished-entry',
135 boxLabel
: gettext('Remove vanished user and group entries.'),
138 xtype
: 'proxmoxcheckbox',
139 fieldLabel
: gettext('Properties'),
140 name
: 'remove-vanished-properties',
141 boxLabel
: gettext('Remove properties from vanished users.'),
146 xtype
: 'displayfield',
147 reference
: 'defaulthint',
148 value
: gettext('Default sync options can be set by editing the realm.'),
159 xtype
: 'proxmoxHelpButton',
160 reference
: 'help_btn',
161 onlineHelp
: 'pveum_ldap_sync',
166 text
: gettext('Preview'),
167 reference
: 'preview_btn',
170 text
: gettext('Sync'),
171 reference
: 'sync_btn',
175 initComponent: function() {
179 throw "no realm defined";
184 Proxmox
.Utils
.API2Request({
185 url
: `/access/domains/${me.realm}`,
188 failure: function(response
) {
189 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
192 success: function(response
) {
193 let default_options
= response
.result
.data
['sync-defaults-options'];
194 if (default_options
) {
195 let options
= PVE
.Parser
.parsePropertyString(default_options
);
196 if (options
['remove-vanished']) {
197 let opts
= options
['remove-vanished'].split(';');
198 for (const opt
of opts
) {
199 options
[`remove-vanished-${opt}`] = 1;
202 let ipanel
= me
.lookup('ipanel');
203 ipanel
.setValues(options
);
205 me
.lookup('defaulthint').setVisible(true);
208 // check validity for button state
209 me
.lookup('form').isValid();