Merge branch '8784-dir-listings'
[arvados.git] / apps / workbench / app / assets / javascripts / report_issue.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 $(document).
6   on('click', "#report-issue-submit", function(e){
7     $(this).html('Sending');
8     $(this).prop('disabled', true);
9     var $cancelButton = $('#report-issue-cancel');
10     if ($cancelButton) {
11       $cancelButton.html('Close');
12     }
13     $('div').remove('.modal-footer-status');
14
15     $.ajax('/report_issue', {
16         type: 'POST',
17         data: $(this).parents('form').serialize()
18     }).success(function(data, status, jqxhr) {
19         var $sendButton = $('#report-issue-submit');
20         $sendButton.html('Report sent');
21         $('div').remove('.modal-footer-status');
22         $('.modal-footer').append('<div><br/></div><div class="modal-footer-status alert alert-success"><p class="contain-align-left">Thanks for reporting this issue!</p></div>');
23     }).fail(function(jqxhr, status, error) {
24         var $sendButton = $('#report-issue-submit');
25         if ($sendButton && $sendButton.prop('disabled')) {
26           $('div').remove('.modal-footer-status');
27           $('.modal-footer').append('<div><br/></div><div class="modal-footer-status alert alert-danger"><p class="contain-align-left">We are sorry. We could not submit your report! We really want this to work, though -- please try again.</p></div>');
28           $sendButton.html('Send problem report');
29           $sendButton.prop('disabled', false);
30         }
31         var $cancelButton = $('#report-issue-cancel');
32         $cancelButton.html('Cancel');
33     });
34     return false;
35   });