137 lines
2.8 KiB
Vue
137 lines
2.8 KiB
Vue
<template>
|
|
<div id="uploads">
|
|
<Menu></Menu>
|
|
|
|
<div class="page">
|
|
<div v-if="uploads !== null">
|
|
<div class="pure-g list-header">
|
|
<div class="pure-u-3-4">{{ $t('admin.uploads.created') }}</div>
|
|
<div class="pure-u-1-4">{{ $t('admin.uploads.owner') }}</div>
|
|
</div>
|
|
|
|
<div v-for="upload in uploads" class="list">
|
|
<div class="pure-g row">
|
|
<div class="pure-u-3-4">{{ upload.created }}</div>
|
|
<div class="pure-u-1-4">{{ upload.username }}</div>
|
|
<div class="pure-u-1-1">
|
|
<div class="file" v-for="file in upload.files" :title="file.name">
|
|
<a :href="getDownloadUrl(file)">
|
|
<img :src="getFileIconUrl(file.name)" class="icon">
|
|
<span class="filename">{{ file.name }}</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="uploads.length == 0" class="nodata">
|
|
{{ $t('admin.empty') }}
|
|
</div>
|
|
</div>
|
|
|
|
<div v-else class="loading">
|
|
{{ $t('admin.loading') }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios';
|
|
import Menu from './Menu.vue';
|
|
import shared from '../../shared';
|
|
|
|
export default {
|
|
data()
|
|
{
|
|
return {
|
|
uploads: null
|
|
};
|
|
},
|
|
|
|
components: {
|
|
Menu
|
|
},
|
|
|
|
created()
|
|
{
|
|
var self = this;
|
|
|
|
if (!shared.token)
|
|
{
|
|
self.$router.push('/admin');
|
|
return;
|
|
}
|
|
|
|
|
|
axios.get('/admin/uploads', {
|
|
headers: {
|
|
Authorization: 'Bearer ' + shared.token
|
|
}
|
|
})
|
|
.then((response) =>
|
|
{
|
|
self.uploads = response.data;
|
|
})
|
|
.catch((error) =>
|
|
{
|
|
if (error.response && error.response.status == 403)
|
|
{
|
|
shared.token = null;
|
|
self.$router.push('/admin');
|
|
}
|
|
else
|
|
shared.$emit('showNotification', error.message);
|
|
});
|
|
},
|
|
|
|
methods: {
|
|
getFileIconUrl(filename)
|
|
{
|
|
var ext = this.getExtension(filename);
|
|
if (ext == '')
|
|
ext = '_blank';
|
|
|
|
return '/images/fileicons/32px/' + ext + '.png';
|
|
},
|
|
|
|
|
|
getExtension(filename)
|
|
{
|
|
var parts = filename.split('.');
|
|
return parts.length > 0 ? parts.pop() : '';
|
|
},
|
|
|
|
|
|
getDownloadUrl(file)
|
|
{
|
|
return '/admin/download/' + encodeURIComponent(file.id) + '/' + encodeURIComponent(file.name);
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.file
|
|
{
|
|
display: inline-block;
|
|
width: 10rem;
|
|
padding: .5rem;
|
|
|
|
font-size: 75%;
|
|
|
|
text-align: center;
|
|
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
|
|
.icon
|
|
{
|
|
display: block;
|
|
margin-bottom: .5rem;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
}
|
|
}
|
|
</style> |