Skip to content

Commit

Permalink
Merge pull request #655 from CGDogan/subdir
Browse files Browse the repository at this point in the history
images in subdirs
  • Loading branch information
birm authored Sep 11, 2023
2 parents ab43e1f + b711883 commit 87fb0a5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
9 changes: 8 additions & 1 deletion apps/batchloader/batchLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ $(document).ready(function() {
store.findSlide().then((response) => {
for (i=0; i<response.length; i++) {
existingSlides.push(response[i].name);
existingFiles.push((response[i].location).substring((response[i].location).lastIndexOf('/')+1,
if (response[i].filepath) {
existingFiles.push(response[i].filepath);
} else {
existingFiles.push((response[i].location).substring((response[i].location).lastIndexOf('/')+1,
(response[i].location).length));
}
}
}).catch((error) => {
console.log(error);
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion apps/loader/chunked_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 6 additions & 3 deletions apps/loader/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>{
Expand Down
14 changes: 8 additions & 6 deletions apps/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
16 changes: 8 additions & 8 deletions apps/viewer/uicallbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 87fb0a5

Please sign in to comment.