From 720ffaf0083564c85a07d66a6d303f34706add41 Mon Sep 17 00:00:00 2001 From: Zephyrrus Date: Thu, 2 Jul 2020 02:50:55 +0300 Subject: feat: start refactoring the code to actually use vuex This includes creating multiple stores as needed for components and removing all complex states from components (since all those states should be stored in vuex) --- src/site/pages/dashboard/index.vue | 124 +++++++++++++++++++++++-------------- 1 file changed, 77 insertions(+), 47 deletions(-) (limited to 'src/site/pages/dashboard') diff --git a/src/site/pages/dashboard/index.vue b/src/site/pages/dashboard/index.vue index 0eb9532..6c1b99b 100644 --- a/src/site/pages/dashboard/index.vue +++ b/src/site/pages/dashboard/index.vue @@ -6,27 +6,55 @@
-

Your uploaded files

+
- + - + + +
@@ -34,6 +62,8 @@ + - -- cgit v1.2.3 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 + src/site/pages/dashboard/albums/_id.vue | 60 +++++++++++++++++++++-------- src/site/pages/dashboard/albums/index.vue | 28 ++++++++++---- src/site/pages/dashboard/tags/index.vue | 2 + 5 files changed, 69 insertions(+), 24 deletions(-) (limited to 'src/site/pages/dashboard') 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() }); diff --git a/src/site/pages/dashboard/albums/_id.vue b/src/site/pages/dashboard/albums/_id.vue index 47e7057..c082b63 100644 --- a/src/site/pages/dashboard/albums/_id.vue +++ b/src/site/pages/dashboard/albums/_id.vue @@ -10,25 +10,53 @@
-

Files

+ +
- - + :files="files" + :total="count"> + +
diff --git a/src/site/pages/dashboard/albums/index.vue b/src/site/pages/dashboard/albums/index.vue index 2a54ab8..a010254 100644 --- a/src/site/pages/dashboard/albums/index.vue +++ b/src/site/pages/dashboard/albums/index.vue @@ -18,7 +18,8 @@ @keyup.enter.native="createAlbum" />

@@ -37,7 +38,7 @@ + + + + diff --git a/src/site/pages/dashboard/albums/index.vue b/src/site/pages/dashboard/albums/index.vue index a010254..a2ba522 100644 --- a/src/site/pages/dashboard/albums/index.vue +++ b/src/site/pages/dashboard/albums/index.vue @@ -7,26 +7,33 @@
-

Manage your albums

+

+ Manage your albums +


-

- + @click="createAlbum"> + Create album +

-
@@ -45,15 +52,19 @@ import AlbumEntry from '~/components/album/AlbumEntry.vue'; export default { components: { Sidebar, - AlbumEntry + AlbumEntry, }, middleware: ['auth', ({ store }) => { - store.dispatch('albums/fetch'); + try { + store.dispatch('albums/fetch'); + } catch (e) { + this.alert({ text: e.message, error: true }); + } }], data() { return { newAlbumName: null, - isCreatingAlbum: false + isCreatingAlbum: false, }; }, computed: mapState(['config', 'albums']), @@ -62,7 +73,7 @@ export default { }, methods: { ...mapActions({ - 'alert': 'alert/set' + 'alert': 'alert/set', }), async createAlbum() { if (!this.newAlbumName || this.newAlbumName === '') return; @@ -78,8 +89,8 @@ export default { this.isCreatingAlbum = false; this.newAlbumName = null; } - } - } + }, + }, }; -- 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/account.vue | 78 +++++--- src/site/pages/dashboard/admin/user/_id.vue | 45 +++-- src/site/pages/dashboard/admin/users.vue | 270 ++++++++++++++-------------- src/site/pages/dashboard/albums/_id.vue | 17 +- src/site/pages/dashboard/index.vue | 42 +++-- 5 files changed, 251 insertions(+), 201 deletions(-) (limited to 'src/site/pages/dashboard') diff --git a/src/site/pages/dashboard/account.vue b/src/site/pages/dashboard/account.vue index 1c335e8..fb8b273 100644 --- a/src/site/pages/dashboard/account.vue +++ b/src/site/pages/dashboard/account.vue @@ -6,62 +6,82 @@
-

Account settings

+

+ Account settings +


- - - - - - - -
- +
- -

- +

- +
@@ -75,7 +95,7 @@ import Sidebar from '~/components/sidebar/Sidebar.vue'; export default { components: { - Sidebar + Sidebar, }, middleware: ['auth', ({ store }) => { store.dispatch('auth/fetchCurrentUser'); @@ -84,21 +104,21 @@ export default { return { password: '', newPassword: '', - reNewPassword: '' + reNewPassword: '', }; - }, + }, computed: { ...mapGetters({ 'apiKey': 'auth/getApiKey' }), ...mapState({ - user: state => state.auth.user - }) + user: (state) => state.auth.user, + }), }, metaInfo() { return { title: 'Account' }; }, methods: { ...mapActions({ - getUserSetttings: 'auth/fetchCurrentUser' + getUserSetttings: 'auth/fetchCurrentUser', }), async changePassword() { const { password, newPassword, reNewPassword } = this; @@ -106,21 +126,21 @@ export default { if (!password || !newPassword || !reNewPassword) { this.$store.dispatch('alert/set', { text: 'One or more fields are missing', - error: true + error: true, }); return; } if (newPassword !== reNewPassword) { this.$store.dispatch('alert/set', { text: 'Passwords don\'t match', - error: true + error: true, }); return; } const response = await this.$store.dispatch('auth/changePassword', { password, - newPassword + newPassword, }); if (response) { @@ -131,13 +151,13 @@ export default { this.$buefy.dialog.confirm({ type: 'is-danger', message: 'Are you sure you want to regenerate your API key? Previously generated API keys will stop working. Make sure to write the new key down as this is the only time it will be displayed to you.', - onConfirm: () => this.requestNewAPIKey() + onConfirm: () => this.requestNewAPIKey(), }); }, async requestNewAPIKey() { - const response = await this.$store.dispatch('auth/requestAPIKey'); + const response = await this.$store.dispatch('auth/requestAPIKey'); this.$buefy.toast.open(response.message); - } - } + }, + }, }; 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 @@ + + + + - - - - - - diff --git a/src/site/pages/dashboard/albums/_id.vue b/src/site/pages/dashboard/albums/_id.vue index 0d3bd68..33b0319 100644 --- a/src/site/pages/dashboard/albums/_id.vue +++ b/src/site/pages/dashboard/albums/_id.vue @@ -14,7 +14,7 @@

- {{ name }} + {{ images.name }}

@@ -45,7 +45,7 @@