added is admin
This commit is contained in:
@@ -1,18 +1,22 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
|
||||
import { layout, current_room } from './Store_chat';
|
||||
import { get_room_users, leave_room } from './Request_rooms';
|
||||
import { layout, current_room, settings_user } from './Store_chat';
|
||||
import { get_room_users, leave_room, get_is_admin } from './Request_rooms';
|
||||
import Button from './Element_button.svelte';
|
||||
|
||||
export let back = "";
|
||||
|
||||
let users = get_room_users();
|
||||
let is_admin = false;
|
||||
get_is_admin().then(response => is_admin = response);
|
||||
|
||||
console.log("current_room:", $current_room);
|
||||
|
||||
function user_profile()
|
||||
function user_profile(username: string)
|
||||
{
|
||||
console.log("in user_profile");
|
||||
settings_user.set(username);
|
||||
layout.set("user");
|
||||
}
|
||||
|
||||
function user_leave_room()
|
||||
@@ -51,18 +55,20 @@
|
||||
invite someone
|
||||
</Button>
|
||||
{/if}
|
||||
{#if $current_room.protection }
|
||||
<p class="__center">this room is password protected</p>
|
||||
<Button new_layout="change_password">
|
||||
change password
|
||||
</Button>
|
||||
<Button new_layout="remove_password">
|
||||
remove password
|
||||
</Button>
|
||||
{:else}
|
||||
<Button new_layout="add_password">
|
||||
add password
|
||||
</Button>
|
||||
{#if is_admin === true }
|
||||
{#if $current_room.protection }
|
||||
<p class="__center">this room is password protected</p>
|
||||
<Button new_layout="change_password">
|
||||
change password
|
||||
</Button>
|
||||
<Button new_layout="remove_password">
|
||||
remove password
|
||||
</Button>
|
||||
{:else}
|
||||
<Button new_layout="add_password">
|
||||
add password
|
||||
</Button>
|
||||
{/if}
|
||||
{/if}
|
||||
<p>room users :</p>
|
||||
<div class="room_users">
|
||||
@@ -73,7 +79,7 @@
|
||||
<p>list of users is loading...</p>
|
||||
{:then users}
|
||||
{#each users as user}
|
||||
<Button new_layout="user" my_class="list" on:click={user_profile}>
|
||||
<Button my_class="list" on:click={function(){user_profile(user)}}>
|
||||
{user}
|
||||
</Button>
|
||||
{/each}
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
<script>
|
||||
|
||||
import { layout } from './Store_chat';
|
||||
import { layout, current_room, settings_user } from './Store_chat';
|
||||
import { get_is_admin } from './Request_rooms';
|
||||
import Button from './Element_button.svelte';
|
||||
import { push } from "svelte-spa-router";
|
||||
import { invited_username } from '../store_invitation';
|
||||
|
||||
export let back = "";
|
||||
|
||||
let mute = "mute";
|
||||
let block = "block";
|
||||
|
||||
import { push } from "svelte-spa-router";
|
||||
import { invited_username } from '../store_invitation';
|
||||
let is_admin = false;
|
||||
get_is_admin().then(response => is_admin = response);
|
||||
|
||||
function game_invitation()
|
||||
{
|
||||
const usernamePLACEHOLDER = "hulamy";
|
||||
invited_username.set(usernamePLACEHOLDER);
|
||||
const username = $settings_user;
|
||||
invited_username.set(username);
|
||||
push("/game");
|
||||
}
|
||||
|
||||
@@ -28,7 +32,7 @@
|
||||
|
||||
<!-- user -->
|
||||
<Button my_class="user deactivate">
|
||||
<user>
|
||||
{$settings_user}
|
||||
</Button>
|
||||
|
||||
<!-- close -->
|
||||
@@ -39,7 +43,7 @@
|
||||
<!-- room_name -->
|
||||
{#if back === "room_set"}
|
||||
<Button my_class="room_name deactivate __border_top">
|
||||
<room_name>
|
||||
{$current_room.name}
|
||||
</Button>
|
||||
{/if}
|
||||
|
||||
@@ -49,7 +53,7 @@
|
||||
<Button>
|
||||
view profile
|
||||
</Button>
|
||||
<Button on_click={() => game_invitation()}>
|
||||
<Button on:click={game_invitation}>
|
||||
game invitation
|
||||
</Button>
|
||||
<Button>
|
||||
|
||||
@@ -157,10 +157,20 @@ export async function get_all_users()
|
||||
return response.users;
|
||||
}
|
||||
|
||||
export async function leave_room()
|
||||
export async function leave_room(): Promise<void>
|
||||
{
|
||||
console.log("in leave_room");
|
||||
|
||||
let response: FetchResponse = await fetch_chat_request('leave', FetchMethod.DELETE);
|
||||
}
|
||||
|
||||
export async function get_is_admin(): Promise<boolean>
|
||||
{
|
||||
console.log("in is_admin");
|
||||
|
||||
let response: FetchResponse = await fetch_chat_request('isadmin', FetchMethod.GET);
|
||||
console.log("is_admin return:", response.is_admin);
|
||||
|
||||
return response.is_admin;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ export let current_room = writable({
|
||||
type: "",
|
||||
protection: false,
|
||||
});
|
||||
export let settings_user = writable("");
|
||||
|
||||
export let user;
|
||||
export let socket;
|
||||
|
||||
@@ -24,6 +24,7 @@ export interface FetchResponse
|
||||
users?: string[];
|
||||
room?: Room;
|
||||
rooms?: Room[];
|
||||
is_admin?: boolean;
|
||||
}
|
||||
|
||||
export interface FetchInit
|
||||
|
||||
Reference in New Issue
Block a user