From 92be4504ccb8f6d918013e5c33870858cd22376a Mon Sep 17 00:00:00 2001 From: Zephyrrus Date: Sat, 4 Jul 2020 03:26:35 +0300 Subject: feat: refactor most of the album components to use store for presentation and actions --- src/site/pages/dashboard/admin/file/_id.vue | 2 ++ src/site/pages/dashboard/admin/user/_id.vue | 1 + 2 files changed, 3 insertions(+) (limited to 'src/site/pages/dashboard/admin') diff --git a/src/site/pages/dashboard/admin/file/_id.vue b/src/site/pages/dashboard/admin/file/_id.vue index 5821292..5853770 100644 --- a/src/site/pages/dashboard/admin/file/_id.vue +++ b/src/site/pages/dashboard/admin/file/_id.vue @@ -130,6 +130,7 @@ export default { methods: { promptDisableUser() { this.$buefy.dialog.confirm({ + type: 'is-danger', message: 'Are you sure you want to disable the account of the user that uploaded this file?', onConfirm: () => this.disableUser() }); @@ -142,6 +143,7 @@ export default { }, promptBanIP() { this.$buefy.dialog.confirm({ + type: 'is-danger', message: 'Are you sure you want to ban the IP this file was uploaded from?', onConfirm: () => this.banIP() }); diff --git a/src/site/pages/dashboard/admin/user/_id.vue b/src/site/pages/dashboard/admin/user/_id.vue index 2a56c34..8c73037 100644 --- a/src/site/pages/dashboard/admin/user/_id.vue +++ b/src/site/pages/dashboard/admin/user/_id.vue @@ -85,6 +85,7 @@ export default { methods: { promptDisableUser() { this.$buefy.dialog.confirm({ + type: 'is-danger', message: 'Are you sure you want to disable the account of the user that uploaded this file?', onConfirm: () => this.disableUser() }); -- cgit v1.2.3 From fb0bc57542a44dcc94149f393d8a4ff0c2e7902b Mon Sep 17 00:00:00 2001 From: Zephyrrus Date: Tue, 7 Jul 2020 02:02:59 +0300 Subject: feat: try fixing THE SHITTY WATERFALL --- src/site/pages/dashboard/admin/user/_id.vue | 45 +++-- src/site/pages/dashboard/admin/users.vue | 270 ++++++++++++++-------------- 2 files changed, 168 insertions(+), 147 deletions(-) (limited to 'src/site/pages/dashboard/admin') diff --git a/src/site/pages/dashboard/admin/user/_id.vue b/src/site/pages/dashboard/admin/user/_id.vue index 8c73037..1755b89 100644 --- a/src/site/pages/dashboard/admin/user/_id.vue +++ b/src/site/pages/dashboard/admin/user/_id.vue @@ -9,40 +9,51 @@
-

User details

+

+ User details +


- {{ user.id }} - {{ user.username }} - {{ user.enabled }} - - {{ files.length }}
- +
-
@@ -57,14 +68,14 @@ import Grid from '~/components/grid/Grid.vue'; export default { components: { Sidebar, - Grid + Grid, }, middleware: ['auth', 'admin'], data() { return { options: {}, files: null, - user: null + user: null, }; }, async asyncData({ $axios, route }) { @@ -72,13 +83,13 @@ export default { const response = await $axios.$get(`/admin/users/${route.params.id}`); return { files: response.files ? response.files : null, - user: response.user ? response.user : null + user: response.user ? response.user : null, }; } catch (error) { console.error(error); return { files: null, - user: null + user: null, }; } }, @@ -87,15 +98,15 @@ export default { this.$buefy.dialog.confirm({ type: 'is-danger', message: 'Are you sure you want to disable the account of the user that uploaded this file?', - onConfirm: () => this.disableUser() + onConfirm: () => this.disableUser(), }); }, async disableUser() { const response = await this.$axios.$post('admin/users/disable', { - id: this.user.id + id: this.user.id, }); this.$buefy.toast.open(response.message); - } - } + }, + }, }; diff --git a/src/site/pages/dashboard/admin/users.vue b/src/site/pages/dashboard/admin/users.vue index 695cf0b..269946c 100644 --- a/src/site/pages/dashboard/admin/users.vue +++ b/src/site/pages/dashboard/admin/users.vue @@ -1,3 +1,143 @@ + + + + - - - - - - -- cgit v1.2.3 From ad852de51a0d2dd5d29c08838d5a430c58849e74 Mon Sep 17 00:00:00 2001 From: Zephyrrus Date: Wed, 8 Jul 2020 04:00:12 +0300 Subject: chore: linter the entire project using the new rules --- src/site/pages/dashboard/admin/file/_id.vue | 82 ++++++++++++++++++---------- src/site/pages/dashboard/admin/settings.vue | 85 +++++++++++++++++++---------- 2 files changed, 107 insertions(+), 60 deletions(-) (limited to 'src/site/pages/dashboard/admin') diff --git a/src/site/pages/dashboard/admin/file/_id.vue b/src/site/pages/dashboard/admin/file/_id.vue index 5853770..34fcd01 100644 --- a/src/site/pages/dashboard/admin/file/_id.vue +++ b/src/site/pages/dashboard/admin/file/_id.vue @@ -9,74 +9,90 @@
-

File details

+

+ File details +


- {{ file.id }} - {{ file.name }} - {{ file.original }} - {{ file.ip }} - - {{ file.url }} - {{ formatBytes(file.size) }} - {{ file.hash }} -
- {{ user.id }} - {{ user.username }} - {{ user.enabled }} - - {{ user.fileCount }} @@ -86,10 +102,16 @@
- - + +
@@ -102,14 +124,14 @@ import Sidebar from '~/components/sidebar/Sidebar.vue'; export default { components: { - Sidebar + Sidebar, }, middleware: ['auth', 'admin'], data() { return { options: {}, file: null, - user: null + user: null, }; }, async asyncData({ $axios, route }) { @@ -117,13 +139,13 @@ export default { const response = await $axios.$get(`file/${route.params.id}`); return { file: response.file ? response.file : null, - user: response.user ? response.user : null + user: response.user ? response.user : null, }; } catch (error) { console.error(error); return { file: null, - user: null + user: null, }; } }, @@ -132,12 +154,12 @@ export default { this.$buefy.dialog.confirm({ type: 'is-danger', message: 'Are you sure you want to disable the account of the user that uploaded this file?', - onConfirm: () => this.disableUser() + onConfirm: () => this.disableUser(), }); }, async disableUser() { const response = await this.$axios.$post('admin/users/disable', { - id: this.user.id + id: this.user.id, }); this.$buefy.toast.open(response.message); }, @@ -145,12 +167,12 @@ export default { this.$buefy.dialog.confirm({ type: 'is-danger', message: 'Are you sure you want to ban the IP this file was uploaded from?', - onConfirm: () => this.banIP() + onConfirm: () => this.banIP(), }); }, async banIP() { const response = await this.$axios.$post('admin/ban/ip', { - ip: this.file.ip + ip: this.file.ip, }); this.$buefy.toast.open(response.message); }, @@ -163,8 +185,8 @@ export default { const i = Math.floor(Math.log(bytes) / Math.log(k)); - return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; - } - } + return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`; + }, + }, }; diff --git a/src/site/pages/dashboard/admin/settings.vue b/src/site/pages/dashboard/admin/settings.vue index 2d59fff..9e63a7c 100644 --- a/src/site/pages/dashboard/admin/settings.vue +++ b/src/site/pages/dashboard/admin/settings.vue @@ -6,87 +6,112 @@
-

Service settings

+

+ Service settings +


- - - - - - - - - - - - - - - - - - - -
- +
@@ -99,12 +124,12 @@ import Sidebar from '~/components/sidebar/Sidebar.vue'; export default { components: { - Sidebar + Sidebar, }, middleware: ['auth', 'admin'], data() { return { - options: {} + options: {}, }; }, metaInfo() { @@ -115,19 +140,19 @@ export default { }, methods: { async getSettings() { - const response = await this.$axios.$get(`service/config`); + const response = await this.$axios.$get('service/config'); this.options = response.config; }, promptRestartService() { this.$buefy.dialog.confirm({ message: 'Keep in mind that restarting only works if you have PM2 or something similar set up. Continue?', - onConfirm: () => this.restartService() + onConfirm: () => this.restartService(), }); }, async restartService() { - const response = await this.$axios.$post(`service/restart`); + const response = await this.$axios.$post('service/restart'); this.$buefy.toast.open(response.message); - } - } + }, + }, }; -- cgit v1.2.3 From fd3f6de51a082dcd72c2ef557747e031ef7b9c4a Mon Sep 17 00:00:00 2001 From: Zephyrrus Date: Thu, 9 Jul 2020 02:24:40 +0300 Subject: refactor: refactor most of the admin pages to use the store instead of internal states --- src/site/pages/dashboard/admin/user/_id.vue | 66 ++++++++++++++++------------- src/site/pages/dashboard/admin/users.vue | 66 +++++++++++++---------------- 2 files changed, 67 insertions(+), 65 deletions(-) (limited to 'src/site/pages/dashboard/admin') diff --git a/src/site/pages/dashboard/admin/user/_id.vue b/src/site/pages/dashboard/admin/user/_id.vue index 1755b89..7814468 100644 --- a/src/site/pages/dashboard/admin/user/_id.vue +++ b/src/site/pages/dashboard/admin/user/_id.vue @@ -41,20 +41,27 @@ - {{ files.length }} + {{ user.files.length }}
- + + + Enable user +
+ v-if="user.files.length" + :files="user.files" /> @@ -62,6 +69,7 @@