Fix jupyter javascript; this all needs a ton of disentanglement and standardization.

This commit is contained in:
Dannon Baker
2017-11-02 16:08:38 -04:00
parent 2004f31ad5
commit f7ccdd7c74
5 changed files with 25 additions and 20 deletions
@@ -1,3 +1,5 @@
var IES = window.IES;
function message_failed_auth(password){
toastr.info(
"Automatic authorization failed. You can manually login with:<br>" + password + "<br> <a href='https://github.com/bgruening/galaxy-ipython/wiki/Automatic-Authorization-Failed' target='_blank'>More details ...</a>",
@@ -36,7 +38,7 @@ function message_no_auth(){
function load_notebook(password, notebook_login_url, notebook_access_url){
// Test notebook_login_url for accessibility, executing the login+load function whenever
// we've successfully connected to the IE.
test_ie_availability(notebook_login_url, function(){
IES.test_ie_availability(notebook_login_url, function(){
_handle_notebook_loading(password, notebook_login_url, notebook_access_url);
keep_alive();
});
@@ -53,10 +55,10 @@ function keep_alive(){
var count_max = 60;
// we sleep 15 seconds between requests and the default timeout for the Jupyter container is 120 seconds, so start
// with a pretty high ajax timeout. sleep starts low because we want to get the warning up pretty quickly
var spin_state = make_spin_state("IE keepalive", 8000, 16000, 2000, 5000, 15000, 5000, false);
var spin_state = IES.make_spin_state("IE keepalive", 8000, 16000, 2000, 5000, 15000, 5000, false);
var success = function(){
console.log("IE keepalive request succeeded");
toastr.clear()
toastr.clear();
if(spin_state.count >= warn_at){
toastr.clear();
toastr.success(
@@ -81,12 +83,12 @@ function keep_alive(){
);
return false; // keep spinning
}else if(spin_state.count >= count_max){
spin_error("IE keepalive failure limit reached", "Lost connection to interactive environment, contact your administrator", false);
IES.spin_error("IE keepalive failure limit reached", "Lost connection to interactive environment, contact your administrator", false);
return true; // stop spinning
}
}
console.log("IE keepalive worker starting");
spin(notebook_access_url, false, success, timeout_error, timeout_error, spin_state);
IES.spin(notebook_access_url, false, success, timeout_error, timeout_error, spin_state);
}
@@ -109,17 +111,17 @@ function _handle_notebook_loading(password, notebook_login_url, notebook_access_
},
// If that is successful, load the notebook
success: function(){
append_notebook(notebook_access_url);
IES.append_notebook(notebook_access_url);
},
error: function(jqxhr, status, error){
if(ie_password_auth){
// Failure happens due to CORS
message_failed_auth(password);
append_notebook(notebook_access_url);
IES.append_notebook(notebook_access_url);
}else{
message_failed_connection();
// Do we want to try and load the notebook anyway? Just in case?
append_notebook(notebook_access_url);
IES.append_notebook(notebook_access_url);
}
}
});
@@ -127,6 +129,6 @@ function _handle_notebook_loading(password, notebook_login_url, notebook_access_
else {
// Not using password auth, just embed it to avoid content-origin issues.
message_no_auth();
append_notebook(notebook_access_url);
IES.append_notebook(notebook_access_url);
}
}
@@ -61,7 +61,9 @@ ${ ie.plugin_require_config() }
// Load notebook
requirejs(['galaxy.interactive_environments', 'plugin/jupyter'], function(IES){
IES.default(ie_readiness_url, function(){
// This global is not awesome, get rid of it when possible (when IES are a part of the build process)
window.IES = IES;
IES.load_when_ready(ie_readiness_url, function(){
load_notebook(ie_password, notebook_login_url, notebook_access_url);
});
});