diff options
Diffstat (limited to 'src/site/pages')
| -rw-r--r-- | src/site/pages/a/_identifier.vue | 3 | ||||
| -rw-r--r-- | src/site/pages/dashboard/admin/file/_id.vue | 170 | ||||
| -rw-r--r-- | src/site/pages/dashboard/admin/settings.vue (renamed from src/site/pages/dashboard/settings.vue) | 2 | ||||
| -rw-r--r-- | src/site/pages/dashboard/admin/user/_id.vue | 102 | ||||
| -rw-r--r-- | src/site/pages/dashboard/admin/users.vue (renamed from src/site/pages/dashboard/users.vue) | 4 |
5 files changed, 277 insertions, 4 deletions
diff --git a/src/site/pages/a/_identifier.vue b/src/site/pages/a/_identifier.vue index 923e8cc..62035b3 100644 --- a/src/site/pages/a/_identifier.vue +++ b/src/site/pages/a/_identifier.vue @@ -35,7 +35,8 @@ :files="files" :isPublic="true" :width="200" - :enableSearch="false" /> + :enableSearch="false" + :enableToolbar="false" /> </div> </div> </template> diff --git a/src/site/pages/dashboard/admin/file/_id.vue b/src/site/pages/dashboard/admin/file/_id.vue new file mode 100644 index 0000000..6718b32 --- /dev/null +++ b/src/site/pages/dashboard/admin/file/_id.vue @@ -0,0 +1,170 @@ +<style lang="scss" scoped> + .underline { text-decoration: underline; } +</style> +<template> + <section class="hero is-fullheight dashboard"> + <div class="hero-body"> + <div class="container"> + <div class="columns"> + <div class="column is-narrow"> + <Sidebar /> + </div> + <div class="column"> + <h2 class="subtitle">File details</h2> + <hr> + + <div class="columns"> + <div class="column is-6"> + <b-field label="ID" + horizontal> + <span>{{ file.id }}</span> + </b-field> + + <b-field label="Name" + horizontal> + <span>{{ file.name }}</span> + </b-field> + + <b-field label="Original Name" + horizontal> + <span>{{ file.original }}</span> + </b-field> + + <b-field label="IP" + horizontal> + <span class="underline">{{ file.ip }}</span> + </b-field> + + <b-field label="Link" + horizontal> + <a :href="file.url" + target="_blank">{{ file.url }}</a> + </b-field> + + <b-field label="Size" + horizontal> + <span>{{ formatBytes(file.size) }}</span> + </b-field> + + <b-field label="Hash" + horizontal> + <span>{{ file.hash }}</span> + </b-field> + + <b-field label="Uploaded" + horizontal> + <span><timeago :since="file.createdAt" /></span> + </b-field> + </div> + <div class="column is-6"> + <b-field label="User Id" + horizontal> + <span>{{ user.id }}</span> + </b-field> + + <b-field label="Username" + horizontal> + <span>{{ user.username }}</span> + </b-field> + + <b-field label="Enabled" + horizontal> + <span>{{ user.enabled }}</span> + </b-field> + + <b-field label="Registered" + horizontal> + <span><timeago :since="user.createdAt" /></span> + </b-field> + + <b-field label="Files" + horizontal> + <span> + <nuxt-link :to="`/dashboard/admin/user/${user.id}`">{{ user.fileCount }}</nuxt-link> + </span> + </b-field> + </div> + </div> + + <div class="mb2 mt2 text-center"> + <button class="button is-danger" + @click="promptBanIP">Ban IP</button> + <button class="button is-danger" + @click="promptDisableUser">Disable user</button> + </div> + </div> + </div> + </div> + </div> + </section> +</template> + +<script> +import Sidebar from '~/components/sidebar/Sidebar.vue'; + +export default { + components: { + Sidebar + }, + middleware: ['auth', 'admin'], + data() { + return { + options: {}, + file: null, + user: null + }; + }, + async asyncData({ $axios, route }) { + try { + const response = await $axios.$get(`file/${route.params.id}`); + return { + file: response.file ? response.file : null, + user: response.user ? response.user : null + }; + } catch (error) { + console.error(error); + return { + file: null, + user: null + }; + } + }, + methods: { + promptDisableUser() { + this.$buefy.dialog.confirm({ + message: 'Are you sure you want to disable the account of the user that uploaded this file?', + onConfirm: () => this.disableUser() + }); + }, + async disableUser() { + const response = await this.$axios.$post('admin/users/disable', { + id: this.user.id + }); + this.$buefy.toast.open(response.message); + }, + promptBanIP() { + this.$buefy.dialog.confirm({ + message: 'Are you sure you want to ban the IP this file was uploaded from?', + onConfirm: () => this.banIP() + }); + }, + async banIP() { + const response = await this.$axios.$post('admin/ban/ip', { + ip: this.file.ip + }); + this.$buefy.toast.open(response.message); + }, + formatBytes(bytes, decimals = 2) { + if (bytes === 0) return '0 Bytes'; + + const k = 1024; + const dm = decimals < 0 ? 0 : decimals; + const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + + const i = Math.floor(Math.log(bytes) / Math.log(k)); + + return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; + } + } +}; +</script> diff --git a/src/site/pages/dashboard/settings.vue b/src/site/pages/dashboard/admin/settings.vue index 35a23e8..052a641 100644 --- a/src/site/pages/dashboard/settings.vue +++ b/src/site/pages/dashboard/admin/settings.vue @@ -103,7 +103,7 @@ export default { components: { Sidebar }, - middleware: 'admin', + middleware: ['auth', 'admin'], data() { return { options: {} diff --git a/src/site/pages/dashboard/admin/user/_id.vue b/src/site/pages/dashboard/admin/user/_id.vue new file mode 100644 index 0000000..7703b1c --- /dev/null +++ b/src/site/pages/dashboard/admin/user/_id.vue @@ -0,0 +1,102 @@ +<style lang="scss" scoped> + .underline { text-decoration: underline; } +</style> +<template> + <section class="hero is-fullheight dashboard"> + <div class="hero-body"> + <div class="container"> + <div class="columns"> + <div class="column is-narrow"> + <Sidebar /> + </div> + <div class="column"> + <h2 class="subtitle">User details</h2> + <hr> + + <b-field label="User Id" + horizontal> + <span>{{ user.id }}</span> + </b-field> + + <b-field label="Username" + horizontal> + <span>{{ user.username }}</span> + </b-field> + + <b-field label="Enabled" + horizontal> + <span>{{ user.enabled }}</span> + </b-field> + + <b-field label="Registered" + horizontal> + <span><timeago :since="user.createdAt" /></span> + </b-field> + + <b-field label="Files" + horizontal> + <span>{{ files.length }}</span> + </b-field> + + <div class="mb2 mt2 text-center"> + <button class="button is-danger" + @click="promptDisableUser">Disable user</button> + </div> + + <Grid v-if="files.length" + :files="files" /> + </div> + </div> + </div> + </div> + </section> +</template> + +<script> +import Sidebar from '~/components/sidebar/Sidebar.vue'; +import Grid from '~/components/grid/Grid.vue'; + +export default { + components: { + Sidebar, + Grid + }, + middleware: ['auth', 'admin'], + data() { + return { + options: {}, + files: null, + user: null + }; + }, + async asyncData({ $axios, route }) { + try { + const response = await $axios.$get(`/admin/users/${route.params.id}`); + return { + files: response.files ? response.files : null, + user: response.user ? response.user : null + }; + } catch (error) { + console.error(error); + return { + files: null, + user: null + }; + } + }, + methods: { + promptDisableUser() { + this.$buefy.dialog.confirm({ + message: 'Are you sure you want to disable the account of the user that uploaded this file?', + onConfirm: () => this.disableUser() + }); + }, + async disableUser() { + const response = await this.$axios.$post('admin/users/disable', { + id: this.user.id + }); + this.$buefy.toast.open(response.message); + } + } +}; +</script> diff --git a/src/site/pages/dashboard/users.vue b/src/site/pages/dashboard/admin/users.vue index 66ccebe..1fefa1e 100644 --- a/src/site/pages/dashboard/users.vue +++ b/src/site/pages/dashboard/admin/users.vue @@ -146,7 +146,7 @@ <b-table-column field="username" label="Username" centered> - {{ props.row.username }} + <nuxt-link :to="`/dashboard/admin/user/${props.row.id}`">{{ props.row.username }}</nuxt-link> </b-table-column> <b-table-column field="enabled" @@ -192,7 +192,7 @@ </template> <script> -import Sidebar from '../../components/sidebar/Sidebar.vue'; +import Sidebar from '~/components/sidebar/Sidebar.vue'; export default { components: { |