From 81b062ca0e46104f18c91b2fae158d95fd8629b2 Mon Sep 17 00:00:00 2001 From: Artem Anufrij Date: Wed, 15 Feb 2023 23:36:37 +0100 Subject: [PATCH] finish share menu --- public/config.json | 4 +- src/components/dialogs/AlbumViewer.vue | 13 ++- src/components/dialogs/BoxViewer.vue | 108 +++++++++++++------------ src/store/modules/albums/actions.js | 15 ++-- src/store/modules/albums/mutations.js | 1 + src/store/modules/albums/state.js | 2 +- src/store/modules/boxes/actions.js | 10 +++ src/store/modules/boxes/mutations.js | 1 + src/store/modules/boxes/state.js | 2 +- 9 files changed, 92 insertions(+), 64 deletions(-) diff --git a/public/config.json b/public/config.json index a3b7d4a..f966bb7 100644 --- a/public/config.json +++ b/public/config.json @@ -1,5 +1,5 @@ { - "backend_de": "http://localhost:31204", - "backend_dev": "https://webplay.rocks", + "backend_dev": "http://localhost:31204", + "backend_de": "https://webplay.rocks", "backend": "https://webplay.rocks" } \ No newline at end of file diff --git a/src/components/dialogs/AlbumViewer.vue b/src/components/dialogs/AlbumViewer.vue index 4059168..e1b4001 100644 --- a/src/components/dialogs/AlbumViewer.vue +++ b/src/components/dialogs/AlbumViewer.vue @@ -37,9 +37,12 @@ }}
- + @@ -59,7 +62,6 @@

- - - -
-

- - {{ selectedBox.title }} -
- {{ box_videos.length }} Videos -
-

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

+ + {{ selectedBox.title }} +
+ {{ box_videos.length }} Videos +
+

+ + + +
@@ -168,8 +173,11 @@ export default { resetCover() { this.$store.dispatch("boxes/resetCover", this.selectedBox); }, - share() { - this.$store.dispatch("boxes/share", this.selectedBox); + shareEnable() { + this.$store.dispatch("boxes/shareEnable", this.selectedBox); + }, + shareDisable() { + this.$store.dispatch("boxes/shareDisable", this.selectedBox); }, }, computed: { diff --git a/src/store/modules/albums/actions.js b/src/store/modules/albums/actions.js index 77d3db1..b2496d4 100644 --- a/src/store/modules/albums/actions.js +++ b/src/store/modules/albums/actions.js @@ -154,11 +154,14 @@ export default { } axios.put(context.rootGetters.server + "/api/albums/" + album._id, body, context.rootGetters.headers); }, - share(context, album) { - return new Promise((resolve) => { - axios.get(context.rootGetters.server + "/api/albums/" + album._id + "/share", context.rootGetters.headers).then(res => { - resolve(res.data); - }); - }) + shareEnable(context, album) { + axios.post(context.rootGetters.server + "/api/albums/" + album._id + "/share", {}, context.rootGetters.headers).then(res => { + album.share = res.data; + }); + }, + shareDisable(context, album) { + axios.delete(context.rootGetters.server + "/api/albums/" + album._id + "/share", context.rootGetters.headers).then(() => { + album.share = {}; + }); } } \ No newline at end of file diff --git a/src/store/modules/albums/mutations.js b/src/store/modules/albums/mutations.js index 6b1384c..dafa403 100644 --- a/src/store/modules/albums/mutations.js +++ b/src/store/modules/albums/mutations.js @@ -59,6 +59,7 @@ export default { } else if (existsAlbum && album.tracks.length > 0) { existsAlbum.covers = album.covers || {}; + existsAlbum.share = album.share; existsAlbum.tracks = album.tracks; existsAlbum.tracks.forEach((track) => { track.parent = existsAlbum; diff --git a/src/store/modules/albums/state.js b/src/store/modules/albums/state.js index 6dd41cd..e504bbe 100644 --- a/src/store/modules/albums/state.js +++ b/src/store/modules/albums/state.js @@ -1,7 +1,7 @@ export default { collection: [], newest: [], - selectedAlbum: { tracks: [], covers: {} }, + selectedAlbum: { tracks: [], covers: {}, share: {} }, page: 1, loading: false, eos: false diff --git a/src/store/modules/boxes/actions.js b/src/store/modules/boxes/actions.js index b8e0b90..ba5ef48 100644 --- a/src/store/modules/boxes/actions.js +++ b/src/store/modules/boxes/actions.js @@ -130,4 +130,14 @@ export default { box.covers = {} }); }, + shareEnable(context, box) { + axios.post(context.rootGetters.server + "/api/boxes/" + box._id + "/share", {}, context.rootGetters.headers).then(res => { + box.share = res.data; + }); + }, + shareDisable(context, box) { + axios.delete(context.rootGetters.server + "/api/boxes/" + box._id + "/share", context.rootGetters.headers).then(() => { + box.share = {}; + }); + } } \ No newline at end of file diff --git a/src/store/modules/boxes/mutations.js b/src/store/modules/boxes/mutations.js index 3ce0166..0f2e27c 100644 --- a/src/store/modules/boxes/mutations.js +++ b/src/store/modules/boxes/mutations.js @@ -50,6 +50,7 @@ export default { }); } else if (existsBox && box.videos.length > 0) { existsBox.covers = box.covers || {}; + existsBox.share = box.share; existsBox.videos = box.videos; existsBox.videos.forEach((video) => { video.parent = existsBox; diff --git a/src/store/modules/boxes/state.js b/src/store/modules/boxes/state.js index c23a06d..21705b4 100644 --- a/src/store/modules/boxes/state.js +++ b/src/store/modules/boxes/state.js @@ -1,7 +1,7 @@ export default { collection: [], newest: [], - selectedBox: { videos: [], covers: {} }, + selectedBox: { videos: [], covers: {}, share: {} }, page: 1, loading: false, eos: false