diff --git a/jupyter-openbis-extension/static/uploadDialog.js b/jupyter-openbis-extension/static/uploadDialog.js index 9f848ee0a4d2d4dc6a0d8a122a1a2749803aeb06..6b0ac727300cb7419d491caf06afc0b325313055 100644 --- a/jupyter-openbis-extension/static/uploadDialog.js +++ b/jupyter-openbis-extension/static/uploadDialog.js @@ -58,6 +58,30 @@ define([ } } + function getOpenBISHistoryId() { + var resultDatasetHistoryId = ""; + if(Jupyter && + Jupyter.notebook && + Jupyter.notebook.metadata && + Jupyter.notebook.metadata.openbisHistoryId) { + resultDatasetHistoryId = Jupyter.notebook.metadata.openbisHistoryId; + } + if (!resultDatasetHistoryId) { + var resultDatasetHistoryIdIdx = 0; + while(Jupyter.notebook.get_cell(resultDatasetHistoryIdIdx) != null) { + var cell = Jupyter.notebook.get_cell(resultDatasetHistoryIdIdx); + var cellText = cell.get_text(); + if(cell.get_text().startsWith("resultDatasetHistoryId='")) { + var firstIndexOf = cell.get_text().indexOf("'"); + var lastIndexOf = cell.get_text().indexOf("'", firstIndexOf + 1); + resultDatasetHistoryId = cell.get_text().substring(firstIndexOf + 1, lastIndexOf); + } + resultDatasetHistoryIdIdx++; + } + } + return resultDatasetHistoryId; + } + function getDatasetTypes(env, connection_name, dataset_types, input_fields) { // get all DatasetTypes of a given connection @@ -104,7 +128,9 @@ define([ var mem = state.uploadDataSetTypes[dts[dataset_types.selectedIndex].code] if (mem == null) { - mem = {} + mem = { + "$HISTORY_ID" : getOpenBISHistoryId() + } } input_field.value = pa.code in mem ? mem[pa.code] : ""