Album stuff

This commit is contained in:
Pitu 2017-02-07 04:52:53 -03:00
parent 31e9a19821
commit 36e17b0372
4 changed files with 16 additions and 1 deletions

View File

@ -18,8 +18,10 @@ albumsController.list = function(req, res, next){
let fields = ['id', 'name']
if(req.params.sidebar === undefined)
if(req.params.sidebar === undefined){
fields.push('timestamp')
fields.push('identifier')
}
db.table('albums').select(fields).where({enabled: 1, userid: user[0].id}).then((albums) => {
@ -31,6 +33,14 @@ albumsController.list = function(req, res, next){
album.date = new Date(album.timestamp * 1000)
album.date = album.date.getFullYear() + '-' + (album.date.getMonth() + 1) + '-' + album.date.getDate() + ' ' + (album.date.getHours() < 10 ? '0' : '') + album.date.getHours() + ':' + (album.date.getMinutes() < 10 ? '0' : '') + album.date.getMinutes() + ':' + (album.date.getSeconds() < 10 ? '0' : '') + album.date.getSeconds()
let basedomain = req.get('host')
for(let domain of config.domains)
if(domain.host === req.get('host'))
if(domain.hasOwnProperty('resolve'))
basedomain = domain.resolve
album.identifier = basedomain + '/' + album.identifier
ids.push(album.id)
}
@ -196,6 +206,7 @@ albumsController.get = function(req, res, next){
return res.json({
success: true,
title: title,
count: files.length,
files
})

View File

@ -45,6 +45,7 @@
<div class="hero-head">
<div class="container">
<h1 class="title" id='title' style='margin-top: 1.5rem;'></h1>
<h1 class="subtitle" id='count'></h1>
<hr>
</div>
</div>

View File

@ -4,6 +4,7 @@ album.get = function(album){
axios.get('/api/album/get/' + album)
.then(function (response) {
document.getElementById('title').innerHTML = response.data.title;
document.getElementById('count').innerHTML = response.data.count + ' files';
var container = document.createElement('div');
container.innerHTML = `<div class="columns is-multiline is-mobile" id="table"></div>`

View File

@ -272,6 +272,7 @@ panel.getAlbums = function(){
<th>Name</th>
<th>Files</th>
<th>Created At</th>
<th>Public link</th>
<th></th>
</tr>
</thead>
@ -290,6 +291,7 @@ panel.getAlbums = function(){
<th>${item.name}</th>
<th>${item.files}</th>
<td>${item.date}</td>
<td><a href="${item.identifier}" target="_blank">Album link</a></td>
<td>
<a class="button is-small is-primary is-outlined" title="Edit name" onclick="panel.renameAlbum(${item.id})">
<span class="icon is-small">