From 0dcaf36332cfa79f198a0cce04a1789822acd1ca Mon Sep 17 00:00:00 2001 From: Pitu Date: Wed, 18 Jan 2017 04:05:56 -0300 Subject: Added browsing galleries from dashboard --- controllers/albumsController.js | 6 +++--- controllers/uploadController.js | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'controllers') diff --git a/controllers/albumsController.js b/controllers/albumsController.js index 72c8177..76129ec 100644 --- a/controllers/albumsController.js +++ b/controllers/albumsController.js @@ -15,6 +15,9 @@ albumsController.list = function(req, res, next){ db.table('albums').select(fields).then((albums) => { + if(req.headers.extended === undefined) + return res.json({ success: true, albums }) + let ids = [] for(let album of albums){ album.date = new Date(album.timestamp * 1000) @@ -23,9 +26,6 @@ albumsController.list = function(req, res, next){ ids.push(album.id) } - if(req.headers.extended === undefined) - return res.json({ success: true, albums }) - db.table('files').whereIn('albumid', ids).select('albumid').then((files) => { let albumsCount = {} diff --git a/controllers/uploadController.js b/controllers/uploadController.js index 2828a19..cbb4e64 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -77,7 +77,14 @@ uploadsController.list = function(req, res){ if(req.headers.auth !== config.adminToken) return res.status(401).send('not-authorized') - db.table('files').then((files) => { + db.table('files') + .where(function(){ + if(req.headers.albumid === undefined) + this.where('id', '<>', '') + else + this.where('albumid', req.headers.albumid) + }) + .then((files) => { db.table('albums').then((albums) => { for(let file of files){ -- cgit v1.2.3