2014-10-07 19:28:09 +04:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2014, Arthur Schiwon <blizzz@owncloud.com>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2014-10-08 18:20:52 +04:00
|
|
|
/* global LdapWizard */
|
|
|
|
|
2014-10-07 19:28:09 +04:00
|
|
|
/**
|
|
|
|
* controls behaviour depend on whether the admin is experienced in LDAP or not.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @param {object} wizard the LDAP Wizard object
|
|
|
|
* @param {boolean} initialState whether the admin is experienced or not
|
|
|
|
*/
|
|
|
|
function ExperiencedAdmin(wizard, initialState) {
|
|
|
|
this.wizard = wizard;
|
2014-10-08 16:55:47 +04:00
|
|
|
this._isExperienced = initialState;
|
|
|
|
if(this._isExperienced) {
|
2014-10-08 15:06:18 +04:00
|
|
|
this.hideEntryCounters();
|
|
|
|
}
|
2014-10-07 19:28:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* toggles whether the admin is an experienced one or not
|
|
|
|
*
|
|
|
|
* @param {boolean} whether the admin is experienced or not
|
|
|
|
*/
|
2014-10-08 15:06:18 +04:00
|
|
|
ExperiencedAdmin.prototype.setExperienced = function(isExperienced) {
|
2014-10-08 16:55:47 +04:00
|
|
|
this._isExperienced = isExperienced;
|
|
|
|
if(this._isExperienced) {
|
2014-10-07 19:28:09 +04:00
|
|
|
this.enableRawMode();
|
2014-10-08 15:06:18 +04:00
|
|
|
this.hideEntryCounters();
|
|
|
|
} else {
|
|
|
|
this.showEntryCounters();
|
2014-10-07 19:28:09 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* answers whether the admin is an experienced one or not
|
|
|
|
*
|
|
|
|
* @return {boolean} whether the admin is experienced or not
|
|
|
|
*/
|
|
|
|
ExperiencedAdmin.prototype.isExperienced = function() {
|
2014-10-08 16:55:47 +04:00
|
|
|
return this._isExperienced;
|
2014-10-07 19:28:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* switches all LDAP filters from Assisted to Raw mode.
|
|
|
|
*/
|
2014-10-08 15:06:18 +04:00
|
|
|
ExperiencedAdmin.prototype.enableRawMode = function() {
|
2014-10-29 20:52:55 +03:00
|
|
|
LdapWizard._save({id: 'ldapGroupFilterMode'}, LdapWizard.filterModeRaw);
|
|
|
|
LdapWizard._save({id: 'ldapUserFilterMode' }, LdapWizard.filterModeRaw);
|
|
|
|
LdapWizard._save({id: 'ldapLoginFilterMode'}, LdapWizard.filterModeRaw);
|
2014-10-08 15:06:18 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
ExperiencedAdmin.prototype.updateUserTab = function(mode) {
|
|
|
|
this._updateTab(mode, $('#ldap_user_count'));
|
2014-10-08 18:20:52 +04:00
|
|
|
};
|
2014-10-07 19:28:09 +04:00
|
|
|
|
2014-10-08 15:06:18 +04:00
|
|
|
ExperiencedAdmin.prototype.updateGroupTab = function(mode) {
|
|
|
|
this._updateTab(mode, $('#ldap_group_count'));
|
2014-10-08 18:20:52 +04:00
|
|
|
};
|
2014-10-07 19:28:09 +04:00
|
|
|
|
2014-10-08 15:06:18 +04:00
|
|
|
ExperiencedAdmin.prototype._updateTab = function(mode, $countEl) {
|
|
|
|
if(mode === LdapWizard.filterModeAssisted) {
|
|
|
|
$countEl.removeClass('hidden');
|
2014-10-08 16:55:47 +04:00
|
|
|
} else if(!this._isExperienced) {
|
2014-10-08 15:06:18 +04:00
|
|
|
$countEl.removeClass('hidden');
|
|
|
|
} else {
|
|
|
|
$countEl.addClass('hidden');
|
|
|
|
}
|
2014-10-08 18:20:52 +04:00
|
|
|
};
|
2014-10-08 15:06:18 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* hide user and group counters, they will be displayed on demand only
|
|
|
|
*/
|
|
|
|
ExperiencedAdmin.prototype.hideEntryCounters = function() {
|
|
|
|
$('#ldap_user_count').addClass('hidden');
|
|
|
|
$('#ldap_group_count').addClass('hidden');
|
|
|
|
$('.ldapGetEntryCount').removeClass('hidden');
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* shows user and group counters, they will be displayed on demand only
|
|
|
|
*/
|
|
|
|
ExperiencedAdmin.prototype.showEntryCounters = function() {
|
|
|
|
$('#ldap_user_count').removeClass('hidden');
|
|
|
|
$('#ldap_group_count').removeClass('hidden');
|
|
|
|
$('.ldapGetEntryCount').addClass('hidden');
|
2014-10-07 19:28:09 +04:00
|
|
|
};
|