diff --git a/routes/index.js b/routes/index.js index 1684b842d47797d9a570f1e8020a4e74d7873f93..92526dc125b95c7968e9b77e59b3e0b87a4626a7 100644 --- a/routes/index.js +++ b/routes/index.js @@ -197,7 +197,7 @@ router.get('/files', function(req, res, next) { console.log(absolute_path, shell.test('-d', absolute_path)); if (shell.test('-d', absolute_path)) { 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)) { files[absolute_path]= ({"filename": f, "name": f, "id": absolute_path}) @@ -224,7 +224,6 @@ router.get('/preview', function(req, res, next) { }); - router.get('/context_entities', function(req, res, next) { console.log(req.query.dataset_path); if (req.query.dataset_path) { diff --git a/views/index.ejs b/views/index.ejs index 94ca3a6e672bbbb83e00e992df1331184b78fa2a..95ad808ac26b1278a8d85825f981dc28f2f5424b 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -145,27 +145,42 @@ </template> </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"> <template v-if="!(context[file.id])"> <h1>{{ file.filename }}</h1> <img width="50%" v-bind:src='file._img'> - <form v-if="context" v-on:submit.prevent="addFile(file)"> - <button type="submit">Add file to package</button> + <form v-if="context" v-on:submit.prevent="addFile(file)" style="display:inline;"> + <button type="submit" title="Add file to package">+</button> </form> </template> </div> </div> - - <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> - + </td> + </div> - + </tr> + </table> </div> @@ -272,7 +287,7 @@ "addFile": function addFile(file) { if (!context[file.id]) { 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; context[file.id] = new_item; @@ -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]; this.changed += 1; this.save_context(); }, "linkToNew" : function linkToNew(val) { - alert(val.new_type); this.type = val.new_type; val.id = this.addContext(context); this.save_context();