Skip to content
Snippets Groups Projects
Commit 59373c15 authored by Juan Fuentes's avatar Juan Fuentes
Browse files

setting history id when is available on the jupyter notebook and the selected...

setting history id when is available on the jupyter notebook and the selected dataset type, comments
parent fb688415
No related branches found
No related tags found
No related merge requests found
...@@ -59,13 +59,16 @@ define([ ...@@ -59,13 +59,16 @@ define([
} }
function getOpenBISHistoryId() { function getOpenBISHistoryId() {
// Default empty history id
var resultDatasetHistoryId = ""; var resultDatasetHistoryId = "";
// Search for the history id on the metadata, new format, hidden from the user
if(Jupyter && if(Jupyter &&
Jupyter.notebook && Jupyter.notebook &&
Jupyter.notebook.metadata && Jupyter.notebook.metadata &&
Jupyter.notebook.metadata.openbisHistoryId) { Jupyter.notebook.metadata.openbisHistoryId) {
resultDatasetHistoryId = Jupyter.notebook.metadata.openbisHistoryId; resultDatasetHistoryId = Jupyter.notebook.metadata.openbisHistoryId;
} }
// Search for the history id on the cells, older format
if (!resultDatasetHistoryId) { if (!resultDatasetHistoryId) {
var resultDatasetHistoryIdIdx = 0; var resultDatasetHistoryIdIdx = 0;
while(Jupyter.notebook.get_cell(resultDatasetHistoryIdIdx) != null) { while(Jupyter.notebook.get_cell(resultDatasetHistoryIdIdx) != null) {
...@@ -79,7 +82,7 @@ define([ ...@@ -79,7 +82,7 @@ define([
resultDatasetHistoryIdIdx++; resultDatasetHistoryIdIdx++;
} }
} }
return resultDatasetHistoryId; return resultDatasetHistoryId; // We always return at least the empty one
} }
function getDatasetTypes(env, connection_name, dataset_types, input_fields) { function getDatasetTypes(env, connection_name, dataset_types, input_fields) {
...@@ -129,7 +132,7 @@ define([ ...@@ -129,7 +132,7 @@ define([
var mem = state.uploadDataSetTypes[dts[dataset_types.selectedIndex].code] var mem = state.uploadDataSetTypes[dts[dataset_types.selectedIndex].code]
if (mem == null) { if (mem == null) {
mem = { mem = {
"$HISTORY_ID" : getOpenBISHistoryId() "$HISTORY_ID" : getOpenBISHistoryId() // History Id should get automatically populated if available
} }
} }
input_field.value = pa.code in mem ? mem[pa.code] : "" input_field.value = pa.code in mem ? mem[pa.code] : ""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment