diff --git a/README.md b/README.md index 84edd62..65f5fc8 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,3 @@ -# ChillBox +# team-1 -> *A project by Pausetta.org, Simone Tesini, Francesco De Carlo, Leonardo Segala, Matteo Peretto* - -**ChillBox** is a web app that lets you create a shared radio station with a democratic voting system, so everyone gets to enjoy their favorite music together. -Perfect for venues like swimming pools, cafΓ©s, or even lively parties. - ---- - -## π΅ Voting System - -Joining a ChillBox room is easy: users can either scan the QR code displayed on the host screen or use GPS to find nearby rooms. -Hosts can set a location range, ensuring only people physically present can add or vote for songs. - ---- - -## π Ranking Algorithm - -ChillBox uses a smart ranking algorithm to decide what plays next. The score of each song is based on: - -* Votes from users -* How recently similar songs (same genre or artist) have been played (less = better) -* A bit of randomness to keep things interesting -* A strong penalty for songs played too recently - ---- - -## π Hands-Off Experience - -ChillBox is designed to be almost entirely hands-free. -Once the host sets up a room and optionally connects a screen or projector -(to show the current track, QR code, etc.), ChillBox takes care of the rest. - -ChillBox comes with built-in automatic moderation to keep the music fair and on-theme. - -* Users canβt vote for the same song multiple times. -* A cooldown prevents users from spamming song requests. -* Hosts can define preferred genres and overall mood, so no one can hijack your chill beach vibes with unexpected death metal. - -That said, hosts still have access to essential controls, like pause and skip, if needed. +Test diff --git a/SPEECH.md b/SPEECH.md deleted file mode 100644 index 2ab507f..0000000 --- a/SPEECH.md +++ /dev/null @@ -1,15 +0,0 @@ -# speech - -## Home screen -We start here in the home page. -We can see this little radar animation, which means that the app is looking for nearby ChillBox rooms to join. -It uses GPS for this feature. - -## Join room -When we join a room, the server checks our location and checks if it's within a specified range. -That way, you must physically be in the location to actually be able to add new songs - -## Talk about the host -As you can see here (and hear) on the left, the host is already playing some music. -Now i will add a song on the client side and it will pop up in the list. - diff --git a/backend/src/app.py b/backend/src/app.py index 28c66e9..0fc9f9d 100644 --- a/backend/src/app.py +++ b/backend/src/app.py @@ -29,9 +29,9 @@ init_db(state.db) state.rooms[1000] = Room( id=1000, coord=Coordinates(46.6769043, 11.1851585), - name="Lido Scena", - pin=1234, - tags=set(["chill", "raggaetton", "spanish", "latino", "mexican", "rock"]), + name="Test Room", + pin=None, + tags=set(), range_size=150, songs={}, history=[], @@ -73,7 +73,7 @@ def on_leave(data): @app.get("/api/join") def join(): room_id = request.args.get("room") - code = request.args.get("pin") + code = request.args.get("code") if room_id is None: return error("Missing room id") @@ -81,11 +81,8 @@ def join(): if (room := state.rooms.get(int(room_id))) is None: return error("Invalid room") - if room.pin is not None: - if code is None: - return error("Missing code") - if int(room.pin) != int(code): - return error("Invalid code") + if room.pin is not None and room.pin != code: + return error("Invalid code") distance = distance_between_coords( lhs=room.coord, diff --git a/frontend/src/lib/components/RoomComponent.svelte b/frontend/src/lib/components/RoomComponent.svelte index 0192683..4e742db 100644 --- a/frontend/src/lib/components/RoomComponent.svelte +++ b/frontend/src/lib/components/RoomComponent.svelte @@ -1,45 +1,19 @@ -
+- {errorMsg} -
diff --git a/frontend/src/lib/components/SuggestionList.svelte b/frontend/src/lib/components/SuggestionList.svelte index 6c667a3..6f5d649 100644 --- a/frontend/src/lib/components/SuggestionList.svelte +++ b/frontend/src/lib/components/SuggestionList.svelte @@ -7,8 +7,9 @@ let picked_suggestions: string[] = $state([]) - async function vote(amount: number, songId: string) { + async function vote(idx: number, amount: number, songId: string) { if (picked_suggestions.includes(songId)) return console.log("rejecting vote") + suggestions[idx].upvote += amount await fetch(`/api/song/voting?room=${roomId}&song=${songId}&increment=${amount}`, { method: "POST" }) picked_suggestions.push(songId) console.log("accepted vote") @@ -25,7 +26,7 @@No suggestions yet! Try to add a new one using the Add button
{/if} - {#each suggestions as sug} + {#each suggestions as sug, idx} diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index 470da85..6450247 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -1,8 +1,8 @@ -import { type Coordinates } from "./gps" +import { get_coords, type Coordinates } from "./gps" import { parseSong, parseSuggestion, type FetchError, type Song, type Suggestion } from "./types" -export const joinRoom = async function (roomId: string, coords: Coordinates, pin: string): Promise<[FetchError | null, string]> { - let res = await fetch(`/api/join?room=${roomId}&lat=${coords.latitude}&lon=${coords.longitude}&pin=${pin}`) +export const joinRoom = async function (roomId: string, coords: Coordinates): Promise<[FetchError | null, string]> { + let res = await fetch(`/api/join?room=${roomId}&lat=${coords.latitude}&lon=${coords.longitude}`) if (res.status != 200) { return [{ code: 400, message: "Cannot join the room" }, ""] diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index b0b35bf..e8fb789 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -23,12 +23,12 @@ ChillBox -