From: Arthur Schiwon Date: Fri, 10 Oct 2014 11:30:03 +0000 (+0200) Subject: always abort running ajax request when the method is fired up again X-Git-Tag: v8.0.0alpha1~502^2~7 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ea7975ac8ba94b3dfcd3f61ff74847de97a881b4;p=nextcloud-server.git always abort running ajax request when the method is fired up again --- diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js index 5c696000f5c..75a4830b28e 100644 --- a/apps/user_ldap/js/settings.js +++ b/apps/user_ldap/js/settings.js @@ -148,9 +148,15 @@ var LdapWizard = { userFilter: false, loginFilter: false, groupFilter: false, + ajaxRequests: {}, - ajax: function(param, fnOnSuccess, fnOnError) { - $.post( + ajax: function(param, fnOnSuccess, fnOnError, reqID) { + if(reqID !== undefined) { + if(LdapWizard.ajaxRequests.hasOwnProperty(reqID)) { + LdapWizard.ajaxRequests[reqID].abort(); + } + } + var request = $.post( OC.filePath('user_ldap','ajax','wizard.php'), param, function(result) { @@ -161,6 +167,9 @@ var LdapWizard = { } } ); + if(reqID !== undefined) { + LdapWizard.ajaxRequests[reqID] = request; + } }, applyChanges: function (result) { @@ -244,7 +253,8 @@ var LdapWizard = { LdapWizard.showInfoBox(t('user_ldap', 'Please specify a Base DN')); LdapWizard.showInfoBox(t('user_ldap', 'Could not determine Base DN')); $('#ldap_base').prop('disabled', false); - } + }, + 'guessBaseDN' ); } }, @@ -274,7 +284,8 @@ var LdapWizard = { LdapWizard.hideSpinner('#ldap_port'); $('#ldap_port').prop('disabled', false); LdapWizard.showInfoBox(t('user_ldap', 'Please specify the port')); - } + }, + 'guessPortAndTLS' ); } }, @@ -323,7 +334,7 @@ var LdapWizard = { encodeURIComponent($('#ldap_serverconfig_chooser').val()); LdapWizard.showSpinner(spinnerID); - LdapWizard.ajax(param, + var request = LdapWizard.ajax(param, function(result) { LdapWizard.applyChanges(result); LdapWizard.hideSpinner(spinnerID); @@ -331,7 +342,8 @@ var LdapWizard = { function (result) { OC.Notification.show('Counting the entries failed with, ' + result.message); LdapWizard.hideSpinner(spinnerID); - } + }, + method ); }, @@ -348,7 +360,7 @@ var LdapWizard = { '&ldap_serverconfig_chooser='+ encodeURIComponent($('#ldap_serverconfig_chooser').val()); //runs in the background, no callbacks necessary - LdapWizard.ajax(param, LdapWizard.applyChanges, function(){}); + LdapWizard.ajax(param, LdapWizard.applyChanges, function(){}, 'detectEmailAttribute'); }, detectGroupMemberAssoc: function() { @@ -362,7 +374,8 @@ var LdapWizard = { }, function (result) { // error handling - } + }, + 'determineGroupMemberAssoc' ); }, @@ -395,12 +408,13 @@ var LdapWizard = { {noneSelectedText : 'No attributes found'}); $('#ldap_loginfilter_attributes').multiselect('disable'); LdapWizard.hideSpinner('#ldap_loginfilter_attributes'); - } + }, + 'determineAttributes' ); }, findAvailableGroups: function(multisel, type) { - if(type != 'Users' && type != 'Groups') { + if(type !== 'Users' && type !== 'Groups') { return false; } param = 'action=determineGroupsFor'+encodeURIComponent(type)+ @@ -442,7 +456,8 @@ var LdapWizard = { LdapWizard.userFilterAvailableGroupsHasRun = true; LdapWizard.postInitUserFilter(); } - } + }, + 'findAvailableGroupsFor' + type ); }, @@ -484,7 +499,8 @@ var LdapWizard = { LdapWizard.postInitUserFilter(); } //TODO: error handling - } + }, + 'determine' + type + 'ObjectClasses' ); },