finish share menu
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Artem Anufrij 2023-02-15 23:36:37 +01:00
parent daa2d339ce
commit 81b062ca0e
9 changed files with 92 additions and 64 deletions

View File

@ -1,5 +1,5 @@
{ {
"backend_de": "http://localhost:31204", "backend_dev": "http://localhost:31204",
"backend_dev": "https://webplay.rocks", "backend_de": "https://webplay.rocks",
"backend": "https://webplay.rocks" "backend": "https://webplay.rocks"
} }

View File

@ -37,9 +37,12 @@
}} }}
</button> </button>
<hr /> <hr />
<button @click="shareObject"> <button v-if="!selectedAlbum.share._id" @click="shareEnable">
<awesome-icon icon="share" />Share this album <awesome-icon icon="share" />Share this album
</button> </button>
<button v-else @click="shareDisable">
<awesome-icon icon="share" />Remove share
</button>
</div> </div>
</template> </template>
</DropDown> </DropDown>
@ -59,7 +62,6 @@
</span> </span>
</p> </p>
</div> </div>
<DropDown v-if="$store.getters['user/isAdministrator']"> <DropDown v-if="$store.getters['user/isAdministrator']">
<button class="flat center"> <button class="flat center">
<awesome-icon icon="ellipsis-v" /> <awesome-icon icon="ellipsis-v" />
@ -211,8 +213,11 @@ export default {
selectAlbum(album) { selectAlbum(album) {
this.$store.dispatch("albums/selectAlbum", album); this.$store.dispatch("albums/selectAlbum", album);
}, },
share() { shareEnable() {
this.$store.dispatch("albums/share", this.selectedAlbum); this.$store.dispatch("albums/shareEnable", this.selectedAlbum);
},
shareDisable() {
this.$store.dispatch("albums/shareDisable", this.selectedAlbum);
}, },
}, },
computed: { computed: {

View File

@ -21,8 +21,7 @@
:class="{ active: isFavourite }" :class="{ active: isFavourite }"
@click="toggleFavourite" @click="toggleFavourite"
/> />
<div id="stats" class="z1 pa4"> <div id="stats" class="flex-row z1">
<div class="flex-row">
<DropDown v-if="$store.getters['user/isAdministrator']"> <DropDown v-if="$store.getters['user/isAdministrator']">
<button class="flat center" :title="visibility_text"> <button class="flat center" :title="visibility_text">
<awesome-icon :icon="visibility_icon" /> <awesome-icon :icon="visibility_icon" />
@ -38,6 +37,13 @@
getVisibilityText(item) getVisibilityText(item)
}} }}
</button> </button>
<hr />
<button v-if="!selectedBox.share._id" @click="shareEnable">
<awesome-icon icon="share" />Share this box
</button>
<button v-else @click="shareDisable">
<awesome-icon icon="share" />Remove share
</button>
</div> </div>
</template> </template>
</DropDown> </DropDown>
@ -71,7 +77,6 @@
</DropDown> </DropDown>
</div> </div>
</div> </div>
</div>
<ul id="videoList" class="videos"> <ul id="videoList" class="videos">
<li v-for="item in selectedBox.videos" :key="item._id"> <li v-for="item in selectedBox.videos" :key="item._id">
@ -168,8 +173,11 @@ export default {
resetCover() { resetCover() {
this.$store.dispatch("boxes/resetCover", this.selectedBox); this.$store.dispatch("boxes/resetCover", this.selectedBox);
}, },
share() { shareEnable() {
this.$store.dispatch("boxes/share", this.selectedBox); this.$store.dispatch("boxes/shareEnable", this.selectedBox);
},
shareDisable() {
this.$store.dispatch("boxes/shareDisable", this.selectedBox);
}, },
}, },
computed: { computed: {

View File

@ -154,11 +154,14 @@ export default {
} }
axios.put(context.rootGetters.server + "/api/albums/" + album._id, body, context.rootGetters.headers); axios.put(context.rootGetters.server + "/api/albums/" + album._id, body, context.rootGetters.headers);
}, },
share(context, album) { shareEnable(context, album) {
return new Promise((resolve) => { axios.post(context.rootGetters.server + "/api/albums/" + album._id + "/share", {}, context.rootGetters.headers).then(res => {
axios.get(context.rootGetters.server + "/api/albums/" + album._id + "/share", context.rootGetters.headers).then(res => { album.share = res.data;
resolve(res.data); });
},
shareDisable(context, album) {
axios.delete(context.rootGetters.server + "/api/albums/" + album._id + "/share", context.rootGetters.headers).then(() => {
album.share = {};
}); });
})
} }
} }

View File

@ -59,6 +59,7 @@ export default {
} else if (existsAlbum && album.tracks.length > 0) { } else if (existsAlbum && album.tracks.length > 0) {
existsAlbum.covers = album.covers || {}; existsAlbum.covers = album.covers || {};
existsAlbum.share = album.share;
existsAlbum.tracks = album.tracks; existsAlbum.tracks = album.tracks;
existsAlbum.tracks.forEach((track) => { existsAlbum.tracks.forEach((track) => {
track.parent = existsAlbum; track.parent = existsAlbum;

View File

@ -1,7 +1,7 @@
export default { export default {
collection: [], collection: [],
newest: [], newest: [],
selectedAlbum: { tracks: [], covers: {} }, selectedAlbum: { tracks: [], covers: {}, share: {} },
page: 1, page: 1,
loading: false, loading: false,
eos: false eos: false

View File

@ -130,4 +130,14 @@ export default {
box.covers = {} 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 = {};
});
}
} }

View File

@ -50,6 +50,7 @@ export default {
}); });
} else if (existsBox && box.videos.length > 0) { } else if (existsBox && box.videos.length > 0) {
existsBox.covers = box.covers || {}; existsBox.covers = box.covers || {};
existsBox.share = box.share;
existsBox.videos = box.videos; existsBox.videos = box.videos;
existsBox.videos.forEach((video) => { existsBox.videos.forEach((video) => {
video.parent = existsBox; video.parent = existsBox;

View File

@ -1,7 +1,7 @@
export default { export default {
collection: [], collection: [],
newest: [], newest: [],
selectedBox: { videos: [], covers: {} }, selectedBox: { videos: [], covers: {}, share: {} },
page: 1, page: 1,
loading: false, loading: false,
eos: false eos: false