Initial commit

This commit is contained in:
Thomas Amland
2020-03-01 20:08:02 +01:00
commit b4623926a2
59 changed files with 11280 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>
+66
View File
@@ -0,0 +1,66 @@
<template>
<div>
<div class="min-vh-100 d-flex align-items-stretch justify-spcace-between">
<div class="sidebar elevated d-none d-md-block" :class="{'d-block':showMenu}">
<SideNav></SideNav>
</div>
<div class="main flex-fill">
<div class="container-fluid pt-3 pb-3">
<TopNav/>
<router-view></router-view>
</div>
</div>
</div>
<footer class="footer elevated">
<Player />
</footer>
</div>
</template>
<style lang="scss" >
.sidebar {
// position: sticky;
// top: 0;
// height: calc(100vh - 80px);
// width: 200px;
// min-width: 200px;
// max-width: 200px;
// text-overflow: ellipsis;
.nav-link {
width: 220px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.main {
margin-bottom: 80px;
}
.sidebar {
padding-bottom: 180px;
}
.footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 80px;
}
</style>
<script lang="ts">
import SideNav from "./SideNav.vue";
import TopNav from "./TopNav.vue";
import Player from "@/player/Player.vue";
import { mapState, mapMutations } from 'vuex';
export default {
components: {
SideNav,
TopNav,
Player,
},
computed: {
...mapState(['showMenu'])
},
};
</script>
+76
View File
@@ -0,0 +1,76 @@
<template>
<div class="text-truncate">
<nav class="nav flex-column">
<router-link class="nav-link" :to="{name: 'home'}">
<img src="@/app/logo.png" class="img-fluid">
</router-link>
<router-link class="nav-link" :to="{name: 'home'}">
<Icon>mdi-home</Icon> Home
</router-link>
<router-link class="nav-link" :to="{name: 'queue'}">
<Icon>mdi-view-list</Icon> Playing
</router-link>
<router-link class="nav-link" :to="{name: 'starred'}">
<Icon>mdi-star</Icon> Starred
</router-link>
<a class="nav-link disabled">
<small class="text-uppercase text-muted font-weight-bold">
Library
</small>
</a>
<router-link class="nav-link" :to="{name: 'albums'}">
<Icon>mdi-album</Icon> Albums
</router-link>
<router-link class="nav-link" :to="{name: 'artists'}">
<Icon>mdi-artist</Icon> Artists
</router-link>
<router-link class="nav-item nav-link" :to="{name: 'genres'}">
<Icon>mdi-library-music</Icon> Genres
</router-link>
<PlaylistNav/>
<!--
<router-link class="nav-item nav-link" :to="{name: 'radio'}">
<Icon>mdi-radio</Icon> Radio
</router-link>
<router-link class="nav-item nav-link" :to="{name: 'settings'}">
<Icon>mdi-settings</Icon>Settings
</router-link> -->
<!-- <a href="#" class="nav-item nav-link" @click.prevent="logout">
<Icon>mdi-</Icon> Logout
</a> -->
</nav>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import PlaylistNav from "@/playlist/PlaylistNav.vue";
import { mapState } from 'vuex';
export default Vue.extend({
components: {
PlaylistNav,
},
props: {
show: Boolean
},
methods: {
logout() {
this.$auth.logout();
this.$router.go(0);
},
}
});
</script>
+42
View File
@@ -0,0 +1,42 @@
<template>
<div class="d-flex align-items-center mb-2">
<button class="navbar-toggler text-white d-md-none" @click="toggleMenu">
<Icon>mdi-menu</Icon>
</button>
<div class="ml-auto"></div>
<SearchForm/>
<template v-if="username">
<b-dropdown variant="link" right :text="username">
<b-dropdown-item-button @click="logout">
<Icon>mdi-logout</Icon> Logout
</b-dropdown-item-button>
</b-dropdown>
</template>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import { mapMutations, mapState } from 'vuex';
import SearchForm from '@/search/SearchForm.vue';
export default Vue.extend({
components: {
SearchForm,
},
computed: {
...mapState(["username"])
},
methods: {
...mapMutations([
'toggleMenu',
]),
logout() {
this.$auth.logout();
this.$router.go(0);
}
}
});
</script>
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

+1
View File
@@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 87.5 100"><defs><style>.cls-1{fill:#1697f6;}.cls-2{fill:#7bc6ff;}.cls-3{fill:#1867c0;}.cls-4{fill:#aeddff;}</style></defs><title>Artboard 46</title><polyline class="cls-1" points="43.75 0 23.31 0 43.75 48.32"/><polygon class="cls-2" points="43.75 62.5 43.75 100 0 14.58 22.92 14.58 43.75 62.5"/><polyline class="cls-3" points="43.75 0 64.19 0 43.75 48.32"/><polygon class="cls-4" points="64.58 14.58 87.5 14.58 43.75 100 43.75 62.5 64.58 14.58"/></svg>

After

Width:  |  Height:  |  Size: 539 B

+78
View File
@@ -0,0 +1,78 @@
<template>
<div>
<b-modal title="Login" hide-footer no-close-on-esc :visible="showModal">
<form @submit.prevent="login">
<fieldset :disabled="busy">
<b-form-group label="Server">
<b-form-input name="server" type="text" v-model="server" required></b-form-input>
</b-form-group>
<b-form-group label="Username">
<b-form-input name="username" type="text" v-model="username" required></b-form-input>
</b-form-group>
<b-form-group label="Password">
<b-form-input name="password" type="password" v-model="password" required></b-form-input>
</b-form-group>
<b-form-group>
<b-form-checkbox v-model="rememberLogin">Remember</b-form-checkbox>
</b-form-group>
<b-alert :show="!!error" variant="danger">
Login failed.
</b-alert>
<button class="btn btn-primary" @click="login">
<b-spinner v-show="busy" small type="grow"/>
Login
</button>
</fieldset>
</form>
</b-modal>
</div>
</template>>
<script lang="ts">
import Vue from "vue";
import { mapMutations, mapState } from "vuex";
export default Vue.extend({
props: {
returnTo: { type: String, required: true },
},
data() {
return {
server: "",
username: "",
password: "",
rememberLogin: false,
busy: false,
error: false,
showModal: false,
};
},
async created() {
this.server = await this.$auth.server;
this.username = await this.$auth.username;
this.password = await this.$auth.password;
const success = await this.$auth.autoLogin();
if (success) {
this.$store.commit("setLoginSuccess", { username: this.username});
this.$router.push(this.returnTo);
} else {
this.showModal = true;
}
},
methods: {
login() {
this.busy = true;
this.$auth.login(this.server, this.username, this.password, this.rememberLogin)
.then(() => {
this.$store.commit("setLoginSuccess", { username: this.username });
this.$router.push(this.returnTo);
})
.catch(err => {
this.error = true;
})
.finally(() => {
this.busy = false;
});
}
}
});
</script>
+58
View File
@@ -0,0 +1,58 @@
import axios from 'axios';
export class AuthService {
public server: string = "";
public username: string = "";
public password: string = "";
private authenticated: boolean = false;
constructor() {
this.server = localStorage.getItem("server") || "";
this.username = localStorage.getItem("username") || "";
this.password = localStorage.getItem("password") || "";
}
private saveSession() {
localStorage.setItem("server", this.server);
localStorage.setItem("username", this.username);
localStorage.setItem("password", this.password);
}
async autoLogin(): Promise<boolean> {
if (!this.server || !this.username) {
return false;
}
return this.login(this.server, this.username, this.password, false)
.then(() => true)
.catch(() => false);
}
async login(server: string, username: string, password: string, remember: boolean) {
return axios.get(`${server}/rest/ping.view?u=${username}&p=${password}&v=1.15.0&c=app&f=json`)
.then((response) => {
const subsonicResponse = response.data["subsonic-response"];
if (!subsonicResponse || subsonicResponse.status !== "ok") {
const err = new Error(subsonicResponse.status);
return Promise.reject(err);
}
this.authenticated = true;
this.server = server;
this.username = username;
this.password = password;
if (remember) {
this.saveSession();
}
})
}
logout() {
localStorage.clear();
sessionStorage.clear();
}
isAuthenticated() {
return this.authenticated;
}
}
+9
View File
@@ -0,0 +1,9 @@
<template>
<div></div>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
});
</script>
+35
View File
@@ -0,0 +1,35 @@
<template>
<b-dropdown variant="link" boundary="window" no-caret toggle-class="p-0">
<template #button-content>
<Icon>mdi-dots-vertical</Icon>
</template>
<b-dropdown-item-button @click="toggleStarred()">
{{ starred ? 'Unstar' : 'Star' }}
</b-dropdown-item-button>
<slot :item="track"></slot>
</b-dropdown>
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
props: {
track: { type: Object, required: true },
},
data() {
return {
starred: this.track.starred,
}
},
methods: {
toggleStarred() {
if (this.starred) {
this.$api.unstar('track', this.track.id);
} else {
this.$api.star('track', this.track.id);
}
this.starred = !this.starred;
},
}
});
</script>
+115
View File
@@ -0,0 +1,115 @@
<template>
<div>
<b-table-simple borderless hover>
<thead>
<tr>
<th class="pl-0 pr-0 text-center text-muted"></th>
<th class="text-left">Title</th>
<th class="text-left">Artist</th>
<th v-if="showAlbum" class="text-left">Album</th>
<th class="text-right">Duration</th>
<th class="text-right">Actions</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in tracks" :key="item.id"
draggable="true" @dragstart="dragstart(item.id, $event)"
:class="{'text-primary': item.id === playingTrackId}">
<td class="pl-0 pr-0 text-center text-muted" style="min-width: 20px; max-width: 20px;">
<span class="track-status">
<template v-if="item.id === playingTrackId">
<Icon>{{ isPlaying ? 'mdi-volume-high' : 'mdi-play' }}</Icon>
</template>
<template v-else>{{ item.track || 1 }}</template>
</span>
<span class="track-status-hover">
<span v-if="item.id === playingTrackId" @click="playPause()">
<Icon>{{ isPlaying ? 'mdi-pause' : 'mdi-play' }}</Icon>
</span>
<span v-else @click="play(index)">
<Icon>mdi-play</Icon>
</span>
</span>
</td>
<td>{{ item.title }}</td>
<td>
<template v-if="item.artistId">
<router-link :to="{name: 'artist', params: {id: item.artistId}}">
{{ item.artist }}
</router-link>
</template>
<template v-else>
{{ item.artist }}
</template>
</td>
<td v-if="showAlbum">
<router-link :to="{name: 'album', params: {id: item.albumId}}">
{{ item.album }}
</router-link>
</td>
<td class="text-right">
{{ item.duration | duration }}
</td>
<td class="text-right">
<TrackContextMenu :track="item">
<template v-slot="{ item }">
<slot name="context-menu" :index="index" :item="item"></slot>
</template>
</TrackContextMenu>
</td>
</tr>
</tbody>
</b-table-simple>
</div>
</template>
<style lang="scss" scoped>
.track-status-hover {
display: none;
}
tr:hover {
.track-status-hover {
display: inline;
}
.track-status {
display: none;
}
}
</style>
<script lang="ts">
import Vue from "vue";
import { mapActions, mapMutations, mapGetters, mapState } from 'vuex';
import TrackContextMenu from "@/library/TrackContextMenu.vue"
export default Vue.extend({
components: {
TrackContextMenu,
},
props: {
tracks: { type: Array, required: true },
showAlbum: { type: Boolean, default: false },
},
computed: {
...mapState("player", {
isPlaying: "isPlaying",
}),
...mapGetters({
playingTrackId: "player/trackId",
}),
},
methods: {
...mapMutations({
playPause: "player/playPause",
}),
play(index: number) {
this.$store.dispatch('player/play', {
index,
queue: this.tracks,
})
},
dragstart(id: string, event: any) {
console.log("dragstart: " + id)
event.dataTransfer.setData("id", id);
},
}
});
</script>
+45
View File
@@ -0,0 +1,45 @@
<template>
<div v-if="album">
<div class="row mb-4">
<div class="col-auto">
<b-img height="300" width="300" :src="album.image"></b-img>
</div>
<div class="col">
<h1>{{ album.name }}</h1>
<p>by
<router-link :to="{name: 'artist', params: { id: album.artistId }}">
{{ album.artist }}
</router-link>
<span v-if="album.year"> · {{ album.year }}</span>
<span v-if="album.genre"> · {{ album.genre }}</span>
</p>
</div>
</div>
<div class="row">
<div class="col">
<TrackList :tracks="album.song"/>
</div>
</div>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import TrackList from "@/library/TrackList.vue"
export default Vue.extend({
components: {
TrackList,
},
props: {
id: String
},
data() {
return {
album: null,
}
},
async mounted() {
this.album = await this.$api.getAlbumDetails(this.id);
}
});
</script>
+35
View File
@@ -0,0 +1,35 @@
<template>
<div class="card">
<img class="card-img-top" :src="item.image">
<div class="card-body">
<div class=" ">
<div class="text-truncate">
<router-link :to="{name: 'album', params: { id: item.id } }">
<strong>{{ item.name }}</strong>
</router-link>
</div>
<div class="text-truncate text-muted">
{{ item.artist }}
</div>
</div>
</div>
</div>
</template>
<style scoped lang="scss">
.on-hover {
opacity: 0.6;
}
.show-btns {
color: rgba(255, 255, 255, 1) !important;
}
</style>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
props: {
item: Object
}
});
</script>
+62
View File
@@ -0,0 +1,62 @@
<template>
<div>
<Spinner :data="albums" v-slot="{albums: data}">
<Tiles :items="albums" v-slot="{ item }" square>
<div class="text-truncate">
<router-link :to="{name: 'album', params: { id: item.id } }">
<strong>{{ item.name }}</strong>
</router-link>
</div>
<div class="text-truncate text-muted">
<router-link :to="{name: 'artist', params: { id: item.artistId } }">
{{ item.artist }}
</router-link>
</div>
</Tiles>
</Spinner>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import AlbumCard from "./AlbumCard.vue";
export default Vue.extend({
components: {
AlbumCard
},
props: {
msg: String
},
data() {
return {
sort: "newest",
albums: null,
};
},
computed: {
sortOptions() {
return [
{ text: "A-Z", value: "alphabeticalByName" },
{ text: "Date", value: "newest" },
{ text: "frequent", value: "frequent" },
// { text: "random", value: "random" },
// { text: "recent", value: "recent" },
// { text: "starred", value: "starred" },
]
}
},
watch: {
sort: {
immediate: true,
handler(value: string) {
this.albums = null;
this.$api.getAlbums(value).then(albums => {
this.albums = albums;
});
}
}
},
created() {
}
});
</script>
+21
View File
@@ -0,0 +1,21 @@
<template>
<div>
<div class="text-truncate">
<router-link :to="{name: 'artist', params: { id: item.id } }">
<strong>{{ item.name }}</strong>
</router-link>
</div>
<div class="text-truncate text-muted">
<strong>{{ item.albumCount }}</strong> albums
</div>
</div>
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
props: {
item: { type: Object, required: true }
}
});
</script>
+58
View File
@@ -0,0 +1,58 @@
<template>
<div v-if="item">
<div class="row mb-2">
<!-- <div class="col"> -->
<!-- <b-img height="300" width="300" :src="item.image"></b-img> -->
<!-- </div> -->
<div class="col col-xl-8">
<h1>{{ item.name }}</h1>
<p>{{ item.description }}</p>
</div>
</div>
<h3 class="pt-5">Albums</h3>
<Tiles :items="item.albums" v-slot="{ item }" square>
<div class="text-truncate">
<router-link :to="{name: 'album', params: { id: item.id } }">
<strong>{{ item.name }}</strong>
</router-link>
</div>
<div class="text-truncate text-muted">
{{ item.artist }}
</div>
</Tiles>
<h3 class="pt-5">Similar artist</h3>
<Tiles :items="item.similarArtist" v-slot="{ item }">
<ArtistCard :item="item"></ArtistCard>
</Tiles>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import AlbumCard from "@/library/album/AlbumCard.vue";
import ArtistCard from "@/library/artist/ArtistCard.vue";
export default Vue.extend({
components: {
AlbumCard,
ArtistCard,
},
props: {
id: String
},
data() {
return {
item: null as any,
}
},
watch: {
id: {
immediate: true,
async handler(value: string) {
this.item = null,
this.item = await this.$api.getArtistDetails(this.id);
}
}
}
});
</script>
+32
View File
@@ -0,0 +1,32 @@
<template>
<Tiles :items="items" v-slot="{ item }">
<div class="text-truncate">
<router-link :to="{name: 'artist', params: { id: item.id } }">
<strong>{{ item.name }}</strong>
</router-link>
</div>
<div class="text-truncate text-muted">
<strong>{{ item.albumCount }}</strong> albums
</div>
</Tiles>
</template>
<script lang="ts">
import Vue from "vue";
import ArtistCard from "./ArtistCard.vue";
export default Vue.extend({
components: {
ArtistCard,
},
data() {
return {
items: []
};
},
created() {
this.$api.getArtists().then(items => {
this.items = items;
});
}
});
</script>
+27
View File
@@ -0,0 +1,27 @@
<template>
<div v-if="item">
<h1>{{ item.name }}</h1>
<TrackList :tracks="item.tracks" show-album/>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import TrackList from "@/library/TrackList.vue"
export default Vue.extend({
components: {
TrackList,
},
props: {
id: String
},
data() {
return {
item: null as any,
}
},
async created() {
this.item = await this.$api.getGenreDetails(this.id);
}
});
</script>
+34
View File
@@ -0,0 +1,34 @@
<template>
<Tiles :items="items">
<template v-slot="{ item }">
<div class="text-truncate">
<router-link :to="{name: 'genre', params: { id: item.id } }">
<strong>{{ item.name }}</strong>
</router-link>
</div>
<div class="text-truncate text-muted">
<strong>{{ item.albumCount }}</strong> albums ·
<strong>{{ item.songCount }}</strong> songs
</div>
</template>
</Tiles>
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
components: {
},
data() {
return {
items: []
};
},
created() {
this.$api.getGenres().then(items => {
this.items = items;
});
}
});
</script>
+25
View File
@@ -0,0 +1,25 @@
<template>
<div v-if="items">
<TrackList :tracks="items.tracks"/>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import TrackList from "@/library/TrackList.vue"
export default Vue.extend({
components: {
TrackList,
},
data() {
return {
items: null as any,
}
},
created() {
this.$api.getStarred().then(result => {
this.items = result;
})
}
});
</script>
+40
View File
@@ -0,0 +1,40 @@
import Vue from 'vue'
import Router from "vue-router"
import Vuex from "vuex"
import BootstrapVue from 'bootstrap-vue'
import '@/style/main.scss'
import '@/shared/components'
import '@/shared/filters'
import App from '@/app/App.vue'
import {setupRouter} from '@/shared/router'
import {setupStore} from '@/shared/store'
import { API } from '@/shared/api';
import { AuthService } from '@/auth/service';
import { connectAudioToStore } from './player/store'
declare module 'vue/types/vue' {
interface Vue {
$auth: AuthService
$api: API
}
}
Vue.config.productionTip = false
Vue.use(Router)
Vue.use(Vuex);
Vue.use(BootstrapVue)
const authService = new AuthService();
const api = new API(authService);
const router = setupRouter(authService);
const store = setupStore(authService, api);
connectAudioToStore(store);
Vue.prototype.$auth = authService;
Vue.prototype.$api = api;
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
+94
View File
@@ -0,0 +1,94 @@
<template>
<div class="d-flex player">
<div v-if="track" class="d-none d-sm-block">
<b-img :src="track.image" block width="80px" height="80px"></b-img>
</div>
<div class="flex-fill">
<!-- Progress --->
<div class="progress2" @click="seek">
<b-progress :value="progress" :max="100" height="4px"></b-progress>
</div>
<div class="row d-flex align-items-center p-2 m-0">
<!-- Track info --->
<div class="col d-flex p-0 text-truncate">
<div class="d-flex align-items-center">
<template v-if="track">
<div class="ml-2 align-middle">
<div>{{ track.title }}</div>
<div>{{ track.artist }}</div>
</div>
</template>
</div>
</div>
<!-- Controls--->
<div class="col-auto p-0">
<b-button variant="link" class="m-2"
:disabled="!hasPrevious" @click="playPrevious">
<Icon>mdi-skip-previous</Icon>
</b-button>
<b-button variant="link" size="lg" class="m-2" @click="playPause">
<Icon>{{ isPlaying ? 'mdi-pause' : 'mdi-play' }}</Icon>
</b-button>
<b-button variant="link" class="m-2"
:disabled="!hasNext" @click="playNext">
<Icon>mdi-skip-next</Icon>
</b-button>
</div>
<div class="col p-0 text-truncate">
<div v-if="track" class="text-right">
<span>{{ currentTime | duration }} / {{ duration | duration }}</span>
</div>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.progress2 {
cursor: pointer;
}
</style>
<script lang="ts">
import Vue from "vue";
import { mapMutations, mapState, mapGetters, mapActions } from 'vuex';
export default Vue.extend({
data() {
return {
};
},
computed: {
...mapState("player", {
isPlaying: (state: any) => state.isPlaying,
currentTime: (state: any) => state.currentTime,
duration: (state: any) => state.duration,
}),
...mapGetters("player", [
"track",
"progress",
"hasNext",
"hasPrevious",
]),
},
methods: {
...mapMutations("player", [
"playPause",
]),
...mapActions("player", [
"playNext",
"playPrevious",
]),
seek(event: any) {
if (event.target) {
const width = event.target.clientWidth;
const value = event.offsetX / width
this.$store.commit("player/seek", value)
// this.internalValue = e.offsetX / width * 100
}
}
}
});
</script>
+33
View File
@@ -0,0 +1,33 @@
<template>
<div>
<TrackList :tracks="tracks">
<template #context-menu="{index}">
<b-dropdown-item-button @click="remove(index)">
Remove
</b-dropdown-item-button>
</template>
</TrackList>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import { mapState, mapMutations } from 'vuex';
import TrackList from "@/library/TrackList.vue";
export default Vue.extend({
components: {
TrackList,
},
computed: {
...mapState("player", {
tracks: (state: any) => state.queue,
})
},
methods: {
...mapMutations("player", {
play: "playQueueIndex",
remove: "removeFromQueue",
}),
}
});
</script>
+27
View File
@@ -0,0 +1,27 @@
<template>
<div>
<div class="col" d-flex fill-height grow>
<h1>{{ track.name }}</h1>
<div>{{ track.artist }}</div>
<v-card color=blue tile height="100%" width="100%"></v-card>
</div>
</template>
<style scoped lang="scss">
.on-hover {
opacity: 0.6;
}
.show-btns {
color: rgba(255, 255, 255, 1) !important;
}
</style>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
props: {
album: Object
}
});
</script>
+127
View File
@@ -0,0 +1,127 @@
import { Store, Module } from 'vuex'
interface State {
queue: any[];
queueIndex: number;
isPlaying: boolean;
duration: number; // duration of current track in seconds
currentTime: number; // position of current track in seconds
}
const audio = new Audio();
const storedQueue = JSON.parse(localStorage.getItem("queue") || "[]");
const storedQueueIndex = parseInt(localStorage.getItem("queueIndex") || "-1");
if (storedQueueIndex > -1 && storedQueueIndex < storedQueue.length) {
audio.src = storedQueue[storedQueueIndex].url;
}
export const playerModule: Module<State, any> = {
namespaced: true,
state: {
queue: storedQueue,
queueIndex: storedQueueIndex,
isPlaying: false,
duration: 0,
currentTime: 0,
},
mutations: {
playPause(state: State) {
if (state.isPlaying) {
state.isPlaying = false;
audio.pause();
} else {
state.isPlaying = true;
audio.play();
}
},
seek(state, value: number) {
console.log("seek: " + value);
if (state.queueIndex != -1) {
const seconds = state.duration * value;
audio.currentTime = seconds;
}
},
setQueueAndPlay(state, { queue, index }) {
state.queue = queue;
state.queueIndex = index;
localStorage.setItem("queue", JSON.stringify(queue));
localStorage.setItem("queueIndex", index);
state.isPlaying = true;
audio.src = queue[index].url;
audio.play();
},
playQueueIndex(state, index) {
if (state.queue.length === 0) {
return;
}
index = index < state.queue.length ? index : 0;
state.isPlaying = true;
state.queueIndex = index;
audio.src = state.queue[index].url;
audio.play();
},
removeFromQueue(state, index) {
state.queue.splice(index, 1);
if (index < state.queueIndex) {
state.queueIndex--;
}
},
setProgress(state: State, value: any) {
state.currentTime = value;
},
setDuration(state: State, value: any) {
state.duration = value;
},
},
actions: {
play({ commit }, { queue, index }) {
commit('setQueueAndPlay', { index, queue });
},
playNext({ commit, state }) {
commit("playQueueIndex", state.queueIndex + 1);
},
playPrevious({ commit, state }) {
commit("playQueueIndex", state.queueIndex - 1);
},
},
getters: {
track(state) {
if (state.queueIndex != -1) {
return state.queue[state.queueIndex];
}
return null;
},
trackId(state, getters): number {
return getters.track ? getters.track.id : -1;
},
progress(state) {
if (state.currentTime > -1 && state.duration > 0) {
return (state.currentTime / state.duration) * 100;
}
return 0;
},
hasNext(state) {
return state.queueIndex < state.queue.length - 1;
},
hasPrevious(state) {
return state.queueIndex > 0;
},
},
};
export function connectAudioToStore(store: Store<any>) {
audio.ontimeupdate = (event) => {
store.commit("player/setProgress", audio.currentTime)
};
audio.ondurationchange = (event) => {
store.commit("player/setDuration", audio.duration);
}
audio.onended = (event) => {
store.dispatch("player/playNext");
}
}
+48
View File
@@ -0,0 +1,48 @@
<template>
<Spinner :data="playlist" v-slot="{ data }">
<h1>{{ data.name }}</h1>
<TrackList :tracks="data.tracks" show-album @remove="remove(index)">
<template v-slot:context-menu="{index}">
<b-dropdown-item-button @click="remove(index)">
Remove
</b-dropdown-item-button>
</template>
</TrackList>
</Spinner>
</template>
<script lang="ts">
import Vue from "vue";
import TrackList from "@/library/TrackList.vue";
export default Vue.extend({
components: {
TrackList,
},
props: {
id: String,
},
data() {
return {
playlist: null as any,
};
},
watch: {
'id': {
immediate: true,
handler(value: string) {
this.playlist = null;
this.$api.getPlaylist(value).then(playlist => {
this.playlist = playlist;//.sort((a: any, b:any) => a.created.localeCompare(b.created));
});
}
}
},
methods: {
remove(index: number) {
console.log("remove: " + index)
this.$api.removeFromPlaylist(this.id, index.toString());
this.playlist.tracks.splice(index, 1);
}
}
});
</script>
+47
View File
@@ -0,0 +1,47 @@
<template>
<div>
<b-table-simple>
<thead>
<tr>
<th>Name</th>
<th>Created</th>
<th>Updated</th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in playlists" :key="item.id">
<td>
<router-link :to="{name: 'playlist', params: { id: item.id } }">
{{ item.name }}
</router-link>
</td>
<td>{{ item.created | dateTime }}</td>
<td>{{ item.changed | dateTime }}</td>
<td class="text-right">
<OverflowMenu>
<b-dropdown-item-btn @click="deletePlaylist(item.id)">Delete</b-dropdown-item-btn>
</OverflowMenu>
</td>
</tr>
</tbody>
</b-table-simple>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import { mapState, mapActions } from 'vuex';
export default Vue.extend({
computed: {
...mapState([
"playlists"
]),
},
methods: {
...mapActions({
deletePlaylist: 'deletePlaylist'
})
}
});
</script>
+72
View File
@@ -0,0 +1,72 @@
<template>
<div>
<span class="nav-link">
<small class="text-uppercase text-muted font-weight-bold">
Playlists
<button class="btn btn-link btn-sm p-0 float-right" @click="showModal = true">
<Icon>mdi-plus</Icon>
</button>
</small>
</span>
<router-link class="nav-item nav-link" :to="{name: 'playlist', params: { id: 'random' }}">
<Icon>mdi-view-list</Icon> Random
</router-link>
<router-link v-for="item in playlists" :key="item.id"
:to="{name: 'playlist', params: { id: item.id }}"
class="nav-item nav-link">
<span @dragover="onDragover" @drop="onDrop(item.id, $event)">
<Icon>mdi-playlist-music</Icon> {{ item.name }}
</span>
</router-link>
<router-link class="nav-item nav-link" :to="{name: 'playlists'}">
More...
</router-link>
<b-modal v-model="showModal" title="New playlist">
<b-form-group label="Name">
<b-form-input type="text" v-model="playlistName"/>
</b-form-group>
<template #modal-footer>
<b-button variant="primary" @click="createPlaylist">Create</b-button>
</template>
</b-modal>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import { mapState } from 'vuex';
export default Vue.extend({
data() {
return {
playlistName: "",
showModal: false,
}
},
computed: {
playlists() {
return this.$store.state.playlists.slice(0, 10);
},
},
methods: {
createPlaylist() {
this.$store.dispatch("createPlaylist", this.playlistName);
this.playlistName = "";
this.showModal = false;
},
onDrop(playlistId: string, event: any) {
console.log("onDrop")
event.preventDefault();
const trackId = event.dataTransfer.getData("id");
this.$store.dispatch("addTrackToPlaylist", { playlistId, trackId })
},
onDragover(event: any) {
console.log("onDragover")
event.preventDefault();
},
}
});
</script>
+42
View File
@@ -0,0 +1,42 @@
<template>
<div v-if="items">
<TrackList :tracks="items" show-album/>
<table class="table">
<thead>
</thead>
<tbody>
<tr v-for="item in items" :key="item.id">
<td>
<Icon @click="() => {}">mdi-play-outline</Icon>
<Icon @click="() => {}">mdi-plus</Icon>
</td>
<td>{{ item.artist }}</td>
<td>{{ item.album }}</td>
<td>{{ item.duration | duration }}</td>
</tr>
</tbody>
</table>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import TrackList from "@/library/TrackList.vue";
export default Vue.extend({
components: {
TrackList,
},
data() {
return {
loading: true,
items: [] as any[],
};
},
created() {
this.$api.getRandomSongs().then(items => {
this.loading = false;
this.items = items;//.sort((a: any, b:any) => a.created.localeCompare(b.created));
});
}
});
</script>
+24
View File
@@ -0,0 +1,24 @@
<template>
<div>
<form class="form-inline my-2 my-lg-0" @submit.prevent="search">
<input
class="form-control mr-sm-2"
type="search" placeholder="Search"
v-model="query">
</form>
</div>
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
props: {
query: String
},
methods: {
search(): void {
this.$router.push({ name: 'search', query: { q: this.query } });
}
}
});
</script>
+102
View File
@@ -0,0 +1,102 @@
<template>
<div v-if="result">
<div>
<h5 class="text-uppercase">Artists</h5>
<div class="d-flex">
<div class="tiles">
<div v-for="item in result.artists" :key="item.id">
<ArtistCard :item="item"></ArtistCard>
</div>
</div>
</div>
<b-table-simple hover borderless>
<tbody>
<tr v-for="item in result.artists" :key="item.id">
<td>{{ item.name }}</td>
</tr>
</tbody>
</b-table-simple>
</div>
<div>
<h5 class="text-uppercase">Albums</h5>
<div class="d-flex">
<div class="tiles">
<div v-for="item in result.albums" :key="item.id">
<AlbumCard :item="item"></AlbumCard>
</div>
</div>
</div>
<b-table-simple hover borderless>
<tbody>
<tr v-for="item in result.albums">
<td>{{ item.name }}</td>
<td>{{ item.artist }}</td>
</tr>
</tbody>
</b-table-simple>
</div>
<div>
<h5 class="text-uppercase">Tracks</h5>
<b-table-simple hover>
<!-- <thead>
<tr>
<th class="text-left"></th>
<th class="text-left">Title</th>
<th class="text-left">Artist</th>
<th class="text-left">Album</th>
<th class="text-left">Duration</th>
<th class="text-left">Actions</th>
</tr>
</thead> -->
<tbody>
<tr v-for="(item, index) in result.tracks">
<td>
<span @click="play(index)">
<Icon>mdi-play</Icon>
</span>
</td>
<td>{{ item.title }}</td>
<td>{{ item.artist }}</td>
<td>{{ item.album }}</td>
<!-- <td>{{ item.duration | duration }}</td> -->
</tr>
</tbody>
</b-table-simple>
</div>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import AlbumCard from "@/library/album/AlbumCard.vue";
import ArtistCard from "@/library/artist/ArtistCard.vue";
export default Vue.extend({
components: {
AlbumCard,
ArtistCard,
},
props: {
query: String,
},
data() {
return {
result: null as any,
};
},
watch: {
query: {
immediate: true,
handler(value: string) {
this.$api.search(this.query).then(result => {
this.result = result;
});
}
}
},
});
</script>
+267
View File
@@ -0,0 +1,267 @@
import axios, { AxiosRequestConfig, AxiosInstance } from "axios"
import { AuthService } from '@/auth/service';
export class API {
readonly http: AxiosInstance;
readonly get: (path: string, params?: any) => Promise<any>;
readonly post: (path: string, params?: any) => Promise<any>;
constructor(private auth: AuthService) {
this.http = axios.create({});
this.http.interceptors.request.use((config: AxiosRequestConfig) => {
config.params = config.params || {};
config.baseURL = this.auth.server
config.params.u = this.auth.username;
config.params.p = this.auth.password;
config.params.c = "app";
config.params.f = "json";
config.params.v = "1.15.0";
return config;
});
this.get = (path: string, params: any = {}) => {
return this.http.get(path, {params}).then(response => {
const subsonicResponse = response.data["subsonic-response"];
if (subsonicResponse.status !== "ok") {
const err = new Error(subsonicResponse.status);
return Promise.reject(err);
}
return Promise.resolve(subsonicResponse);
})
}
this.post = (path: string, params: any = {}) => {
return this.http.post(path, params).then(response => {
const subsonicResponse = response.data["subsonic-response"];
if (subsonicResponse.status !== "ok") {
const err = new Error(subsonicResponse.status);
return Promise.reject(err);
}
return Promise.resolve(subsonicResponse);
})
}
}
async getGenres() {
const response = await this.get("rest/getGenres", {});
return response.genres.genre.map((item: any) => ({
id: encodeURIComponent(item.value),
name: item.value,
...item,
}));
}
async getGenreDetails(id: string) {
const params = {
genre: decodeURIComponent(id),
count: 500,
offset: 0,
}
const response = await this.get("rest/getSongsByGenre", params);
return {
name: id,
tracks: this.normalizeTrackList(response.songsByGenre.song),
}
}
async getArtists(offset: any = 0, size: any = 400) {
const params = {
type: "random",
offset,
size,
};
const data = await this.get("rest/getArtists", params);
return data.artists.index.flatMap((index: any) => index.artist.map((artist: any) => ({
id: artist.id,
name: artist.name,
...artist
})));
}
async getAlbums(sort: string) {
const params = {
type: sort,
offset: "0",
size: "500",
};
const data = await this.get("rest/getAlbumList2", params);
return data.albumList2.album.map((item: any) => ({
...item,
image: item.coverArt ? this.getCoverArtUrl(item) : undefined,
}));
}
async getArtistDetails(id: string) {
const params = { id };
const [info1, info2] = await Promise.all([
this.get("rest/getArtist", params).then(r => r.artist),
this.get("rest/getArtistInfo2", params).then(r => r.artistInfo2),
])
return {
info1,
info2,
id: info1.id,
name: info1.name,
description: info2.biography,
image: info2.largeImageUrl || info2.mediumImageUrl || info2.smallImageUrl,
lastFmUrl: info2.lastFmUrl,
musicBrainzId: info2.musicBrainzId,
albums: info1.album.map((album: any) => this.normalizeAlbumResponse(album)),
similarArtist: (info2.similarArtist || []).map((artist: any) => ({
id: artist.id,
name: artist.name,
...artist
}))
};
}
async getAlbumDetails(id: string) {
const params = {id};
const data = await this.get("rest/getAlbum", params);
const item = data.album;
const image = this.getCoverArtUrl(item);
const trackList = item.song.map((s: any) => ({
...s,
image,
url: this.getStreamUrl(s.id),
}))
return {
...item,
image,
song: trackList,
};
}
async getPlaylists() {
const response = await this.get("rest/getPlaylists");
return response.playlists.playlist.map((playlist: any) => ({
...playlist,
name: playlist.name || "(Unnamed)",
}));
}
async getPlaylist(id: string) {
if (id === 'random') {
return {
id,
name: 'Random',
tracks: await this.getRandomSongs(),
};
}
const response = await this.get("rest/getPlaylist", { id });
return {
...response.playlist,
name: response.playlist.name || "(Unnamed)",
tracks: this.normalizeTrackList(response.playlist.entry || []),
};
}
async createPlaylist(name: string) {
await this.get("rest/createPlaylist", { name });
return this.getPlaylists();
}
async deletePlaylist(id: string) {
await this.get("rest/deletePlaylist", { id });
}
async addToPlaylist(playlistId: string, trackId: string) {
const params = {
playlistId,
songIdToAdd: trackId,
}
await this.get("rest/updatePlaylist", params);
}
async removeFromPlaylist(playlistId: string, index: string) {
const params = {
playlistId,
songIndexToRemove: index,
}
await this.get("rest/updatePlaylist", params);
}
async getRandomSongs() {
const params = {
size: 200,
};
const data = await this.get("rest/getRandomSongs", params);
return this.normalizeTrackList(data.randomSongs.song);
}
async getStarred() {
const [tracks, albums] = await Promise.all([
this.get("rest/getStarred2").then(r => r.starred2.song),
this.get("rest/getAlbumList2", { type: 'starred' }).then(r => r.albumList2),
this.get("rest/getAlbumList2", { type: 'starred' }).then(r => r.albumList2),
]);
return { tracks, albums }
}
async star(type: 'track' | 'album' | 'artist', id: string) {
const params = {
id: type === 'track' ? id : undefined,
albumId: type === 'album' ? id : undefined,
artistId: type === 'artist' ? id : undefined,
}
await this.get("rest/star", params);
}
async unstar(type: 'track' | 'album' | 'artist', id: string) {
const params = {
id: type === 'track' ? id : undefined,
albumId: type === 'album' ? id : undefined,
artistId: type === 'artist' ? id : undefined,
}
await this.get("rest/unstar", params);
}
async search(query: string) {
const params = {
query,
};
const data = await this.get("rest/search3", params);
return {
tracks: data.searchResult3.song || [],
albums: (data.searchResult3.album || []).map((x: any) => this.normalizeAlbumResponse(x)),
artists: (data.searchResult3.artist || []).map((x: any) => this.normalizeArtistResponse(x)),
};
}
private normalizeTrackList(items: any[]) {
return items.map((item => ({
...item,
url: this.getStreamUrl(item.id),
image: this.getCoverArtUrl(item),
})))
}
private normalizeAlbumResponse(item: any) {
return {
...item,
image: this.getCoverArtUrl(item)
}
}
private normalizeArtistResponse(item: any) {
return {
...item,
image: this.getCoverArtUrl(item)
}
}
private getCoverArtUrl(item: any) {
if (!item.coverArt) {
return undefined;
}
const { server, username, password } = this.auth;
return `${server}/rest/getCoverArt?id=${item.coverArt}&v=1.15.0&u=${username}&p=${password}&c=test&size=300`
}
private getStreamUrl(id: any) {
const { server, username, password } = this.auth;
return `${server}/rest/stream?id=${id}&format=raw&v=1.15.0&u=${username}&p=${password}&c=test&size=300`
}
}
+8
View File
@@ -0,0 +1,8 @@
<template>
<span :class="`mdi ${$slots.default[0].text}`"></span>
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({});
</script>
+52
View File
@@ -0,0 +1,52 @@
<template functional>
<div class="fixed-img bg-secondary">
<div class="fixed-img-inner">
<img v-if="props.src" :src="props.src">
<div v-else class="text-muted">
<Icon>mdi-music</Icon>
</div>
</div>
</div>
</template>
<style lang="scss">
.fixed-img-sq {
padding-bottom: 100%;
}
.fixed-img-rect {
padding-bottom: 70%;
}
.fixed-img {
position: relative;
width: 100%;
.tile-img-inner {
position: absolute;
width: 100%;
height: 100%;
img {
width: 100%;
height: 100%;
object-fit: cover;
}
span {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 4.5rem;
}
}
}
</style>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
props: {
square: { type: Boolean, default: false },
}
});
</script>
+13
View File
@@ -0,0 +1,13 @@
<template>
<b-dropdown variant="link" boundary="window" no-caret toggle-class="p-0">
<template #button-content>
<Icon>mdi-dots-vertical</Icon>
</template>
<slot/>
</b-dropdown>
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({});
</script>
+12
View File
@@ -0,0 +1,12 @@
<template functional>
<div>
<slot v-if="props.data" :data="props.data"></slot>
<div v-else class="text-center">
<span class="spinner-grow"/>
</div>
</div>
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({})
</script>
+79
View File
@@ -0,0 +1,79 @@
<template functional>
<div class="tiles" :class="props.square ? 'tiles-sq' : 'tiles-rect'">
<div v-for="(item, index) in props.items" :key="item.id">
<div class="card">
<div class="tile-img bg-secondary">
<div class="tile-img-inner">
<img v-if="item.image" :src="item.image">
<div v-else class="fallback-img text-muted">
<Icon>mdi-music</Icon>
</div>
</div>
</div>
<div class="card-body">
<slot :item="item" :index="index"></slot>
</div>
</div>
</div>
</div>
</template>
<style lang="scss">
.tiles {
display: grid;
grid-gap: 12px;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
@media(max-width: 442px) { // 15px padding + 200px tile + 12px gap + 200px tile + 15px padding
.tiles {
grid-gap: 8px;
grid-template-columns: repeat(2, minmax(1px, 1fr))
}
}
.tiles-sq {
.tile-img {
padding-bottom: 100%;
}
}
.tiles-rect {
.tile-img {
padding-bottom: 70%;
}
}
.tile-img {
position: relative;
width: 100%;
.tile-img-inner {
position: absolute;
width: 100%;
height: 100%;
img {
width: 100%;
height: 100%;
object-fit: cover;
}
.fallback-img {
*{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 4.5rem;
}
}
}
}
</style>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
props: {
items: { type: Array, required: true },
square: { type: Boolean, default: false },
}
});
</script>
+19
View File
@@ -0,0 +1,19 @@
import Vue from 'vue';
import Icon from "./Icon.vue";
import OverflowMenu from "./OverflowMenu.vue";
import Spinner from "./Spinner.vue";
import Tiles from "./Tiles.vue";
const components = {
Icon,
OverflowMenu,
Spinner,
Tiles,
};
type Key = keyof typeof components;
Object.keys(components).forEach((_key) => {
const key = _key as keyof typeof components;
Vue.component(key, components[key]);
});
+12
View File
@@ -0,0 +1,12 @@
import Vue from 'vue';
Vue.filter("duration", (value: number) => {
const minutes = Math.floor(value / 60);
const seconds = Math.floor(value % 60);
return (minutes < 10 ? '0' : '') + minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
})
Vue.filter("dateTime", (value: string) => {
return value;
})
+118
View File
@@ -0,0 +1,118 @@
import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/auth/Login.vue'
import Queue from '@/player/Queue.vue'
import Home from '@/home/Home.vue'
import AlbumList from '@/library/album/AlbumList.vue'
import ArtistDetails from '@/library/artist/ArtistDetails.vue'
import ArtistList from '@/library/artist/ArtistList.vue'
import Album from '@/library/album/Album.vue'
import RandomSongs from '@/playlist/RandomSongs.vue'
import GenreList from '@/library/genre/GenreList.vue'
import GenreDetails from '@/library/genre/GenreDetails.vue'
import Starred from '@/library/starred/Starred.vue'
import Playlist from '@/playlist/Playlist.vue'
import PlaylistList from '@/playlist/PlaylistList.vue'
import SearchResult from '@/search/SearchResult.vue'
import { AuthService } from '@/auth/service';
export function setupRouter(auth: AuthService) {
const router = new Router({
mode: 'history',
linkExactActiveClass: 'active',
base: process.env.BASE_URL,
routes: [
{
path: '/',
name: 'home',
component: Home
},
{
name: 'login',
path: '/login',
component: Login,
props: (route) => ({
returnTo: route.query.returnTo,
})
},
{
name: 'queue',
path: '/queue',
component: Queue,
},
{
name: 'albums',
path: '/albums',
component: AlbumList
},
{
name: 'album',
path: '/album/:id',
component: Album,
props: true,
},
{
name: 'artists',
path: '/artists',
component: ArtistList
},
{
name: 'artist',
path: '/artist/:id',
component: ArtistDetails,
props: true,
},
{
name: 'genres',
path: '/genres',
component: GenreList,
},
{
name: 'genre',
path: '/genre/:id',
component: GenreDetails,
props: true,
},
{
name: 'starred',
path: '/starred',
component: Starred,
},
{
name: 'playlists',
path: '/playlists',
component: PlaylistList,
},
{
name: 'playlist',
path: '/playlist/:id',
component: Playlist,
props: true,
},
{
name: 'playlist-random',
path: '/random',
component: RandomSongs,
},
{
name: 'search',
path: '/search',
component: SearchResult,
props: (route) => ({
query: route.query.q,
})
},
]
});
router.beforeEach((to, from, next) => {
if (to.name !== 'login' && !auth.isAuthenticated()) {
next({name: 'login', query: { returnTo: to.fullPath }});
} else {
next();
}
});
return router;
}
+82
View File
@@ -0,0 +1,82 @@
import Vue from 'vue'
import Vuex, { Module } from 'vuex'
import { ActionContext } from "vuex"
import { playerModule } from "@/player/store"
import axios from 'axios';
import { AuthService } from '@/auth/service';
import { API } from './api';
interface State {
isLoggedIn: boolean;
username: null | string;
showMenu: boolean;
errors: any[];
playlists: any[];
}
const setupRootModule = (authService: AuthService, api: API): Module<State, any> => ({
state: {
isLoggedIn: false,
username: null,
showMenu: false,
errors: [],
playlists: [],
},
mutations: {
setLoginSuccess(state, { username }) {
state.isLoggedIn = true;
state.username = username;
},
toggleMenu(state) {
state.showMenu = !state.showMenu;
},
setPlaylists(state, playlists: any[]) {
state.playlists = playlists;
},
removePlaylist(state, id: string) {
state.playlists = state.playlists.filter(p => p.id !== id);
},
},
actions: {
loadPlaylists({ commit }) {
api.getPlaylists().then(result => {
commit("setPlaylists", result);
})
},
createPlaylist({ commit }, name) {
api.createPlaylist(name).then(result => {
commit("setPlaylists", result);
})
},
addTrackToPlaylist({ }, { playlistId, trackId }) {
api.addToPlaylist(playlistId, trackId);
},
deletePlaylist({ commit, state }, id) {
api.deletePlaylist(id).then(() => {
commit("removePlaylist", id)
})
}
},
});
export function setupStore(authService: AuthService, api: API) {
const store = new Vuex.Store({
strict: true,
...setupRootModule(authService, api),
modules: {
player: {
namespaced: true,
...playerModule
}
}
})
store.watch(
(state) => state.isLoggedIn,
() => {
store.dispatch("loadPlaylists")
}
);
return store;
}
+4
View File
@@ -0,0 +1,4 @@
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}
+23
View File
@@ -0,0 +1,23 @@
@import '~roboto-fontface/css/roboto/roboto-fontface.css';
@import '~@mdi/font/css/materialdesignicons.css';
$enable-rounded: false;
$enable-print-styles: false;
.breadcrumb {
background: none !important;
padding: 0 !important;
}
@import './theme.scss';
a.active {
color: $primary;
}
h1, h2, h3 {
// color: $primary;
color: #fff;
}
@import '~bootstrap';
@import '~bootstrap-vue';
+31
View File
@@ -0,0 +1,31 @@
// $BASE: #080808;
// $BASE_EVEVATED: #222;
$BASE: #000;
$BASE_EVEVATED: rgb(25, 25, 25);
$primary: #09f;
$danger: #e54b4b;
// $black: #000 !default;
$body-bg: $BASE;
$body-color: #ccc;
$link-color: #ccc;
$text-muted: #999;
// strong { color: #ddd }
// Cards
$card-cap-bg: $BASE_EVEVATED;
$card-bg: $BASE_EVEVATED;
$modal-content-bg: $BASE_EVEVATED;
$input-bg: $BASE_EVEVATED;
$input-color: #ccc !default;
$progress-bg: rgb(35, 35, 35);
$border-color: #444;
.elevated {
background-color: $BASE_EVEVATED;
}