move
This commit is contained in:
139
src/views/Albums.vue
Normal file
139
src/views/Albums.vue
Normal file
@@ -0,0 +1,139 @@
|
||||
<template>
|
||||
<div class="flex-column" style="max-height: 100%; height: 100%">
|
||||
<MessageScreen
|
||||
title="Still no Audio content"
|
||||
subtitle="You still don't have any Audio content on your instance"
|
||||
icon="music"
|
||||
:commands="messageCommands"
|
||||
@commandClicked="sync"
|
||||
:showCommands="$store.getters['user/isAdministrator']"
|
||||
v-if="albums.length == 0 && !loading"
|
||||
/>
|
||||
<AlbumViewer />
|
||||
<div ref="albums" id="albums" @scroll="loadNextPage" @resize="loadNextPage">
|
||||
<AlbumItem
|
||||
class="ma"
|
||||
v-for="album in albums"
|
||||
:key="album._id"
|
||||
:item="album"
|
||||
@click="openAlbum(album)"
|
||||
/>
|
||||
<div id="albumsLoadingControl" class="loadingItem" v-if="!eos">
|
||||
Loading next albums...
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import AlbumViewer from "../components/dialogs/AlbumViewer";
|
||||
|
||||
import { mapGetters } from "vuex";
|
||||
export default {
|
||||
name: "AlbumsView",
|
||||
data() {
|
||||
return {
|
||||
scrollPosition: 0,
|
||||
messageCommands: [
|
||||
{
|
||||
title: "Scan for Audio files",
|
||||
subtitle: "Scann your server for audio files…",
|
||||
icon: "sync",
|
||||
command: "scan",
|
||||
},
|
||||
],
|
||||
viewMenu: [
|
||||
{
|
||||
title: "Synchronize Music",
|
||||
icon: "sync-alt",
|
||||
roles: ["admin"],
|
||||
event: this.sync,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
if (this.$route.query.id) {
|
||||
this.$store.dispatch("albums/loadAlbum", this.$route.query.id);
|
||||
} else {
|
||||
this.loadNextPage(true);
|
||||
}
|
||||
this.$store.dispatch("setViewMenu", this.viewMenu);
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
albums: ["albums/collection"],
|
||||
loading: ["albums/loading"],
|
||||
eos: ["albums/eos"],
|
||||
}),
|
||||
},
|
||||
methods: {
|
||||
openAlbum(album) {
|
||||
this.$store.dispatch("albums/selectAlbum", album);
|
||||
},
|
||||
loadNextPage(force) {
|
||||
this.scrollPosition = this.$refs.albums.scrollTop;
|
||||
if ((!this.eos && this.isLoadingControlVisible()) || force === true) {
|
||||
this.$store.dispatch("albums/loadAlbums", force);
|
||||
}
|
||||
},
|
||||
isLoadingControlVisible() {
|
||||
let element = document.getElementById("albumsLoadingControl");
|
||||
if (!element) {
|
||||
return false;
|
||||
}
|
||||
let bounding = element.getBoundingClientRect();
|
||||
|
||||
let vVisible =
|
||||
bounding.top - 256 <=
|
||||
(window.innerHeight || document.documentElement.clientHeight) &&
|
||||
bounding.top > -256;
|
||||
return vVisible;
|
||||
},
|
||||
sync() {
|
||||
this.$store.dispatch("startScanningMusic");
|
||||
setTimeout(() => {
|
||||
this.loadNextPage(true);
|
||||
}, 3000);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
loading(newVal) {
|
||||
if (!newVal) {
|
||||
this.$nextTick(() => {
|
||||
this.loadNextPage();
|
||||
if (this.$store.getters["albums/selectedAlbum"]._id) {
|
||||
this.$store.dispatch("albums/preloads");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
"$route.path": function (newVal) {
|
||||
if (newVal == "/albums") {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.albums.scrollTop = this.scrollPosition;
|
||||
this.$store.dispatch("setViewMenu", this.viewMenu);
|
||||
if (!this.loading) {
|
||||
this.loadNextPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
"$route.query": function (newVal) {
|
||||
if (this.$route.path == "/albums") {
|
||||
if (newVal.id) {
|
||||
if (this.$store.getters["albums/selectedAlbum"]._id != newVal.id) {
|
||||
this.$store.dispatch("albums/selectAlbumById", newVal.id);
|
||||
}
|
||||
} else {
|
||||
this.$store.commit("albums/resetSelectedAlbum");
|
||||
}
|
||||
} else {
|
||||
this.$store.commit("albums/resetSelectedAlbum");
|
||||
}
|
||||
},
|
||||
},
|
||||
components: {
|
||||
AlbumViewer,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
149
src/views/Artists.vue
Normal file
149
src/views/Artists.vue
Normal file
@@ -0,0 +1,149 @@
|
||||
<template>
|
||||
<div class="flex-column" style="max-height: 100%; height: 100%">
|
||||
<MessageScreen
|
||||
title="Still no Audio content"
|
||||
subtitle="You still don't have any Audio content on your instance"
|
||||
icon="music"
|
||||
:commands="messageCommands"
|
||||
@commandClicked="sync"
|
||||
:showCommands="$store.getters['user/isAdministrator']"
|
||||
v-if="artists.length == 0 && !loading"
|
||||
/>
|
||||
<ArtistViewer />
|
||||
<div
|
||||
ref="artists"
|
||||
id="artists"
|
||||
@scroll="loadNextPage"
|
||||
@resize="loadNextPage"
|
||||
>
|
||||
<ArtistItem
|
||||
class="ma"
|
||||
v-for="artist in artists"
|
||||
:key="artist._id"
|
||||
:item="artist"
|
||||
@click="openArtist(artist)"
|
||||
/>
|
||||
<div
|
||||
id="artistsLoadingControl"
|
||||
class="loadingItem"
|
||||
@click="loadNextPage"
|
||||
v-if="!eos"
|
||||
>
|
||||
Loading next artists...
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import ArtistViewer from "../components/dialogs/ArtistViewer";
|
||||
|
||||
import { mapGetters } from "vuex";
|
||||
|
||||
export default {
|
||||
name: "ArtistsView",
|
||||
data() {
|
||||
return {
|
||||
scrollPosition: 0,
|
||||
messageCommands: [
|
||||
{
|
||||
title: "Scan for Audio files",
|
||||
subtitle: "Scann your server for audio files…",
|
||||
icon: "sync",
|
||||
command: "scan",
|
||||
},
|
||||
],
|
||||
viewMenu: [
|
||||
{
|
||||
title: "Synchronize Music",
|
||||
icon: "sync-alt",
|
||||
roles: ["admin"],
|
||||
event: this.sync,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
if (this.$route.query.id) {
|
||||
this.$store.dispatch("artists/loadArtist", this.$route.query.id);
|
||||
} else {
|
||||
this.loadNextPage(true);
|
||||
}
|
||||
this.$store.dispatch("setViewMenu", this.viewMenu);
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
artists: ["artists/collection"],
|
||||
loading: ["artists/loading"],
|
||||
eos: ["artists/eos"],
|
||||
}),
|
||||
},
|
||||
methods: {
|
||||
openArtist(artist) {
|
||||
this.$store.dispatch("artists/selectArtist", artist);
|
||||
},
|
||||
loadNextPage(force) {
|
||||
this.scrollPosition = this.$refs.artists.scrollTop;
|
||||
if ((!this.eos && this.isLoadingControlVisible()) || force === true) {
|
||||
this.$store.dispatch("artists/loadArtists", force);
|
||||
this.$store.dispatch("setViewMenu", this.viewMenu);
|
||||
}
|
||||
},
|
||||
isLoadingControlVisible() {
|
||||
let element = document.getElementById("artistsLoadingControl");
|
||||
if (!element) {
|
||||
return false;
|
||||
}
|
||||
let bounding = element.getBoundingClientRect();
|
||||
|
||||
let vVisible =
|
||||
bounding.top - 256 <=
|
||||
(window.innerHeight || document.documentElement.clientHeight) &&
|
||||
bounding.top > -256;
|
||||
return vVisible;
|
||||
},
|
||||
sync() {
|
||||
this.$store.dispatch("startScanningMusic");
|
||||
setTimeout(() => {
|
||||
this.loadNextPage(true);
|
||||
}, 3000);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
loading(newVal) {
|
||||
if (!newVal) {
|
||||
this.$nextTick(() => {
|
||||
this.loadNextPage();
|
||||
});
|
||||
}
|
||||
},
|
||||
"$route.path": function (newVal) {
|
||||
if (newVal == "/artists") {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.artists.scrollTop = this.scrollPosition;
|
||||
|
||||
this.$store.dispatch("setViewMenu", this.viewMenu);
|
||||
if (!this.loading) {
|
||||
this.loadNextPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
"$route.query": function (newVal) {
|
||||
if (this.$route.path == "/artists") {
|
||||
if (newVal.id) {
|
||||
if (this.$store.getters["artists/selectedArtist"]._id != newVal.id) {
|
||||
this.$store.dispatch("artists/selectArtistById", newVal.id);
|
||||
}
|
||||
} else {
|
||||
this.$store.commit("artists/resetSelectedArtist");
|
||||
}
|
||||
} else {
|
||||
this.$store.commit("artists/resetSelectedArtist");
|
||||
}
|
||||
},
|
||||
},
|
||||
components: {
|
||||
ArtistViewer,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
148
src/views/Boxes.vue
Normal file
148
src/views/Boxes.vue
Normal file
@@ -0,0 +1,148 @@
|
||||
<template>
|
||||
<div class="flex-column" style="max-height: 100%; height: 100%">
|
||||
<MessageScreen
|
||||
title="Still no Video content"
|
||||
subtitle="You still don't have any Video content on your instance"
|
||||
icon="video"
|
||||
:commands="messageCommands"
|
||||
@commandClicked="sync"
|
||||
:showCommands="$store.getters['user/isAdministrator']"
|
||||
v-if="boxes.length == 0 && !loading"
|
||||
/>
|
||||
<BoxViewer />
|
||||
<div ref="boxes" id="boxes" @scroll="loadNextPage" @resize="loadNextPage">
|
||||
<BoxItem
|
||||
class="ma"
|
||||
v-for="box in boxes"
|
||||
:key="box._id"
|
||||
:item="box"
|
||||
@click="openBox(box)"
|
||||
/>
|
||||
<div
|
||||
id="boxesLoadingControl"
|
||||
class="loadingItem"
|
||||
@click="loadNextPage"
|
||||
v-if="!eos"
|
||||
>
|
||||
Loading next Boxes...
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import BoxViewer from "../components/dialogs/BoxViewer";
|
||||
|
||||
import { mapGetters } from "vuex";
|
||||
|
||||
export default {
|
||||
name: "BoxesView",
|
||||
data() {
|
||||
return {
|
||||
scrollPosition: 0,
|
||||
messageCommands: [
|
||||
{
|
||||
title: "Scan for Video files",
|
||||
subtitle: "Scann your server for video files…",
|
||||
icon: "sync",
|
||||
command: "scan",
|
||||
},
|
||||
],
|
||||
viewMenu: [
|
||||
{
|
||||
title: "Synchronize Videos",
|
||||
icon: "sync-alt",
|
||||
roles: ["admin"],
|
||||
event: this.sync,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
if (this.$route.query.id) {
|
||||
this.$store.dispatch("boxes/loadBox", this.$route.query.id);
|
||||
} else {
|
||||
this.loadNextPage(true);
|
||||
}
|
||||
this.$store.dispatch("setViewMenu", this.viewMenu);
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
boxes: ["boxes/collection"],
|
||||
loading: ["boxes/loading"],
|
||||
eos: ["boxes/eos"],
|
||||
}),
|
||||
},
|
||||
methods: {
|
||||
openBox(box) {
|
||||
this.$store.dispatch("boxes/selectBox", box);
|
||||
},
|
||||
loadNextPage(force) {
|
||||
this.scrollPosition = this.$refs.boxes.scrollTop;
|
||||
if ((!this.eos && this.isLoadingControlVisible()) || force === true) {
|
||||
this.$store.dispatch("boxes/loadBoxes", force);
|
||||
}
|
||||
},
|
||||
isLoadingControlVisible() {
|
||||
let element = document.getElementById("boxesLoadingControl");
|
||||
if (!element) {
|
||||
return false;
|
||||
}
|
||||
let bounding = element.getBoundingClientRect();
|
||||
|
||||
let vVisible =
|
||||
bounding.top - 256 <=
|
||||
(window.innerHeight || document.documentElement.clientHeight) &&
|
||||
bounding.top > -256;
|
||||
return vVisible;
|
||||
},
|
||||
sync() {
|
||||
this.$store.dispatch("startScanningVideos");
|
||||
setTimeout(() => {
|
||||
this.loadNextPage(true);
|
||||
}, 3000);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
loading(newVal) {
|
||||
if (!newVal) {
|
||||
this.$nextTick(() => {
|
||||
this.loadNextPage();
|
||||
if (this.$store.getters["boxes/selectedBox"]._id) {
|
||||
this.$store.dispatch("boxes/preload");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
"$route.path": function (newVal) {
|
||||
if (newVal == "/boxes") {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.boxes.scrollTop = this.scrollPosition;
|
||||
this.$store.dispatch("setViewMenu", this.viewMenu);
|
||||
if (!this.loading) {
|
||||
this.loadNextPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
"$route.query": function (newVal) {
|
||||
if (this.$route.path == "/boxes") {
|
||||
if (newVal.id) {
|
||||
if (this.$store.getters["boxes/selectedBox"]._id != newVal.id) {
|
||||
this.$store.dispatch("boxes/selectBoxById", newVal.id);
|
||||
}
|
||||
} else {
|
||||
this.$store.commit("boxes/resetSelectedBox");
|
||||
}
|
||||
if (!newVal.play) {
|
||||
this.$store.dispatch("videos/resetSelectedVideo");
|
||||
}
|
||||
} else {
|
||||
this.$store.commit("boxes/resetSelectedBox");
|
||||
}
|
||||
},
|
||||
},
|
||||
components: {
|
||||
BoxViewer,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
59
src/views/Favourites.vue
Normal file
59
src/views/Favourites.vue
Normal file
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<div class="flex-column" style="max-height: 100%; height: 100%">
|
||||
<div id="favourites">
|
||||
<h2 class="ma-left ma-top ma4-bottom" v-if="albums.length > 0">Albums</h2>
|
||||
<div id="albums" class="flex-row">
|
||||
<AlbumItem
|
||||
class="ma"
|
||||
v-for="album in albums"
|
||||
:key="album._id"
|
||||
:item="album"
|
||||
/>
|
||||
</div>
|
||||
<h2 class="ma-left ma-top ma4-bottom ma-right" v-if="artists.length > 0">
|
||||
<hr class="ma-bottom" v-if="albums.length > 0" />
|
||||
Artists
|
||||
</h2>
|
||||
<div id="artists" class="flex-row">
|
||||
<ArtistItem
|
||||
class="ma"
|
||||
v-for="artist in artists"
|
||||
:key="artist._id"
|
||||
:item="artist"
|
||||
/>
|
||||
</div>
|
||||
<h2 class="ma-left ma-top ma4-bottom ma-right" v-if="boxes.length > 0">
|
||||
<hr class="ma-bottom" v-if="albums.length > 0 || artists.length > 0" />
|
||||
Videos
|
||||
</h2>
|
||||
<div id="boxes" class="flex-row">
|
||||
<BoxItem class="ma" v-for="box in boxes" :key="box._id" :item="box" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { mapGetters } from "vuex";
|
||||
|
||||
export default {
|
||||
name: "FavouritesView",
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch("albums/loadFavourites");
|
||||
this.$store.dispatch("artists/loadFavourites");
|
||||
this.$store.dispatch("boxes/loadFavourites");
|
||||
},
|
||||
methods: {},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
albums: ["albums/favourites"],
|
||||
artists: ["artists/favourites"],
|
||||
boxes: ["boxes/favourites"],
|
||||
}),
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
</style>
|
||||
224
src/views/Home.vue
Normal file
224
src/views/Home.vue
Normal file
@@ -0,0 +1,224 @@
|
||||
<template>
|
||||
<div id="welcome" ref="welcome" @scroll="loadNextPage">
|
||||
<div id="welcomeLeft" class="flex-column grow">
|
||||
<div id="banner" class="center flex-column shadow">
|
||||
<h1>WebPlay</h1>
|
||||
<p>
|
||||
<b>{{ serverInfo.stats.tracks.toLocaleString("de-DE") }}</b> Tracks
|
||||
and
|
||||
<b>{{ serverInfo.stats.videos.toLocaleString("de-DE") }}</b> Videos |
|
||||
Users:
|
||||
<b>{{ serverInfo.stats.users }}</b>
|
||||
</p>
|
||||
</div>
|
||||
<MessageScreen
|
||||
title="First Run?"
|
||||
subtitle="You still don't have any Music or Video content on your instance"
|
||||
icon="sync"
|
||||
:commands="messageCommands"
|
||||
@commandClicked="messageCommand"
|
||||
:showCommands="$store.getters['user/isAdministrator']"
|
||||
v-if="serverInfo.stats.tracks == 0 && serverInfo.stats.videos == 0"
|
||||
/>
|
||||
<MessageScreen
|
||||
v-else-if="mostListened.length == 0 && mostViewed.length == 0"
|
||||
title="Still no history or trends"
|
||||
subtitle="Still no history or trends on this instance"
|
||||
icon="info"
|
||||
/>
|
||||
<template v-else>
|
||||
<h2 class="ma-left ma-top pa-top ma4-bottom" v-if="history.length > 0">
|
||||
Last played
|
||||
</h2>
|
||||
<template v-if="history.length > 0">
|
||||
<div id="history" :class="{ more: historyAll == true }">
|
||||
<template v-for="item in history">
|
||||
<AlbumItem
|
||||
class="ma8"
|
||||
v-if="item.type == 'album'"
|
||||
:item="item"
|
||||
:key="item._id"
|
||||
/>
|
||||
<ArtistItem
|
||||
class="ma8"
|
||||
v-if="item.type == 'artist'"
|
||||
:item="item"
|
||||
:key="item._id"
|
||||
/>
|
||||
<BoxItem
|
||||
class="ma8"
|
||||
v-if="item.type == 'box'"
|
||||
:item="item"
|
||||
:key="item._id"
|
||||
/>
|
||||
<RadioItem
|
||||
class="ma8"
|
||||
v-if="item.type == 'radio'"
|
||||
:item="item"
|
||||
:key="item._id"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<span class="pa-top pa-right right" @click="toggleHistory">
|
||||
<awesome-icon
|
||||
:icon="historyAll ? 'arrow-up' : 'arrow-down'"
|
||||
class="pa8-right"
|
||||
/>{{ historyToggleText }}</span
|
||||
>
|
||||
</template>
|
||||
<div id="mostUsed" class="flex-row ma">
|
||||
<div id="mostListened" class="grow" v-if="mostListened.length > 0">
|
||||
<h2 class="ma-top pa-top ma4-bottom">Most listened</h2>
|
||||
<div class="flex-column">
|
||||
<TrackItem
|
||||
v-for="(item, i) in mostListened"
|
||||
:track="item"
|
||||
:key="i"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mostViewed" class="grow" v-if="mostViewed.length > 0">
|
||||
<h2 class="ma-top pa-top ma4-bottom">Most viewed</h2>
|
||||
<div id="mostViewedVideos" class="flex-row">
|
||||
<VideoItem
|
||||
v-for="(item, i) in mostViewed"
|
||||
:video="item"
|
||||
:key="i"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div
|
||||
v-if="newestAlbums.length > 0 || newestBoxes.length > 0"
|
||||
id="newest"
|
||||
class="pa-left pa-right"
|
||||
>
|
||||
<template v-if="newestAlbums.length > 0">
|
||||
<h3>Newest Music</h3>
|
||||
<div id="newestMusic" class="flex-column pa-bottom">
|
||||
<AlbumItem
|
||||
class="ma8"
|
||||
v-for="item in newestAlbums"
|
||||
type="line"
|
||||
:item="item"
|
||||
:key="item._id"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="newestBoxes.length > 0">
|
||||
<h3>Newest Videos</h3>
|
||||
<div id="newestVideos" class="flex-row">
|
||||
<BoxItem
|
||||
class="ma8 small"
|
||||
v-for="item in newestBoxes"
|
||||
:item="item"
|
||||
:key="item._id"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import RadioItem from "../components/Radio";
|
||||
import TrackItem from "../components/Track";
|
||||
import VideoItem from "../components/Video";
|
||||
import { mapGetters } from "vuex";
|
||||
|
||||
export default {
|
||||
name: "HomeView",
|
||||
data() {
|
||||
return {
|
||||
scrollPosition: 0,
|
||||
historyAll: false,
|
||||
messageCommands: [
|
||||
{
|
||||
title: "Scan for Music files",
|
||||
subtitle: "Scann your server for music files…",
|
||||
icon: "music",
|
||||
command: "scanMusic",
|
||||
},
|
||||
{
|
||||
title: "Scan for Video files",
|
||||
subtitle: "Scann your server for video files…",
|
||||
icon: "video",
|
||||
command: "scanVideos",
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.loadItems();
|
||||
},
|
||||
methods: {
|
||||
loadItems() {
|
||||
this.$refs.welcome.scrollTop = this.scrollPosition;
|
||||
this.$store.dispatch("albums/loadNewest");
|
||||
this.$store.dispatch("boxes/loadNewest");
|
||||
this.$store.dispatch("tracks/loadMostListened");
|
||||
this.$store.dispatch("videos/loadMostViewed");
|
||||
},
|
||||
loadNextPage() {
|
||||
this.scrollPosition = this.$refs.welcome.scrollTop;
|
||||
},
|
||||
messageCommand(req) {
|
||||
switch (req.command) {
|
||||
case "scanMusic":
|
||||
this.$store.dispatch("startScanningMusic");
|
||||
setTimeout(() => {
|
||||
this.$store.dispatch("albums/loadAlbums", true);
|
||||
this.$router.push("/albums");
|
||||
}, 3000);
|
||||
break;
|
||||
case "scanVideos":
|
||||
this.$store.dispatch("startScanningVideos");
|
||||
setTimeout(() => {
|
||||
this.$store.dispatch("boxes/loadBoxes", true);
|
||||
this.$router.push("/boxes");
|
||||
}, 3000);
|
||||
break;
|
||||
}
|
||||
},
|
||||
toggleHistory() {
|
||||
this.historyAll = !this.historyAll;
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
history: "user/history",
|
||||
newestAlbums: "albums/newest",
|
||||
newestBoxes: "boxes/newest",
|
||||
serverInfo: "serverInfo",
|
||||
mostListened: "tracks/mostListened",
|
||||
mostViewed: "videos/mostViewed",
|
||||
}),
|
||||
historyToggleText() {
|
||||
return this.historyAll ? "less..." : "more...";
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
"$route.path": function (newVal) {
|
||||
if (newVal == "/") {
|
||||
this.$store.dispatch("resetViewMenu", this.viewMenu);
|
||||
this.$nextTick(() => {
|
||||
this.loadItems();
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
components: {
|
||||
RadioItem,
|
||||
TrackItem,
|
||||
VideoItem,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
#history.more {
|
||||
max-height: initial;
|
||||
}
|
||||
</style>
|
||||
222
src/views/Login.vue
Normal file
222
src/views/Login.vue
Normal file
@@ -0,0 +1,222 @@
|
||||
<template>
|
||||
<div id="login">
|
||||
<div id="loginViewer">
|
||||
<div id="loginLogin" class="flex-column">
|
||||
<img id="loginLogo" src="static/icon_64_flat.svg" />
|
||||
<h1>Web Play</h1>
|
||||
<form id="loginForm" @submit.prevent="login" method="POST">
|
||||
<p>
|
||||
<input
|
||||
ref="username"
|
||||
name="username"
|
||||
type="text"
|
||||
placeholder="username"
|
||||
id="username"
|
||||
/>
|
||||
</p>
|
||||
<p>
|
||||
<input
|
||||
ref="password"
|
||||
name="password"
|
||||
type="password"
|
||||
placeholder="password"
|
||||
id="password"
|
||||
/>
|
||||
</p>
|
||||
<ExpanderControl
|
||||
title="Server configuration"
|
||||
v-if="$store.getters.isElectron"
|
||||
>
|
||||
<p>
|
||||
<input
|
||||
ref="backend"
|
||||
name="backend"
|
||||
type="url"
|
||||
placeholder="backend"
|
||||
id="backend"
|
||||
v-model.lazy="server"
|
||||
@change="backendChanged"
|
||||
/>
|
||||
</p>
|
||||
</ExpanderControl>
|
||||
<button class="flat gray-border" action="submit">Login</button>
|
||||
</form>
|
||||
<p>{{ message }}</p>
|
||||
</div>
|
||||
<div
|
||||
id="loginContinue"
|
||||
class="flex-column"
|
||||
v-if="allow_guests || allow_registration"
|
||||
>
|
||||
<div id="loginGuest" class="flex-column" v-if="allow_guests">
|
||||
<button @click="continueAsGuest">
|
||||
<awesome-icon icon="music" class="ma" /><span class="ma4"
|
||||
>Continue as Guest</span
|
||||
>
|
||||
</button>
|
||||
</div>
|
||||
<p class="center ma pa-top" v-if="allow_guests && allow_registration">
|
||||
or
|
||||
</p>
|
||||
<div
|
||||
id="loginRegestration"
|
||||
class="flex-column ma-right ma-left"
|
||||
v-if="allow_registration"
|
||||
>
|
||||
<ExpanderControl title="Register now" class="ma-right ma-left">
|
||||
<form autocomplete="off" method="POST">
|
||||
<p>
|
||||
<input
|
||||
type="email"
|
||||
placeholder="Email adress"
|
||||
v-model="newUserAcc.email"
|
||||
autocomplete="one-time-code"
|
||||
/>
|
||||
</p>
|
||||
<p>
|
||||
<input
|
||||
type="text"
|
||||
v-model="newUserAcc.name"
|
||||
placeholder="Account"
|
||||
autocomplete="one-time-code"
|
||||
/>
|
||||
</p>
|
||||
<p>
|
||||
<input
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
v-model="newUserAcc.pass"
|
||||
autocomplete="one-time-code"
|
||||
pattern=".{5,}"
|
||||
/>
|
||||
</p>
|
||||
<button class="flat gray-border" action="submit">Register</button>
|
||||
</form>
|
||||
</ExpanderControl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ExpanderControl from "../components/base-components/Expander";
|
||||
|
||||
export default {
|
||||
name: "LoginView",
|
||||
data() {
|
||||
return {
|
||||
message: "",
|
||||
finished_checks: false,
|
||||
newUserAcc: { name: "", email: "", pass: "" },
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.username.focus();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
checkTocken() {
|
||||
let token = localStorage.getItem("token");
|
||||
if (token) {
|
||||
this.$store.dispatch("user/setToken", token);
|
||||
this.$store
|
||||
.dispatch("user/load")
|
||||
.then(() => {
|
||||
this.goto();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
this.checkIfNewBackend();
|
||||
});
|
||||
} else {
|
||||
this.checkIfNewBackend();
|
||||
}
|
||||
},
|
||||
login() {
|
||||
this.$store
|
||||
.dispatch("user/login", {
|
||||
username: this.$refs.username.value,
|
||||
password: this.$refs.password.value,
|
||||
})
|
||||
.then(() => {
|
||||
this.goto();
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err.status == 401) {
|
||||
this.message = "Login failed…";
|
||||
} else {
|
||||
this.message = "Server error…";
|
||||
}
|
||||
this.$refs.password.focus();
|
||||
this.$refs.password.select();
|
||||
});
|
||||
},
|
||||
checkIfNewBackend() {
|
||||
this.$store.dispatch("checkIfInstanceIsNew").then((res) => {
|
||||
if (res) {
|
||||
this.$router.replace("setup");
|
||||
} else if (this.$route.query.redirect) {
|
||||
this.continueAsGuest();
|
||||
}
|
||||
this.finished_checks = true;
|
||||
});
|
||||
},
|
||||
continueAsGuest() {
|
||||
if (this.allow_guests) {
|
||||
this.$store.dispatch("user/useGuestAccount").then(() => {
|
||||
this.goto();
|
||||
});
|
||||
}
|
||||
},
|
||||
goto() {
|
||||
if (this.$route.query.redirect) {
|
||||
let redirect = decodeURIComponent(this.$route.query.redirect);
|
||||
let route = redirect.split("?");
|
||||
if (route[1]) {
|
||||
let urlParams = new URLSearchParams(route[1]);
|
||||
let params = Object.fromEntries(urlParams);
|
||||
this.$router.replace({ path: route[0], query: params });
|
||||
} else {
|
||||
this.$router.replace(route[0]);
|
||||
}
|
||||
} else {
|
||||
this.$router.replace("/");
|
||||
}
|
||||
},
|
||||
backendChanged() {
|
||||
this.$store.dispatch("setNewBackend", this.$refs.backend.value);
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
server() {
|
||||
return this.$store.getters.server;
|
||||
},
|
||||
allow_guests() {
|
||||
return this.$store.state.serverConfig.allows.guests;
|
||||
},
|
||||
allow_registration() {
|
||||
return this.$store.state.serverConfig.allows.register;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
server() {
|
||||
this.checkTocken();
|
||||
},
|
||||
allow_guests(newVal) {
|
||||
if (newVal && this.finished_checks && this.$route.query.redirect) {
|
||||
this.continueAsGuest();
|
||||
}
|
||||
},
|
||||
"$route.path": function (newVal) {
|
||||
if (newVal == "/artists") {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.username.focus();
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
components: { ExpanderControl },
|
||||
};
|
||||
</script>
|
||||
77
src/views/Radios.vue
Normal file
77
src/views/Radios.vue
Normal file
@@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<div ref="radios" id="radios" @scroll="loadNextPage">
|
||||
<RadioItem v-for="(radio, i) in radios" :key="i" :item="radio" />
|
||||
<MessageScreen
|
||||
v-if="radios.length == 0"
|
||||
title="No Radios"
|
||||
subtitle="Import some Online Radios into your Library"
|
||||
icon="podcast"
|
||||
:commands="messageCommands"
|
||||
@commandClicked="addRadio"
|
||||
:showCommands="$store.getters['user/isAdministrator']"
|
||||
/>
|
||||
<RadiosEditor ref="radiosEditor" />
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import RadioItem from "../components/Radio";
|
||||
import RadiosEditor from "../components/dialogs/Radios";
|
||||
import { mapGetters } from "vuex";
|
||||
|
||||
export default {
|
||||
name: "RadiosView",
|
||||
data() {
|
||||
return {
|
||||
scrollPosition: 0,
|
||||
messageCommands: [
|
||||
{
|
||||
title: "Add Online Radio",
|
||||
subtitle: "Add an url into your Library…",
|
||||
icon: "plus",
|
||||
},
|
||||
],
|
||||
viewMenu: [
|
||||
{
|
||||
title: "Manage Radio Stations",
|
||||
icon: "podcast",
|
||||
roles: ["moderator", "admin"],
|
||||
event: this.addRadio,
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch("radios/loadRadios");
|
||||
this.$store.dispatch("setViewMenu", this.viewMenu);
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({ radios: "radios/collection" }),
|
||||
},
|
||||
methods: {
|
||||
loadNextPage() {
|
||||
this.scrollPosition = this.$refs.radios.scrollTop;
|
||||
this.$store.dispatch("radios/loadRadios");
|
||||
},
|
||||
addRadio() {
|
||||
this.$refs.radiosEditor.open();
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
"$route.path": function (newVal) {
|
||||
if (newVal == "/radios") {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.radios.scrollTop = this.scrollPosition;
|
||||
this.$store.dispatch("setViewMenu", this.viewMenu);
|
||||
if (!this.loading) {
|
||||
this.loadNextPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
components: {
|
||||
RadioItem,
|
||||
RadiosEditor,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
99
src/views/Search.vue
Normal file
99
src/views/Search.vue
Normal file
@@ -0,0 +1,99 @@
|
||||
<template>
|
||||
<div
|
||||
ref="search"
|
||||
id="search"
|
||||
@scroll="checkCoverVisibility"
|
||||
@resize="checkCoverVisibility"
|
||||
>
|
||||
<template v-for="item in collection">
|
||||
<AlbumItem
|
||||
class="ma"
|
||||
v-if="item.type == 'album'"
|
||||
:item="item"
|
||||
:key="item._id"
|
||||
/>
|
||||
<ArtistItem
|
||||
class="ma"
|
||||
v-if="item.type == 'artist'"
|
||||
:item="item"
|
||||
:key="item._id"
|
||||
/>
|
||||
<BoxItem
|
||||
class="ma"
|
||||
v-if="item.type == 'box'"
|
||||
:item="item"
|
||||
:key="item._id"
|
||||
/>
|
||||
<RadioItem
|
||||
class="ma"
|
||||
v-if="item.type == 'radio'"
|
||||
:item="item"
|
||||
:key="item._id"
|
||||
/>
|
||||
<TrackItem v-if="item.type == 'track'" :track="item" :key="item._id" />
|
||||
<VideoItem v-if="item.type == 'video'" :video="item" :key="item._id" />
|
||||
</template>
|
||||
<MessageScreen
|
||||
v-if="collection.length == 0"
|
||||
title="No Results"
|
||||
subtitle="Try an other search term…"
|
||||
icon="search"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import TrackItem from "../components/Track";
|
||||
import VideoItem from "../components/Video";
|
||||
import RadioItem from "../components/Radio";
|
||||
import { mapGetters } from "vuex";
|
||||
|
||||
export default {
|
||||
name: "SearchView",
|
||||
data() {
|
||||
return {
|
||||
scrollPosition: 0,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
if (this.$route.query.q) {
|
||||
this.$store.commit("search/setTerm", this.$route.query.q);
|
||||
}
|
||||
this.$store.dispatch("setViewMenu", this.viewMenu);
|
||||
},
|
||||
methods: {
|
||||
checkCoverVisibility() {
|
||||
this.scrollPosition = this.$refs.search.scrollTop;
|
||||
},
|
||||
searchRequest(q) {
|
||||
this.$store.dispatch("search/search", q);
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
term: "search/term",
|
||||
collection: "search/collection",
|
||||
search: "search/collection",
|
||||
}),
|
||||
},
|
||||
watch: {
|
||||
"$route.path": function (newVal) {
|
||||
if (newVal == "/search") {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.search.scrollTop = this.scrollPosition;
|
||||
this.$store.dispatch("setViewMenu", this.viewMenu);
|
||||
});
|
||||
}
|
||||
},
|
||||
term(newVal) {
|
||||
if (newVal && newVal != "") {
|
||||
this.searchRequest(newVal);
|
||||
}
|
||||
},
|
||||
},
|
||||
components: {
|
||||
VideoItem,
|
||||
RadioItem,
|
||||
TrackItem,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
88
src/views/Setup.vue
Normal file
88
src/views/Setup.vue
Normal file
@@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<div id="setup">
|
||||
<img id="loginLogo" src="static/icon_64_flat.svg" />
|
||||
<h1>WebPlay Setup</h1>
|
||||
<form id="setupForm" @submit.prevent="setup" method="POST">
|
||||
<p>
|
||||
<input
|
||||
ref="username"
|
||||
name="username"
|
||||
type="text"
|
||||
placeholder="username"
|
||||
id="username"
|
||||
/>
|
||||
</p>
|
||||
<p>
|
||||
<input
|
||||
ref="password"
|
||||
name="password"
|
||||
type="password"
|
||||
placeholder="password"
|
||||
id="password"
|
||||
/>
|
||||
</p>
|
||||
<p v-if="$store.getters.isElectron">
|
||||
<input
|
||||
ref="backend"
|
||||
name="backend"
|
||||
type="url"
|
||||
placeholder="backend"
|
||||
id="backend"
|
||||
v-model.lazy="server"
|
||||
@change="backendChanged"
|
||||
/>
|
||||
</p>
|
||||
<button class="flat" action="submit">Create admin account</button>
|
||||
</form>
|
||||
<p>{{ message }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "SetupView",
|
||||
data() {
|
||||
return {
|
||||
message: "",
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
if (this.server != "none") {
|
||||
this.checkIfNewBackend();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setup() {
|
||||
let user = {
|
||||
username: this.$refs.username.value,
|
||||
password: this.$refs.password.value,
|
||||
};
|
||||
this.$store.dispatch("system/createInstanceAccess", user);
|
||||
},
|
||||
checkIfNewBackend() {
|
||||
this.$store.dispatch("checkIfInstanceIsNew").then((res) => {
|
||||
if (!res) {
|
||||
this.$router.replace("login");
|
||||
}
|
||||
});
|
||||
},
|
||||
backendChanged() {
|
||||
this.$http
|
||||
.post("/settings", { backend: this.$refs.backend.value })
|
||||
.then(() => {
|
||||
this.$store.state.server = this.$refs.backend.value;
|
||||
});
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
server() {
|
||||
return this.$store.getters.server;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
server() {
|
||||
this.checkIfNewBackend();
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
64
src/views/Users.vue
Normal file
64
src/views/Users.vue
Normal file
@@ -0,0 +1,64 @@
|
||||
<template>
|
||||
<div class="flex-row pa">
|
||||
<div class="flex-column">
|
||||
<img id="profile" src="/static/icons/dummy/artist.svg" alt="" />
|
||||
<h2>{{ me.name }}</h2>
|
||||
<input type="text" class="h1 borderless" v-model="me.fullname" />
|
||||
|
||||
<h3>Prefered Language</h3>
|
||||
<select v-model="$store.getters['user/settings'].video_lang">
|
||||
<option
|
||||
v-for="(item, i) in this.$store.state.system.lists.video_lang"
|
||||
:key="i"
|
||||
>
|
||||
{{ item }}
|
||||
</option>
|
||||
</select>
|
||||
<h3>Video quality</h3>
|
||||
<select v-model="$store.getters['user/settings'].video_quality">
|
||||
<option
|
||||
v-for="(item, i) in this.$store.state.system.lists.video_quality"
|
||||
:key="i"
|
||||
>
|
||||
{{ item }}
|
||||
</option>
|
||||
</select>
|
||||
<h3>Audio quality [kBin/s]</h3>
|
||||
<select v-model="$store.getters['user/settings'].desktop_bpm">
|
||||
<option
|
||||
v-for="(item, i) in this.$store.state.system.lists.audio_quality"
|
||||
:key="i"
|
||||
>
|
||||
{{ item }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex-column">
|
||||
<h3>My Music</h3>
|
||||
<div class="albums"></div>
|
||||
<h3>My Videos</h3>
|
||||
<div class="boxes"></div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "UsersView",
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
me() {
|
||||
return this.$store.state.user;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
img#profile {
|
||||
width: 512px;
|
||||
max-width: 100%;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user