diff --git a/backend/api/database7.db b/backend/api/database7.db index 83abb7d..3eb0c6a 100644 Binary files a/backend/api/database7.db and b/backend/api/database7.db differ diff --git a/frontend/src/components/exos/EditForm.svelte b/frontend/src/components/exos/EditForm.svelte index 982050d..b374b97 100644 --- a/frontend/src/components/exos/EditForm.svelte +++ b/frontend/src/components/exos/EditForm.svelte @@ -40,12 +40,14 @@ const exerciceStore = getContext<{ exerciceStore: any }>("exerciceStore"); const tagsStore = getContext<{ tagsStore: any }>("tagsStore"); const { navigate } = getContext<{ navigate: Function }>("navigation"); - const {success, error} = getContext<{ success: Function, error: Function }>("notif"); + const { success, error } = getContext<{ success: Function, error: Function }>("notif"); + let loading = false
{ + loading = true if (editing && exo != null) { editExo(exo.id_code, { name: $name.value, @@ -53,21 +55,25 @@ private: $prv.value, ...($model.dirty == true && { file: $model.value[0] }) }).then((r) => { + loading=false success('Exercice modifié !', `Exercice ${r.data.name} modifié avec succès !`) exo=r.data updateExo(r.data); cancel() }).catch((e) => { + loading=false console.log(e) error('Erreur', 'Une erreur est survenue lors de la modification de l\'exercice') }); } else { + createExo({ name: $name.value, consigne: $consigne.value, private: $prv.value, file: $model.value[0] }).then((r) => { + loading=false updateExo(r.data); success('Exercice créé !', `Exercice ${r.data.name} créé avec succès !`) goto(`/exercices/${r.data.id_code}`) @@ -84,6 +90,7 @@ }, true ); }).catch((e) => { + loading=false error('Erreur', 'Une erreur est survenue lors de la création de l\'exercice') }); } @@ -117,7 +124,13 @@ defaultValue={editing &&exo!= null? exo.exo_source: null} />
- +
{#if errors.length !== 0} diff --git a/frontend/src/components/rooms/Members.svelte b/frontend/src/components/rooms/Members.svelte index da2c9e2..e25cda8 100644 --- a/frontend/src/components/rooms/Members.svelte +++ b/frontend/src/components/rooms/Members.svelte @@ -12,7 +12,7 @@ const room: Writable = getContext("room"); const member: Writable = getContext("member"); const { send } = getContext<{ send: Function }>("ws"); - + const { alert } = getContext<{ alert: Function }>("alert"); $: online = $room != null ? $room.members.filter((r): r is Member => "online" in r && r.online == true) @@ -25,6 +25,16 @@ $room != null ? $room.members.filter((r): r is Waiter => "waiter_id" in r && !!r.waiter_id) : []; + const ban = (m: Member) => { + if (!$member.isAdmin || m.isAdmin) return; + alert( + { + title: "Bannir", description: "Êtes-vous sûr de vouloir bannir cet utilisateur ?", validate: () => { + send("ban", { member_id: m.id_code }); + }, validateButton: "Bannir" + } + ); + };
@@ -66,9 +76,7 @@ class:member={m.id_code == $member.id_code} class="online" title={$member.isAdmin && !m.isAdmin ? 'Bannir' : ''} - on:click={() => { - $member.isAdmin && !m.isAdmin && send('ban', { member_id: m.id_code }); - }} + on:click={(e)=>ban(m)} on:keydown={() => {}} > {m.username} @@ -90,9 +98,7 @@ class:bannable={m.id_code != $member.id_code && $member.isAdmin && !m.isAdmin} class:member={m.id_code == $member.id_code} title={$member.isAdmin && !m.isAdmin ? 'Bannir' : ''} - on:click={() => { - $member.isAdmin && !m.isAdmin && send('ban', { member_id: m.id_code }); - }} + on:click={(e)=>ban(m)} on:keydown={() => {}} > {m.username} diff --git a/frontend/src/routes/room/+page.svelte b/frontend/src/routes/room/+page.svelte index a8e81bb..f48720e 100644 --- a/frontend/src/routes/room/+page.svelte +++ b/frontend/src/routes/room/+page.svelte @@ -1,6 +1,7 @@
@@ -26,4 +27,5 @@ display: flex; gap: 20px; } + \ No newline at end of file diff --git a/frontend/src/routes/room/[...slug]/+page.svelte b/frontend/src/routes/room/[...slug]/+page.svelte index 8899508..004ff5c 100644 --- a/frontend/src/routes/room/[...slug]/+page.svelte +++ b/frontend/src/routes/room/[...slug]/+page.svelte @@ -102,6 +102,7 @@ return; } if ($room != null) { + info("Départ", `*${data.member.username}* n'est plus dans la salle`); $room.members = [ ...$room.members.filter((r) => "waiter_id" in r || r.id_code != data.member.id_code) ]; @@ -211,6 +212,7 @@ case "joined": if ($room != null) { + info("Arrivée", `*${data.member.username}* a rejoint la salle`) $room.members = [ ...$room?.members.filter( (m) => @@ -358,6 +360,7 @@ $parcours.validated = $parcours.pb.mistakes <= $parcours.max_mistakes; } } + return case "challenge_change": if ($parcours != null && $member != null && !!$parcours.challenges[data.member]) { $parcours.challenges[data.member].challenges = $parcours.challenges[ @@ -447,6 +450,7 @@ $: console.log("edit", $page.url.searchParams.get("a")); onDestroy(() => { + ws.close(1000); }); diff --git a/frontend/src/routes/room/create/+page.svelte b/frontend/src/routes/room/create/+page.svelte index b103dd0..15bf8d6 100644 --- a/frontend/src/routes/room/create/+page.svelte +++ b/frontend/src/routes/room/create/+page.svelte @@ -7,6 +7,8 @@ let name = ""; let pseudo = ""; const { isAuth } = getContext("auth"); + let loading = false; + const { error } = getContext("notif");
@@ -20,15 +22,27 @@ class="primary-btn" on:click={() => { console.log('(NAME)', name) + loading = true createRoom({ name }, !$isAuth ? pseudo : null).then((r) => { + if(!$isAuth){ sessionStorage.setItem('reconnect', r.member) } goto(`/room/${r.room}`); - }); + loading= false + }).catch((e) => { + error("Erreur", "Une erreur est survenue lors de la création de la salle") + loading= false + console.log(e); + }); }} > - Valider + {#if loading} + + {:else} + Créer + {/if} +
@@ -51,4 +65,10 @@ display: flex; justify-content: center; } + + .spinner { + width: 15px; + height: 15px; + border-width: 2px !important; + } diff --git a/frontend/src/routes/room/join/+page.svelte b/frontend/src/routes/room/join/+page.svelte index cb62362..a595325 100644 --- a/frontend/src/routes/room/join/+page.svelte +++ b/frontend/src/routes/room/join/+page.svelte @@ -4,7 +4,6 @@ let room = ""; -
diff --git a/frontend/src/routes/signin/+page.svelte b/frontend/src/routes/signin/+page.svelte index 0f1792d..04b7c10 100644 --- a/frontend/src/routes/signin/+page.svelte +++ b/frontend/src/routes/signin/+page.svelte @@ -11,6 +11,7 @@ $: { !$initialLoading && !!$isAuth && goto('/dashboard'); } + let loading = false
@@ -37,13 +38,19 @@
@@ -65,4 +72,9 @@ gap: 20px; } } + .spinner{ + width: 15px; + height: 15px; + border-width: 2px!important; + } diff --git a/frontend/src/routes/signup/+page.svelte b/frontend/src/routes/signup/+page.svelte index 059ba95..6d04d24 100644 --- a/frontend/src/routes/signup/+page.svelte +++ b/frontend/src/routes/signup/+page.svelte @@ -18,6 +18,7 @@ const myForm = form(username, password, confirm); $: !$initialLoading && !!$isAuth && goto('/dashboard'); + let loading = false
@@ -62,7 +63,9 @@
@@ -92,4 +100,9 @@ gap: 20px; } } + .spinner{ + width: 15px; + height: 15px; + border-width: 2px!important; + } diff --git a/frontend/src/store/ws.ts b/frontend/src/store/ws.ts index 54e7e0b..fb3113c 100644 --- a/frontend/src/store/ws.ts +++ b/frontend/src/store/ws.ts @@ -9,7 +9,6 @@ export const connect = (url,) => { const ws = new ReconnectingWebSocket(url); ws.onmessage = (m) => { - console.log('MESAGE', m) messages.update((o) => [JSON.parse(m.data), ...o]); Object.values(get(handlers)).map(h => {