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

1 line
3.6 KiB
JavaScript

define("galaxy.interactive_environments",["exports"],function(t){"use strict";function e(){$("#spinner").remove(),$("#main").children().remove()}function n(){$("#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 i(t,e,n,i,o,a,r,s){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!==o?o:500,sleep_max:void 0!==a?a:8e3,sleep_step:void 0!==r?r:100,log_attempts:void 0===s||s,count:0}}function o(t,n,i){console.log(t),i&&e(),"string"==typeof n&&(toastr.clear(),toastr.error(n,"Error",{closeButton:!0,timeOut:0,extendedTimeOut:0,tapToDismiss:!1}))}function a(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 r(t,e,n,i,o,r){var s=function(){var s={url:t,xhrFields:{withCredentials:!0},type:"GET",timeout:r.ajax_timeout,success:function(t,e,i){n(t,e,i)||(r.count++,a(r))},error:function(t,e,n){"timeout"==e?(r.ajax_timeout<r.ajax_timeout_max&&(r.ajax_timeout+=r.ajax_timeout_step),r.count++,i(t,e,n)||a(r)):(r.count++,o(t,e,n)||a(r))}};e&&(s.dataType="json"),$.ajax(s)};console.log("Setting up new spinner for "+r.type+" on "+t),r.spinner=s,window.setTimeout(s,r.sleep)}function s(t,i,a,s,c){var u=function(t,e){1==e.count&&(n(),toastr.info(t,null,{closeButton:!0,timeOut:0,extendedTimeOut:0,tapToDismiss:!1}))},l=function(t,e,n){return u(a.waiting,c),40==c.count&&toastr.warning(a.wait_warn,"Warning",{closeButton:!0,timeOut:0,extendedTimeOut:0,tapToDismiss:!1}),!1};r(t,i,function(t){if(!i||i&&1==t)console.log(a.success),e(),toastr.clear(),s();else{if(i&&0==t)return u(a.not_ready,c),!1;o("Invalid response to "+c.type+" request",a.invalid_response,!0)}return!0},l,l,c)}Object.defineProperty(t,"__esModule",{value:!0}),t.append_notebook=function(t){e(),$("#main").append('<iframe frameBorder="0" seamless="seamless" style="width: 100%; height: 100%; overflow:hidden;" scrolling="no" src="'+t+'"></iframe>')},t.clear_main_area=e,t.display_spinner=n,t.make_spin_state=i,t.spin_error=o,t.spin=r,t.test_ie_availability=function(t,e){s(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,i("IE availability"))},t.load_when_ready=function(t,e){s(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,i("IE container readiness"))}});