Added folder slideshow filter
Signed-off-by: James Ketrenos <james_gitlab@ketrenos.com>
This commit is contained in:
parent
45300cacf5
commit
fa06d76a01
@ -108,6 +108,9 @@ function makeFaceBoxes() {
|
|||||||
el.parentElement.removeChild(el);
|
el.parentElement.removeChild(el);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("Not showing face boxes");
|
||||||
|
return;
|
||||||
|
|
||||||
const el = document.getElementById("photo"),
|
const el = document.getElementById("photo"),
|
||||||
photo = photos[photoIndex];
|
photo = photos[photoIndex];
|
||||||
|
|
||||||
@ -151,7 +154,7 @@ function makeFaceBoxes() {
|
|||||||
function loadPhoto(index) {
|
function loadPhoto(index) {
|
||||||
const photo = photos[index],
|
const photo = photos[index],
|
||||||
xml = new XMLHttpRequest(),
|
xml = new XMLHttpRequest(),
|
||||||
url = base + photo.path /* + "thumbs/scaled/"*/ + photo.filename,
|
url = base + photo.path + "thumbs/scaled/" + photo.filename,
|
||||||
taken = new Date(photo.taken);
|
taken = new Date(photo.taken);
|
||||||
|
|
||||||
document.getElementById("loading").textContent = "0%";
|
document.getElementById("loading").textContent = "0%";
|
||||||
@ -302,13 +305,22 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
info = document.getElementById("info");
|
info = document.getElementById("info");
|
||||||
|
|
||||||
/* Trim off everything up to and including the ? (if its there) */
|
/* Trim off everything up to and including the ? (if its there) */
|
||||||
var parts = window.location.href.match(/^.*\?(.*)$/);
|
var parts = window.location.href.match(/^.*\?(.*)$/),
|
||||||
|
mode = "holiday",
|
||||||
|
filter = "";
|
||||||
if (parts) {
|
if (parts) {
|
||||||
holiday = parts[1];
|
parts = parts[1].split("=");
|
||||||
|
if (parts.length == 1) {
|
||||||
|
filter = parts[0];
|
||||||
|
} else {
|
||||||
|
mode = parts[0];
|
||||||
|
filter = parts[1];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
holiday = "memorial day";
|
filter = "memorial day";
|
||||||
}
|
}
|
||||||
window.fetch("api/v1/photos/holiday/" + holiday.replace(/ +/g, "%20"))
|
|
||||||
|
window.fetch("api/v1/photos/" + mode + "/" + filter.replace(/ +/g, "%20"))
|
||||||
.then(res => res.json()).then(function(data) {
|
.then(res => res.json()).then(function(data) {
|
||||||
if (data.items.length) {
|
if (data.items.length) {
|
||||||
info.textContent = photos.length + " photos found. Shuffling.";
|
info.textContent = photos.length + " photos found. Shuffling.";
|
||||||
@ -316,11 +328,11 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
photoIndex = -1;
|
photoIndex = -1;
|
||||||
nextPhoto();
|
nextPhoto();
|
||||||
} else {
|
} else {
|
||||||
info.textContent = "No photos found for " + data.holiday + ".";
|
info.textContent = "No photos found for " + filter + ".";
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
info.textContent = "Unable to fetch holiday :(";
|
info.textContent = "Unable to fetch " + mode + "=" + filter + " :(";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -675,6 +675,43 @@ router.get("/holiday/:holiday", function(req, res/*, next*/) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
router.get("/folder/:folder", function(req, res/*, next*/) {
|
||||||
|
|
||||||
|
const folder = req.params.folder;
|
||||||
|
|
||||||
|
console.log("Searching for photos under folder: " + folder);
|
||||||
|
|
||||||
|
let query = "SELECT photos.*,albums.path AS path FROM photos " +
|
||||||
|
"INNER JOIN albums ON (photos.albumId=albums.id AND albums.path LIKE :folder) " +
|
||||||
|
"WHERE (photos.duplicate=0 AND photos.deleted=0 AND photos.scanned NOT NULL) " +
|
||||||
|
"ORDER BY strftime('%Y-%m-%d', taken) DESC,id DESC";
|
||||||
|
|
||||||
|
return photoDB.sequelize.query(query, {
|
||||||
|
replacements: {
|
||||||
|
folder: folder + '%'
|
||||||
|
},
|
||||||
|
type: photoDB.Sequelize.QueryTypes.SELECT
|
||||||
|
}).then(function(photos) {
|
||||||
|
console.log("Found " + photos.length + " photos.");
|
||||||
|
photos.forEach(function(photo) {
|
||||||
|
for (var key in photo) {
|
||||||
|
if (photo[key] instanceof Date) {
|
||||||
|
photo[key] = moment(photo[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return res.status(200).json({
|
||||||
|
folder: folder,
|
||||||
|
items: photos
|
||||||
|
});
|
||||||
|
|
||||||
|
}).catch(function(error) {
|
||||||
|
console.error("Query failed: " + query);
|
||||||
|
return Promise.reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
/* Each photos has:
|
/* Each photos has:
|
||||||
|
|
||||||
* locations
|
* locations
|
||||||
@ -986,6 +1023,8 @@ console.log("Trying path as: " + path);
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.get("/*", function(req, res/*, next*/) {
|
router.get("/*", function(req, res/*, next*/) {
|
||||||
|
console.log("Generic loader");
|
||||||
|
|
||||||
let limit = parseInt(req.query.limit) || 50,
|
let limit = parseInt(req.query.limit) || 50,
|
||||||
id, cursor, index;
|
id, cursor, index;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user