Files
galaxy/static/scripts/galaxy.interactive_environments.js
T

3 lines
3.6 KiB
JavaScript

"use strict";function append_notebook(t){clear_main_area(),$("#main").append('<iframe frameBorder="0" seamless="seamless" style="width: 100%; height: 100%; overflow:hidden;" scrolling="no" src="'+t+'"></iframe>')}function clear_main_area(){$("#spinner").remove(),$("#main").children().remove()}function display_spinner(){$("#main").append('<img id="spinner" src="'+galaxy_root+'static/style/largespinner.gif" style="position:absolute;margin:auto;top:0;left:0;right:0;bottom:0;">')}function make_spin_state(t,e,n,i,a,o,s,r){return{type:void 0!==t?t:"GIE spin",ajax_timeout:void 0!==e?e:2e3,ajax_timeout_max:void 0!==n?n:16e3,ajax_timeout_step:void 0!==i?i:500,sleep:void 0!==a?a:500,sleep_max:void 0!==o?o:8e3,sleep_step:void 0!==s?s:100,log_attempts:void 0===r||r,count:0}}function spin_error(t,e,n){console.log(t),n&&clear_main_area(),"string"==typeof e&&(toastr.clear(),toastr.error(e,"Error",{closeButton:!0,timeOut:0,extendedTimeOut:0,tapToDismiss:!1}))}function spin_again(t){t.sleep<t.sleep_max&&(t.sleep+=t.sleep_step),t.log_attempts&&console.log(t.type+" request "+t.count+" request timeout "+t.ajax_timeout+"ms sleeping "+t.sleep/1e3+"s"),window.setTimeout(t.spinner,t.sleep)}function spin(t,e,n,i,a,o){var s=function(){var s={url:t,xhrFields:{withCredentials:!0},type:"GET",timeout:o.ajax_timeout,success:function(t,e,i){n(t,e,i)||(o.count++,spin_again(o))},error:function(t,e,n){"timeout"==e?(o.ajax_timeout<o.ajax_timeout_max&&(o.ajax_timeout+=o.ajax_timeout_step),o.count++,i(t,e,n)||spin_again(o)):(o.count++,a(t,e,n)||spin_again(o))}};e&&(s.dataType="json"),$.ajax(s)};console.log("Setting up new spinner for "+o.type+" on "+t),o.spinner=s,window.setTimeout(s,o.sleep)}function spin_until(t,e,n,i,a){var o=function(t,e){1==e.count&&(display_spinner(),toastr.info(t,null,{closeButton:!0,timeOut:0,extendedTimeOut:0,tapToDismiss:!1}))},s=function(t,e,i){return o(n.waiting,a),40==a.count&&toastr.warning(n.wait_warn,"Warning",{closeButton:!0,timeOut:0,extendedTimeOut:0,tapToDismiss:!1}),!1};spin(t,e,function(t){if(!e||e&&1==t)console.log(n.success),clear_main_area(),toastr.clear(),i();else{if(e&&0==t)return o(n.not_ready,a),!1;spin_error("Invalid response to "+a.type+" request",n.invalid_response,!0)}return!0},s,s,a)}function load_when_ready(t,e){spin_until(t,!0,{success:"Galaxy reports IE container ready, returning",not_ready:"Galaxy is launching a container in which to run this interactive environment. Please wait...",unknown_response:"Galaxy failed to launch a container in which to run this interactive environment, contact a Galaxy administrator.",waiting:"Galaxy is launching a container in which to run this interactive environment. Please wait...",wait_warn:"It is taking an usually long time to start a container. Attempts will continue but you may want to report this condition to a Galaxy administrator if it does not succeed soon.",error:"Galaxy encountered an error while attempting to determine the readiness of this interactive environment's container, contact a Galaxy administrator."},e,make_spin_state("IE container readiness"))}function test_ie_availability(t,e){spin_until(t,!1,{success:"IE connection succeeded, returning",waiting:"Interactive environment container is running, attempting to connect to the IE. Please wait...",wait_warn:"It is taking an usually long time to connect to the interactive environment. Attempts will continue but you may want to report this condition to a Galaxy administrator if it does not succeed soon.",error:"An error was encountered while attempting to connect to the interactive environment, contact your administrator."},e,make_spin_state("IE availability"))}
//# sourceMappingURL=../maps/galaxy.interactive_environments.js.map