X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f5a30607d1746b29688363530a3011ee5c2f4f9a..a31587cba5c2c38e0fc4f91981baf8bf2605664c:/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 a40334b8a2..eb4fbc3901 100644 --- a/apps/workbench/app/assets/javascripts/request_shell_access.js +++ b/apps/workbench/app/assets/javascripts/request_shell_access.js @@ -1,36 +1,14 @@ -$(document).ready(function(){ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +$(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) { - requestSent = localStorage.getItem('request_shell_access'); - if (requestSent != null) { - $("#shell_access_requested_msg").html(requestSent) - } 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'); - $('div').remove('.shell_access_requested'); - - $('.no_shell_access').append('

A request for shell access was sent.

'); - var timestamp = new Date(); - localStorage.setItem("request_shell_access", "A request for shell access was sent on " + - timestamp.toLocaleDateString() + - " at " + timestamp.toLocaleTimeString()); - }). - 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.

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