wip protected room
This commit is contained in:
@@ -38,6 +38,8 @@
|
||||
name: room_name,
|
||||
type: room_type,
|
||||
};
|
||||
if (is_protected === true)
|
||||
room.password = room_password;
|
||||
// send the new room
|
||||
response = await create_room(room);
|
||||
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
console.log("room:", room);
|
||||
const updated_room = await join_room(room);
|
||||
console.log("updated room:", updated_room);
|
||||
await change_room(updated_room);
|
||||
if (room.protection)
|
||||
layout.set("protected");
|
||||
else
|
||||
await change_room(updated_room);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -1,10 +1,35 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
|
||||
import { layout } from './Store_chat';
|
||||
import { layout, current_room_name, current_room_type } from './Store_chat';
|
||||
import { change_room } from './Request_rooms';
|
||||
import Button from './Element_button.svelte';
|
||||
import Warning from './Element_warning.svelte';
|
||||
|
||||
export let back = "";
|
||||
|
||||
let room_password: string;
|
||||
let response = {
|
||||
status: 0,
|
||||
message: "",
|
||||
};
|
||||
|
||||
async function handleSubmit(evt)
|
||||
{
|
||||
let formIsValid = evt.target.checkValidity();
|
||||
|
||||
if (!formIsValid)
|
||||
return;
|
||||
|
||||
let room = {
|
||||
name: current_room_name,
|
||||
type: current_room_type,
|
||||
password: room_password,
|
||||
};
|
||||
|
||||
// go to room
|
||||
response = await change_room(room);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="grid_box">
|
||||
@@ -32,6 +57,17 @@
|
||||
<input id="chat_pswd" type="password" required>
|
||||
<input type="submit" value="⮡">
|
||||
</form>
|
||||
|
||||
<form on:submit|preventDefault={handleSubmit}>
|
||||
{#if response.status >= 300}
|
||||
<Warning content={response.message}/>
|
||||
{/if}
|
||||
<label for="chat_pswd"><p>enter password :</p></label>
|
||||
<input id="chat_pswd" bind:value={room_password} type="password" placeholder="minimum 8 characters" minlength="8" name="password" required>
|
||||
<input type="submit" value="⮡">
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -76,7 +76,6 @@ export async function change_room(room: Room)
|
||||
{
|
||||
console.log("in change_room");
|
||||
|
||||
console.log("room:", room);
|
||||
const response = await fetch('/api/v2/chat/change', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -112,7 +111,10 @@ export async function get_my_rooms()
|
||||
console.log("in get_my_rooms");
|
||||
|
||||
const response = await fetch('/api/v2/chat/myrooms');
|
||||
console.log("response.status", response.status);
|
||||
const data = await response.json();
|
||||
console.log("data:", data);
|
||||
|
||||
let rooms = data.rooms.map(room => set_client_name_on_room(room));
|
||||
console.log("rooms:", rooms);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user