feat: show file's upload date in album pages

This commit is contained in:
Bobby 2022-09-19 07:13:09 +07:00
parent ff397fbf28
commit db03240d06
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09
3 changed files with 18 additions and 5 deletions

View File

@ -47,7 +47,7 @@ routes.get('/a/:identifier', async (req, res) => {
}
const files = await utils.db.table('files')
.select('name', 'size')
.select('name', 'size', 'timestamp')
.where('albumid', album.id)
.orderBy('id', 'desc')

View File

@ -8,9 +8,21 @@ const page = {
}
window.addEventListener('DOMContentLoaded', () => {
const elements = document.querySelectorAll('.file-size')
for (let i = 0; i < elements.length; i++) {
elements[i].innerHTML = page.getPrettyBytes(parseInt(elements[i].innerHTML.replace(/\s*B$/i, '')))
const files = document.querySelectorAll('.image-container')
// Prettify individual file's data rows
for (let i = 0; i < files.length; i++) {
const sizeElem = files[i].querySelector('.details .file-size')
if (sizeElem) {
const str = sizeElem.dataset.value || sizeElem.innerHTML.replace(/\s*B$/i, '')
sizeElem.innerHTML = page.getPrettyBytes(parseInt(str))
}
const dateElem = files[i].querySelector('.details .file-date')
if (dateElem) {
const str = dateElem.dataset.value
dateElem.innerHTML = page.getPrettyDate(new Date(parseInt(str) * 1000))
}
}
page.lazyLoad = new LazyLoad()

View File

@ -129,7 +129,8 @@
</a>
<div class="details">
<p class="name">{{ file.name }}</p>
<p class="file-size">{{ file.size }} B</p>
<p class="file-size" data-value="{{ file.size }}">{{ file.size }} B</p>
<p class="file-date" data-value="{{ file.timestamp }}"></p>
</div>
</div>
{% endfor %}