From e2f8adc5dbc4ad34870766b904f3a308f4733b67 Mon Sep 17 00:00:00 2001 From: Neshura Date: Tue, 30 Apr 2024 05:19:41 +0200 Subject: [PATCH] Album Page Views --- .../components/custom/PlayerSidebar.svelte | 23 ++++++----- .../custom/Views/AlbumComponent.svelte | 20 ++++++++++ .../custom/Views/album-pages-utils.svelte.ts | 30 +++++++++++++++ src/routes/+layout.svelte | 13 ++++--- src/routes/+page.svelte | 17 +++------ src/routes/albums/all/+page.svelte | 38 +++++++++++++++++++ src/routes/albums/favourites/+page.svelte | 37 ++++++++++++++++++ src/routes/albums/most-played/+page.svelte | 37 ++++++++++++++++++ src/routes/albums/random/+page.svelte | 37 ++++++++++++++++++ src/routes/albums/recently-added/+page.svelte | 37 ++++++++++++++++++ .../albums/recently-played/+page.svelte | 37 ++++++++++++++++++ src/routes/albums/top-rated/+page.svelte | 37 ++++++++++++++++++ 12 files changed, 335 insertions(+), 28 deletions(-) create mode 100644 src/lib/components/custom/Views/AlbumComponent.svelte create mode 100644 src/lib/components/custom/Views/album-pages-utils.svelte.ts create mode 100644 src/routes/albums/all/+page.svelte create mode 100644 src/routes/albums/favourites/+page.svelte create mode 100644 src/routes/albums/most-played/+page.svelte create mode 100644 src/routes/albums/random/+page.svelte create mode 100644 src/routes/albums/recently-added/+page.svelte create mode 100644 src/routes/albums/recently-played/+page.svelte create mode 100644 src/routes/albums/top-rated/+page.svelte diff --git a/src/lib/components/custom/PlayerSidebar.svelte b/src/lib/components/custom/PlayerSidebar.svelte index ee563de..73a2e2f 100644 --- a/src/lib/components/custom/PlayerSidebar.svelte +++ b/src/lib/components/custom/PlayerSidebar.svelte @@ -6,22 +6,25 @@ import {View} from "$lib/components/custom/Views/views.svelte"; import {AlbumView} from "$lib/components/custom/Views/views.svelte.js"; import {viewState} from "$lib/states/view-state.svelte"; + import {goto} from "$app/navigation"; let playlists = $state([]); + let expanded = $state(true); + $inspect(expanded)
- - - - - - - - - + + {#if expanded} + + + + + + + + {/if}
diff --git a/src/lib/components/custom/Views/AlbumComponent.svelte b/src/lib/components/custom/Views/AlbumComponent.svelte new file mode 100644 index 0000000..d95fcb4 --- /dev/null +++ b/src/lib/components/custom/Views/AlbumComponent.svelte @@ -0,0 +1,20 @@ + + + + +
updateScroll(self)}> + {#if albums.loading} + {#each [...Array(20).keys()] as i} + + {/each} + {:else} + {#each albums.list as album} + + {/each} + {/if} +
\ No newline at end of file diff --git a/src/lib/components/custom/Views/album-pages-utils.svelte.ts b/src/lib/components/custom/Views/album-pages-utils.svelte.ts new file mode 100644 index 0000000..c751a8a --- /dev/null +++ b/src/lib/components/custom/Views/album-pages-utils.svelte.ts @@ -0,0 +1,30 @@ +import {type AlbumID3, type GetAlbumList2Response, OpenSubsonic, type Parameter} from "$lib/opensubsonic"; + +export class AlbumState { + list: Array = $state(new Array()) + loading: boolean = $state(true) + paginating: boolean = $state(false) + paginationIncrement: number = $state(100) + pagination: number = $state(0) + mode: string = $state("alphabeticalByName") + + async fetchAlbums(): Promise { + const parameters: Array = [ + {key: "type", value: this.mode}, + {key: "size", value: this.paginationIncrement.toString()}, + {key: "offset", value: this.pagination.toString()}, + ]; + + const data: GetAlbumList2Response = await OpenSubsonic.get("getAlbumList2", parameters); + if (data && data.albumList2.album) { + this.list = this.list.concat(data.albumList2.album); + this.pagination += this.paginationIncrement; + this.paginating = false; + this.loading = false; + } + } + + setMode(mode: string): void { + this.mode = mode; + } +} \ No newline at end of file diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 94f8872..9390832 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -5,16 +5,15 @@ import QueueFrame from "$lib/components/custom/QueueFrame.svelte"; import {onMount} from "svelte"; import PlayerControls from "$lib/components/custom/PlayerControls.svelte"; - import {AlbumView, View} from "$lib/components/custom/Views/views.svelte"; import PlayerSidebar from "$lib/components/custom/PlayerSidebar.svelte"; + import {queueState} from "$lib/states/play-queue.svelte"; + import {playbackState} from "$lib/states/playback-state.svelte"; let { children } = $props(); - let viewMode = $state(View.Albums); - let subViewMode = $state(AlbumView.All); - onMount(() => { - + queueState.getPlayQueue(true); + playbackState.song = new Audio(); // needed so source is not undefined }) @@ -25,7 +24,9 @@
- {@render children()} +
+ {@render children()} +
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 4579c7a..8e9c60c 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -7,11 +7,6 @@ import {queueState} from "$lib/states/play-queue.svelte"; import {playbackState} from "$lib/states/playback-state.svelte"; import {viewState} from "$lib/states/view-state.svelte"; - - onMount(() => { - queueState.getPlayQueue(true); - playbackState.song = new Audio(); // needed so source is not undefined - }) @@ -19,12 +14,10 @@ -
- {#if viewState.current.mode === View.Albums}es - - {:else if viewState.current.mode === View.Artists} -

Get Fucked

- {/if} -
+{#if viewState.current.mode === View.Albums}es + +{:else if viewState.current.mode === View.Artists} +

Get Fucked

+{/if} diff --git a/src/routes/albums/all/+page.svelte b/src/routes/albums/all/+page.svelte new file mode 100644 index 0000000..8f2848a --- /dev/null +++ b/src/routes/albums/all/+page.svelte @@ -0,0 +1,38 @@ + + + + + + diff --git a/src/routes/albums/favourites/+page.svelte b/src/routes/albums/favourites/+page.svelte new file mode 100644 index 0000000..0b6938d --- /dev/null +++ b/src/routes/albums/favourites/+page.svelte @@ -0,0 +1,37 @@ + + + + + \ No newline at end of file diff --git a/src/routes/albums/most-played/+page.svelte b/src/routes/albums/most-played/+page.svelte new file mode 100644 index 0000000..80a60da --- /dev/null +++ b/src/routes/albums/most-played/+page.svelte @@ -0,0 +1,37 @@ + + + + + \ No newline at end of file diff --git a/src/routes/albums/random/+page.svelte b/src/routes/albums/random/+page.svelte new file mode 100644 index 0000000..0b502d9 --- /dev/null +++ b/src/routes/albums/random/+page.svelte @@ -0,0 +1,37 @@ + + + + + \ No newline at end of file diff --git a/src/routes/albums/recently-added/+page.svelte b/src/routes/albums/recently-added/+page.svelte new file mode 100644 index 0000000..737878c --- /dev/null +++ b/src/routes/albums/recently-added/+page.svelte @@ -0,0 +1,37 @@ + + + + + \ No newline at end of file diff --git a/src/routes/albums/recently-played/+page.svelte b/src/routes/albums/recently-played/+page.svelte new file mode 100644 index 0000000..62891a0 --- /dev/null +++ b/src/routes/albums/recently-played/+page.svelte @@ -0,0 +1,37 @@ + + + + + \ No newline at end of file diff --git a/src/routes/albums/top-rated/+page.svelte b/src/routes/albums/top-rated/+page.svelte new file mode 100644 index 0000000..5287df6 --- /dev/null +++ b/src/routes/albums/top-rated/+page.svelte @@ -0,0 +1,37 @@ + + + + + \ No newline at end of file