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,55 +21,60 @@
: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" /> </button>
</button> <template v-slot:dropdown-content>
<template v-slot:dropdown-content> <div>
<div> <button
<button v-for="(item, i) in $store.state.system.lists.visibility"
v-for="(item, i) in $store.state.system.lists.visibility" :key="i"
:key="i" @click="setVisibility(item)"
@click="setVisibility(item)" >
> <awesome-icon :icon="getVisibilityIcon(item)" />{{
<awesome-icon :icon="getVisibilityIcon(item)" />{{ getVisibilityText(item)
getVisibilityText(item) }}
}} </button>
</button> <hr />
</div> <button v-if="!selectedBox.share._id" @click="shareEnable">
</template> <awesome-icon icon="share" />Share this box
</DropDown> </button>
<div class="grow flex-column"> <button v-else @click="shareDisable">
<p class="ma4 center"> <awesome-icon icon="share" />Remove share
<span class=""> </button>
<b>{{ selectedBox.title }}</b> </div>
<br /> </template>
<b>{{ box_videos.length }}</b> Videos </DropDown>
</span> <div class="grow flex-column">
</p> <p class="ma4 center">
</div> <span class="">
<DropDown v-if="$store.getters['user/isAdministrator']"> <b>{{ selectedBox.title }}</b>
<button class="flat center"> <br />
<awesome-icon icon="ellipsis-v" /> <b>{{ box_videos.length }}</b> Videos
</button> </span>
<template v-slot:dropdown-content> </p>
<div>
<button @click="uploadNewCover">
<awesome-icon icon="image" />Set new Cover...
</button>
<button @click="resetCover">
<awesome-icon icon="eraser" />Reset Cover
</button>
<hr />
<button @click="mergeBox">
<awesome-icon icon="compress-alt" />Merge Boxes...
</button>
</div>
</template>
</DropDown>
</div> </div>
<DropDown v-if="$store.getters['user/isAdministrator']">
<button class="flat center">
<awesome-icon icon="ellipsis-v" />
</button>
<template v-slot:dropdown-content>
<div>
<button @click="uploadNewCover">
<awesome-icon icon="image" />Set new Cover...
</button>
<button @click="resetCover">
<awesome-icon icon="eraser" />Reset Cover
</button>
<hr />
<button @click="mergeBox">
<awesome-icon icon="compress-alt" />Merge Boxes...
</button>
</div>
</template>
</DropDown>
</div> </div>
</div> </div>
@ -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