Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Teams Support #25

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion frontend/src/CreateRoom.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import Loading from './Loading.svelte';
import Button from "./Button.svelte";

let useTeams = false;
let teams = [];
let defaultTeams = ['Dev', 'QA'];
let observer = false;
let loading = false;
let name = '';
Expand All @@ -11,7 +14,7 @@
{
loading = true;

roomStore.create(name, observer);
roomStore.create(name, teams.length === 0 ? defaultTeams : teams, observer);
}

function handleKeyUp(event)
Expand All @@ -22,13 +25,33 @@
createRoom();
}
}

function teamsChanged()
{
teams = document.getElementById('teams').value().trim().split("\n");
}
</script>

{#if loading}
<Loading/>
{:else}
<input type="text" placeholder="Enter Your Name" bind:value={name} on:keyup={handleKeyUp}><br>

<label>
<input type="checkbox" name="teams" value="true" bind:checked={useTeams}>
Use Teams
</label>
{#if useTeams}

<textarea
id="teams"
name="teams"
rows="3"
placeholder={defaultTeams.join("\n")}
on:change={teamsChanged}
on:keyup={teamsChanged}
></textarea>
{/if}
<label>
<input type="checkbox" name="observer" value="true" bind:checked={observer}> Observer
</label>
Expand Down
19 changes: 13 additions & 6 deletions frontend/src/JoinRoom.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
<script>
import roomstore from './store/room';
import roomStore from './store/room';
import Loading from './Loading.svelte';
import Button from "./Button.svelte";
import {onMount} from "svelte";

export let room_id = "";

let loading = false;
let joiningRoom = false;
let name = '';
let observer = false;

$: roomInfoLoading = !($roomStore.id);

onMount(() => {
roomStore.fetchRoomInfo(room_id);
})

function joinRoom()
{
loading = true;
roomstore.join(room_id, name, observer);
joiningRoom = true;
roomStore.join(room_id, name, observer);
}

function handleKeyUp(event)
Expand All @@ -25,7 +32,7 @@
}
</script>

{#if loading}
{#if roomInfoLoading || joiningRoom}
<Loading/>
{:else}
<input type="text" placeholder="Enter Your Name" bind:value={name} on:keyup={handleKeyUp}><br>
Expand Down Expand Up @@ -95,4 +102,4 @@
.buttons {
margin-top: 2em;
}
</style>
</style>
2 changes: 1 addition & 1 deletion frontend/src/RoomControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
socket.addEventListener('message', function (event) {
const message = JSON.parse(event.data);

if ((message.action === 'roomsettingschanged' && message.data.votes_revealed === true) || message.action === 'votesreset') {
if ((message.action === 'roomupdate' && message.data.votes_revealed === true) || message.action === 'votesreset') {
disable_buttons = false;
}
});
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/store/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default (function () {
let room_id = "";
let saved_name = "";
let saved_observer = false;
let isProduction = true;

socket.addEventListener('message', function (event) {
const message = JSON.parse(event.data);
Expand All @@ -26,7 +27,7 @@ export default (function () {
join(message.data.room_id, saved_name, saved_observer);
break;

case 'roomsettingschanged':
case 'roomupdate':
room_id = message.data.room_id;

update((room) => {
Expand Down
2 changes: 1 addition & 1 deletion lambda/joinroom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ exports.handler = async (event) => {
ConnectionId: event.requestContext.connectionId,
Data: Buffer.from(JSON.stringify(
{
"action": "roomsettingschanged",
"action": "roomupdate",
"data": roomData
}
))
Expand Down
2 changes: 1 addition & 1 deletion lambda/revealvotes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ exports.handler = async (event) => {
ConnectionId: voter.voter_id,
Data: Buffer.from(JSON.stringify(
{
"action": "roomsettingschanged",
"action": "roomupdate",
"data": roomData
}
))
Expand Down