From dcdf1ae1f98c06fe998d5ab6212ede2392597681 Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Wed, 23 Aug 2017 14:02:48 +0000
Subject: [PATCH] SSDM-4223 : Lab notebooks get created and open after
 creation, even if filenames collide and the server renames then in sequence

SVN: 38654
---
 .../1/as/webapps/eln-lims/html/js/util/JupyterUtil.js | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/JupyterUtil.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/JupyterUtil.js
index 6542dd958da..00ebadd6186 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/JupyterUtil.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/JupyterUtil.js
@@ -18,9 +18,10 @@ var JupyterUtil = new function() {
 	
 	this.createJupyterNotebookAndOpen = function(dataSetIds) {
 		var folder = "openbis";
-		var fileName = dataSetIds[0];
-		var jupyterURL = profile.jupyterIntegrationServerEndpoint + "?token=" + mainController.serverFacade.openbisServer.getSession() + "&folder=" + folder + "&filename=" + fileName + ".ipynb";
+		var fileName = dataSetIds[0] + ".ipynb";
+		var jupyterURL = profile.jupyterIntegrationServerEndpoint + "?token=" + mainController.serverFacade.openbisServer.getSession() + "&folder=" + folder + "&filename=" + fileName;
 		var newJupyterNotebook = this.createJupyterNotebookContent(dataSetIds);
+		var jupyterNotebookURL = profile.jupyterEndpoint + "user/" + mainController.serverFacade.getUserId() + "/notebooks/" + folder + "/";
 		
 		$.ajax({
             url : jupyterURL,
@@ -31,7 +32,9 @@ var JupyterUtil = new function() {
 //            contentType: 'application/json',
             data : JSON.stringify(newJupyterNotebook),
             success : function(result) {
-            	alert("success:" + JSON.stringify(result));
+            	//alert("success:" + JSON.stringify(result));
+            	var win = window.open(jupyterNotebookURL + result.fileName, '_blank');
+				win.focus(); 
             },
             error : function(result) {
             	alert("error: " + JSON.stringify(result));
@@ -49,7 +52,7 @@ var JupyterUtil = new function() {
 			      },
 			      "outputs": [],
 			      "source": [
-			        "Initialize Openbis API\n",
+			        "#Initialize Openbis API\n",
 			        "o = Openbis(url='" + profile.jupyterOpenbisEndpoint + "', verify_certificates=False)"
 			      ]
 		};
-- 
GitLab