From eaa85ff336d366fc0f4a5183d65cfe7bb4781083 Mon Sep 17 00:00:00 2001 From: vermeul <swen@ethz.ch> Date: Thu, 4 Jul 2019 15:04:03 +0200 Subject: [PATCH] notebook will automatically save itself when uploading --- .../static/uploadDialog.js | 60 +++++++++++-------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/jupyter-openbis-extension/static/uploadDialog.js b/jupyter-openbis-extension/static/uploadDialog.js index f196acd..a8bdb9a 100644 --- a/jupyter-openbis-extension/static/uploadDialog.js +++ b/jupyter-openbis-extension/static/uploadDialog.js @@ -475,33 +475,41 @@ define([ saveState() return true } - - if (IPython.notebook.dirty === true) { - dialog.modal({ - body: 'Please save the notebook before uploading it to openBIS.', - title: 'Save notebook first', - buttons: { - 'Back': {} - }, - notebook: env.notebook, - keyboard_manager: env.notebook.keyboard_manager - }) - } else { - dialog.modal({ - body: uploadDialogBox, - title: 'Upload openBIS DataSet', - buttons: { - 'Cancel': { - click: onCancel - }, - 'Upload': { - class: 'btn-primary btn-large', - click: onOk - } + dialog_params = { + body: uploadDialogBox, + title: 'Upload openBIS DataSet', + buttons: { + 'Cancel': { + click: onCancel }, - notebook: env.notebook, - keyboard_manager: env.notebook.keyboard_manager - }) + 'Upload': { + class: 'btn-primary btn-large', + click: onOk + } + }, + notebook: env.notebook, + keyboard_manager: env.notebook.keyboard_manager + } + + if (env.notebook.dirty === true) { + env.notebook.save_notebook() + .then(function () { + dialog.modal(dialog_params) + }) + .catch(function (error) { + dialog.modal({ + body: error, + title: 'Error saving the notebook', + buttons: { + 'Back': {} + }, + notebook: env.notebook, + keyboard_manager: env.notebook.keyboard_manager + }) + }) + } + else { + dialog.modal(dialog_params) } } } -- GitLab