feature: album links

This commit is contained in:
Pitu 2019-09-30 07:06:22 +00:00
parent ca9e1c859d
commit 8e4f1b7838
4 changed files with 19 additions and 18 deletions

View File

@ -17,9 +17,13 @@ class albumGET extends Route {
Make sure it exists and it's enabled
*/
const link = await db.table('links')
.where({ identifier, enabled: true })
.where({
identifier,
enabled: true,
enableDownload: true
})
.first();
if (!link) return res.status(400).json({ message: 'The identifier supplied could not be found' });
if (!link) return res.status(400).json({ message: 'The supplied identifier could not be found' });
/*
Same with the album, just to make sure is not a deleted album and a leftover link

View File

@ -26,7 +26,7 @@ class Server {
/*
This bypasses the headers.accept for album download, since it's accesed directly through the browser.
*/
if (req.url.includes('/api/album/') && req.url.includes('/zip') && req.method === 'GET') return next();
if ((req.url.includes('/api/album/') || req.url.includes('/zip')) && req.method === 'GET') return next();
if (req.headers.accept && req.headers.accept.includes('application/vnd.lolisafe.json')) return next();
return res.status(405).json({ message: 'Incorrect `Accept` header provided' });
});

View File

@ -80,7 +80,8 @@
:gutterWidth="10"
:gutterHeight="4">
<!-- Gotta implement search and pagination here -->
<input v-model="searchTerm"
<input v-if="enableSearch"
v-model="searchTerm"
type="text"
placeholder="Search..."
@input="search()"
@ -115,12 +116,14 @@
<i class="icon-interface-window" />
</a>
</b-tooltip>
<!--
<b-tooltip label="Tags"
position="is-top">
<a @click="manageTags(item)">
<i class="icon-ecommerce-tag-c" />
</a>
</b-tooltip>
-->
<b-tooltip label="Delete"
position="is-top">
<a @click="deleteFile(item, index)">
@ -157,6 +160,10 @@ export default {
width: {
type: Number,
default: 150
},
enableSearch: {
type: Boolean,
default: true
}
},
data() {

View File

@ -34,7 +34,8 @@
<Grid v-if="files && files.length"
:files="files"
:isPublic="true"
:width="200" />
:width="200"
:enableSearch="false" />
</div>
</div>
</template>
@ -65,7 +66,7 @@ export default {
},
async asyncData({ app, params, error }) {
try {
const data = await axios.get(`${app.store.state.config.baseURL}/album/${params.identifier}`);
const { data } = await axios.get(`${app.store.state.config.baseURL}/album/${params.identifier}`);
const downloadLink = data.downloadEnabled ? `${app.store.state.config.baseURL}/album/${params.identifier}/zip` : null;
return {
name: data.name,
@ -74,6 +75,7 @@ export default {
downloadLink
};
} catch (err) {
console.log('Error when retrieving album', err);
/*
return {
name: null,
@ -118,18 +120,6 @@ export default {
{ vmid: 'og:description', property: 'og:description', content: 'A modern and self-hosted file upload service that can handle anything you throw at it. Fast uploads, file manager and sharing capabilities all crafted with a beautiful user experience in mind.' }
]
};
},
mounted() {
/*
if (this.error) {
if (this.error === 404) {
this.$toast.open('Album not found', true, 3000);
setTimeout(() => this.$router.push('/404'), 3000);
return;
}
this.$toast.open(`Error code ${this.error}`, true, 3000);
}
*/
}
};
</script>