diff --git a/web/src/lib/favorites.js b/web/src/lib/favorites.js index 8bdc015..16a8d42 100644 --- a/web/src/lib/favorites.js +++ b/web/src/lib/favorites.js @@ -1,8 +1,7 @@ -export async function AddFavorite() { - let name = document.getElementById("name")?.value; - let link = documnent.getElementById("link")?.value; +export async function AddFavorite(token) { + let name = document.getElementById("name").value; + let link = document.getElementById("link").value; let folder = document.getElementById("folder")?.value; - let token = document.getElementById("token")?.token; // Request let route = `https://gerry.thetipo.rocks/favorites` @@ -31,12 +30,9 @@ export async function AddFavorite() { } } -export async function RemoveFavorite() { - let name = document.getElementById("name")?.value; - let token = document.getElementById("token")?.value; - +export async function RemoveFavorite(token, name) { // Request - let route = `https://gerry.thetipo.rocks/favorites` + let route = `https://gerry.thetipo.rocks/favorites` + new URLSearchParams({'name': name, 'token': token}).toString(); let response = await fetch(route, { method: 'DELETE', headers: { @@ -60,26 +56,21 @@ export async function RemoveFavorite() { } } -export async function GetFavorites() { - let token = document.getElementById("token")?.value; - +export async function GetFavorites(token) { // Request - let route = `https://gerry.thetipo.rocks/favorites` + let route = `https://gerry.thetipo.rocks/favorites?` + new URLSearchParams({"token": token}).toString(); let response = await fetch(route, { method: "GET", headers: { 'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' }, - body: { - 'token': token, - }, }) // Error Handling switch(response.status) { case 200: - return 0; + return await response.json(); case 401: return -1; } diff --git a/web/src/lib/queue.js b/web/src/lib/queue.js index 9be1f27..1ea3cf7 100644 --- a/web/src/lib/queue.js +++ b/web/src/lib/queue.js @@ -1,18 +1,15 @@ // This file contains every function used in the queue.svelte component -export async function AddToQueue() { +export async function AddToQueue(GuildID, token) { // Values needed for adding a song to a queue - let GuildID = document.getElementById("id")?.value; - let song = document.getElementById("song")?.value; - let token = document.getElementById("token")?.value; + let song = document.getElementById("song").value; let shuffle; - let playlist = document.getElementById("playlist").value; - let loop = document.getElementById("loop").value; - let priority = document.getElementById("priority").value + let playlist = document.getElementById("playlist")?.checked; + let loop = document.getElementById("loop")?.checked; + let priority = document.getElementById("priority")?.checked if(playlist) { - shuffle = document.getElementById("shuffle").value; + shuffle = document.getElementById("shuffle")?.checked; } - // Request let route = `https://gerry.thetipo.rocks/queue/${GuildID}` let response = await fetch(route, { @@ -44,21 +41,15 @@ export async function AddToQueue() { } } -export async function RemoveFromQueue() { // AKA skip - let GuildID = document.getElementById("id")?.value; - let clear = document.getElementById("clear")?.value; - +export async function RemoveFromQueue(GuildID, token, clear=false) { // AKA skip // Request - let route = `https://gerry.thetipo.rocks/queue/${GuildID}` + let route = `https://gerry.thetipo.rocks/queue/${GuildID}` + new URLSearchParams({'clean': clear, 'token': token}).toString(); let response = await fetch(route, { method: "DELETE", headers: { 'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' }, - body: new URLSearchParams({ - 'clean': clear - }).toString(), }) // Error Handling diff --git a/web/src/lib/song.js b/web/src/lib/song.js index 4d3c2e4..8089aaa 100644 --- a/web/src/lib/song.js +++ b/web/src/lib/song.js @@ -1,22 +1,18 @@ -export async function ToggleSong(action = "") { - let GuildID = document.getElementById("id").value; - let token = document.getElementById("token").value; +// This file contains a function used in the queue.svelte component +export async function ToggleSong(GuildID, token, action = "") { // AKA Pause/Resume Song // Request - if(route === "") { + if(action === "") { return -8 } else { - let route = `https://gerry.thetipo.rocks/song/${action}/${GuildID}`; + let route = `https://gerry.thetipo.rocks/song/${action}/${GuildID}?` + new URLSearchParams({"token": token}).toString(); let response = await fetch(route, { method: "GET", headers: { 'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' }, - body: { - 'token': token, - }, }) // Error Handling diff --git a/web/src/routes/+layout.svelte b/web/src/routes/+layout.svelte index da212a0..1dcadb7 100644 --- a/web/src/routes/+layout.svelte +++ b/web/src/routes/+layout.svelte @@ -3,3 +3,5 @@ + + diff --git a/web/src/routes/+page.svelte b/web/src/routes/+page.svelte index 474f896..ecb7958 100644 --- a/web/src/routes/+page.svelte +++ b/web/src/routes/+page.svelte @@ -4,6 +4,9 @@ import { Tabs, TabItem} from "flowbite-svelte" import StarSolid from "flowbite-svelte-icons/StarSolid.svelte" import ListMusicSolid from "flowbite-svelte-icons/ListMusicSolid.svelte" + let GuildId = "very cool guild id"; + let token = "very cool token" + @@ -11,14 +14,14 @@ Queue - +
Favorites
- +
diff --git a/web/src/routes/favorites.svelte b/web/src/routes/favorites.svelte index 0912cdd..c7b90df 100644 --- a/web/src/routes/favorites.svelte +++ b/web/src/routes/favorites.svelte @@ -1,11 +1,66 @@ - -
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+ + + +
-
+{#await favorites} +

Loading Favorites

+{:then favorite} + {#if favorite.length != 0} +
+ Song Name + Link + Folder +
+ {#each favorite as song} +
+

{song.name}

+

{song.link}

+
+

{song.folder}

+ +
+ +
+ {/each} + {:else} +

You have no favorites

+ {/if} +{/await} diff --git a/web/src/routes/queue.svelte b/web/src/routes/queue.svelte index 9a70d22..e8cd216 100644 --- a/web/src/routes/queue.svelte +++ b/web/src/routes/queue.svelte @@ -2,30 +2,61 @@ import {Button} from "flowbite-svelte"; import {Avatar} from "flowbite-svelte" import {P, Heading, A} from "flowbite-svelte"; + import {Modal} from "flowbite-svelte"; + import {Input, Label, Checkbox} from "flowbite-svelte"; import { GetQueue, AddToQueue, RemoveFromQueue } from "../lib/queue"; + import { ToggleSong } from "../lib/song" import PlaySolid from "flowbite-svelte-icons/PlaySolid.svelte" import PauseSolid from "flowbite-svelte-icons/PauseSolid.svelte" - let queue = GetQueue("145618799947677696", "iAADRNu7eEfcHmcT9j9pbUsI4Rff7ihG"); + export let GuildId ; + export let token; + + let queue = GetQueue(GuildId, token); + let showModal = false; + let isPlaylist = false; + - + +
+
+
+ + +
+
+ (isPlaylist=!isPlaylist)} id="playlist">Playlist + Shuffle + Loop song + Priority +
+
+
+ + + +
+ {#await queue}

Fetching Queue

{:then json} +{#if json.length != 0}
- thumbnail -
-
-
+ thumbnail +
+
+

{json[0].title}

Requested by {json[0].user}

+
Queue @@ -38,6 +69,16 @@
{/if} {/each} +
+ +
+
+{:else} +

Queue is empty

+ +{/if} + {/await} + diff --git a/web/tailwind.config.cjs b/web/tailwind.config.cjs index b391a54..2b108ac 100644 --- a/web/tailwind.config.cjs +++ b/web/tailwind.config.cjs @@ -17,7 +17,7 @@ const config = { 400: '#FFBCAD', 500: '#FE795D', 600: '#EF562F', - 700: '#EB4F27', + 700: '#D38401', 800: '#CC4522', 900: '#A5371B' }