user admin visible
This commit is contained in:
@@ -412,14 +412,27 @@ export class ChatController {
|
|||||||
const room_name = await this.chatService.getCurrentRoomName(req.user.username);
|
const room_name = await this.chatService.getCurrentRoomName(req.user.username);
|
||||||
const room = await this.chatService.getRoomByName(room_name);
|
const room = await this.chatService.getRoomByName(room_name);
|
||||||
const users = room.users;
|
const users = room.users;
|
||||||
|
const admins = room.admins;
|
||||||
|
|
||||||
let index = users.indexOf(req.user.username);
|
let index = users.indexOf(req.user.username);
|
||||||
if (index > -1)
|
if (index > -1)
|
||||||
{
|
|
||||||
users.splice(index, 1);
|
users.splice(index, 1);
|
||||||
}
|
|
||||||
|
|
||||||
res.status(HttpStatus.OK).json({ users: users });
|
let ret_users = users.map(username =>
|
||||||
|
{
|
||||||
|
let new_user =
|
||||||
|
{
|
||||||
|
name: username,
|
||||||
|
isadmin: false,
|
||||||
|
};
|
||||||
|
if (admins.includes(username))
|
||||||
|
new_user.isadmin = true;
|
||||||
|
|
||||||
|
return new_user;
|
||||||
|
});
|
||||||
|
console.log("ret_user:", ret_users);
|
||||||
|
|
||||||
|
res.status(HttpStatus.OK).json({ users: ret_users });
|
||||||
printCaller("- out ");
|
printCaller("- out ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,5 +216,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* .admin
|
||||||
|
*/
|
||||||
|
.admin p {
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
.admin :global(span) {
|
||||||
|
margin-left: auto;
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
import { layout, current_room, settings_user } from './Store_chat';
|
import { layout, current_room, settings_user } from './Store_chat';
|
||||||
import { get_room_users, leave_room, get_is_admin } from './Request_rooms';
|
import { get_room_users, leave_room, get_is_admin } from './Request_rooms';
|
||||||
|
import { User } from './Types_chat';
|
||||||
import { to_print } from './Utils_chat';
|
import { to_print } from './Utils_chat';
|
||||||
import Button from './Element_button.svelte';
|
import Button from './Element_button.svelte';
|
||||||
|
|
||||||
export let back = "";
|
export let back = "";
|
||||||
|
|
||||||
let users = get_room_users();
|
let users: User[] = get_room_users();
|
||||||
let is_admin = false;
|
let is_admin = false;
|
||||||
get_is_admin().then(response => is_admin = response);
|
get_is_admin().then(response => is_admin = response);
|
||||||
|
|
||||||
@@ -81,8 +82,11 @@
|
|||||||
<p>list of users is loading...</p>
|
<p>list of users is loading...</p>
|
||||||
{:then users}
|
{:then users}
|
||||||
{#each users as user}
|
{#each users as user}
|
||||||
<Button my_class="list" on:click={function(){user_profile(user)}}>
|
<Button my_class="list admin" on:click={function(){user_profile(user)}}>
|
||||||
{user}
|
{user.name}
|
||||||
|
{#if user.isadmin }
|
||||||
|
<span>admin</span>
|
||||||
|
{/if}
|
||||||
</Button>
|
</Button>
|
||||||
{/each}
|
{/each}
|
||||||
{/await}
|
{/await}
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ export interface Message
|
|||||||
type: string;
|
type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface User
|
||||||
|
{
|
||||||
|
name: string;
|
||||||
|
isadmin: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface FetchResponse
|
export interface FetchResponse
|
||||||
{
|
{
|
||||||
status: number;
|
status: number;
|
||||||
@@ -21,7 +27,7 @@ export interface FetchResponse
|
|||||||
code?: string;
|
code?: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
messages?: Message[];
|
messages?: Message[];
|
||||||
users?: string[];
|
users?: User[];
|
||||||
room?: Room;
|
room?: Room;
|
||||||
rooms?: Room[];
|
rooms?: Room[];
|
||||||
is_admin?: boolean;
|
is_admin?: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user