Skip to content
Snippets Groups Projects
Commit 583a6c72 authored by Swen Vermeul's avatar Swen Vermeul
Browse files

Merge branch 'master' of sissource.ethz.ch:sispub/jupyter-openbis-extension

parents 2d03a893 7c35f077
No related branches found
No related tags found
No related merge requests found
...@@ -7,15 +7,12 @@ define([ ...@@ -7,15 +7,12 @@ define([
function writeMetaData(data) { function writeMetaData(data) {
var notebook = IPython.notebook var notebook = IPython.notebook
if (typeof notebook.metadata.openbis_connections === 'undefined') { if (typeof notebook.metadata.datasets === 'undefined') {
notebook.metadata.openbis_connections = {} notebook.metadata.datasets = {}
}
if (typeof notebook.metadata.openbis_connections[data.url] === 'undefined') {
notebook.metadata.openbis_connections[data.url] = {}
} }
// store metadata about the downloaded files into the notebook-metadata // store metadata about the downloaded files into the notebook-metadata
if (data.permId) { if (data.permId) {
notebook.metadata.openbis_connections[data.url][data.permId] = { notebook.metadata.datasets[data.permId] = {
"permId": data.permId, "permId": data.permId,
"path": data.path, "path": data.path,
"dataStore": data.dataStore, "dataStore": data.dataStore,
......
...@@ -7,7 +7,9 @@ define([], ...@@ -7,7 +7,9 @@ define([],
}, },
uploadDataSetType: null, uploadDataSetType: null,
uploadDataSetTypes: {}, uploadDataSetTypes: {},
uploadEntityIdentifier: '' uploadEntityIdentifier: '',
getSelectedDataSets: () => [],
getSelectedFiles: () => []
} }
} }
) )
\ No newline at end of file
...@@ -30,6 +30,35 @@ define([ ...@@ -30,6 +30,35 @@ define([
spinner.src="" spinner.src=""
} }
function get_file_list(env, container) {
var url = env.notebook.base_url + 'general/filelist'
fetch(url)
.then( function(response) {
if (response.ok) {
response.json()
.then(function(data){
var values = Object.keys(data.files)
values.sort()
state.getSelectedFiles = createSelectTable(values, container, false)
})
}
else {
console.error(response.status)
}
})
}
function get_dataset_list(env, container) {
console.log(env.notebook.metadata.datasets)
var datasets = env.notebook.metadata.datasets
if (datasets != null) {
var values = Object.keys(datasets)
values.sort()
state.getSelectedDataSets = createSelectTable(values, container, true)
}
}
function getDatasetTypes(env, connection_name, dataset_types, input_fields) { function getDatasetTypes(env, connection_name, dataset_types, input_fields) {
// get all DatasetTypes of a given connection // get all DatasetTypes of a given connection
...@@ -127,6 +156,32 @@ define([ ...@@ -127,6 +156,32 @@ define([
}) })
} }
function createSelectTable(values, container, checked) {
var table = document.createElement("TABLE")
table.className = 'table-bordered table-striped table-condensed'
table.style.width = "100%"
var body = table.createTBody()
var checkboxes = []
values.forEach( value => {
var row = body.insertRow()
var checkbox = document.createElement("INPUT")
checkbox.type = "checkbox"
checkbox.value = value
checkbox.checked = checked
checkboxes.push(checkbox)
row.insertCell().appendChild(checkbox)
var valueCell = row.insertCell()
valueCell.textContent = value
valueCell.style.width = "100%"
})
container.appendChild(table)
return () => checkboxes.filter(cb => cb.checked).map(cb => cb.value)
}
return { return {
help: 'upload Notebook and Data to openBIS', help: 'upload Notebook and Data to openBIS',
icon: 'fa-upload', icon: 'fa-upload',
...@@ -161,14 +216,19 @@ define([ ...@@ -161,14 +216,19 @@ define([
sampleIdentifier.style.width="100%" sampleIdentifier.style.width="100%"
var ds_title = document.createElement("STRONG") var ds_title = document.createElement("STRONG")
ds_title.textContent = "DataSet files" ds_title.textContent = "DataSets"
var ds_files = document.createElement("INPUT") var dataSetListContainer = document.createElement("DIV")
ds_files.type = "text" dataSetListContainer.style.height="150px"
ds_files.placeholder = "filenames" dataSetListContainer.style.overflow="scroll"
ds_files.name = "ds_files" get_dataset_list(env, dataSetListContainer)
ds_files.size = "90"
ds_files.style.width="100%" var files_title = document.createElement("STRONG")
files_title.textContent = "Files"
var fileListContainer = document.createElement("DIV")
fileListContainer.style.height="150px"
fileListContainer.style.overflow="scroll"
get_file_list(env, fileListContainer)
var inputs = document.createElement("DIV") var inputs = document.createElement("DIV")
inputs.style.marginTop = '10px' inputs.style.marginTop = '10px'
inputs.appendChild(main_error) inputs.appendChild(main_error)
...@@ -181,7 +241,9 @@ define([ ...@@ -181,7 +241,9 @@ define([
inputs.appendChild(sample_error) inputs.appendChild(sample_error)
inputs.appendChild(sampleIdentifier) inputs.appendChild(sampleIdentifier)
inputs.appendChild(ds_title) inputs.appendChild(ds_title)
inputs.appendChild(ds_files) inputs.appendChild(dataSetListContainer)
inputs.appendChild(files_title)
inputs.appendChild(fileListContainer)
var uploadDialogBox = $('<div/>').append(inputs) var uploadDialogBox = $('<div/>').append(inputs)
...@@ -206,15 +268,11 @@ define([ ...@@ -206,15 +268,11 @@ define([
var uploadUrl = env.notebook.base_url + 'openbis/dataset/' + connection_name var uploadUrl = env.notebook.base_url + 'openbis/dataset/' + connection_name
var notebook = IPython.notebook var notebook = IPython.notebook
var files = state.getSelectedFiles()
var re = /\/notebooks\/(.*?)$/ var re = /\/notebooks\/(.*?)$/
var files = []
var filepath = window.location.pathname.match(re)[1] var filepath = window.location.pathname.match(re)[1]
files.push(filepath) files.push(filepath)
// FIXME
//if (ds_files.val()) {
// files.push(ds_files.value)
//}
var props = {} var props = {}
for (input of $('#upload-input-fields').find('input')) { for (input of $('#upload-input-fields').find('input')) {
props[input.name] = input.value props[input.name] = input.value
......
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