interaction blocked users and view profile ok, still block message todo
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
lines_width: "1px",
|
||||
lines_color: "rgb(30, 30, 30)",
|
||||
lines_light_color: "rgb(70, 70, 70)",
|
||||
bg_color: "rgb(251, 156, 81)",
|
||||
bg_color: "rgb(251, 139, 36)",
|
||||
bg_light_color: "rgb(251, 156, 81)",
|
||||
|
||||
btn_color: "rgb(220, 220, 220)",
|
||||
@@ -28,6 +28,8 @@
|
||||
chat_other_color: "rgb(250, 250, 250)",
|
||||
chat_other_bg_color: "rgb(190, 130, 70)",
|
||||
chat_serveur_color: "rgb(110, 110, 110)",
|
||||
chat_msg_bg_color: "rgb(251, 163, 80)",
|
||||
chat_conv_bg_color: "rgb(251, 163, 80)",
|
||||
}
|
||||
let style_dark =
|
||||
{
|
||||
@@ -53,6 +55,8 @@
|
||||
chat_other_color: "rgb( 90, 90, 90)",
|
||||
chat_other_bg_color: "rgb(210, 210, 210)",
|
||||
chat_serveur_color: "rgb(190, 190, 190)",
|
||||
chat_msg_bg_color: "rgb( 82, 82, 82)",
|
||||
chat_conv_bg_color: "rgb( 82, 82, 82)",
|
||||
}
|
||||
|
||||
let style = style_light;
|
||||
@@ -102,6 +106,8 @@
|
||||
--chat_other_color={style.chat_other_color}
|
||||
--chat_other_bg_color={style.chat_other_bg_color}
|
||||
--chat_serveur_color={style.chat_serveur_color}
|
||||
--chat_msg_bg_color={style.chat_msg_bg_color}
|
||||
--chat_conv_bg_color={style.chat_conv_bg_color}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
background-color: var(--bg_color);
|
||||
background-color: var(--chat_msg_bg_color);
|
||||
border: var(--lines_width) solid var(--lines_color);
|
||||
}
|
||||
.grid_box .text_area {
|
||||
@@ -132,6 +132,7 @@
|
||||
.grid_box .panel_msg {
|
||||
flex-direction: column-reverse;
|
||||
border: var(--lines_width) solid var(--lines_color);
|
||||
background-color: var(--chat_conv_bg_color);
|
||||
}
|
||||
.grid_box .msg_thread {
|
||||
width: 100%;
|
||||
|
||||
@@ -9,15 +9,16 @@
|
||||
export let back = "";
|
||||
|
||||
let users: User[] = get_room_users();
|
||||
|
||||
let is_admin = false;
|
||||
get_is_admin().then(response => is_admin = response);
|
||||
|
||||
to_print("current_room:", $current_room);
|
||||
|
||||
function user_profile(username: string)
|
||||
function user_profile(room_user: string)
|
||||
{
|
||||
to_print("in user_profile");
|
||||
settings_user.set(username);
|
||||
settings_user.set(room_user);
|
||||
layout.set("user");
|
||||
}
|
||||
|
||||
@@ -82,7 +83,7 @@
|
||||
<p>list of users is loading...</p>
|
||||
{:then users}
|
||||
{#each users as user}
|
||||
<Button my_class="list admin" on:click={function(){user_profile(user.name)}}>
|
||||
<Button my_class="list admin {user.isblocked ? 'blocked' : ''}" on:click={function(){user_profile(user)}}>
|
||||
{user.name}
|
||||
{#if user.isadmin }
|
||||
<span>admin</span>
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
|
||||
import { layout } from './Store_chat';
|
||||
import { layout, settings_user } from './Store_chat';
|
||||
import { list_block_user } from './Request_rooms';
|
||||
import { User } from './Types_chat';
|
||||
import { to_print } from './Utils_chat';
|
||||
import Button from './Element_button.svelte';
|
||||
|
||||
export let back = "";
|
||||
|
||||
let users: User[] = list_block_user();
|
||||
|
||||
function user_profile(room_user: string)
|
||||
{
|
||||
to_print("in user_profile");
|
||||
settings_user.set(room_user);
|
||||
layout.set("user");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="grid_box">
|
||||
@@ -31,21 +43,15 @@
|
||||
<div class="__show_if_only_child">
|
||||
<p class="__center">/ you have blocked no one /</p>
|
||||
</div>
|
||||
<!-- placeholders
|
||||
<Button bind:layout new_layout="user" my_class="list blocked">
|
||||
user 1
|
||||
</Button>
|
||||
<Button bind:layout new_layout="user" my_class="list blocked">
|
||||
user 2
|
||||
</Button>
|
||||
<Button bind:layout new_layout="user" my_class="list blocked">
|
||||
user 3
|
||||
</Button>
|
||||
<Button bind:layout new_layout="user" my_class="list blocked">
|
||||
user 4
|
||||
</Button>
|
||||
------------- -->
|
||||
<!-- END placeholders -->
|
||||
{#await users}
|
||||
<p>list of users is loading...</p>
|
||||
{:then users}
|
||||
{#each users as user}
|
||||
<Button my_class="list blocked" on:click={function(){user_profile(user)}}>
|
||||
{user.name}
|
||||
</Button>
|
||||
{/each}
|
||||
{/await}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
|
||||
export let back = "";
|
||||
|
||||
let mute = "mute";
|
||||
let block = "block";
|
||||
|
||||
let is_admin = false;
|
||||
get_is_admin().then(response => is_admin = response);
|
||||
|
||||
@@ -23,30 +20,36 @@
|
||||
function game_invitation()
|
||||
{
|
||||
to_print("in game_invitation");
|
||||
const username = $settings_user;
|
||||
const username = $settings_user.name;
|
||||
invited_username.set(username);
|
||||
push("/game");
|
||||
}
|
||||
function view_profile()
|
||||
{
|
||||
to_print("in view_profile");
|
||||
push(`/profile/users/${$settings_user.name}`);
|
||||
}
|
||||
async function block_user()
|
||||
{
|
||||
to_print("in block_user");
|
||||
await set_block_user($settings_user);
|
||||
await set_block_user($settings_user.name);
|
||||
layout.set("room");
|
||||
}
|
||||
async function unblock_user()
|
||||
{
|
||||
to_print("in unblock_user");
|
||||
await remove_block_user($settings_user);
|
||||
await remove_block_user($settings_user.name);
|
||||
layout.set("room");
|
||||
}
|
||||
async function get_list_block_user()
|
||||
{
|
||||
to_print("in get_list_block_user");
|
||||
await list_block_user();
|
||||
}
|
||||
async function make_user_admin()
|
||||
{
|
||||
to_print("in make_user_admin");
|
||||
response = await make_admin($settings_user);
|
||||
response = await make_admin($settings_user.name);
|
||||
//show errors
|
||||
if (response.status >= 300 || response.error)
|
||||
show_error = response.error;
|
||||
@@ -64,7 +67,7 @@
|
||||
|
||||
<!-- user -->
|
||||
<Button my_class="user deactivate">
|
||||
{$settings_user}
|
||||
{$settings_user.name}
|
||||
</Button>
|
||||
|
||||
<!-- close -->
|
||||
@@ -91,19 +94,22 @@
|
||||
<Button on:click={game_invitation}>
|
||||
game invitation
|
||||
</Button>
|
||||
<Button on:click={block_user}>
|
||||
block
|
||||
</Button>
|
||||
<Button on:click={unblock_user}>
|
||||
unblock
|
||||
</Button>
|
||||
{#if $settings_user.isblocked}
|
||||
<Button on:click={unblock_user}>
|
||||
unblock
|
||||
</Button>
|
||||
{:else}
|
||||
<Button on:click={block_user}>
|
||||
block
|
||||
</Button>
|
||||
{/if}
|
||||
|
||||
{#if is_admin && back === "room_set" && $current_room.type !== "direct"}
|
||||
<Button on:click={make_user_admin}>
|
||||
make admin
|
||||
</Button>
|
||||
<Button new_layout="mute">
|
||||
{mute}
|
||||
mute
|
||||
</Button>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { msgs, user, layout, socket, current_room } from './Store_chat';
|
||||
import type { Room, FetchResponse } from './Types_chat';
|
||||
import { FetchMethod, Mute } from './Types_chat';
|
||||
import { FetchMethod, Mute, User } from './Types_chat';
|
||||
import { to_print } from './Utils_chat';
|
||||
import { fetch_chat_request, set_client_name_on_room, fill_fetch_response } from './Request_utils';
|
||||
|
||||
@@ -27,9 +27,9 @@ export async function create_room(room: Room)
|
||||
{
|
||||
to_print("in create_room");
|
||||
|
||||
to_print("room sent to create:", room);
|
||||
to_print("room sent to create:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('create', FetchMethod.POST, room);
|
||||
to_print("room returned from create:", response.room);
|
||||
to_print("room returned from create:", response.room);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -38,9 +38,9 @@ export async function join_room(room: Room)
|
||||
{
|
||||
to_print("in join_room");
|
||||
|
||||
to_print("room sent to join:", room);
|
||||
to_print("room sent to join:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('join', FetchMethod.POST, room);
|
||||
to_print("room returned from join:", response.room);
|
||||
to_print("room returned from join:", response.room);
|
||||
|
||||
return response.room;
|
||||
}
|
||||
@@ -49,9 +49,9 @@ export async function change_room(room: Room)
|
||||
{
|
||||
to_print("in change_room");
|
||||
|
||||
to_print("room sent to change:", room);
|
||||
to_print("room sent to change:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('change', FetchMethod.POST, room);
|
||||
to_print("room returned from change:", response.room);
|
||||
to_print("room returned from change:", response.room);
|
||||
|
||||
await get_room_messages();
|
||||
|
||||
@@ -65,9 +65,9 @@ export async function validate_password(room: Room)
|
||||
{
|
||||
to_print("in validate_password");
|
||||
|
||||
to_print("room sent to validate password:", room);
|
||||
to_print("room sent to validate password:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('passwordauth', FetchMethod.POST, room);
|
||||
to_print("room returned from validate password:", response.room);
|
||||
to_print("room returned from validate password:", response.room);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -76,9 +76,9 @@ export async function add_password(room: Room)
|
||||
{
|
||||
to_print("in add_password");
|
||||
|
||||
to_print("room sent to add password:", room);
|
||||
to_print("room sent to add password:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('addpassword', FetchMethod.POST, room);
|
||||
to_print("room returned from add password:", response.room);
|
||||
to_print("room returned from add password:", response.room);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -93,9 +93,9 @@ export async function change_password(room: Room, old_password: string)
|
||||
old_password: old_password,
|
||||
}
|
||||
|
||||
to_print("room sent to change password:", room);
|
||||
to_print("room sent to change password:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('changepassword', FetchMethod.POST, request_body);
|
||||
to_print("room returned from change password:", response.room);
|
||||
to_print("room returned from change password:", response.room);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -104,9 +104,9 @@ export async function remove_password(room: Room)
|
||||
{
|
||||
to_print("in send_password");
|
||||
|
||||
to_print("room sent to remove password:", room);
|
||||
to_print("room sent to remove password:", room);
|
||||
let response: FetchResponse = await fetch_chat_request('removepassword', FetchMethod.DELETE, room);
|
||||
to_print("room returned from remove password:", response.room);
|
||||
to_print("room returned from remove password:", response.room);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -140,11 +140,12 @@ export async function get_all_rooms()
|
||||
return response.rooms;
|
||||
}
|
||||
|
||||
export async function get_room_users()
|
||||
export async function get_room_users(): Promise<User[]>
|
||||
{
|
||||
to_print("in get_room_users");
|
||||
|
||||
let response: FetchResponse = await fetch_chat_request('roomusers', FetchMethod.GET);
|
||||
to_print("response from get_room_users:", response);
|
||||
|
||||
return response.users;
|
||||
}
|
||||
@@ -169,9 +170,9 @@ export async function make_admin(username): Promise<FetchResponse>
|
||||
{
|
||||
to_print("in is_admin");
|
||||
|
||||
to_print("username sent to setadmin:", username);
|
||||
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);
|
||||
to_print("response from setadmin:", response);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -181,9 +182,9 @@ export async function get_is_admin(): Promise<boolean>
|
||||
to_print("in is_admin");
|
||||
|
||||
let response: FetchResponse = await fetch_chat_request('isadmin', FetchMethod.GET);
|
||||
to_print("is_admin return:", response.is_admin);
|
||||
to_print("is_admin return:", response.condition);
|
||||
|
||||
return response.is_admin;
|
||||
return response.condition;
|
||||
}
|
||||
|
||||
export async function set_mute(date_limit: Date, username: string, time: string): Promise<FetchResponse>
|
||||
@@ -200,9 +201,9 @@ export async function set_mute(date_limit: Date, username: string, time: string)
|
||||
time: time,
|
||||
}
|
||||
|
||||
to_print("setmute send body:", body);
|
||||
to_print("setmute send body:", body);
|
||||
let response: FetchResponse = await fetch_chat_request('setmute', FetchMethod.POST, body );
|
||||
to_print("setmute return:", response);
|
||||
to_print("setmute return:", response);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -212,7 +213,7 @@ export async function get_is_mute(username: string): Promise<Mute>
|
||||
to_print("in get_is_mute");
|
||||
|
||||
let response: FetchResponse = await fetch_chat_request('ismute', FetchMethod.POST, {username: username} );
|
||||
to_print("ismute return:", response);
|
||||
to_print("ismute return:", response);
|
||||
|
||||
return response.mute;
|
||||
}
|
||||
@@ -238,3 +239,13 @@ export async function remove_block_user(username: string): Promise<void>
|
||||
await fetch_chat_request('unblock', FetchMethod.POST, {username: username} );
|
||||
}
|
||||
|
||||
export async function list_block_user(username: string): Promise<string>
|
||||
{
|
||||
to_print("in list_block_user");
|
||||
|
||||
let response = await fetch_chat_request('listblock', FetchMethod.GET);
|
||||
to_print("response.users:", response.users);
|
||||
|
||||
return response.users;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import type { Room, Message } from './Types_chat';
|
||||
import type { Room, Message, User } from './Types_chat';
|
||||
|
||||
export let msgs = writable([]);
|
||||
export let my_rooms = writable([]);
|
||||
export let all_rooms = writable([]);
|
||||
export let msgs = writable<Message[]>();
|
||||
export let my_rooms = writable<Room[]>();
|
||||
export let all_rooms = writable<Room[]>();
|
||||
export let current_room = writable<Room>();
|
||||
export let settings_user = writable<User>();
|
||||
export let layout = writable("close");
|
||||
export let current_room = writable({
|
||||
name: "",
|
||||
type: "",
|
||||
protection: false,
|
||||
});
|
||||
export let settings_user = writable("");
|
||||
|
||||
export let user;
|
||||
export let socket;
|
||||
|
||||
@@ -17,13 +17,14 @@ export interface Mute
|
||||
export interface Message
|
||||
{
|
||||
name: string;
|
||||
type: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface User
|
||||
{
|
||||
name: string;
|
||||
isadmin: boolean;
|
||||
isblocked: boolean;
|
||||
}
|
||||
|
||||
export interface FetchResponse
|
||||
@@ -36,7 +37,7 @@ export interface FetchResponse
|
||||
users?: User[];
|
||||
room?: Room;
|
||||
rooms?: Room[];
|
||||
is_admin?: boolean;
|
||||
condition?: boolean;
|
||||
mute?: Mute;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user