From 6688587eb6bdf118687c630378d40e36a3700a52 Mon Sep 17 00:00:00 2001 From: Zephyrrus Date: Thu, 2 Jul 2020 02:48:21 +0300 Subject: feat: move toolbar into a level and add slot for pagination on grid --- src/site/components/grid/Grid.vue | 57 ++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'src/site') diff --git a/src/site/components/grid/Grid.vue b/src/site/components/grid/Grid.vue index b6615be..279472c 100644 --- a/src/site/components/grid/Grid.vue +++ b/src/site/components/grid/Grid.vue @@ -1,37 +1,40 @@ diff --git a/src/site/pages/login.vue b/src/site/pages/login.vue index 514cbc5..3c43755 100644 --- a/src/site/pages/login.vue +++ b/src/site/pages/login.vue @@ -63,6 +63,8 @@ + + + diff --git a/src/site/components/album/AlbumEntry.vue b/src/site/components/album/AlbumEntry.vue new file mode 100644 index 0000000..4d23d6c --- /dev/null +++ b/src/site/components/album/AlbumEntry.vue @@ -0,0 +1,179 @@ + + + + + + diff --git a/src/site/pages/dashboard/albums/index.vue b/src/site/pages/dashboard/albums/index.vue index 065667a..2a54ab8 100644 --- a/src/site/pages/dashboard/albums/index.vue +++ b/src/site/pages/dashboard/albums/index.vue @@ -25,118 +25,9 @@
-
-
- -
-
-
- -
-
-
-

- {{ album.name }} -

- Updated - {{ album.fileCount || 0 }} files -
-
- - -
- -
-

Public links for this album:

- - - - - - -
-
+ :album="album" />
@@ -146,87 +37,28 @@ + - diff --git a/src/site/store/albums.js b/src/site/store/albums.js new file mode 100644 index 0000000..a33181c --- /dev/null +++ b/src/site/store/albums.js @@ -0,0 +1,56 @@ +/* eslint-disable no-shadow */ +export const state = () => ({ + list: [], + isListLoading: false, + albumDetails: {}, + expandedAlbums: [] +}); + +export const getters = { + isExpanded: state => id => state.expandedAlbums.indexOf(id) > -1, + getDetails: state => id => state.albumDetails[id] || {} +}; + +export const actions = { + async fetch({ commit, dispatch }) { + try { + commit('albumsRequest'); + const response = await this.$axios.$get(`albums/mini`); + + commit('setAlbums', response.albums); + } catch (e) { + dispatch('alert/set', { text: e.message, error: true }, { root: true }); + } + }, + async fetchDetails({ commit }, albumId) { + const response = await this.$axios.$get(`album/${albumId}/links`); + + commit('setDetails', { + id: albumId, + details: { + links: response.links + } + }); + } +}; + +export const mutations = { + albumsRequest(state) { + state.isLoading = true; + }, + setAlbums(state, albums) { + state.list = albums; + state.isLoading = false; + }, + setDetails(state, { id, details }) { + state.albumDetails[id] = details; + }, + toggleExpandedState(state, id) { + const foundIndex = state.expandedAlbums.indexOf(id); + if (foundIndex > -1) { + state.expandedAlbums.splice(foundIndex, 1); + } else { + state.expandedAlbums.push(id); + } + } +}; -- 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/assets/styles/_colors.scss | 10 +- src/site/assets/styles/style.scss | 139 ++++++++++++++++------------ src/site/components/album/AlbumDetails.vue | 85 +++++++++-------- src/site/components/album/AlbumEntry.vue | 11 +-- src/site/components/grid/Grid.vue | 12 +-- 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 + src/site/store/album.js | 0 src/site/store/albums.js | 75 ++++++++++++++- 12 files changed, 289 insertions(+), 136 deletions(-) create mode 100644 src/site/store/album.js (limited to 'src/site') diff --git a/src/site/assets/styles/_colors.scss b/src/site/assets/styles/_colors.scss index b8861d2..6693d8a 100644 --- a/src/site/assets/styles/_colors.scss +++ b/src/site/assets/styles/_colors.scss @@ -10,6 +10,10 @@ $backgroundAccent: #20222b; $backgroundAccentLighter: #53555e; $backgroundLight1: #f5f6f8; +$scheme-main: $background; +$scheme-main-bis: $backgroundAccent; +$scheme-main-ter: $backgroundAccentLighter; + // customize navbar $navbar-background-color: $backgroundAccent; $navbar-item-color: #f5f6f8; @@ -47,6 +51,10 @@ $pagination-current-background-color: $base-3; $pagination-current-border-color: $base-2; // loading - $loading-background: rgba(0, 0, 0, 0.8); $loading-background: rgba(40, 40, 40, 0.66); + +// dialogs +$modal-card-body-background-color: $background; +$modal-card-head-background-color: $backgroundAccent; +$modal-card-foot-border-top: 1px solid rgba(255, 255, 255, 0.1098); diff --git a/src/site/assets/styles/style.scss b/src/site/assets/styles/style.scss index 69d15d3..6c939b5 100644 --- a/src/site/assets/styles/style.scss +++ b/src/site/assets/styles/style.scss @@ -1,15 +1,16 @@ // Let's first take care of having the customized colors ready. -@import "./_colors.scss"; +@import './_colors.scss'; // Bulma/Buefy customization -@import "../../../node_modules/bulma/sass/utilities/_all.sass"; +@import '../../../node_modules/bulma/sass/utilities/_all.sass'; $body-size: 14px !default; -$family-primary: 'Nunito', BlinkMacSystemFont, -apple-system, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", "Helvetica", "Arial", sans-serif; +$family-primary: 'Nunito', BlinkMacSystemFont, -apple-system, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', + 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif; $size-normal: 1rem; -@import "../../../node_modules/bulma/bulma.sass"; -@import "../../../node_modules/buefy/src/scss/buefy.scss"; +@import '../../../node_modules/bulma/bulma.sass'; +@import '../../../node_modules/buefy/src/scss/buefy.scss'; html { // font-size: 100%; @@ -18,9 +19,9 @@ html { } a { - color: #5E81AC; + color: #5e81ac; &:hover { - color: #81A1C1; + color: #81a1c1; text-decoration: underline; } } @@ -43,10 +44,18 @@ h4 { } @for $i from 1 through 10 { - .mt#{$i} { margin-top: $i + em !important; } - .mb#{$i} { margin-bottom: $i + em !important; } - .ml#{$i} { margin-left: $i + em !important; } - .mr#{$i} { margin-right: $i + em !important; } + .mt#{$i} { + margin-top: $i + em !important; + } + .mb#{$i} { + margin-bottom: $i + em !important; + } + .ml#{$i} { + margin-left: $i + em !important; + } + .mr#{$i} { + margin-right: $i + em !important; + } } .text-center { @@ -58,8 +67,12 @@ hr { height: 1px; } // Bulma color changes. -.tooltip.is-top.is-primary:before { border-top: 5px solid #20222b; } -.tooltip.is-primary:after { background: #20222b; } +.tooltip.is-top.is-primary:before { + border-top: 5px solid #20222b; +} +.tooltip.is-primary:after { + background: #20222b; +} div#drag-overlay { position: fixed; @@ -93,7 +106,6 @@ div#drag-overlay { } } - section.hero { &.dashboard { // background-color: $backgroundLight1 !important; @@ -103,10 +115,12 @@ section.hero { } } -section input, section a.button { +section input, +section a.button { font-size: 14px !important; } -section input, section p.control a.button { +section input, +section p.control a.button { border-left: 0px !important; border-top: 0px !important; border-right: 0px !important; @@ -114,13 +128,15 @@ section input, section p.control a.button { box-shadow: 0 0 0 !important; } -section p.control a.button { margin-left: 10px !important; } +section p.control a.button { + margin-left: 10px !important; +} section p.control button { height: 100%; font-size: 12px; } -.switch input[type=checkbox] + .check:before { +.switch input[type='checkbox'] + .check:before { background: #fbfbfb; } @@ -128,7 +144,8 @@ section p.control button { Register and Login forms */ -section.hero.is-login, section.hero.is-register { +section.hero.is-login, +section.hero.is-register { a { font-size: 1.25em; line-height: 2.5em; @@ -174,18 +191,22 @@ section#register a.is-text { font-size: 1.25em; line-height: 2.5em; } -*/ + .modal-card-head, .modal-card-foot { background: $backgroundLight1; } +*/ .switch { margin-top: 5px; } -.input, .taginput .taginput-container.is-focusable, .textarea, .select select { +.input, +.taginput .taginput-container.is-focusable, +.textarea, +.select select { border: 2px solid #21252d; - border-radius: .3em !important; + border-radius: 0.3em !important; background: rgba(0, 0, 0, 0.15); padding: 1rem; color: $textColor; @@ -203,9 +224,9 @@ button.button.is-primary { border: 2px solid #21252d; color: $textColor; font-size: 1rem; - border-top: 0; - border-left: 0; - border-right: 0; + border-top: 0; + border-left: 0; + border-right: 0; &:hover { background-color: $base-2; } @@ -224,13 +245,16 @@ svg.waves { user-select: none; overflow: hidden; } -div.field-body > div.field { text-align: left; } +div.field-body > div.field { + text-align: left; +} table.table { background: $base-2; color: $textColor; border: 0; thead { - th, td { + th, + td { color: $textColor; } } @@ -244,60 +268,55 @@ table.table { } } } - th, td { + th, + td { border-color: #ffffff1c; } } // vue-bar .vb > .vb-dragger { - z-index: 5; - width: 12px; - right: 0; + z-index: 5; + width: 12px; + right: 0; } .vb > .vb-dragger > .vb-dragger-styler { - -webkit-backface-visibility: hidden; - backface-visibility: hidden; - -webkit-transform: rotate3d(0,0,0,0); - transform: rotate3d(0,0,0,0); - -webkit-transition: - background-color 100ms ease-out, - margin 100ms ease-out, - height 100ms ease-out; - transition: - background-color 100ms ease-out, - margin 100ms ease-out, - height 100ms ease-out; - background-color: $backgroundAccent; - margin: 5px 5px 5px 0; - border-radius: 20px; - height: calc(100% - 10px); - display: block; + -webkit-backface-visibility: hidden; + backface-visibility: hidden; + -webkit-transform: rotate3d(0, 0, 0, 0); + transform: rotate3d(0, 0, 0, 0); + -webkit-transition: background-color 100ms ease-out, margin 100ms ease-out, height 100ms ease-out; + transition: background-color 100ms ease-out, margin 100ms ease-out, height 100ms ease-out; + background-color: $backgroundAccent; + margin: 5px 5px 5px 0; + border-radius: 20px; + height: calc(100% - 10px); + display: block; } .vb.vb-scrolling-phantom > .vb-dragger > .vb-dragger-styler { - background-color: $backgroundAccentLighter; + background-color: $backgroundAccentLighter; } .vb > .vb-dragger:hover > .vb-dragger-styler { - background-color: $backgroundAccentLighter; - margin: 0px; - height: 100%; + background-color: $backgroundAccentLighter; + margin: 0px; + height: 100%; } .vb.vb-dragging > .vb-dragger > .vb-dragger-styler { - background-color: $backgroundAccentLighter; - margin: 0px; - height: 100%; + background-color: $backgroundAccentLighter; + margin: 0px; + height: 100%; } .vb.vb-dragging-phantom > .vb-dragger > .vb-dragger-styler { - background-color: $backgroundAccentLighter; + background-color: $backgroundAccentLighter; } -.vb-content{ - overflow: auto !important +.vb-content { + overflow: auto !important; } // helpers @@ -313,7 +332,7 @@ table.table { height: max-content; } -.pagination a, .pagination a:hover { +.pagination a, +.pagination a:hover { text-decoration: none; } - diff --git a/src/site/components/album/AlbumDetails.vue b/src/site/components/album/AlbumDetails.vue index a02fe55..b646cb0 100644 --- a/src/site/components/album/AlbumDetails.vue +++ b/src/site/components/album/AlbumDetails.vue @@ -25,13 +25,13 @@ label="Allow download" centered> + @input="updateLinkOptions(albumId, props.row)" /> + @click="promptDeleteAlbumLink(albumId, props.row.identifier)">Delete link + + + + + 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; } - } - } + }, + }, }; diff --git a/src/site/store/album.js b/src/site/store/album.js index e69de29..f7c88c9 100644 --- a/src/site/store/album.js +++ b/src/site/store/album.js @@ -0,0 +1,54 @@ +/* eslint-disable no-shadow */ +export const state = () => ({ + files: [], + name: null, + isLoading: false, + pagination: { + page: 1, + limit: 30, + totalFiles: 0, + }, + downloadEnabled: false, +}); + +export const getters = { + getTotalFiles: ({ pagination }) => pagination.totalFiles, + getFetchedCount: ({ files }) => files.length, + shouldPaginate: ({ pagination }) => pagination.totalFiles > pagination.limit, + getLimit: ({ pagination }) => pagination.limit, + getName: ({ name }) => name, +}; + +export const actions = { + async fetchById({ commit, dispatch, state }, { id, page }) { + commit('setIsLoading'); + + page = page || 1; + + try { + const response = await this.$axios.$get(`album/${id}/full`, { + params: { limit: state.pagination.limit, page }, + }); + + commit('setFiles', response); + commit('updatePaginationMeta', { totalFiles: response.count, page }); + } catch (e) { + dispatch('alert/set', { text: e.message, error: true }, { root: true }); + } + }, +}; + +export const mutations = { + setIsLoading(state) { + state.isLoading = true; + }, + setFiles(state, { files, name }) { + state.files = files || []; + state.name = name; + state.isLoading = false; + }, + updatePaginationMeta(state, { page, totalFiles }) { + state.pagination.page = page || 1; + state.pagination.totalFiles = totalFiles || 0; + }, +}; diff --git a/src/site/store/albums.js b/src/site/store/albums.js index d5d45ce..f3d7bcf 100644 --- a/src/site/store/albums.js +++ b/src/site/store/albums.js @@ -5,26 +5,22 @@ export const state = () => ({ list: [], isListLoading: false, albumDetails: {}, - expandedAlbums: [] + expandedAlbums: [], }); export const getters = { - isExpanded: state => id => state.expandedAlbums.indexOf(id) > -1, - getDetails: state => id => state.albumDetails[id] || {} + isExpanded: (state) => (id) => state.expandedAlbums.indexOf(id) > -1, + getDetails: (state) => (id) => state.albumDetails[id] || {}, }; export const actions = { - async fetch({ commit, dispatch }) { - try { - commit('albumsRequest'); - const response = await this.$axios.$get(`albums/mini`); + async fetch({ commit }) { + commit('albumsRequest'); + const response = await this.$axios.$get('albums/mini'); - commit('setAlbums', response.albums); + commit('setAlbums', response.albums); - return response; - } catch (e) { - dispatch('alert/set', { text: e.message, error: true }, { root: true }); - } + return response; }, async fetchDetails({ commit }, albumId) { @@ -33,15 +29,15 @@ export const actions = { commit('setDetails', { id: albumId, details: { - links: response.links - } + links: response.links, + }, }); return response; }, async createAlbum({ commit }, name) { - const response = await this.$axios.$post(`album/new`, { name }); + const response = await this.$axios.$post('album/new', { name }); commit('addAlbum', response.data); @@ -57,7 +53,7 @@ export const actions = { }, async createLink({ commit }, albumId) { - const response = await this.$axios.$post(`album/link/new`, { albumId }); + const response = await this.$axios.$post('album/link/new', { albumId }); commit('addAlbumLink', { albumId, data: response.data }); @@ -65,10 +61,10 @@ export const actions = { }, async updateLinkOptions({ commit }, { albumId, linkOpts }) { - const response = await this.$axios.$post(`album/link/edit`, { + const response = await this.$axios.$post('album/link/edit', { identifier: linkOpts.identifier, enableDownload: linkOpts.enableDownload, - enabled: linkOpts.enabled + enabled: linkOpts.enabled, }); commit('updateAlbumLinkOpts', { albumId, linkOpts: response.data }); @@ -82,7 +78,7 @@ export const actions = { commit('removeAlbumLink', { albumId, identifier }); return response; - } + }, }; export const mutations = { @@ -109,7 +105,7 @@ export const mutations = { }, updateAlbumLinkOpts(state, { albumId, linkOpts }) { const foundIndex = state.albumDetails[albumId].links.findIndex( - ({ identifier }) => identifier === linkOpts.identifier + ({ identifier }) => identifier === linkOpts.identifier, ); const link = state.albumDetails[albumId].links[foundIndex]; state.albumDetails[albumId].links[foundIndex] = { ...link, ...linkOpts }; @@ -125,5 +121,5 @@ export const mutations = { } else { state.expandedAlbums.push(id); } - } + }, }; -- cgit v1.2.3 From 766e74cc51138b32482f65f0f2647eb9d943103e Mon Sep 17 00:00:00 2001 From: Zephyrrus Date: Sun, 5 Jul 2020 04:18:08 +0300 Subject: feat: add video preview on hover to dashboard and apply new linter rules to some of the files --- src/site/components/footer/Footer.vue | 62 ++- src/site/components/grid/Grid.vue | 435 +++++++++++---------- src/site/components/grid/waterfall/Waterfall.vue | 56 +-- .../components/grid/waterfall/WaterfallItem.vue | 29 +- src/site/constants/alertTypes.js | 10 + src/site/plugins/notifier.js | 7 + src/site/store/auth.js | 20 +- src/site/store/images.js | 4 +- 8 files changed, 342 insertions(+), 281 deletions(-) create mode 100644 src/site/constants/alertTypes.js create mode 100644 src/site/plugins/notifier.js (limited to 'src/site') diff --git a/src/site/components/footer/Footer.vue b/src/site/components/footer/Footer.vue index 44e34f4..19d18f2 100644 --- a/src/site/components/footer/Footer.vue +++ b/src/site/components/footer/Footer.vue @@ -1,12 +1,18 @@ + + +.hidden { + display: none; +} - diff --git a/src/site/components/grid/waterfall/Waterfall.vue b/src/site/components/grid/waterfall/Waterfall.vue index af1bd72..cccc3ac 100644 --- a/src/site/components/grid/waterfall/Waterfall.vue +++ b/src/site/components/grid/waterfall/Waterfall.vue @@ -9,8 +9,6 @@
diff --git a/src/site/components/grid/waterfall/WaterfallItem.vue b/src/site/components/grid/waterfall/WaterfallItem.vue index 7c4d814..2a5c69a 100644 --- a/src/site/components/grid/waterfall/WaterfallItem.vue +++ b/src/site/components/grid/waterfall/WaterfallItem.vue @@ -12,26 +12,27 @@ diff --git a/src/site/constants/alertTypes.js b/src/site/constants/alertTypes.js new file mode 100644 index 0000000..1b830bc --- /dev/null +++ b/src/site/constants/alertTypes.js @@ -0,0 +1,10 @@ +export default { + PRIMARY: 'is-primary', + INFO: 'is-info', + SUCCESS: 'is-success', + WARNING: 'is-warning', + ERROR: 'is-danger', + DARK: 'is-dark', + LIGHT: 'is-light', + WHITE: 'is-white', +}; diff --git a/src/site/plugins/notifier.js b/src/site/plugins/notifier.js new file mode 100644 index 0000000..bcf7878 --- /dev/null +++ b/src/site/plugins/notifier.js @@ -0,0 +1,7 @@ +export default ({ store }, inject) => { + inject('notifier', { + showMessage({ content = '', type = '' }) { + store.commit('alert/set', { content, color }); + } + }); +}; diff --git a/src/site/store/auth.js b/src/site/store/auth.js index 73976d6..55009ce 100644 --- a/src/site/store/auth.js +++ b/src/site/store/auth.js @@ -4,14 +4,14 @@ const getDefaultState = () => ({ loggedIn: false, isLoading: false, user: null, - token: null + token: null, }); export const state = getDefaultState; export const getters = { - isLoggedIn: state => state.loggedIn, - getApiKey: state => state.user?.apiKey + isLoggedIn: (state) => state.loggedIn, + getApiKey: (state) => state.user?.apiKey, }; export const actions = { @@ -27,7 +27,7 @@ export const actions = { commit('loginRequest'); try { - const data = await this.$axios.$post(`auth/login`, { username, password }); + const data = await this.$axios.$post('auth/login', { username, password }); this.$axios.setToken(data.token, 'Bearer'); commit('setToken', data.token); @@ -38,7 +38,7 @@ export const actions = { }, async fetchCurrentUser({ commit, dispatch }) { try { - const data = await this.$axios.$get(`users/me`); + const data = await this.$axios.$get('users/me'); commit('setUser', data.user); } catch (e) { dispatch('alert/set', { text: e.message, error: true }, { root: true }); @@ -46,9 +46,9 @@ export const actions = { }, async changePassword({ dispatch }, { password, newPassword }) { try { - const response = await this.$axios.$post(`user/password/change`, { + const response = await this.$axios.$post('user/password/change', { password, - newPassword + newPassword, }); return response; @@ -58,7 +58,7 @@ export const actions = { }, async requestAPIKey({ commit, dispatch }) { try { - const response = await this.$axios.$post(`user/apikey/change`); + const response = await this.$axios.$post('user/apikey/change'); commit('setApiKey', response.apiKey); return response; @@ -68,7 +68,7 @@ export const actions = { }, logout({ commit }) { commit('logout'); - } + }, }; export const mutations = { @@ -94,5 +94,5 @@ export const mutations = { this.$cookies.remove('token'); // reset state to default Object.assign(state, getDefaultState()); - } + }, }; diff --git a/src/site/store/images.js b/src/site/store/images.js index f6dae1b..14f475a 100644 --- a/src/site/store/images.js +++ b/src/site/store/images.js @@ -25,7 +25,7 @@ export const actions = { try { const response = await this.$axios.$get(`files`, { params: { limit: state.pagination.limit, page } }); - commit('updateFiles', { files: response.files }); + commit('setFiles', { files: response.files }); commit('updatePaginationMeta', { totalFiles: response.count, page }); } catch (e) { dispatch('alert/set', { text: e.message, error: true }, { root: true }); @@ -45,7 +45,7 @@ export const mutations = { setIsLoading(state) { state.isLoading = true; }, - updateFiles(state, { files }) { + setFiles(state, { files }) { state.files = files || []; state.isLoading = false; }, -- cgit v1.2.3 From 15f296a7805b7623f56eab67b74ab0bf93a038e1 Mon Sep 17 00:00:00 2001 From: Zephyrrus Date: Tue, 7 Jul 2020 02:02:37 +0300 Subject: chore: eslint stores feat: merge album and images --- src/site/store/.eslintrc.json | 5 +++++ src/site/store/admin.js | 0 src/site/store/album.js | 5 ++++- src/site/store/albums.js | 1 - src/site/store/alert.js | 7 +++---- src/site/store/auth.js | 17 +++++----------- src/site/store/config.js | 5 ++--- src/site/store/images.js | 45 ++++++++++++++++++++++++------------------- src/site/store/index.js | 5 +++-- 9 files changed, 47 insertions(+), 43 deletions(-) create mode 100644 src/site/store/.eslintrc.json create mode 100644 src/site/store/admin.js (limited to 'src/site') diff --git a/src/site/store/.eslintrc.json b/src/site/store/.eslintrc.json new file mode 100644 index 0000000..052e3ef --- /dev/null +++ b/src/site/store/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-shadow": ["error", { "allow": ["state"] }] + } +} diff --git a/src/site/store/admin.js b/src/site/store/admin.js new file mode 100644 index 0000000..e69de29 diff --git a/src/site/store/album.js b/src/site/store/album.js index f7c88c9..d8ffacc 100644 --- a/src/site/store/album.js +++ b/src/site/store/album.js @@ -1,4 +1,3 @@ -/* eslint-disable no-shadow */ export const state = () => ({ files: [], name: null, @@ -36,6 +35,10 @@ export const actions = { dispatch('alert/set', { text: e.message, error: true }, { root: true }); } }, + // TODO: Fix duplicate code between this store and files store + deleteFile({ commit }, fileId) { + + }, }; export const mutations = { diff --git a/src/site/store/albums.js b/src/site/store/albums.js index f3d7bcf..2b4ac60 100644 --- a/src/site/store/albums.js +++ b/src/site/store/albums.js @@ -1,4 +1,3 @@ -/* eslint-disable no-shadow */ import Vue from 'vue'; export const state = () => ({ diff --git a/src/site/store/alert.js b/src/site/store/alert.js index 78c0eaf..ff38e09 100644 --- a/src/site/store/alert.js +++ b/src/site/store/alert.js @@ -1,7 +1,6 @@ -/* eslint-disable no-shadow */ const getDefaultState = () => ({ text: null, - error: false + error: false, }); export const state = getDefaultState; @@ -12,7 +11,7 @@ export const actions = { }, clear({ commit }) { commit('clear'); - } + }, }; export const mutations = { @@ -22,5 +21,5 @@ export const mutations = { }, clear(state) { Object.assign(state, getDefaultState()); - } + }, }; diff --git a/src/site/store/auth.js b/src/site/store/auth.js index 55009ce..69de9ec 100644 --- a/src/site/store/auth.js +++ b/src/site/store/auth.js @@ -1,8 +1,5 @@ -/* eslint-disable no-shadow */ -// only used so I could keep the convention of naming the first param as "state" in mutations const getDefaultState = () => ({ loggedIn: false, - isLoading: false, user: null, token: null, }); @@ -23,18 +20,14 @@ export const actions = { dispatch('alert/set', { text: e.message, error: true }, { root: true }); } }, - async login({ commit, dispatch }, { username, password }) { + async login({ commit }, { username, password }) { commit('loginRequest'); - try { - const data = await this.$axios.$post('auth/login', { username, password }); - this.$axios.setToken(data.token, 'Bearer'); + const data = await this.$axios.$post('auth/login', { username, password }); + this.$axios.setToken(data.token, 'Bearer'); - commit('setToken', data.token); - commit('loginSuccess', { token: data.token, user: data.user }); - } catch (e) { - dispatch('alert/set', { text: e.message, error: true }, { root: true }); - } + commit('setToken', data.token); + commit('loginSuccess', { token: data.token, user: data.user }); }, async fetchCurrentUser({ commit, dispatch }) { try { diff --git a/src/site/store/config.js b/src/site/store/config.js index 6202f84..f52fc0f 100644 --- a/src/site/store/config.js +++ b/src/site/store/config.js @@ -1,4 +1,3 @@ -/* eslint-disable no-shadow */ export const state = () => ({ development: true, version: '4.0.0', @@ -9,11 +8,11 @@ export const state = () => ({ chunkSize: 90, maxLinksPerAlbum: 5, publicMode: false, - userAccounts: false + userAccounts: false, }); export const mutations = { set(state, config) { Object.assign(state, config); - } + }, }; diff --git a/src/site/store/images.js b/src/site/store/images.js index 14f475a..d02219f 100644 --- a/src/site/store/images.js +++ b/src/site/store/images.js @@ -1,19 +1,21 @@ -/* eslint-disable no-shadow */ export const state = () => ({ files: [], isLoading: false, pagination: { page: 1, limit: 30, - totalFiles: 0 - } + totalFiles: 0, + }, + name: null, + downloadEnabled: false, }); export const getters = { getTotalFiles: ({ pagination }) => pagination.totalFiles, getFetchedCount: ({ files }) => files.length, shouldPaginate: ({ pagination }) => pagination.totalFiles > pagination.limit, - getLimit: ({ pagination }) => pagination.limit + getLimit: ({ pagination }) => pagination.limit, + getName: ({ name }) => name, }; export const actions = { @@ -23,34 +25,37 @@ export const actions = { page = page || 1; try { - const response = await this.$axios.$get(`files`, { params: { limit: state.pagination.limit, page } }); + const response = await this.$axios.$get('files', { params: { limit: state.pagination.limit, page } }); - commit('setFiles', { files: response.files }); - commit('updatePaginationMeta', { totalFiles: response.count, page }); + commit('setFilesAndMeta', { ...response, page }); } catch (e) { dispatch('alert/set', { text: e.message, error: true }, { root: true }); } }, - async fetchById({ commit, dispatch }) { - try { - const response = await this.$axios.$get('verify'); - commit('loginSuccess', response); - } catch (e) { - dispatch('alert/set', { text: e.message, error: true }, { root: true }); - } - } + async fetchByAlbumId({ commit, dispatch, state }, { id, page }) { + commit('setIsLoading'); + + page = page || 1; + + const response = await this.$axios.$get(`album/${id}/full`, { + params: { limit: state.pagination.limit, page }, + }); + + commit('setFilesAndMeta', { ...response, page }); + }, }; export const mutations = { setIsLoading(state) { state.isLoading = true; }, - setFiles(state, { files }) { + setFilesAndMeta(state, { + files, name, page, count, + }) { state.files = files || []; + state.name = name ?? null; state.isLoading = false; - }, - updatePaginationMeta(state, { page, totalFiles }) { state.pagination.page = page || 1; - state.pagination.totalFiles = totalFiles || 0; - } + state.pagination.totalFiles = count || 0; + }, }; diff --git a/src/site/store/index.js b/src/site/store/index.js index 8f910ae..c0faffb 100644 --- a/src/site/store/index.js +++ b/src/site/store/index.js @@ -1,5 +1,6 @@ import config from '../../../dist/config.json'; +// eslint-disable-next-line import/prefer-default-export export const actions = { async nuxtClientInit({ commit, dispatch }) { commit('config/set', config); @@ -8,8 +9,8 @@ export const actions = { if (!cookies.token) return dispatch('auth/logout'); commit('auth/setToken', cookies.token); - await dispatch('auth/verify'); - } + return dispatch('auth/verify'); + }, /* alert({ commit }, payload) { if (!payload) return commit('alert', null); commit('alert', { -- 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/components/grid/Grid.vue | 28 +-- src/site/components/grid/waterfall/Waterfall.vue | 47 +++- .../components/grid/waterfall/WaterfallItem.vue | 12 +- src/site/components/imageInfo/ImageInfo.vue | 0 src/site/pages/a/_identifier.vue | 38 +-- 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 ++-- src/site/pages/login.vue | 46 ++-- src/site/plugins/notifier.js | 4 +- 12 files changed, 361 insertions(+), 266 deletions(-) create mode 100644 src/site/components/imageInfo/ImageInfo.vue (limited to 'src/site') diff --git a/src/site/components/grid/Grid.vue b/src/site/components/grid/Grid.vue index d4fe067..e6a8c64 100644 --- a/src/site/components/grid/Grid.vue +++ b/src/site/components/grid/Grid.vue @@ -24,12 +24,10 @@ - + :gutterHeight="4" + :itemWidth="width" + :items="gridFiles"> +
@@ -185,12 +183,10 @@ import { mapState } from 'vuex'; import Waterfall from './waterfall/Waterfall.vue'; -import WaterfallItem from './waterfall/WaterfallItem.vue'; export default { components: { Waterfall, - WaterfallItem, }, props: { files: { @@ -253,13 +249,13 @@ export default { const data = await this.$search.do(this.searchTerm, ['name', 'original', 'type', 'albums:name']); console.log('> Search result data', data); }, - deleteFile(file, index) { - this.$buefy.dialog.confirm({ + deleteFile(file) { + this.$emit('delete', file); + /* this.$buefy.dialog.confirm({ title: 'Deleting file', message: 'Are you sure you want to delete this file?', confirmText: 'Delete File', type: 'is-danger', - hasIcon: true, onConfirm: async () => { const response = await this.$axios.$delete(`file/${file.id}`); if (this.showList) { @@ -274,7 +270,7 @@ export default { } return this.$buefy.toast.open(response.message); }, - }); + }); */ }, isAlbumSelected(id) { if (!this.showingModalForFile) return false; @@ -311,10 +307,6 @@ export default { const foundIndex = this.hoveredItems.indexOf(id); if (foundIndex > -1) return; this.hoveredItems.push(id); - /// XXX: THIS IS NOT OK! - this.$nextTick(() => { - this.$refs.video.forEach((e) => e.play().catch(() => {})); - }); }, mouseOut(id) { console.log('out', id); diff --git a/src/site/components/grid/waterfall/Waterfall.vue b/src/site/components/grid/waterfall/Waterfall.vue index cccc3ac..a83a275 100644 --- a/src/site/components/grid/waterfall/Waterfall.vue +++ b/src/site/components/grid/waterfall/Waterfall.vue @@ -1,14 +1,14 @@ - + + + diff --git a/src/site/components/grid/waterfall/WaterfallItem.vue b/src/site/components/grid/waterfall/WaterfallItem.vue index 2a5c69a..a49c58c 100644 --- a/src/site/components/grid/waterfall/WaterfallItem.vue +++ b/src/site/components/grid/waterfall/WaterfallItem.vue @@ -1,9 +1,3 @@ - -