X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/180498df4db8c43080bb302bc56edea70c940583..c4fa80c6ed2445e1e384455944eb6c4108906cad:/apps/workbench/app/assets/javascripts/request_shell_access.js diff --git a/apps/workbench/app/assets/javascripts/request_shell_access.js b/apps/workbench/app/assets/javascripts/request_shell_access.js index 9378c6b0bf..792ab31312 100644 --- a/apps/workbench/app/assets/javascripts/request_shell_access.js +++ b/apps/workbench/app/assets/javascripts/request_shell_access.js @@ -1,30 +1,10 @@ -$(document).ready(function(){ +$(document).on('ready ajax:success storage', function() { + // Update the "shell access requested" info box according to the + // current state of localStorage. + var msg = localStorage.getItem('request_shell_access'); var $noShellAccessDiv = $('#no_shell_access'); - if ($noShellAccessDiv.length) { - if (getLocalStorageValue('request_shell_access') == 'sent') { - $('div').remove('.no_shell_access_msg'); - } else { - $('div').remove('.shell_access_requested'); - } + if ($noShellAccessDiv.length > 0) { + $('.alert-success p', $noShellAccessDiv).text(msg); + $('.alert-success', $noShellAccessDiv).toggle(!!msg); } - }); - -$(document). - on('click', "#request_shell_submit", function(e){ - $(this).html('Sending request ...'); - $(this).prop('disabled', true); - $('div').remove('.request_shell_access_failed'); - - $.ajax('/'). - success(function(data, status, jqxhr) { - $('div').remove('.no_shell_access_msg'); - $('.no_shell_access').append('

Request sent for shell access.

'); - localStorage.setItem("request_shell_access", "sent"); - }). - fail(function(jqxhr, status, error) { - var $sendButton = $('#request_shell_submit'); - $sendButton.html('Request shell access'); - $sendButton.prop('disabled', false); - $('.no_shell_access').append('

Something went wrong. Please try again.

'); - }); - }); +});