Merge branch 'master' into luke
This commit is contained in:
@@ -81,7 +81,7 @@
|
|||||||
- [/] leave room
|
- [/] leave room
|
||||||
- [/] leave direct impossible
|
- [/] leave direct impossible
|
||||||
- [/] protect room with password
|
- [/] protect room with password
|
||||||
- [ ] add and change password in room
|
- [/] add, change, and remove password in room
|
||||||
- [ ] make admin
|
- [ ] make admin
|
||||||
- [ ] ban
|
- [ ] ban
|
||||||
- [ ] mute
|
- [ ] mute
|
||||||
|
|||||||
@@ -123,19 +123,30 @@ export class ChatController {
|
|||||||
throw new HttpException({ error: true, code: 'FORBIDDEN_CHARACTERS', message: `Your room name can not contains these characters : ${forbidden_chars}` }, HttpStatus.UNPROCESSABLE_ENTITY);
|
throw new HttpException({ error: true, code: 'FORBIDDEN_CHARACTERS', message: `Your room name can not contains these characters : ${forbidden_chars}` }, HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for password protection
|
||||||
if (typeof room.protection === 'undefined')
|
if (typeof room.protection === 'undefined')
|
||||||
room.protection = false;
|
room.protection = false;
|
||||||
else if (room.protection === true)
|
else if (room.protection === true)
|
||||||
{
|
{
|
||||||
if (!room.password || room.password.length === 0)
|
if (!room.password || room.password.length === 0)
|
||||||
{
|
{
|
||||||
printCaller(`throw error: error: true, code: 'PASSWORD_TOO_SHORT', message: 'your password is too short'`);
|
printCaller(`throw error: error: true, code: 'PASSWORD_INVALID', message: 'your password is invalid'`);
|
||||||
throw new HttpException({ error: true, code: 'PASSWORD_TOO_SHORT', message: `your password is too short` }, HttpStatus.UNPROCESSABLE_ENTITY);
|
throw new HttpException({ error: true, code: 'PASSWORD_INVALID', message: `your password is invalid` }, HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
room.users = [req.user.username];
|
room.users = [req.user.username];
|
||||||
await this.chatService.addUserToNewRoom(req.user.username, room);
|
await this.chatService.addUserToNewRoom(req.user.username, room);
|
||||||
|
|
||||||
|
if (room.protection)
|
||||||
|
{
|
||||||
|
let message = `${req.user.username} changed the password`;
|
||||||
|
room.allowed_users = [req.user.username];
|
||||||
|
await this.chatService.setPassword(req.user.username, message, room);
|
||||||
|
let socket: socketDto = this.chatGateway.sockets.get(req.user.username);
|
||||||
|
await socket.to(socket.room).emit('message', "SERVER", message);
|
||||||
|
}
|
||||||
|
|
||||||
const ret_room = this.format_room(room);
|
const ret_room = this.format_room(room);
|
||||||
res.status(HttpStatus.OK).json({ room: ret_room });
|
res.status(HttpStatus.OK).json({ room: ret_room });
|
||||||
printCaller("- out ");
|
printCaller("- out ");
|
||||||
@@ -196,6 +207,7 @@ export class ChatController {
|
|||||||
|
|
||||||
let fields = ["protection", "allowed_users"];
|
let fields = ["protection", "allowed_users"];
|
||||||
const room_db = await this.chatService.getRoomByName(room.name, fields);
|
const room_db = await this.chatService.getRoomByName(room.name, fields);
|
||||||
|
|
||||||
if (room_db.protection === true)
|
if (room_db.protection === true)
|
||||||
{
|
{
|
||||||
if (!room_db.allowed_users.includes(req.user.username))
|
if (!room_db.allowed_users.includes(req.user.username))
|
||||||
@@ -216,8 +228,8 @@ export class ChatController {
|
|||||||
|
|
||||||
@UseGuards(AuthenticateGuard)
|
@UseGuards(AuthenticateGuard)
|
||||||
@UseGuards(TwoFactorGuard)
|
@UseGuards(TwoFactorGuard)
|
||||||
@Post('password')
|
@Post('passwordauth')
|
||||||
async setPassword(@Body() room: roomDto, @Req() req, @Res() res): Promise<void>
|
async passwordAuthentication(@Body() room: roomDto, @Req() req, @Res() res): Promise<void>
|
||||||
{
|
{
|
||||||
printCaller("- in ");
|
printCaller("- in ");
|
||||||
|
|
||||||
@@ -239,6 +251,69 @@ export class ChatController {
|
|||||||
printCaller("- out ");
|
printCaller("- out ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UseGuards(AuthenticateGuard)
|
||||||
|
@UseGuards(TwoFactorGuard)
|
||||||
|
@Post('changepassword')
|
||||||
|
async changePassword(@Body('room') room: roomDto, @Body('old_password') old_password: string, @Req() req, @Res() res): Promise<void>
|
||||||
|
{
|
||||||
|
printCaller("- in ");
|
||||||
|
|
||||||
|
let message = `${req.user.username} changed the password`;
|
||||||
|
room.allowed_users = [req.user.username];
|
||||||
|
room.protection = true;
|
||||||
|
await this.chatService.setPassword(req.user.username, message, room, old_password);
|
||||||
|
|
||||||
|
// inform other connected users
|
||||||
|
let socket: socketDto = this.chatGateway.sockets.get(req.user.username);
|
||||||
|
await socket.to(socket.room).emit('message', "SERVER", message);
|
||||||
|
|
||||||
|
const ret_room = this.format_room(room);
|
||||||
|
res.status(HttpStatus.OK).json({ room: ret_room });
|
||||||
|
printCaller("- out ");
|
||||||
|
}
|
||||||
|
|
||||||
|
@UseGuards(AuthenticateGuard)
|
||||||
|
@UseGuards(TwoFactorGuard)
|
||||||
|
@Post('addpassword')
|
||||||
|
async addPassword(@Body() room: roomDto, @Req() req, @Res() res): Promise<void>
|
||||||
|
{
|
||||||
|
printCaller("- in ");
|
||||||
|
|
||||||
|
let message = `${req.user.username} added a password`;
|
||||||
|
room.allowed_users = [req.user.username];
|
||||||
|
room.protection = true;
|
||||||
|
await this.chatService.setPassword(req.user.username, message, room);
|
||||||
|
|
||||||
|
// inform other connected users
|
||||||
|
let socket: socketDto = this.chatGateway.sockets.get(req.user.username);
|
||||||
|
await socket.to(socket.room).emit('message', "SERVER", message);
|
||||||
|
|
||||||
|
const ret_room = this.format_room(room);
|
||||||
|
res.status(HttpStatus.OK).json({ room: ret_room });
|
||||||
|
printCaller("- out ");
|
||||||
|
}
|
||||||
|
|
||||||
|
@UseGuards(AuthenticateGuard)
|
||||||
|
@UseGuards(TwoFactorGuard)
|
||||||
|
@Delete('removepassword')
|
||||||
|
async removePassword(@Body() room: roomDto, @Req() req, @Res() res): Promise<void>
|
||||||
|
{
|
||||||
|
printCaller("- in ");
|
||||||
|
|
||||||
|
let message = `${req.user.username} removed a new password`;
|
||||||
|
room.allowed_users = [];
|
||||||
|
room.protection = false;
|
||||||
|
await this.chatService.setPassword(req.user.username, message, room);
|
||||||
|
|
||||||
|
// inform other connected users
|
||||||
|
let socket: socketDto = this.chatGateway.sockets.get(req.user.username);
|
||||||
|
await socket.to(socket.room).emit('message', "SERVER", message);
|
||||||
|
|
||||||
|
const ret_room = this.format_room(room);
|
||||||
|
res.status(HttpStatus.OK).json({ room: ret_room });
|
||||||
|
printCaller("- out ");
|
||||||
|
}
|
||||||
|
|
||||||
@UseGuards(AuthenticateGuard)
|
@UseGuards(AuthenticateGuard)
|
||||||
@UseGuards(TwoFactorGuard)
|
@UseGuards(TwoFactorGuard)
|
||||||
@Post('invite')
|
@Post('invite')
|
||||||
@@ -302,6 +377,13 @@ 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;
|
||||||
|
|
||||||
|
let index = users.indexOf(req.user.username);
|
||||||
|
if (index > -1)
|
||||||
|
{
|
||||||
|
users.splice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
res.status(HttpStatus.OK).json({ users: users });
|
res.status(HttpStatus.OK).json({ users: users });
|
||||||
printCaller("- out ");
|
printCaller("- out ");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,6 +206,60 @@ export class ChatService {
|
|||||||
await this.chatroomRepository.save(room_db);
|
await this.chatroomRepository.save(room_db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async setPassword(username: string, message: string, room: roomDto, old_password?: string): Promise<void>
|
||||||
|
{
|
||||||
|
printCaller("-- in ");
|
||||||
|
|
||||||
|
if (room.type === 'direct')
|
||||||
|
{
|
||||||
|
console.log("throw error: error: true, code: 'DIRECT_PASSWORD_FORBIDDEN', message: 'you cannot set a password in a direct message room'");
|
||||||
|
throw new HttpException({ error: true, code: 'DIRECT_PASSWORD_FORBIDDEN', message: `you cannot set a password in a direct message room` }, HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
const current_room = await this.getRoomByName(room.name);
|
||||||
|
|
||||||
|
if (!room.password)
|
||||||
|
{
|
||||||
|
console.log("throw error: error: true, code: 'NO_PASSWORD', message: 'this room has no password protection'");
|
||||||
|
throw new HttpException({ error: true, code: 'NO_PASSWORD', message: `this room has no password protection` }, HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
if (current_room.protection)
|
||||||
|
{
|
||||||
|
if (room.protection && !old_password)
|
||||||
|
{
|
||||||
|
console.log("throw error: error: true, code: 'MISSING_OLD_PASSWORD', message: 'you need to provide the old password to set a new one'");
|
||||||
|
throw new HttpException({ error: true, code: 'MISSING_OLD_PASSWORD', message: `you need to provide the old password to set a new one` }, HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
if (old_password)
|
||||||
|
{
|
||||||
|
const is_match = await bcrypt.compare(old_password, current_room.hash);
|
||||||
|
if (!is_match)
|
||||||
|
{
|
||||||
|
printCaller(`throw error: error: true, code: 'BAD_PASSWORD', message: 'you provided a bad password'`);
|
||||||
|
throw new HttpException({ error: true, code: 'BAD_PASSWORD', message: `you provided a bad password` }, HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const saltOrRounds = 10;
|
||||||
|
const password = room.password;
|
||||||
|
let hash: string;
|
||||||
|
if (room.protection)
|
||||||
|
hash = await bcrypt.hash(password, saltOrRounds);
|
||||||
|
|
||||||
|
// add password to chatroom
|
||||||
|
current_room.allowed_users = room.allowed_users;
|
||||||
|
current_room.protection = room.protection;
|
||||||
|
if (room.protection)
|
||||||
|
current_room.hash = hash;
|
||||||
|
else
|
||||||
|
delete current_room.hash;
|
||||||
|
current_room.messages.push({ name: "SERVER", message: message });
|
||||||
|
await this.chatroomRepository.save(current_room);
|
||||||
|
|
||||||
|
printCaller("-- out ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ADDERS *************************************************
|
/* ADDERS *************************************************
|
||||||
*/
|
*/
|
||||||
@@ -221,19 +275,6 @@ export class ChatService {
|
|||||||
throw new HttpException({ error: true, code: 'ROOM_CONFLICT', message: `This room name already exist` }, HttpStatus.CONFLICT);
|
throw new HttpException({ error: true, code: 'ROOM_CONFLICT', message: `This room name already exist` }, HttpStatus.CONFLICT);
|
||||||
}
|
}
|
||||||
|
|
||||||
let hash;
|
|
||||||
if (room.protection)
|
|
||||||
{
|
|
||||||
if (room.type === 'direct')
|
|
||||||
{
|
|
||||||
console.log("throw error: error: true, code: 'DIRECT_PASSWORD_FORBIDDEN', message: 'you cannot set a password in a direct message room'");
|
|
||||||
throw new HttpException({ error: true, code: 'DIRECT_PASSWORD_FORBIDDEN', message: `you cannot set a password in a direct message room`}, HttpStatus.FORBIDDEN);
|
|
||||||
}
|
|
||||||
const saltOrRounds = 10;
|
|
||||||
const password = room.password;
|
|
||||||
hash = await bcrypt.hash(password, saltOrRounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create chatroom
|
// create chatroom
|
||||||
let newChatroom = new Chatroom();
|
let newChatroom = new Chatroom();
|
||||||
newChatroom.name = room.name;
|
newChatroom.name = room.name;
|
||||||
@@ -241,12 +282,7 @@ export class ChatService {
|
|||||||
newChatroom.owner = username;
|
newChatroom.owner = username;
|
||||||
newChatroom.users = room.users;
|
newChatroom.users = room.users;
|
||||||
newChatroom.allowed_users = [];
|
newChatroom.allowed_users = [];
|
||||||
newChatroom.protection = room.protection;
|
newChatroom.protection = false;
|
||||||
if (room.protection)
|
|
||||||
{
|
|
||||||
newChatroom.hash = hash;
|
|
||||||
newChatroom.allowed_users.push(username);
|
|
||||||
}
|
|
||||||
newChatroom.messages =
|
newChatroom.messages =
|
||||||
[
|
[
|
||||||
{ name: "SERVER", message: `creation of room ${room.name}` },
|
{ name: "SERVER", message: `creation of room ${room.name}` },
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
html, body {
|
html, body {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -12,11 +13,23 @@ body {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||||
/* tmp? */
|
/* tmp? */
|
||||||
background: bisque;
|
background-color: #333;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: "Bit5x3";
|
||||||
|
src:
|
||||||
|
url("./fonts/Bit5x3.woff2") format("woff2"),
|
||||||
|
local("Bit5x3"),
|
||||||
|
url("./fonts/Bit5x3.woff") format("woff");
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
font-display: swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: rgb(0,100,200);
|
color: rgb(0,100,200);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
@@ -30,6 +43,13 @@ a:visited {
|
|||||||
color: rgb(0,80,160);
|
color: rgb(0,80,160);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.background-pages {
|
||||||
|
background-color: #333;
|
||||||
|
font-family: "Bit5x3";
|
||||||
|
font-size: 2vw;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,26 @@
|
|||||||
<script>
|
<script>
|
||||||
import { link } from "svelte-spa-router";
|
import { link } from "svelte-spa-router";
|
||||||
|
import Header from '../pieces/Header.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1>We are sorry!</h1>
|
|
||||||
<p>This isn't a url that we use.</p>
|
<div class="background-pages">
|
||||||
<p>Go home you're drunk.</p>
|
<div class="content">
|
||||||
<a href="/" use:link>
|
<h1>We are sorry!</h1>
|
||||||
<h2>Take me home →</h2>
|
<p>This isn't a url that we use.</p>
|
||||||
</a>
|
<p>Go home you're drunk.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
|
||||||
|
.content {
|
||||||
|
left: 50%;
|
||||||
|
position: absolute;
|
||||||
|
-ms-transform: translateX(-50%);
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -78,8 +78,8 @@
|
|||||||
|
|
||||||
.button-in {
|
.button-in {
|
||||||
background-color: #8c0000;
|
background-color: #8c0000;
|
||||||
border-color: black;
|
border-color: #071013;
|
||||||
border-width: 4px;
|
border-width: 2px;
|
||||||
color: white;
|
color: white;
|
||||||
font-family: "Bit5x3";
|
font-family: "Bit5x3";
|
||||||
font-size: x-large;
|
font-size: x-large;
|
||||||
@@ -88,8 +88,8 @@
|
|||||||
|
|
||||||
.button-out {
|
.button-out {
|
||||||
background-color: #008c8c;
|
background-color: #008c8c;
|
||||||
border-color: black;
|
border-color: #071013;
|
||||||
border-width: 4px;
|
border-width: 2px;
|
||||||
color: white;
|
color: white;
|
||||||
font-family: "Bit5x3";
|
font-family: "Bit5x3";
|
||||||
font-size: x-large;
|
font-size: x-large;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
</script>
|
</script>
|
||||||
<Header />
|
<Header />
|
||||||
<br />
|
<br />
|
||||||
|
<div class="background-pages">
|
||||||
<div class="principal-div">
|
<div class="principal-div">
|
||||||
<table class="stats-table">
|
<table class="stats-table">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -59,6 +59,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
@@ -71,7 +72,6 @@
|
|||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
font-family: sans-serif;
|
|
||||||
min-width: 400px;
|
min-width: 400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
<Chat color="bisque"/>
|
<Chat color="bisque"/>
|
||||||
|
|
||||||
|
<div class="background-pages">
|
||||||
<div class="outer">
|
<div class="outer">
|
||||||
{#if user !== undefined}
|
{#if user !== undefined}
|
||||||
<GenerateUserDisplay user={user}/>
|
<GenerateUserDisplay user={user}/>
|
||||||
@@ -28,13 +29,13 @@
|
|||||||
<div>Failed to load current</div>
|
<div>Failed to load current</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
div.outer{
|
div.outer{
|
||||||
max-width: 960px;
|
max-width: 100%;
|
||||||
margin: 40px auto;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
padding-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -24,22 +24,10 @@
|
|||||||
|
|
||||||
onMount( async() => {
|
onMount( async() => {
|
||||||
|
|
||||||
// DO I ACTUALLY NEED TO ON MOUNT ALL THIS STUFF?
|
|
||||||
// ALSO I COULD JUST USE THE FUNCITONS I MADE...
|
|
||||||
|
|
||||||
|
|
||||||
// yea no idea what
|
|
||||||
// i mean do i fetch user? i will for now
|
|
||||||
user = await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/user`)
|
user = await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/user`)
|
||||||
.then( (x) => x.json() );
|
.then( (x) => x.json() );
|
||||||
|
|
||||||
fetchAll();
|
fetchAll();
|
||||||
// ok this shit works!
|
|
||||||
// const interval = setInterval(() => {
|
|
||||||
// fetchAll();
|
|
||||||
// }, 1000);
|
|
||||||
|
|
||||||
// return () => clearInterval(interval);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchAll = async() => {
|
const fetchAll = async() => {
|
||||||
@@ -234,6 +222,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="background-pages">
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
<div class="top-grid">
|
<div class="top-grid">
|
||||||
|
|
||||||
@@ -353,7 +342,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
/* ok so i want a 12 column grid with a sidebar */
|
/* ok so i want a 12 column grid with a sidebar */
|
||||||
@@ -368,7 +357,14 @@
|
|||||||
|
|
||||||
div.sidebar-list{
|
div.sidebar-list{
|
||||||
grid-column: 1 / span 2;
|
grid-column: 1 / span 2;
|
||||||
background: white;
|
background: #FB8B24;
|
||||||
|
padding: 1vw;
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
border-right: 4px solid #071013;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.sidebar-item{
|
div.sidebar-item{
|
||||||
@@ -393,7 +389,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
div.placeholder{
|
div.placeholder{
|
||||||
color: darkgray;
|
color: white;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +398,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
div.tip{
|
div.tip{
|
||||||
color: darkgray;
|
color: white;
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,6 +106,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
|
<div class="background-pages">
|
||||||
<h2>Look! You can change stuff</h2>
|
<h2>Look! You can change stuff</h2>
|
||||||
<div class="cards">
|
<div class="cards">
|
||||||
<Card>
|
<Card>
|
||||||
@@ -114,7 +115,7 @@
|
|||||||
<div class="label">New Username</div>
|
<div class="label">New Username</div>
|
||||||
<!-- it really hates {user.username} and ${user.username} -->
|
<!-- it really hates {user.username} and ${user.username} -->
|
||||||
<!-- <input type="text" placeholder="current username: ${user.username}" bind:value={set.username}> -->
|
<!-- <input type="text" placeholder="current username: ${user.username}" bind:value={set.username}> -->
|
||||||
<input type="text" placeholder="current username: {nameTmp}" bind:value={set.username}>
|
<input type="text" placeholder="{nameTmp}" bind:value={set.username}>
|
||||||
<div class="success">{success.username}</div>
|
<div class="success">{success.username}</div>
|
||||||
<div class="error">{errors.username}</div>
|
<div class="error">{errors.username}</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -144,7 +145,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|
||||||
@@ -158,6 +159,8 @@
|
|||||||
grid-gap: 20px; */
|
grid-gap: 20px; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
div.cards{
|
div.cards{
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
@@ -190,6 +193,7 @@
|
|||||||
|
|
||||||
.inline-check{
|
.inline-check{
|
||||||
display: inline;
|
display: inline;
|
||||||
|
color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,101 +21,84 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
<header>
|
<div class="header">
|
||||||
<img src="/img/potato_logo.png" alt="Potato Pong Logo" on:click={() => (push('/'))}>
|
<img src="/img/logo_potato.png" alt="Potato Pong Logo" on:click={() => (push('/'))}>
|
||||||
<h1>Potato Pong</h1>
|
<div class="center">
|
||||||
<nav>
|
|
||||||
<button class:selected="{current === '/game'}" on:click={() => (push('/game'))}>Play</button>
|
<button class:selected="{current === '/game'}" on:click={() => (push('/game'))}>Play</button>
|
||||||
<button class:selected="{current === '/spectator'}" on:click={() => (push('/spectator'))}>Spectate</button>
|
<button class:selected="{current === '/spectator'}" on:click={() => (push('/spectator'))}>Spectate</button>
|
||||||
<button class:selected="{current === '/ranking'}" on:click={() => (push('/ranking'))}>Ranking</button>
|
<button class:selected="{current === '/ranking'}" on:click={() => (push('/ranking'))}>Ranking</button>
|
||||||
<button class:selected="{current === '/profile'}" on:click={() => (push('/profile'))}>My Profile</button>
|
<button class:selected="{current === '/profile'}" on:click={() => (push('/profile'))}>My Profile</button>
|
||||||
<!-- <button class:selected="{current === '/profile/settings'}" on:click={() => (push('/profile/settings'))}>Settings</button> -->
|
|
||||||
<button class:selected="{current === '/profile/friends'}" on:click={() => (push('/profile/friends'))}>Friends</button>
|
<button class:selected="{current === '/profile/friends'}" on:click={() => (push('/profile/friends'))}>Friends</button>
|
||||||
<button on:click={handleClickLogout}>Log Out</button>
|
</div>
|
||||||
</nav>
|
<button class="logout" on:click={handleClickLogout}>Log Out</button>
|
||||||
</header>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* See "possible_fonts.css" for more font options... */
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'Bondi';
|
font-family: "Bit5x3";
|
||||||
src:url('/fonts/Bondi.ttf.woff') format('woff'),
|
src:
|
||||||
url('/fonts/Bondi.ttf.svg#Bondi') format('svg'),
|
url("/fonts/Bit5x3.woff2") format("woff2"),
|
||||||
url('/fonts/Bondi.ttf.eot'),
|
local("Bit5x3"),
|
||||||
url('/fonts/Bondi.ttf.eot?#iefix') format('embedded-opentype');
|
url("/fonts/Bit5x3.woff") format("woff");
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
|
font-display: swap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header div.center button.selected {
|
||||||
.selected {
|
|
||||||
background-color: chocolate;
|
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
/* TMP so it's obvious but we need to pick good colors */
|
background-color: #2B3A67;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header div.center button {
|
||||||
|
background-color: #8c0000;
|
||||||
|
border-color: #071013;
|
||||||
|
color: white;
|
||||||
|
font-family: "Bit5x3";
|
||||||
|
border-width: 2px;
|
||||||
|
font-size: 2vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* There is a bunch of unncessary shit in here... why so many flex grids, why is everything the same class? just seemed easier but... */
|
.header button.logout {
|
||||||
|
background-color: #008c8c;
|
||||||
|
border-color: #071013;
|
||||||
header{
|
color: white;
|
||||||
/* background: #f7f7f7; */
|
font-family: "Bit5x3";
|
||||||
background: #618174;
|
border-width: 2px;
|
||||||
/* padding: 20px; */
|
font-size: 2vw;
|
||||||
margin: 0;
|
|
||||||
/* does nothing so far... */
|
|
||||||
/* display: flex; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
header{
|
.header {
|
||||||
/* for some reason this doesn't do shit! */
|
resize: vertical;
|
||||||
position: sticky;
|
overflow: hidden;
|
||||||
/* position: absolute; */
|
background: #FB8B24;
|
||||||
display: grid;
|
box-sizing: border-box;
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
-moz-box-sizing: border-box;
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
border-bottom: 4px solid #071013;
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Headers */
|
.header div.center {
|
||||||
h1{
|
width: fit-content;
|
||||||
font-family: 'Bondi';
|
|
||||||
}
|
|
||||||
|
|
||||||
h1{
|
|
||||||
margin: 0;
|
|
||||||
text-align: left;
|
|
||||||
/* max-width: 40px; */
|
|
||||||
/* this helped with the weird extra space under the image... */
|
|
||||||
display: flex;
|
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
align-self: center;
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
display: inline-block;
|
||||||
|
-ms-transform: translateX(-50%);
|
||||||
|
transform: translateX(-50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Images */
|
.header button.logout {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
img{
|
.header img{
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
max-width: 40px;
|
max-width: 10%;
|
||||||
padding: 7px 20px;
|
float: left;
|
||||||
justify-self: left;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nav{
|
|
||||||
display: flex;
|
|
||||||
justify-content: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav button{
|
|
||||||
margin: 7px 20px;
|
|
||||||
/* padding: 5px; */
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* .none{
|
|
||||||
|
|
||||||
} */
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
import Layouts from './Chat_layouts.svelte';
|
import Layouts from './Chat_layouts.svelte';
|
||||||
import { init_socket } from './Socket_init';
|
import { init_socket } from './Socket_chat';
|
||||||
|
|
||||||
export let color = "transparent";
|
export let color = "transparent";
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
import Debug from './tmp_debug.svelte';
|
|
||||||
|
|
||||||
import { layout } from './Store_chat';
|
import { layout } from './Store_chat';
|
||||||
import ChatBox from './Chat_box_css.svelte';
|
import ChatBox from './Chat_box_css.svelte';
|
||||||
|
|
||||||
@@ -11,7 +9,7 @@
|
|||||||
import NewLayout from './Layout_new.svelte';
|
import NewLayout from './Layout_new.svelte';
|
||||||
import SettingsLayout from './Layout_settings.svelte';
|
import SettingsLayout from './Layout_settings.svelte';
|
||||||
import RoomsetLayout from './Layout_room_set.svelte';
|
import RoomsetLayout from './Layout_room_set.svelte';
|
||||||
import ProtectedLayout from './Layout_protected.svelte';
|
import PasswordLayout from './Layout_password.svelte';
|
||||||
import CreateLayout from './Layout_create.svelte';
|
import CreateLayout from './Layout_create.svelte';
|
||||||
import MuteLayout from './Layout_mute.svelte';
|
import MuteLayout from './Layout_mute.svelte';
|
||||||
import UserLayout from './Layout_user.svelte';
|
import UserLayout from './Layout_user.svelte';
|
||||||
@@ -68,8 +66,17 @@
|
|||||||
{:else if $layout === "room_set"}
|
{:else if $layout === "room_set"}
|
||||||
<RoomsetLayout back={layouts[1]} />
|
<RoomsetLayout back={layouts[1]} />
|
||||||
|
|
||||||
{:else if $layout === "protected"}
|
{:else if $layout === "password"}
|
||||||
<ProtectedLayout back={layouts[1]} />
|
<PasswordLayout back={layouts[1]} />
|
||||||
|
|
||||||
|
{:else if $layout === "add_password"}
|
||||||
|
<PasswordLayout back={layouts[1]} mode="add" />
|
||||||
|
|
||||||
|
{:else if $layout === "change_password"}
|
||||||
|
<PasswordLayout back={layouts[1]} mode="change" />
|
||||||
|
|
||||||
|
{:else if $layout === "remove_password"}
|
||||||
|
<PasswordLayout back={layouts[1]} mode="remove" />
|
||||||
|
|
||||||
{:else if $layout === "create"}
|
{:else if $layout === "create"}
|
||||||
<CreateLayout back={layouts[1]} />
|
<CreateLayout back={layouts[1]} />
|
||||||
@@ -87,8 +94,5 @@
|
|||||||
|
|
||||||
</ChatBox>
|
</ChatBox>
|
||||||
|
|
||||||
<!-- TMP DEBUG -->
|
|
||||||
<Debug bind:layouts />
|
|
||||||
|
|
||||||
<style></style>
|
<style></style>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
<Button
|
<Button
|
||||||
bind:layout
|
bind:layout
|
||||||
new_layout=""
|
new_layout=""
|
||||||
on_click={}
|
|
||||||
my_class=""
|
my_class=""
|
||||||
my_title=""
|
my_title=""
|
||||||
>
|
>
|
||||||
@@ -17,7 +16,6 @@
|
|||||||
export let my_class = "";
|
export let my_class = "";
|
||||||
export let my_title = "";
|
export let my_title = "";
|
||||||
export let new_layout = "";
|
export let new_layout = "";
|
||||||
export let on_click = "";
|
|
||||||
|
|
||||||
function update_layout() {
|
function update_layout() {
|
||||||
layout.set(new_layout);
|
layout.set(new_layout);
|
||||||
@@ -25,7 +23,7 @@
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button on:click={update_layout} on:click={on_click} title={my_title} class={my_class}>
|
<button on:click={update_layout} on:click title={my_title} class={my_class}>
|
||||||
<p><slot></slot></p>
|
<p><slot></slot></p>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
if (room.protection && !room.allowed)
|
if (room.protection && !room.allowed)
|
||||||
{
|
{
|
||||||
await current_room.set(room);
|
await current_room.set(room);
|
||||||
layout.set("protected");
|
layout.set("password");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
<p>rooms are loading...</p>
|
<p>rooms are loading...</p>
|
||||||
{:then rooms}
|
{:then rooms}
|
||||||
{#each rooms as room}
|
{#each rooms as room}
|
||||||
<Button my_class="list" on_click={function() {go_to_room(room)}}>
|
<Button my_class="list" on:click={function() {go_to_room(room)}}>
|
||||||
{room.client_name}
|
{room.client_name}
|
||||||
</Button>
|
</Button>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
<p>users are loading...</p>
|
<p>users are loading...</p>
|
||||||
{:then users}
|
{:then users}
|
||||||
{#each users as user}
|
{#each users as user}
|
||||||
<Button my_class="list" on_click={function() {invite_this_user(user.username)}}>
|
<Button my_class="list" on:click={function() {invite_this_user(user.username)}}>
|
||||||
{user.username}
|
{user.username}
|
||||||
</Button>
|
</Button>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
if (updated_room.protection)
|
if (updated_room.protection)
|
||||||
{
|
{
|
||||||
current_room.set(updated_room);
|
current_room.set(updated_room);
|
||||||
layout.set("protected");
|
layout.set("password");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await change_room(updated_room);
|
await change_room(updated_room);
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
<p>rooms are loading...</p>
|
<p>rooms are loading...</p>
|
||||||
{:then rooms}
|
{:then rooms}
|
||||||
{#each rooms as room}
|
{#each rooms as room}
|
||||||
<Button my_class="list" on_click={function() {join_rooms(room)}}>
|
<Button my_class="list" on:click={function() {join_rooms(room)}}>
|
||||||
{room.name}
|
{room.name}
|
||||||
</Button>
|
</Button>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
import { layout, current_room } from './Store_chat';
|
import { layout, current_room } from './Store_chat';
|
||||||
import { change_room, send_password } from './Request_rooms';
|
import { change_room, validate_password, change_password, add_password, remove_password } from './Request_rooms';
|
||||||
import { FetchResponse } from './Types_chat';
|
import { FetchResponse } from './Types_chat';
|
||||||
import Button from './Element_button.svelte';
|
import Button from './Element_button.svelte';
|
||||||
import Warning from './Element_warning.svelte';
|
import Warning from './Element_warning.svelte';
|
||||||
|
|
||||||
export let back = "";
|
export let back = "";
|
||||||
|
export let mode = "validate";
|
||||||
|
|
||||||
|
let password_state = "";
|
||||||
|
if (mode === 'change')
|
||||||
|
password_state = "new";
|
||||||
|
if (mode === 'remove')
|
||||||
|
password_state = "current";
|
||||||
|
|
||||||
let room_password: string;
|
let room_password: string;
|
||||||
|
let room_old_password: string;
|
||||||
let response: FetchResponse;
|
let response: FetchResponse;
|
||||||
let show_error = false;
|
let show_error = false;
|
||||||
|
|
||||||
@@ -24,12 +32,21 @@
|
|||||||
let room = {
|
let room = {
|
||||||
name: $current_room.name,
|
name: $current_room.name,
|
||||||
type: $current_room.type,
|
type: $current_room.type,
|
||||||
protection: true,
|
|
||||||
password: room_password,
|
password: room_password,
|
||||||
};
|
};
|
||||||
|
room.protection = true;
|
||||||
|
if (mode === 'remove')
|
||||||
|
room.protection = false;
|
||||||
|
|
||||||
// send password
|
// send password
|
||||||
response = await send_password(room);
|
if (mode === 'validate')
|
||||||
|
response = await validate_password(room);
|
||||||
|
if (mode === 'add')
|
||||||
|
response = await add_password(room);
|
||||||
|
if (mode === 'change')
|
||||||
|
response = await change_password(room, room_old_password);
|
||||||
|
if (mode === 'remove')
|
||||||
|
response = await remove_password(room);
|
||||||
|
|
||||||
// go to room
|
// go to room
|
||||||
if (response.status >= 300 || response.error)
|
if (response.status >= 300 || response.error)
|
||||||
@@ -49,7 +66,7 @@
|
|||||||
|
|
||||||
<!-- room_name -->
|
<!-- room_name -->
|
||||||
<Button my_class="room_name deactivate">
|
<Button my_class="room_name deactivate">
|
||||||
<room_name>
|
{$current_room.name}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<!-- close -->
|
<!-- close -->
|
||||||
@@ -57,14 +74,18 @@
|
|||||||
close
|
close
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<!-- panel_protected -->
|
<!-- panel_password -->
|
||||||
<div class="panel panel_protected __border_top">
|
<div class="panel panel_password __border_top">
|
||||||
<p class="title __center">this room is protected</p>
|
<p class="title __center">this room is protected</p>
|
||||||
<form on:submit|preventDefault={handleSubmit}>
|
<form on:submit|preventDefault={handleSubmit}>
|
||||||
{#if show_error}
|
{#if show_error}
|
||||||
<Warning content={response.message}/>
|
<Warning content={response.message}/>
|
||||||
{/if}
|
{/if}
|
||||||
<label for="chat_pswd"><p>enter password :</p></label>
|
{#if mode === 'change'}
|
||||||
|
<label for="chat_old_pswd"><p>enter old password :</p></label>
|
||||||
|
<input id="chat_old_pswd" bind:value={room_old_password} type="password" placeholder="minimum 8 characters" minlength="8" name="old_password" required>
|
||||||
|
{/if}
|
||||||
|
<label for="chat_pswd"><p>enter {password_state} password :</p></label>
|
||||||
<input id="chat_pswd" bind:value={room_password} type="password" placeholder="minimum 8 characters" minlength="8" name="password" required>
|
<input id="chat_pswd" bind:value={room_password} type="password" placeholder="minimum 8 characters" minlength="8" name="password" required>
|
||||||
<input type="submit" value="⮡">
|
<input type="submit" value="⮡">
|
||||||
</form>
|
</form>
|
||||||
@@ -74,16 +95,16 @@
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
/* grid layout "protected"
|
/* grid layout "password"
|
||||||
*/
|
*/
|
||||||
.grid_box :global(.back ) {grid-area: back;}
|
.grid_box :global(.back ) {grid-area: back;}
|
||||||
.grid_box :global(.room_name ) {grid-area: room_name;}
|
.grid_box :global(.room_name ) {grid-area: room_name;}
|
||||||
.grid_box :global(.close ) {grid-area: close;}
|
.grid_box :global(.close ) {grid-area: close;}
|
||||||
.grid_box :global(.panel_protected) {grid-area: panel_protected;}
|
.grid_box :global(.panel_password) {grid-area: panel_password;}
|
||||||
.grid_box {
|
.grid_box {
|
||||||
grid:
|
grid:
|
||||||
' back room_name close ' auto
|
' back room_name close ' auto
|
||||||
' panel_protected panel_protected panel_protected ' 1fr
|
' panel_password panel_password panel_password ' 1fr
|
||||||
/ auto 1fr auto ;
|
/ auto 1fr auto ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- send -->
|
<!-- send -->
|
||||||
<Button my_class="send" on_click={send_msg}>
|
<Button my_class="send" on:click={send_msg}>
|
||||||
send
|
send
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,11 @@
|
|||||||
|
|
||||||
let users = get_room_users();
|
let users = get_room_users();
|
||||||
|
|
||||||
|
console.log("current_room:", $current_room);
|
||||||
|
|
||||||
function user_profile()
|
function user_profile()
|
||||||
{
|
{
|
||||||
console/log("in user_profile");
|
console.log("in user_profile");
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_leave_room()
|
function user_leave_room()
|
||||||
@@ -42,13 +44,26 @@
|
|||||||
<!-- panel_room_set -->
|
<!-- panel_room_set -->
|
||||||
<div class="panel panel_room_set __border_top">
|
<div class="panel panel_room_set __border_top">
|
||||||
{#if $current_room.type !== "direct"}
|
{#if $current_room.type !== "direct"}
|
||||||
<Button on_click={user_leave_room}>
|
<Button on:click={user_leave_room}>
|
||||||
leave
|
leave
|
||||||
</Button>
|
</Button>
|
||||||
<Button new_layout="invite">
|
<Button new_layout="invite">
|
||||||
invite someone
|
invite someone
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/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}
|
||||||
<p>room users :</p>
|
<p>room users :</p>
|
||||||
<div class="room_users">
|
<div class="room_users">
|
||||||
<div class="__show_if_only_child">
|
<div class="__show_if_only_child">
|
||||||
@@ -58,7 +73,7 @@
|
|||||||
<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 new_layout="user" my_class="list" on_click={user_profile}>
|
<Button new_layout="user" my_class="list" on:click={user_profile}>
|
||||||
{user}
|
{user}
|
||||||
</Button>
|
</Button>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -60,14 +60,52 @@ console.log("room returned from change:", response.room);
|
|||||||
layout.set("room");
|
layout.set("room");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function validate_password(room: Room)
|
||||||
|
{
|
||||||
|
console.log("in validate_password");
|
||||||
|
|
||||||
export async function send_password(room: Room)
|
console.log("room sent to validate password:", room);
|
||||||
|
let response: FetchResponse = await fetch_chat_request('passwordauth', FetchMethod.POST, room);
|
||||||
|
console.log("room returned from validate password:", response.room);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function add_password(room: Room)
|
||||||
|
{
|
||||||
|
console.log("in add_password");
|
||||||
|
|
||||||
|
console.log("room sent to add password:", room);
|
||||||
|
let response: FetchResponse = await fetch_chat_request('addpassword', FetchMethod.POST, room);
|
||||||
|
console.log("room returned from add password:", response.room);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function change_password(room: Room, old_password: string)
|
||||||
{
|
{
|
||||||
console.log("in send_password");
|
console.log("in send_password");
|
||||||
|
|
||||||
console.log("room sent to set password:", room);
|
let request_body =
|
||||||
let response: FetchResponse = await fetch_chat_request('password', FetchMethod.POST, room);
|
{
|
||||||
console.log("room returned from set password:", response.room);
|
room: room,
|
||||||
|
old_password: old_password,
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("room sent to change password:", room);
|
||||||
|
let response: FetchResponse = await fetch_chat_request('changepassword', FetchMethod.POST, request_body);
|
||||||
|
console.log("room returned from change password:", response.room);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function remove_password(room: Room)
|
||||||
|
{
|
||||||
|
console.log("in send_password");
|
||||||
|
|
||||||
|
console.log("room sent to remove password:", room);
|
||||||
|
let response: FetchResponse = await fetch_chat_request('removepassword', FetchMethod.DELETE, room);
|
||||||
|
console.log("room returned from remove password:", response.room);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import io from 'socket.io-client';
|
import io from 'socket.io-client';
|
||||||
import { set_socket, set_user } from './Store_chat';
|
import { set_socket, set_user } from './Store_chat';
|
||||||
import { socket_events } from './Socket_events';
|
import { user, msgs } from './Store_chat';
|
||||||
|
|
||||||
const address = `http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}`;
|
const address = `http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}`;
|
||||||
|
|
||||||
@@ -21,6 +21,23 @@ export async function init_socket()
|
|||||||
});
|
});
|
||||||
set_socket(socket);
|
set_socket(socket);
|
||||||
|
|
||||||
|
socket_states(socket);
|
||||||
|
socket_events(socket);
|
||||||
|
}
|
||||||
|
|
||||||
|
function socket_events(socket)
|
||||||
|
{
|
||||||
|
socket.on('message', function(from, message)
|
||||||
|
{
|
||||||
|
console.log("received msg:", message, from);
|
||||||
|
if (from === user.username)
|
||||||
|
from = "me";
|
||||||
|
msgs.update(msgs => [...msgs, { name: from, message: message }]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function socket_states(socket)
|
||||||
|
{
|
||||||
socket.on('connect', function(){ console.log("socket.io connected"); });
|
socket.on('connect', function(){ console.log("socket.io connected"); });
|
||||||
socket.on('disconnect', function(){ console.log("socket.io disconnected"); });
|
socket.on('disconnect', function(){ console.log("socket.io disconnected"); });
|
||||||
socket.on('connect_error', function(){ console.log("socket.io connect_error"); });
|
socket.on('connect_error', function(){ console.log("socket.io connect_error"); });
|
||||||
@@ -33,7 +50,5 @@ export async function init_socket()
|
|||||||
socket.on('reconnect_failed', function(){ console.log("socket.io reconnect_failed"); });
|
socket.on('reconnect_failed', function(){ console.log("socket.io reconnect_failed"); });
|
||||||
socket.on('ping', function(){ console.log("socket.io ping"); });
|
socket.on('ping', function(){ console.log("socket.io ping"); });
|
||||||
socket.on('pong', function(){ console.log("socket.io pong"); });
|
socket.on('pong', function(){ console.log("socket.io pong"); });
|
||||||
|
|
||||||
socket_events(socket);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { user, msgs } from './Store_chat';
|
|
||||||
|
|
||||||
export function socket_events(socket)
|
|
||||||
{
|
|
||||||
socket.on('message', function(from, message)
|
|
||||||
{
|
|
||||||
console.log("received msg:", message, from);
|
|
||||||
if (from === user.username)
|
|
||||||
from = "me";
|
|
||||||
msgs.update(msgs => [...msgs, { name: from, message: message }]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -28,6 +28,6 @@ export enum FetchMethod
|
|||||||
{
|
{
|
||||||
POST = 'POST',
|
POST = 'POST',
|
||||||
GET = 'GET',
|
GET = 'GET',
|
||||||
LEAVE = 'LEAVE',
|
DELETE = 'DELETE',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
<script>
|
|
||||||
|
|
||||||
export let layout = "";
|
|
||||||
export let layouts = [];
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div style="display: flex; flex-direction: column; font-size: 12px; position: fixed; top: 20px; left: 20px; background-color: white;">
|
|
||||||
<p>temp, for testing :</p>
|
|
||||||
<button on:click={function(){layout = "close" }}>close</button>
|
|
||||||
<button on:click={function(){layout = "home" }}>home</button>
|
|
||||||
<button on:click={function(){layout = "room" }}>room</button>
|
|
||||||
<button on:click={function(){layout = "new" }}>new</button>
|
|
||||||
<button on:click={function(){layout = "settings" }}>settings</button>
|
|
||||||
<button on:click={function(){layout = "room_set" }}>room_set</button>
|
|
||||||
<button on:click={function(){layout = "protected"}}>protected</button>
|
|
||||||
<button on:click={function(){layout = "create" }}>create</button>
|
|
||||||
<button on:click={function(){layout = "mute" }}>mute</button>
|
|
||||||
<button on:click={function(){
|
|
||||||
layouts = ["settings", "settings"];
|
|
||||||
layout = "user";
|
|
||||||
}}>user from settings</button>
|
|
||||||
<button on:click={function(){
|
|
||||||
layouts = ["room_set", "room_set"];
|
|
||||||
layout = "user";
|
|
||||||
}}>user from room_set</button>
|
|
||||||
</div>
|
|
||||||
Reference in New Issue
Block a user