Skip to content
Snippets Groups Projects
Commit 42a46fe2 authored by PTSEFTON's avatar PTSEFTON
Browse files

Added directory support (add a dataset)

parent f53a361d
No related merge requests found
...@@ -197,7 +197,7 @@ router.get('/files', function(req, res, next) { ...@@ -197,7 +197,7 @@ router.get('/files', function(req, res, next) {
console.log(absolute_path, shell.test('-d', absolute_path)); console.log(absolute_path, shell.test('-d', absolute_path));
if (shell.test('-d', absolute_path)) { if (shell.test('-d', absolute_path)) {
if (!defaults.ignore_dirs.includes(f)){ if (!defaults.ignore_dirs.includes(f)){
dirs.push({"absolute": absolute_path, "name": f}) dirs.push({"absolute": absolute_path, "name": f, "id": absolute_path})
} }
} else if (!defaults.ignore_files.includes(f)) { } else if (!defaults.ignore_files.includes(f)) {
files[absolute_path]= ({"filename": f, "name": f, "id": absolute_path}) files[absolute_path]= ({"filename": f, "name": f, "id": absolute_path})
...@@ -224,7 +224,6 @@ router.get('/preview', function(req, res, next) { ...@@ -224,7 +224,6 @@ router.get('/preview', function(req, res, next) {
}); });
router.get('/context_entities', function(req, res, next) { router.get('/context_entities', function(req, res, next) {
console.log(req.query.dataset_path); console.log(req.query.dataset_path);
if (req.query.dataset_path) { if (req.query.dataset_path) {
......
...@@ -145,27 +145,42 @@ ...@@ -145,27 +145,42 @@
</template> </template>
</a> </h1> </a> </h1>
<div id="filelist" border="1"> <table>
<tr>
<tr>
<th>Directories</th>
<th>Files</th>
</tr>
<tr>
<td>
<div id="dirlist">
<ul v-for="dir in files.dirs">
<li><a v-bind:href="'?path=' + dir.absolute + '&dataset_path=' + dataset_path">{{ dir.name }}</a>
<form v-if="context" v-on:submit.prevent="addDir(dir)" style="display:inline;">
<button type="submit" title="Add directory to package">+</button>
</form></li>
</ul>
</div>
</td>
<td>
<div id="filelist">
<div v-for="(file, path) in files.files"> <div v-for="(file, path) in files.files">
<template v-if="!(context[file.id])"> <template v-if="!(context[file.id])">
<h1>{{ file.filename }}</h1> <h1>{{ file.filename }}</h1>
<img width="50%" v-bind:src='file._img'> <img width="50%" v-bind:src='file._img'>
<form v-if="context" v-on:submit.prevent="addFile(file)"> <form v-if="context" v-on:submit.prevent="addFile(file)" style="display:inline;">
<button type="submit">Add file to package</button> <button type="submit" title="Add file to package">+</button>
</form> </form>
</template> </template>
</div> </div>
</div> </div>
</td>
<div id="filelist" border="1">
<ul v-for="dir in files.dirs">
<li><a v-bind:href="'?path=' + dir.absolute + '&dataset_path=' + dataset_path">{{ dir.name }}</a></li>
</ul>
</div>
</div> </div>
</tr>
</table>
</div> </div>
...@@ -272,7 +287,7 @@ ...@@ -272,7 +287,7 @@
"addFile": function addFile(file) { "addFile": function addFile(file) {
if (!context[file.id]) { if (!context[file.id]) {
var new_item = JSON.parse(JSON.stringify(schema.types.File.template)); var new_item = JSON.parse(JSON.stringify(schema.types.File.template));
new_item.properties.name[0].value = file.id; new_item.properties.name[0].value = file.name;
new_item._img = file._img; new_item._img = file._img;
context[file.id] = new_item; context[file.id] = new_item;
...@@ -284,16 +299,28 @@ ...@@ -284,16 +299,28 @@
} }
}, },
"addDir": function addDir(file) {
if (!context[file.id]) {
var new_item = JSON.parse(JSON.stringify(schema.types.Dataset.template));
new_item.properties.name[0].value = file.name;
new_item._img = file._img;
context[file.id] = new_item;
"removeItem": function remove_item(id) { this.changed += 1;
this.save_context();
}
else {
alert("Already got that file"); //Should never fire but you never know
}
},
"removeItem": function remove_item(id) {
delete context[id]; delete context[id];
this.changed += 1; this.changed += 1;
this.save_context(); this.save_context();
}, },
"linkToNew" : function linkToNew(val) { "linkToNew" : function linkToNew(val) {
alert(val.new_type);
this.type = val.new_type; this.type = val.new_type;
val.id = this.addContext(context); val.id = this.addContext(context);
this.save_context(); this.save_context();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment