User admin: properly handle AJAX errors.

Added specific handling for clicking on non-existing users. The styling
might need some tweaking (it's pretty ugly), but then again, it's just
for us admins.
This commit is contained in:
2016-09-06 11:27:49 +02:00
parent 486686f1f9
commit 3bb55fd3db
2 changed files with 23 additions and 2 deletions

View File

@@ -104,7 +104,20 @@ script(type="text/javascript").
var url = '/u/' + userId + '/edit?embed=1';
$.get(url, function(dataHtml){
$('#search-hit-container').html(dataHtml);
});
})
.fail(function(jqXHR, textStatus, errorThrown) {
var $userbox = $(".search-hit.users[data-user-id='" + userId + "']");
var $msgbox = $userbox.find('.search-hit-roles');
if (console) console.log('Error fetching user', userId, '; jqXHR=', jqXHR);
$userbox.addClass('alert alert-warning');
if (jqXHR.status == 404) {
$msgbox.text('This user does not seem to exist.');
} else {
$msgbox.text('There was an error fetching the user: ' + jqXHR.responseText + '.')
}
})
;
}
$('body').on('click', '.search-hit', function(){