Commit 411733ea authored by dcoudrin's avatar dcoudrin
Browse files

if notebook saved while on GUI, GUI shown on load

parent e4436f5a
......@@ -54,6 +54,7 @@ export function switchView () {
const nbpApp = document.getElementsByClassName('nbp-app');
if (!isVisible(notebookPanel)) {
Jupyter.notebook.metadata.biocham_gui = false;
Jupyter.keyboard_manager.enable();
notebookPanel.style.height = '100%';
notebookPanel.style.visibility = 'visible';
......@@ -69,6 +70,7 @@ export function switchView () {
body.classList.add('notebook_app');
}
else if (isVisible(notebookPanel)) {
Jupyter.notebook.metadata.biocham_gui = true;
// Need to disable the notebook shortcuts when in the GUI
Jupyter.keyboard_manager.disable();
notebookPanel.style.visibility = 'hidden';
......@@ -190,19 +192,6 @@ function loadGUI(kernelName) {
//}
}
function saveMetadata() {
Jupyter.notebook.events.on('notebook_saved.Notebook', function () {
const gui = document.getElementById('gui_panel');
console.log(Jupyter.notebook.metadata.biocham_gui);
if (gui.style.display !== 'none') {
Jupyter.notebook.metadata.biocham_gui = true;
} else {
Jupyter.notebook.metadata.biocham_gui = false;
}
//Jupyter.notebook.save_notebook();
});
}
/**
* Jupyter extension loading, only load the GUI if Jupyter uses biocham
* kernel.
......@@ -212,14 +201,12 @@ export function load_ipython_extension() {
// the GUI is not loaded.
try {
loadGUI(Jupyter.notebook.kernel.name);
saveMetadata();
if (Jupyter.notebook.metadata.biocham_gui) {
document.getElementById('switch_btn').click();
}
} catch(e) {
Jupyter.notebook.events.on('kernel_ready.Kernel', function () {
loadGUI(Jupyter.notebook.kernel.name);
saveMetadata();
if (Jupyter.notebook.metadata.biocham_gui) {
document.getElementById('switch_btn').click();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment