diff --git a/controllers/albumsController.js b/controllers/albumsController.js index af4ed5b..07d4743 100644 --- a/controllers/albumsController.js +++ b/controllers/albumsController.js @@ -111,7 +111,7 @@ self.list = async (req, res, next) => { if (isNaN(offset)) offset = 0 else if (offset < 0) offset = Math.max(0, Math.ceil(count / 25) + offset) - fields.push('identifier', 'enabled', 'timestamp', 'editedAt', 'download', 'public', 'description') + fields.push('identifier', 'enabled', 'timestamp', 'editedAt', 'zipGeneratedAt', 'download', 'public', 'description') if (all) fields.push('userid') albums = await db.table('albums') @@ -126,18 +126,34 @@ self.list = async (req, res, next) => { album.download = album.download !== 0 album.public = album.public !== 0 album.uploads = 0 + album.size = 0 + album.zipSize = null // Map by IDs albumids[album.id] = album } + const getAlbumZipSize = async album => { + if (!album.zipGeneratedAt) return + try { + const filePath = path.join(paths.zips, `${album.identifier}.zip`) + const stats = await paths.stat(filePath) + albumids[album.id].zipSize = stats.size + } catch (error) { + if (error.code !== 'ENOENT') logger.error(error) + } + } + + await Promise.all(albums.map(album => getAlbumZipSize(album))) + const uploads = await db.table('files') .whereIn('albumid', Object.keys(albumids)) - .select('albumid') + .select('albumid', 'size') for (const upload of uploads) { if (albumids[upload.albumid]) { albumids[upload.albumid].uploads++ + albumids[upload.albumid].size += parseInt(upload.size) } } diff --git a/controllers/pathsController.js b/controllers/pathsController.js index f1bc29a..18d38ea 100644 --- a/controllers/pathsController.js +++ b/controllers/pathsController.js @@ -16,6 +16,7 @@ const fsFuncs = [ 'readFile', 'rename', 'rmdir', + 'stat', 'symlink', 'unlink', 'writeFile' diff --git a/src/css/dashboard.scss b/src/css/dashboard.scss index e2ab6fa..bc516e1 100644 --- a/src/css/dashboard.scss +++ b/src/css/dashboard.scss @@ -153,10 +153,19 @@ li[data-action="page-ellipsis"] { color: $grey-lightest } -.table .originalname { - max-width: 200px; - text-overflow: ellipsis; - overflow: hidden +.table { + .originalname { + max-width: 200px; + text-overflow: ellipsis; + overflow: hidden + } + + th, + td { + &[title] { + cursor: help + } + } } /** Thumbs extension **/ diff --git a/src/js/dashboard.js b/src/js/dashboard.js index a3276cd..eea13ef 100644 --- a/src/js/dashboard.js +++ b/src/js/dashboard.js @@ -1757,7 +1757,10 @@ page.getAlbums = (params = {}) => {
Current public link: ${albumUrlText}
+