make admin ok
This commit is contained in:
@@ -164,6 +164,7 @@
|
||||
width: 20px;
|
||||
height: 2px;
|
||||
background-color: black;
|
||||
background-color: var(--lines_color);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
</Button>
|
||||
{/if}
|
||||
{#if is_admin === true }
|
||||
<p class="__center">you are admin in this room</p>
|
||||
{#if $current_room.protection }
|
||||
<p class="__center">this room is password protected</p>
|
||||
<Button new_layout="change_password">
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
|
||||
import { layout, current_room, settings_user } from './Store_chat';
|
||||
import { get_is_admin } from './Request_rooms';
|
||||
import { get_is_admin, make_admin } from './Request_rooms';
|
||||
import type { FetchResponse } from './Types_chat';
|
||||
import { to_print } from './Utils_chat';
|
||||
import Button from './Element_button.svelte';
|
||||
import { push } from "svelte-spa-router";
|
||||
import { invited_username } from '../store_invitation';
|
||||
import Warning from './Element_warning.svelte';
|
||||
|
||||
export let back = "";
|
||||
|
||||
@@ -15,6 +17,9 @@
|
||||
let is_admin = false;
|
||||
get_is_admin().then(response => is_admin = response);
|
||||
|
||||
let response: FetchResponse;
|
||||
let show_error = false;
|
||||
|
||||
function game_invitation()
|
||||
{
|
||||
to_print("in game_invitation");
|
||||
@@ -26,13 +31,18 @@
|
||||
{
|
||||
to_print("in view_profile");
|
||||
}
|
||||
function make_admin()
|
||||
async function make_user_admin()
|
||||
{
|
||||
to_print("in make_admin");
|
||||
to_print("in make_user_admin");
|
||||
response = await make_admin($settings_user);
|
||||
|
||||
//show errors
|
||||
if (response.status >= 300 || response.error)
|
||||
show_error = response.error;
|
||||
}
|
||||
function mute_user()
|
||||
async function ban_mute_user()
|
||||
{
|
||||
to_print("in mute_user");
|
||||
to_print("in ban_mute_user");
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -63,6 +73,9 @@
|
||||
|
||||
<!-- panel_user -->
|
||||
<div class="panel panel_user __border_top">
|
||||
{#if show_error}
|
||||
<Warning content={response.message}/>
|
||||
{/if}
|
||||
<p class="__center">user options :</p>
|
||||
<Button on:click={view_profile}>
|
||||
view profile
|
||||
@@ -72,10 +85,10 @@
|
||||
</Button>
|
||||
|
||||
{#if back === "room_set"}
|
||||
<Button on:click={make_admin}>
|
||||
<Button on:click={make_user_admin}>
|
||||
make admin
|
||||
</Button>
|
||||
<Button on:click={mute_user}>
|
||||
<Button on:click={ban_mute_user}>
|
||||
{mute}
|
||||
</Button>
|
||||
{/if}
|
||||
|
||||
@@ -165,6 +165,17 @@ export async function leave_room(): Promise<void>
|
||||
let response: FetchResponse = await fetch_chat_request('leave', FetchMethod.DELETE);
|
||||
}
|
||||
|
||||
export async function make_admin(username): Promise<boolean>
|
||||
{
|
||||
to_print("in is_admin");
|
||||
|
||||
to_print("username sent to setadmin:", username);
|
||||
let response: FetchResponse = await fetch_chat_request('setadmin', FetchMethod.POST, {username: username} );
|
||||
to_print("response from setadmin:", response);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function get_is_admin(): Promise<boolean>
|
||||
{
|
||||
to_print("in is_admin");
|
||||
|
||||
Reference in New Issue
Block a user