Commit 51d614e64c88a9932b9fad928f9e14c57cafb5ed
1 parent
9c314ef2
Exists in
master
and in
2 other branches
Add a spinner to the Downlaod button, as it may take a long time.
Showing
1 changed file
with
21 additions
and
1 deletions
Show diff stats
web/view/home.html.jinja2
... | ... | @@ -162,6 +162,7 @@ |
162 | 162 | class="mdl-button mdl-button--raised mdl-button--primary" |
163 | 163 | title="Download the raw data for each selected target and parameters."> |
164 | 164 | Download |
165 | + <div id="download_spinner" class="mdl-spinner mdl-js-spinner is-active"></div> | |
165 | 166 | </button> |
166 | 167 | <button id="samp" |
167 | 168 | class="samp mdl-button mdl-button--raised mdl-button--primary mdl-button--disabled" |
... | ... | @@ -346,6 +347,14 @@ |
346 | 347 | background-color: #c8d3e1; |
347 | 348 | } |
348 | 349 | |
350 | + #download_spinner { | |
351 | + display: none; | |
352 | + top: 2px; | |
353 | + left: 4px; | |
354 | + width: 14px; | |
355 | + height: 14px; | |
356 | + } | |
357 | + | |
349 | 358 | {# CSS Spinners #} |
350 | 359 | |
351 | 360 | #plots_loader { |
... | ... | @@ -665,15 +674,26 @@ jQuery().ready(function($){ |
665 | 674 | window.location = "?input_slug="+new_input_slug; |
666 | 675 | return false; |
667 | 676 | }); |
677 | + var download_spinner = $('#download_spinner'); | |
678 | + var waiting_for_download = false; | |
668 | 679 | $('#download').on("click", function(e){ |
680 | + if (waiting_for_download) return; | |
681 | + download_spinner.css('display', 'inline-block'); | |
682 | + waiting_for_download = true; | |
669 | 683 | var url = sw.buildDownloadUrl(); |
670 | 684 | console.info("Downloading " + url); |
671 | 685 | $.ajax({ |
672 | 686 | type: 'GET', |
673 | 687 | url: url, |
674 | 688 | processData: false, |
675 | - success: function (data) { window.location = url; }, | |
689 | + success: function (data) { | |
690 | + download_spinner.css('display', 'none'); | |
691 | + waiting_for_download = false; | |
692 | + window.location = url; | |
693 | + }, | |
676 | 694 | error: function (xhr) { |
695 | + download_spinner.css('display', 'none'); | |
696 | + waiting_for_download = false; | |
677 | 697 | console.error('Cannot download.', xhr); |
678 | 698 | alert("Our apologies, there was an error while downloading."); |
679 | 699 | } | ... | ... |