user and group counts are only upated on demand in experienced mode

This commit is contained in:
Arthur Schiwon 2014-10-08 13:06:18 +02:00
parent b6fc7f5599
commit 7ba787e649
6 changed files with 100 additions and 17 deletions

View File

@ -82,6 +82,10 @@
margin: 5px; margin: 5px;
} }
.ldap_count {
line-height: 45px;
}
.ldapSettingControls { .ldapSettingControls {
margin-top: 3px; margin-top: 3px;
} }

View File

@ -13,7 +13,10 @@
*/ */
function ExperiencedAdmin(wizard, initialState) { function ExperiencedAdmin(wizard, initialState) {
this.wizard = wizard; this.wizard = wizard;
this.isExperienced = false; this.isExperienced = initialState;
if(this.isExperienced) {
this.hideEntryCounters();
}
} }
@ -22,10 +25,13 @@ function ExperiencedAdmin(wizard, initialState) {
* *
* @param {boolean} whether the admin is experienced or not * @param {boolean} whether the admin is experienced or not
*/ */
ExperiencedAdmin.prototype.toggle = function(isExperienced) { ExperiencedAdmin.prototype.setExperienced = function(isExperienced) {
this.isExperienced = isExperienced; this.isExperienced = isExperienced;
if(this.isExperienced) { if(this.isExperienced) {
this.enableRawMode(); this.enableRawMode();
this.hideEntryCounters();
} else {
this.showEntryCounters();
} }
}; };
@ -41,7 +47,7 @@ ExperiencedAdmin.prototype.isExperienced = function() {
/** /**
* switches all LDAP filters from Assisted to Raw mode. * switches all LDAP filters from Assisted to Raw mode.
*/ */
ExperiencedAdmin.prototype.enableRawMode = function () { ExperiencedAdmin.prototype.enableRawMode = function() {
containers = { containers = {
'toggleRawGroupFilter': '#rawGroupFilterContainer', 'toggleRawGroupFilter': '#rawGroupFilterContainer',
'toggleRawLoginFilter': '#rawLoginFilterContainer', 'toggleRawLoginFilter': '#rawLoginFilterContainer',
@ -53,6 +59,40 @@ ExperiencedAdmin.prototype.enableRawMode = function () {
this.wizard[method](); this.wizard[method]();
} }
}; };
};
ExperiencedAdmin.prototype.updateUserTab = function(mode) {
this._updateTab(mode, $('#ldap_user_count'));
}
ExperiencedAdmin.prototype.updateGroupTab = function(mode) {
this._updateTab(mode, $('#ldap_group_count'));
}
ExperiencedAdmin.prototype._updateTab = function(mode, $countEl) {
if(mode === LdapWizard.filterModeAssisted) {
$countEl.removeClass('hidden');
} else if(!this.isExperienced) {
$countEl.removeClass('hidden');
} else {
$countEl.addClass('hidden');
}
}
/**
* 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');
}; };

View File

@ -113,6 +113,10 @@ LdapFilter.prototype.setMode = function(mode) {
} }
} }
LdapFilter.prototype.getMode = function() {
return this.mode;
}
LdapFilter.prototype.unlock = function() { LdapFilter.prototype.unlock = function() {
this.locked = false; this.locked = false;
if(this.lazyRunCompose) { if(this.lazyRunCompose) {
@ -122,6 +126,7 @@ LdapFilter.prototype.unlock = function() {
}; };
LdapFilter.prototype.findFeatures = function() { LdapFilter.prototype.findFeatures = function() {
//TODO: reset this.foundFeatures when any base DN changes
if(!this.foundFeatures && !this.locked && this.mode === LdapWizard.filterModeAssisted) { if(!this.foundFeatures && !this.locked && this.mode === LdapWizard.filterModeAssisted) {
this.foundFeatures = true; this.foundFeatures = true;
if(this.target === 'User') { if(this.target === 'User') {
@ -139,4 +144,12 @@ LdapFilter.prototype.findFeatures = function() {
LdapWizard.findObjectClasses(objcEl, this.target); LdapWizard.findObjectClasses(objcEl, this.target);
LdapWizard.findAvailableGroups(avgrEl, this.target + "s"); LdapWizard.findAvailableGroups(avgrEl, this.target + "s");
} }
} };
LdapFilter.prototype.updateCount = function() {
if(this.target === 'User') {
LdapWizard.countUsers();
} else if (this.target === 'Group') {
LdapWizard.countGroups();
}
};

View File

@ -317,27 +317,30 @@ var LdapWizard = {
} }
}, },
_countThings: function(method) { _countThings: function(method, spinnerID) {
param = 'action='+method+ param = 'action='+method+
'&ldap_serverconfig_chooser='+ '&ldap_serverconfig_chooser='+
encodeURIComponent($('#ldap_serverconfig_chooser').val()); encodeURIComponent($('#ldap_serverconfig_chooser').val());
LdapWizard.showSpinner(spinnerID);
LdapWizard.ajax(param, LdapWizard.ajax(param,
function(result) { function(result) {
LdapWizard.applyChanges(result); LdapWizard.applyChanges(result);
LdapWizard.hideSpinner(spinnerID);
}, },
function (result) { function (result) {
// error handling OC.Notification.show('Counting the entries failed with, ' + result.message);
LdapWizard.hideSpinner(spinnerID);
} }
); );
}, },
countGroups: function() { countGroups: function() {
LdapWizard._countThings('countGroups'); LdapWizard._countThings('countGroups', '#ldap_group_count');
}, },
countUsers: function() { countUsers: function() {
LdapWizard._countThings('countUsers'); LdapWizard._countThings('countUsers', '#ldap_user_count');
}, },
detectEmailAttribute: function() { detectEmailAttribute: function() {
@ -531,6 +534,7 @@ var LdapWizard = {
init: function() { init: function() {
LdapWizard.instantiateFilters(); LdapWizard.instantiateFilters();
LdapWizard.admin.setExperienced($('#ldap_experienced_admin').is(':checked'));
LdapWizard.basicStatusCheck(); LdapWizard.basicStatusCheck();
LdapWizard.functionalityCheck(); LdapWizard.functionalityCheck();
LdapWizard.isConfigurationActiveControlLocked = false; LdapWizard.isConfigurationActiveControlLocked = false;
@ -574,6 +578,13 @@ var LdapWizard = {
LdapWizard.userFilter = new LdapFilter('User', function(mode) { LdapWizard.userFilter = new LdapFilter('User', function(mode) {
LdapWizard.userFilter.findFeatures(); LdapWizard.userFilter.findFeatures();
}); });
$('#rawUserFilterContainer .ldapGetEntryCount').click(function(event) {
event.preventDefault();
$('#ldap_user_count').text('');
LdapWizard.userFilter.updateCount();
LdapWizard.detectEmailAttribute();
$('#ldap_user_count').removeClass('hidden');
});
delete LdapWizard.loginFilter; delete LdapWizard.loginFilter;
LdapWizard.loginFilter = new LdapFilter('Login', function(mode) { LdapWizard.loginFilter = new LdapFilter('Login', function(mode) {
@ -584,6 +595,13 @@ var LdapWizard = {
LdapWizard.groupFilter = new LdapFilter('Group', function(mode) { LdapWizard.groupFilter = new LdapFilter('Group', function(mode) {
LdapWizard.groupFilter.findFeatures(); LdapWizard.groupFilter.findFeatures();
}); });
$('#rawGroupFilterContainer .ldapGetEntryCount').click(function(event) {
event.preventDefault();
$('#ldap_group_count').text('');
LdapWizard.groupFilter.updateCount();
LdapWizard.detectGroupMemberAssoc();
$('#ldap_group_count').removeClass('hidden');
});
}, },
userFilterObjectClassesHasRun: false, userFilterObjectClassesHasRun: false,
@ -638,10 +656,10 @@ var LdapWizard = {
} }
} }
if(triggerObj.id == 'ldap_userlist_filter') { if(triggerObj.id == 'ldap_userlist_filter' && !LdapWizard.admin.isExperienced()) {
LdapWizard.countUsers(); LdapWizard.countUsers();
LdapWizard.detectEmailAttribute(); LdapWizard.detectEmailAttribute();
} else if(triggerObj.id == 'ldap_group_filter') { } else if(triggerObj.id == 'ldap_group_filter' && !LdapWizard.admin.isExperienced()) {
LdapWizard.countGroups(); LdapWizard.countGroups();
LdapWizard.detectGroupMemberAssoc(); LdapWizard.detectGroupMemberAssoc();
} }
@ -766,6 +784,7 @@ var LdapWizard = {
'groupFilterGroupSelectState', 'groupFilterGroupSelectState',
'ldapGroupFilterMode' 'ldapGroupFilterMode'
); );
LdapWizard.admin.updateGroupTab(LdapWizard.groupFilter.getMode());
}, },
toggleRawLoginFilter: function() { toggleRawLoginFilter: function() {
@ -801,6 +820,7 @@ var LdapWizard = {
'userFilterGroupSelectState', 'userFilterGroupSelectState',
'ldapUserFilterMode' 'ldapUserFilterMode'
); );
LdapWizard.admin.updateUserTab(LdapWizard.userFilter.getMode());
}, },
updateStatusIndicator: function(isComplete) { updateStatusIndicator: function(isComplete) {
@ -956,6 +976,6 @@ $(document).ready(function() {
expAdminCB = $('#ldap_experienced_admin'); expAdminCB = $('#ldap_experienced_admin');
LdapWizard.admin = new ExperiencedAdmin(LdapWizard, expAdminCB.is(':checked')); LdapWizard.admin = new ExperiencedAdmin(LdapWizard, expAdminCB.is(':checked'));
expAdminCB.change(function() { expAdminCB.change(function() {
LdapWizard.admin.toggle($(this).is(':checked')); LdapWizard.admin.setExperienced($(this).is(':checked'));
}); });
}); });

View File

@ -30,13 +30,16 @@
placeholder="<?php p($l->t('Raw LDAP filter'));?>" placeholder="<?php p($l->t('Raw LDAP filter'));?>"
title="<?php p($l->t('The filter specifies which LDAP groups shall have access to the %s instance.', $theme->getName()));?>" title="<?php p($l->t('The filter specifies which LDAP groups shall have access to the %s instance.', $theme->getName()));?>"
/> />
<button class="ldapGetEntryCount hidden" name="ldapGetEntryCount" type="button">
<?php p($l->t('Test Filter'));?>
</button>
</p> </p>
<p> <p>
<div class="ldapWizardInfo invisible">&nbsp;</div> <div class="ldapWizardInfo invisible">&nbsp;</div>
</p> </p>
<p> <p class="ldap_count">
<span id="ldap_group_count">0 <?php p($l->t('groups found'));?></span> <span id="ldap_group_count">0 <?php p($l->t('groups found'));?></span>
</p> </p>
<?php print_unescaped($_['wizardControls']); ?> <?php print_unescaped($_['wizardControls']); ?>
</div> </div>
</fieldset> </fieldset>

View File

@ -30,13 +30,16 @@
placeholder="<?php p($l->t('Raw LDAP filter'));?>" placeholder="<?php p($l->t('Raw LDAP filter'));?>"
title="<?php p($l->t('The filter specifies which LDAP users shall have access to the %s instance.', $theme->getName()));?>" title="<?php p($l->t('The filter specifies which LDAP users shall have access to the %s instance.', $theme->getName()));?>"
/> />
<button class="ldapGetEntryCount hidden" name="ldapGetEntryCount" type="button">
<?php p($l->t('Test Filter'));?>
</button>
</p> </p>
<p> <p>
<div class="ldapWizardInfo invisible">&nbsp;</div> <div class="ldapWizardInfo invisible">&nbsp;</div>
</p> </p>
<p> <p class="ldap_count">
<span id="ldap_user_count">0 <?php p($l->t('users found'));?></span> <span id="ldap_user_count">0 <?php p($l->t('users found'));?></span>
</p> </p>
<?php print_unescaped($_['wizardControls']); ?> <?php print_unescaped($_['wizardControls']); ?>
</div> </div>
</fieldset> </fieldset>