-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unify count filters and introduce display name attribute detection #11837
Changes from all commits
cb3af1d
f725cc6
71944a5
f9b4f5f
4a3fe42
c9e8656
d8bb8af
0e6d471
031d6c1
6b6147d
b5e707b
c07c338
503de94
9aef83b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,8 +151,10 @@ var LdapWizard = { | |
ajaxRequests: {}, | ||
|
||
ajax: function(param, fnOnSuccess, fnOnError, reqID) { | ||
if(reqID !== undefined) { | ||
if(!_.isUndefined(reqID)) { | ||
if(LdapWizard.ajaxRequests.hasOwnProperty(reqID)) { | ||
console.log('aborting ' + reqID); | ||
console.log(param); | ||
LdapWizard.ajaxRequests[reqID].abort(); | ||
} | ||
} | ||
|
@@ -167,9 +169,10 @@ var LdapWizard = { | |
} | ||
} | ||
); | ||
if(reqID !== undefined) { | ||
if(!_.isUndefined(reqID)) { | ||
LdapWizard.ajaxRequests[reqID] = request; | ||
} | ||
return request; | ||
}, | ||
|
||
applyChanges: function (result) { | ||
|
@@ -342,7 +345,7 @@ var LdapWizard = { | |
}, | ||
|
||
_countThings: function(method, spinnerID, doneCallback) { | ||
param = 'action='+method+ | ||
var param = 'action='+method+ | ||
'&ldap_serverconfig_chooser='+ | ||
encodeURIComponent($('#ldap_serverconfig_chooser').val()); | ||
|
||
|
@@ -351,14 +354,14 @@ var LdapWizard = { | |
function(result) { | ||
LdapWizard.applyChanges(result); | ||
LdapWizard.hideSpinner(spinnerID); | ||
if(doneCallback !== undefined) { | ||
if(!_.isUndefined(doneCallback)) { | ||
doneCallback(method); | ||
} | ||
}, | ||
function (result) { | ||
OC.Notification.show('Counting the entries failed with, ' + result.message); | ||
LdapWizard.hideSpinner(spinnerID); | ||
if(doneCallback !== undefined) { | ||
if(!_.isUndefined(doneCallback)) { | ||
doneCallback(method); | ||
} | ||
}, | ||
|
@@ -374,20 +377,62 @@ var LdapWizard = { | |
LdapWizard._countThings('countUsers', '#ldap_user_count', doneCallback); | ||
}, | ||
|
||
/** | ||
* called after detectors have run | ||
* @callback runDetectorsCallback | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems somewhat lonely and without context to me that comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's how JS doc works :) This defines the runDetectorsCallback used in the following method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. Good to know. Black magic that is. ;-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
/** | ||
* runs detectors to determine appropriate attributes, e.g. displayName | ||
* @param {string} type either "User" or "Group" | ||
* @param {runDetectorsCallback} triggered after all detectors have completed | ||
*/ | ||
runDetectors: function(type, callback) { | ||
if(type === 'Group') { | ||
$.when(LdapWizard.detectGroupMemberAssoc()) | ||
.then(callback, callback); | ||
if( LdapWizard.admin.isExperienced | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to gather all detectors in two arrays ? At least it would remove the need for all these ifs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Detectors do not depend on experienced mode or not, they are the same. Only in the later case it is not guaranteed that they are triggered, because this is only on demand, but having the detectors running is important for a proper configuration. |
||
&& !(LdapWizard.detectorsRunInXPMode & LdapWizard.groupDetectors)) { | ||
LdapWizard.detectorsRunInXPMode += LdapWizard.groupDetectors; | ||
} | ||
} else if(type === 'User') { | ||
var req1 = LdapWizard.detectUserDisplayNameAttribute(); | ||
var req2 = LdapWizard.detectEmailAttribute(); | ||
$.when(req1, req2) | ||
.then(callback, callback); | ||
if( LdapWizard.admin.isExperienced | ||
&& !(LdapWizard.detectorsRunInXPMode & LdapWizard.userDetectors)) { | ||
LdapWizard.detectorsRunInXPMode += LdapWizard.userDetectors; | ||
} | ||
} | ||
}, | ||
|
||
/** | ||
* runs detector to find out a fitting user display name attribute | ||
*/ | ||
detectUserDisplayNameAttribute: function() { | ||
var param = 'action=detectUserDisplayNameAttribute' + | ||
'&ldap_serverconfig_chooser='+ | ||
encodeURIComponent($('#ldap_serverconfig_chooser').val()); | ||
|
||
//runs in the background, no callbacks necessary | ||
return LdapWizard.ajax(param, LdapWizard.applyChanges, function(){}, 'detectUserDisplayNameAttribute'); | ||
}, | ||
|
||
detectEmailAttribute: function() { | ||
param = 'action=detectEmailAttribute'+ | ||
var param = 'action=detectEmailAttribute'+ | ||
'&ldap_serverconfig_chooser='+ | ||
encodeURIComponent($('#ldap_serverconfig_chooser').val()); | ||
//runs in the background, no callbacks necessary | ||
LdapWizard.ajax(param, LdapWizard.applyChanges, function(){}, 'detectEmailAttribute'); | ||
return LdapWizard.ajax(param, LdapWizard.applyChanges, function(){}, 'detectEmailAttribute'); | ||
}, | ||
|
||
detectGroupMemberAssoc: function() { | ||
param = 'action=determineGroupMemberAssoc'+ | ||
'&ldap_serverconfig_chooser='+ | ||
encodeURIComponent($('#ldap_serverconfig_chooser').val()); | ||
|
||
LdapWizard.ajax(param, | ||
return LdapWizard.ajax(param, | ||
function(result) { | ||
//pure background story | ||
}, | ||
|
@@ -409,7 +454,7 @@ var LdapWizard = { | |
$('#ldap_loginfilter_attributes').find('option').remove(); | ||
for (var i in result.options['ldap_loginfilter_attributes']) { | ||
//FIXME: move HTML into template | ||
attr = result.options['ldap_loginfilter_attributes'][i]; | ||
var attr = result.options['ldap_loginfilter_attributes'][i]; | ||
$('#ldap_loginfilter_attributes').append( | ||
"<option value='"+attr+"'>"+attr+"</option>"); | ||
} | ||
|
@@ -566,8 +611,12 @@ var LdapWizard = { | |
}, | ||
|
||
isConfigurationActiveControlLocked: true, | ||
detectorsRunInXPMode: 0, | ||
userDetectors: 1, | ||
groupDetectors: 2, | ||
|
||
init: function() { | ||
LdapWizard.detectorsRunInXPMode = 0; | ||
LdapWizard.instantiateFilters(); | ||
LdapWizard.admin.setExperienced($('#ldap_experienced_admin').is(':checked')); | ||
LdapWizard.basicStatusCheck(); | ||
|
@@ -620,8 +669,9 @@ var LdapWizard = { | |
instantiateFilters: function() { | ||
delete LdapWizard.userFilter; | ||
LdapWizard.userFilter = new LdapFilter('User', function(mode) { | ||
if(mode === LdapWizard.filterModeAssisted) { | ||
LdapWizard.groupFilter.updateCount(); | ||
if( !LdapWizard.admin.isExperienced() | ||
|| mode === LdapWizard.filterModeAssisted) { | ||
LdapWizard.userFilter.updateCount(); | ||
} | ||
LdapWizard.userFilter.findFeatures(); | ||
}); | ||
|
@@ -630,7 +680,6 @@ var LdapWizard = { | |
$('#ldap_user_count').text(''); | ||
LdapWizard.showSpinner('#rawUserFilterContainer .ldapGetEntryCount'); | ||
LdapWizard.userFilter.updateCount(LdapWizard.hideTestSpinner); | ||
LdapWizard.detectEmailAttribute(); | ||
$('#ldap_user_count').removeClass('hidden'); | ||
}); | ||
|
||
|
@@ -641,7 +690,8 @@ var LdapWizard = { | |
|
||
delete LdapWizard.groupFilter; | ||
LdapWizard.groupFilter = new LdapFilter('Group', function(mode) { | ||
if(mode === LdapWizard.filterModeAssisted) { | ||
if( !LdapWizard.admin.isExperienced() | ||
|| mode === LdapWizard.filterModeAssisted) { | ||
LdapWizard.groupFilter.updateCount(); | ||
} | ||
LdapWizard.groupFilter.findFeatures(); | ||
|
@@ -651,7 +701,6 @@ var LdapWizard = { | |
$('#ldap_group_count').text(''); | ||
LdapWizard.showSpinner('#rawGroupFilterContainer .ldapGetEntryCount'); | ||
LdapWizard.groupFilter.updateCount(LdapWizard.hideTestSpinner); | ||
LdapWizard.detectGroupMemberAssoc(); | ||
$('#ldap_group_count').removeClass('hidden'); | ||
}); | ||
}, | ||
|
@@ -668,7 +717,7 @@ var LdapWizard = { | |
postInitUserFilter: function() { | ||
if(LdapWizard.userFilterObjectClassesHasRun && | ||
LdapWizard.userFilterAvailableGroupsHasRun) { | ||
LdapWizard.userFilter.compose(LdapWizard.detectEmailAttribute); | ||
LdapWizard.userFilter.compose(); | ||
} | ||
}, | ||
|
||
|
@@ -679,7 +728,7 @@ var LdapWizard = { | |
//do not allow to switch tabs as long as a save process is active | ||
return false; | ||
} | ||
newTabIndex = 0; | ||
var newTabIndex = 0; | ||
if(ui.newTab[0].id === '#ldapWizard2') { | ||
LdapWizard.initUserFilter(); | ||
newTabIndex = 1; | ||
|
@@ -691,9 +740,23 @@ var LdapWizard = { | |
newTabIndex = 3; | ||
} | ||
|
||
curTabIndex = $('#ldapSettings').tabs('option', 'active'); | ||
var curTabIndex = $('#ldapSettings').tabs('option', 'active'); | ||
if(curTabIndex >= 0 && curTabIndex <= 3) { | ||
LdapWizard.controlUpdate(newTabIndex); | ||
//run detectors in XP mode, when "Test Filter" button has not been | ||
//clicked in order to make sure that email, displayname, member- | ||
//group association attributes are properly set. | ||
if( curTabIndex === 1 | ||
&& LdapWizard.admin.isExperienced | ||
&& !(LdapWizard.detecorsRunInXPMode & LdapWizard.userDetectors) | ||
) { | ||
LdapWizard.runDetectors('User', function(){}); | ||
} else if( curTabIndex === 3 | ||
&& LdapWizard.admin.isExperienced | ||
&& !(LdapWizard.detecorsRunInXPMode & LdapWizard.groupDetectors) | ||
) { | ||
LdapWizard.runDetectors('Group', function(){}); | ||
} | ||
} | ||
}, | ||
|
||
|
@@ -711,15 +774,15 @@ var LdapWizard = { | |
} | ||
} | ||
|
||
if(triggerObj.id === 'ldap_userlist_filter' && !LdapWizard.admin.isExperienced()) { | ||
LdapWizard.detectEmailAttribute(); | ||
} else if(triggerObj.id === 'ldap_group_filter' && !LdapWizard.admin.isExperienced()) { | ||
LdapWizard.detectGroupMemberAssoc(); | ||
} | ||
|
||
if(triggerObj.id === 'ldap_loginfilter_username' | ||
|| triggerObj.id === 'ldap_loginfilter_email') { | ||
LdapWizard.loginFilter.compose(); | ||
} else if (!LdapWizard.admin.isExperienced()) { | ||
if(triggerObj.id === 'ldap_userlist_filter') { | ||
LdapWizard.userFilter.updateCount(); | ||
} else if (triggerObj.id === 'ldap_group_filter') { | ||
LdapWizard.groupFilter.updateCount(); | ||
} | ||
} | ||
|
||
if($('#ldapSettings').tabs('option', 'active') == 0) { | ||
|
@@ -749,7 +812,7 @@ var LdapWizard = { | |
LdapWizard._save($('#'+originalObj)[0], $.trim(values)); | ||
if(originalObj === 'ldap_userfilter_objectclass' | ||
|| originalObj === 'ldap_userfilter_groups') { | ||
LdapWizard.userFilter.compose(LdapWizard.detectEmailAttribute); | ||
LdapWizard.userFilter.compose(true); | ||
//when user filter is changed afterwards, login filter needs to | ||
//be adjusted, too | ||
if(!LdapWizard.loginFilter) { | ||
|
@@ -760,7 +823,7 @@ var LdapWizard = { | |
LdapWizard.loginFilter.compose(); | ||
} else if(originalObj === 'ldap_groupfilter_objectclass' | ||
|| originalObj === 'ldap_groupfilter_groups') { | ||
LdapWizard.groupFilter.compose(); | ||
LdapWizard.groupFilter.compose(true); | ||
} | ||
}, | ||
|
||
|
@@ -830,10 +893,10 @@ var LdapWizard = { | |
LdapWizard._save({ id: modeKey }, LdapWizard.filterModeAssisted); | ||
if(isUser) { | ||
LdapWizard.blacklistRemove('ldap_userlist_filter'); | ||
LdapWizard.userFilter.compose(LdapWizard.detectEmailAttribute); | ||
LdapWizard.userFilter.compose(true); | ||
} else { | ||
LdapWizard.blacklistRemove('ldap_group_filter'); | ||
LdapWizard.groupFilter.compose(); | ||
LdapWizard.groupFilter.compose(true); | ||
} | ||
} | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use
OC.buildQueryString({action: method, ...}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but then i need to do it everywhere. Maybe not in a bugfix PR.