Commit 51d614e64c88a9932b9fad928f9e14c57cafb5ed

Authored by Goutte
1 parent 9c314ef2

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,6 +162,7 @@
162 class="mdl-button mdl-button--raised mdl-button--primary" 162 class="mdl-button mdl-button--raised mdl-button--primary"
163 title="Download the raw data for each selected target and parameters."> 163 title="Download the raw data for each selected target and parameters.">
164 Download 164 Download
  165 + <div id="download_spinner" class="mdl-spinner mdl-js-spinner is-active"></div>
165 </button> 166 </button>
166 <button id="samp" 167 <button id="samp"
167 class="samp mdl-button mdl-button--raised mdl-button--primary mdl-button--disabled" 168 class="samp mdl-button mdl-button--raised mdl-button--primary mdl-button--disabled"
@@ -346,6 +347,14 @@ @@ -346,6 +347,14 @@
346 background-color: #c8d3e1; 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 {# CSS Spinners #} 358 {# CSS Spinners #}
350 359
351 #plots_loader { 360 #plots_loader {
@@ -665,15 +674,26 @@ jQuery().ready(function($){ @@ -665,15 +674,26 @@ jQuery().ready(function($){
665 window.location = "?input_slug="+new_input_slug; 674 window.location = "?input_slug="+new_input_slug;
666 return false; 675 return false;
667 }); 676 });
  677 + var download_spinner = $('#download_spinner');
  678 + var waiting_for_download = false;
668 $('#download').on("click", function(e){ 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 var url = sw.buildDownloadUrl(); 683 var url = sw.buildDownloadUrl();
670 console.info("Downloading " + url); 684 console.info("Downloading " + url);
671 $.ajax({ 685 $.ajax({
672 type: 'GET', 686 type: 'GET',
673 url: url, 687 url: url,
674 processData: false, 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 error: function (xhr) { 694 error: function (xhr) {
  695 + download_spinner.css('display', 'none');
  696 + waiting_for_download = false;
677 console.error('Cannot download.', xhr); 697 console.error('Cannot download.', xhr);
678 alert("Our apologies, there was an error while downloading."); 698 alert("Our apologies, there was an error while downloading.");
679 } 699 }