always abort running ajax request when the method is fired up again

This commit is contained in:
Arthur Schiwon 2014-10-10 13:30:03 +02:00
parent f31d4caf57
commit ea7975ac8b
1 changed files with 28 additions and 12 deletions

View File

@ -148,9 +148,15 @@ var LdapWizard = {
userFilter: false, userFilter: false,
loginFilter: false, loginFilter: false,
groupFilter: false, groupFilter: false,
ajaxRequests: {},
ajax: function(param, fnOnSuccess, fnOnError) { ajax: function(param, fnOnSuccess, fnOnError, reqID) {
$.post( if(reqID !== undefined) {
if(LdapWizard.ajaxRequests.hasOwnProperty(reqID)) {
LdapWizard.ajaxRequests[reqID].abort();
}
}
var request = $.post(
OC.filePath('user_ldap','ajax','wizard.php'), OC.filePath('user_ldap','ajax','wizard.php'),
param, param,
function(result) { function(result) {
@ -161,6 +167,9 @@ var LdapWizard = {
} }
} }
); );
if(reqID !== undefined) {
LdapWizard.ajaxRequests[reqID] = request;
}
}, },
applyChanges: function (result) { applyChanges: function (result) {
@ -244,7 +253,8 @@ var LdapWizard = {
LdapWizard.showInfoBox(t('user_ldap', 'Please specify a Base DN')); LdapWizard.showInfoBox(t('user_ldap', 'Please specify a Base DN'));
LdapWizard.showInfoBox(t('user_ldap', 'Could not determine Base DN')); LdapWizard.showInfoBox(t('user_ldap', 'Could not determine Base DN'));
$('#ldap_base').prop('disabled', false); $('#ldap_base').prop('disabled', false);
} },
'guessBaseDN'
); );
} }
}, },
@ -274,7 +284,8 @@ var LdapWizard = {
LdapWizard.hideSpinner('#ldap_port'); LdapWizard.hideSpinner('#ldap_port');
$('#ldap_port').prop('disabled', false); $('#ldap_port').prop('disabled', false);
LdapWizard.showInfoBox(t('user_ldap', 'Please specify the port')); LdapWizard.showInfoBox(t('user_ldap', 'Please specify the port'));
} },
'guessPortAndTLS'
); );
} }
}, },
@ -323,7 +334,7 @@ var LdapWizard = {
encodeURIComponent($('#ldap_serverconfig_chooser').val()); encodeURIComponent($('#ldap_serverconfig_chooser').val());
LdapWizard.showSpinner(spinnerID); LdapWizard.showSpinner(spinnerID);
LdapWizard.ajax(param, var request = LdapWizard.ajax(param,
function(result) { function(result) {
LdapWizard.applyChanges(result); LdapWizard.applyChanges(result);
LdapWizard.hideSpinner(spinnerID); LdapWizard.hideSpinner(spinnerID);
@ -331,7 +342,8 @@ var LdapWizard = {
function (result) { function (result) {
OC.Notification.show('Counting the entries failed with, ' + result.message); OC.Notification.show('Counting the entries failed with, ' + result.message);
LdapWizard.hideSpinner(spinnerID); LdapWizard.hideSpinner(spinnerID);
} },
method
); );
}, },
@ -348,7 +360,7 @@ var LdapWizard = {
'&ldap_serverconfig_chooser='+ '&ldap_serverconfig_chooser='+
encodeURIComponent($('#ldap_serverconfig_chooser').val()); encodeURIComponent($('#ldap_serverconfig_chooser').val());
//runs in the background, no callbacks necessary //runs in the background, no callbacks necessary
LdapWizard.ajax(param, LdapWizard.applyChanges, function(){}); LdapWizard.ajax(param, LdapWizard.applyChanges, function(){}, 'detectEmailAttribute');
}, },
detectGroupMemberAssoc: function() { detectGroupMemberAssoc: function() {
@ -362,7 +374,8 @@ var LdapWizard = {
}, },
function (result) { function (result) {
// error handling // error handling
} },
'determineGroupMemberAssoc'
); );
}, },
@ -395,12 +408,13 @@ var LdapWizard = {
{noneSelectedText : 'No attributes found'}); {noneSelectedText : 'No attributes found'});
$('#ldap_loginfilter_attributes').multiselect('disable'); $('#ldap_loginfilter_attributes').multiselect('disable');
LdapWizard.hideSpinner('#ldap_loginfilter_attributes'); LdapWizard.hideSpinner('#ldap_loginfilter_attributes');
} },
'determineAttributes'
); );
}, },
findAvailableGroups: function(multisel, type) { findAvailableGroups: function(multisel, type) {
if(type != 'Users' && type != 'Groups') { if(type !== 'Users' && type !== 'Groups') {
return false; return false;
} }
param = 'action=determineGroupsFor'+encodeURIComponent(type)+ param = 'action=determineGroupsFor'+encodeURIComponent(type)+
@ -442,7 +456,8 @@ var LdapWizard = {
LdapWizard.userFilterAvailableGroupsHasRun = true; LdapWizard.userFilterAvailableGroupsHasRun = true;
LdapWizard.postInitUserFilter(); LdapWizard.postInitUserFilter();
} }
} },
'findAvailableGroupsFor' + type
); );
}, },
@ -484,7 +499,8 @@ var LdapWizard = {
LdapWizard.postInitUserFilter(); LdapWizard.postInitUserFilter();
} }
//TODO: error handling //TODO: error handling
} },
'determine' + type + 'ObjectClasses'
); );
}, },