Merge branch 'master' into 4951-request-vm
[arvados.git] / apps / workbench / app / assets / javascripts / request_shell_access.js
1 $(document).ready(function(){
2     var $noShellAccessDiv = $('#no_shell_access');
3     if ($noShellAccessDiv.length) {
4       if (getLocalStorageValue('request_shell_access') == 'sent') {
5         $('div').remove('.no_shell_access_msg');
6       } else {
7         $('div').remove('.shell_access_requested');
8       }
9     }
10   });
11
12 $(document).
13   on('click', "#request_shell_submit", function(e){
14     $(this).html('Sending request ...');
15     $(this).prop('disabled', true);
16     $('div').remove('.request_shell_access_failed');
17
18     $.ajax('/').
19       success(function(data, status, jqxhr) {
20         $('div').remove('.no_shell_access_msg');
21         $('.no_shell_access').append('<div class="alert alert-success"><p class="contain-align-left">Request sent for shell access.</p></div>');
22         localStorage.setItem("request_shell_access", "sent");
23       }).
24       fail(function(jqxhr, status, error) {
25         var $sendButton = $('#request_shell_submit');
26         $sendButton.html('Request shell access');
27         $sendButton.prop('disabled', false);
28         $('.no_shell_access').append('<div class="request_shell_access_failed alert alert-danger"><p class="contain-align-left">Something went wrong. Please try again.</p></div>');
29       });
30   });