1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
6 on('notifications:recount',
8 var menu = $('.notification-menu');
9 n = $('.notification', menu).not('.empty').length;
10 $('.notification-count', menu).html(n>0 ? n : '');
12 on('ajax:success', 'form.new_authorized_key',
13 function(e, data, status, xhr) {
14 $(e.target).parents('.notification').eq(0).fadeOut('slow', function() {
15 $('<li class="alert alert-success daxalert">SSH key added.</li>').hide().replaceAll(this).fadeIn('slow');
16 $(document).trigger('notifications:recount');
19 on('ajax:complete', 'form.new_authorized_key',
20 function(e, data, status, xhr) {
21 $($('input[name=disable_element]', e.target).val()).
24 on('ajax:error', 'form.new_authorized_key',
25 function(e, xhr, status, error) {
27 response = $.parseJSON(xhr.responseText);
28 error_div = $(e.target).parent().find('div.ajax-errors');
29 if (error_div.length == 0) {
30 $(e.target).parent().append('<div class="alert alert-error ajax-errors"></div>');
31 error_div = $(e.target).parent().find('div.ajax-errors');
33 if (response.errors) {
34 error_div.html($('<p/>').text(response.errors).html());
36 error_div.html('<p>Sorry, request failed.</p>');
39 $($('input[name=disable_element]', e.target).val()).
42 on('click', 'form[data-remote] input[type=submit]',
44 $(e.target).parents('form').eq(0).parent().find('div.ajax-errors').html('').hide();
47 find('input[name=disable_element]').