Moved LdapFilter into a separate js file in user_ldap.
This commit is contained in:
parent
43e79f41f3
commit
ef65381a0b
3 changed files with 96 additions and 102 deletions
95
apps/user_ldap/js/ldapFilter.js
Normal file
95
apps/user_ldap/js/ldapFilter.js
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
function LdapFilter(target) {
|
||||||
|
this.locked = true;
|
||||||
|
this.target = false;
|
||||||
|
this.mode = LdapWizard.filterModeAssisted;
|
||||||
|
this.lazyRunCompose = false;
|
||||||
|
|
||||||
|
if( target === 'User' ||
|
||||||
|
target === 'Login' ||
|
||||||
|
target === 'Group') {
|
||||||
|
this.target = target;
|
||||||
|
this.determineMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LdapFilter.prototype.compose = function() {
|
||||||
|
var action;
|
||||||
|
|
||||||
|
if(this.locked) {
|
||||||
|
this.lazyRunCompose = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.target === 'User') {
|
||||||
|
action = 'getUserListFilter';
|
||||||
|
} else if(this.target === 'Login') {
|
||||||
|
action = 'getUserLoginFilter';
|
||||||
|
} else if(this.target === 'Group') {
|
||||||
|
action = 'getGroupFilter';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$('#raw'+this.target+'FilterContainer').hasClass('invisible')) {
|
||||||
|
//Raw filter editing, i.e. user defined filter, don't compose
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var param = 'action='+action+
|
||||||
|
'&ldap_serverconfig_chooser='+
|
||||||
|
encodeURIComponent($('#ldap_serverconfig_chooser').val());
|
||||||
|
|
||||||
|
var filter = this;
|
||||||
|
|
||||||
|
LdapWizard.ajax(param,
|
||||||
|
function(result) {
|
||||||
|
LdapWizard.applyChanges(result);
|
||||||
|
if(filter.target === 'User') {
|
||||||
|
LdapWizard.countUsers();
|
||||||
|
} else if(filter.target === 'Group') {
|
||||||
|
LdapWizard.countGroups();
|
||||||
|
LdapWizard.detectGroupMemberAssoc();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function (result) {
|
||||||
|
// error handling
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
LdapFilter.prototype.determineMode = function() {
|
||||||
|
var param = 'action=get'+encodeURIComponent(this.target)+'FilterMode'+
|
||||||
|
'&ldap_serverconfig_chooser='+
|
||||||
|
encodeURIComponent($('#ldap_serverconfig_chooser').val());
|
||||||
|
|
||||||
|
var filter = this;
|
||||||
|
LdapWizard.ajax(param,
|
||||||
|
function(result) {
|
||||||
|
property = 'ldap' + filter.target + 'FilterMode';
|
||||||
|
filter.mode = result.changes[property];
|
||||||
|
if(filter.mode == LdapWizard.filterModeRaw
|
||||||
|
&& $('#raw'+filter.target+'FilterContainer').hasClass('invisible')) {
|
||||||
|
LdapWizard['toggleRaw'+filter.target+'Filter']();
|
||||||
|
} else if(filter.mode == LdapWizard.filterModeAssisted
|
||||||
|
&& !$('#raw'+filter.target+'FilterContainer').hasClass('invisible')) {
|
||||||
|
LdapWizard['toggleRaw'+filter.target+'Filter']();
|
||||||
|
}
|
||||||
|
filter.unlock();
|
||||||
|
},
|
||||||
|
function (result) {
|
||||||
|
//on error case get back to default i.e. Assisted
|
||||||
|
if(!$('#raw'+filter.target+'FilterContainer').hasClass('invisible')) {
|
||||||
|
LdapWizard['toggleRaw'+filter.target+'Filter']();
|
||||||
|
filter.mode = LdapWizard.filterModeAssisted;
|
||||||
|
}
|
||||||
|
filter.unlock();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
LdapFilter.prototype.unlock = function() {
|
||||||
|
this.locked = false;
|
||||||
|
if(this.lazyRunCompose) {
|
||||||
|
this.lazyRunCompose = false;
|
||||||
|
this.compose();
|
||||||
|
}
|
||||||
|
}
|
|
@ -138,108 +138,6 @@ var LdapConfiguration = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// LdapFilter object.
|
|
||||||
|
|
||||||
function LdapFilter(target) {
|
|
||||||
this.locked = true;
|
|
||||||
this.target = false;
|
|
||||||
this.mode = LdapWizard.filterModeAssisted;
|
|
||||||
this.lazyRunCompose = false;
|
|
||||||
|
|
||||||
if( target === 'User' ||
|
|
||||||
target === 'Login' ||
|
|
||||||
target === 'Group') {
|
|
||||||
this.target = target;
|
|
||||||
this.determineMode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LdapFilter.prototype.compose = function() {
|
|
||||||
var action;
|
|
||||||
|
|
||||||
if(this.locked) {
|
|
||||||
this.lazyRunCompose = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.target === 'User') {
|
|
||||||
action = 'getUserListFilter';
|
|
||||||
} else if(this.target === 'Login') {
|
|
||||||
action = 'getUserLoginFilter';
|
|
||||||
} else if(this.target === 'Group') {
|
|
||||||
action = 'getGroupFilter';
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$('#raw'+this.target+'FilterContainer').hasClass('invisible')) {
|
|
||||||
//Raw filter editing, i.e. user defined filter, don't compose
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var param = 'action='+action+
|
|
||||||
'&ldap_serverconfig_chooser='+
|
|
||||||
encodeURIComponent($('#ldap_serverconfig_chooser').val());
|
|
||||||
|
|
||||||
var filter = this;
|
|
||||||
|
|
||||||
LdapWizard.ajax(param,
|
|
||||||
function(result) {
|
|
||||||
LdapWizard.applyChanges(result);
|
|
||||||
if(filter.target === 'User') {
|
|
||||||
LdapWizard.countUsers();
|
|
||||||
} else if(filter.target === 'Group') {
|
|
||||||
LdapWizard.countGroups();
|
|
||||||
LdapWizard.detectGroupMemberAssoc();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function (result) {
|
|
||||||
// error handling
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
LdapFilter.prototype.determineMode = function() {
|
|
||||||
var param = 'action=get'+encodeURIComponent(this.target)+'FilterMode'+
|
|
||||||
'&ldap_serverconfig_chooser='+
|
|
||||||
encodeURIComponent($('#ldap_serverconfig_chooser').val());
|
|
||||||
|
|
||||||
var filter = this;
|
|
||||||
LdapWizard.ajax(param,
|
|
||||||
function(result) {
|
|
||||||
property = 'ldap' + filter.target + 'FilterMode';
|
|
||||||
filter.mode = result.changes[property];
|
|
||||||
if(filter.mode == LdapWizard.filterModeRaw
|
|
||||||
&& $('#raw'+filter.target+'FilterContainer').hasClass('invisible')) {
|
|
||||||
LdapWizard['toggleRaw'+filter.target+'Filter']();
|
|
||||||
} else if(filter.mode == LdapWizard.filterModeAssisted
|
|
||||||
&& !$('#raw'+filter.target+'FilterContainer').hasClass('invisible')) {
|
|
||||||
LdapWizard['toggleRaw'+filter.target+'Filter']();
|
|
||||||
}
|
|
||||||
filter.unlock();
|
|
||||||
},
|
|
||||||
function (result) {
|
|
||||||
//on error case get back to default i.e. Assisted
|
|
||||||
if(!$('#raw'+filter.target+'FilterContainer').hasClass('invisible')) {
|
|
||||||
LdapWizard['toggleRaw'+filter.target+'Filter']();
|
|
||||||
filter.mode = LdapWizard.filterModeAssisted;
|
|
||||||
}
|
|
||||||
filter.unlock();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
LdapFilter.prototype.unlock = function() {
|
|
||||||
this.locked = false;
|
|
||||||
if(this.lazyRunCompose) {
|
|
||||||
this.lazyRunCompose = false;
|
|
||||||
this.compose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// end of LdapFilter object.
|
|
||||||
|
|
||||||
|
|
||||||
var LdapWizard = {
|
var LdapWizard = {
|
||||||
checkPortInfoShown: false,
|
checkPortInfoShown: false,
|
||||||
saveBlacklist: {},
|
saveBlacklist: {},
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
OC_Util::checkAdminUser();
|
OC_Util::checkAdminUser();
|
||||||
|
|
||||||
|
OCP\Util::addScript('user_ldap', 'ldapFilter');
|
||||||
OCP\Util::addScript('user_ldap', 'settings');
|
OCP\Util::addScript('user_ldap', 'settings');
|
||||||
OCP\Util::addScript('core', 'jquery.multiselect');
|
OCP\Util::addScript('core', 'jquery.multiselect');
|
||||||
OCP\Util::addStyle('user_ldap', 'settings');
|
OCP\Util::addStyle('user_ldap', 'settings');
|
||||||
|
|
Loading…
Reference in a new issue