From b711883d7a6633bea68710f5dfcb9ab1fc0efeb5 Mon Sep 17 00:00:00 2001 From: CGDogan <126820728+CGDogan@users.noreply.github.com> Date: Wed, 6 Sep 2023 11:58:52 +0100 Subject: [PATCH] images in subdirs --- apps/batchloader/batchLoader.js | 9 ++++++++- apps/loader/chunked_upload.js | 6 +++++- apps/loader/loader.js | 9 ++++++--- apps/model/model.js | 14 ++++++++------ apps/viewer/uicallbacks.js | 16 ++++++++-------- 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/apps/batchloader/batchLoader.js b/apps/batchloader/batchLoader.js index 251120814..64ac34dd9 100644 --- a/apps/batchloader/batchLoader.js +++ b/apps/batchloader/batchLoader.js @@ -21,8 +21,12 @@ $(document).ready(function() { store.findSlide().then((response) => { for (i=0; i { console.log(error); @@ -403,6 +407,9 @@ function finishUpload(token, filename, i) { fileNames[i] = newName; $('tr:eq('+(i+1)+') td:nth-child(2) span')[0].innerText = newName; } + if (a.relpath) { + fileNames[i] = a.relpath; + } if (typeof a === 'object' && a.error) { finishUploadSuccess = false; // $('#check_btn').hide(); diff --git a/apps/loader/chunked_upload.js b/apps/loader/chunked_upload.js index 9d54c074b..ab03c25fb 100644 --- a/apps/loader/chunked_upload.js +++ b/apps/loader/chunked_upload.js @@ -131,7 +131,11 @@ function finishUpload() { regReq.then((x)=>x.json()).then((a)=>{ changeStatus('UPLOAD | Finished', a, reset); reset = false; console.log(a); - if (a.filepath) { + if (a.relpath) { + document.getElementById('filename'+0).value = a.relpath; + } else if (a.filename) { + document.getElementById('filename'+0).value = a.filename; + } else if (a.filepath) { document.getElementById('filename'+0).value = a.filepath.slice(a.filepath.lastIndexOf('/')+1); } if (typeof a === 'object' && a.error) { diff --git a/apps/loader/loader.js b/apps/loader/loader.js index 47f96c4ba..ca1ddea45 100644 --- a/apps/loader/loader.js +++ b/apps/loader/loader.js @@ -122,12 +122,15 @@ function handleDownload(id) { store.getSlide(id) .then((response) => { if (response[0]) { - return response[0]['location']; + if (response[0]['filepath']) { + return response[0]['filepath']; + } + let location = response[0]['location']; + return location.substring(location.lastIndexOf('/')+1, location.length); } else { throw new Error('Slide not found'); } - }).then((location) => { - fileName = location.substring(location.lastIndexOf('/')+1, location.length); + }).then((fileName) => { console.log(fileName); return fileName; }).then((fileName) =>{ diff --git a/apps/model/model.js b/apps/model/model.js index 02315e996..56a58930a 100644 --- a/apps/model/model.js +++ b/apps/model/model.js @@ -408,15 +408,17 @@ function initCore() { $CAMIC.store.getSlide($D.params.slideId).then((response) => { if (response[0]) { - return response[0]['location']; + if (response[0]["filepath"]) { + return response[0]["filepath"]; + } + return location.substring( + location.lastIndexOf('/') + 1, + location.length, + ); } else { throw new Error('Slide not found'); } - }).then((location) => { - fileName = location.substring( - location.lastIndexOf('/') + 1, - location.length, - ); + }).then((fileName) => { console.log(fileName); }); diff --git a/apps/viewer/uicallbacks.js b/apps/viewer/uicallbacks.js index f2e55ed4e..bb5d3d6e1 100644 --- a/apps/viewer/uicallbacks.js +++ b/apps/viewer/uicallbacks.js @@ -586,18 +586,18 @@ function imageDownload() { .getSlide(id) .then((response) => { if (response[0]) { - return response[0]['location']; + if (response[0]['filepath']) { + return response[0]['filepath'] + } + let location = response[0]['location']; + return location.substring( + location.lastIndexOf('/') + 1, + location.length, + ); } else { throw new Error('Slide not found'); } }) - .then((location) => { - fileName = location.substring( - location.lastIndexOf('/') + 1, - location.length, - ); - return fileName; - }) .then((fileName) => { fetch(downloadURL + fileName, { credentials: 'same-origin',