-

+
{{user?.name}}
@@ -40,12 +40,12 @@
diff --git a/frontend/src/app/private/private.component.ts b/frontend/src/app/private/private.component.ts
index 2239238..49c9b88 100644
--- a/frontend/src/app/private/private.component.ts
+++ b/frontend/src/app/private/private.component.ts
@@ -1,6 +1,7 @@
-import {NgModule, Component, OnInit} from '@angular/core';
+import {NgModule, Component, OnInit, Input} from '@angular/core';
import {ChatService} from "../services/chat/chat.service";
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
+import {AuthService} from "../services/auth/auth.service";
@Component({
@@ -9,11 +10,13 @@ import {FormsModule, ReactiveFormsModule} from "@angular/forms";
styleUrls: ['./private.component.scss']
})
export class PrivateComponent implements OnInit {
+
public userList = [
{
id: 1,
name: 'Yuki Vachot',
- phone: '0608020103',
+ login: 'yuki',
+ password: 'vachot1',
roomId: {
2: 'room-1',
3: 'room-2',
@@ -23,7 +26,8 @@ export class PrivateComponent implements OnInit {
{
id: 2,
name: 'Wilfried Vallee',
- phone: '0604080701',
+ login: 'wilfried',
+ password: 'vallee2',
roomId: {
1: 'room-1',
3: 'room-4',
@@ -33,7 +37,8 @@ export class PrivateComponent implements OnInit {
{
id: 3,
name: 'Khai Phan',
- phone: '0603050960',
+ login: 'khai',
+ password: 'phan3',
roomId: {
1: 'room-2',
2: 'room-4',
@@ -53,7 +58,7 @@ export class PrivateComponent implements OnInit {
public showScreen: boolean;
// @ts-ignore
- public phone: string;
+ public password: string;
// @ts-ignore
public currentUser;
// @ts-ignore
@@ -62,11 +67,13 @@ export class PrivateComponent implements OnInit {
constructor(
+ private Auth: AuthService,
private chatService: ChatService,
) {
-
-
+ this.currentUser = this.Auth.sendAuth(this.currentUser);
+ this.userList = this.userList.filter((user) => user.password !== this.currentUser.password.toString());
+ console.log(this.userList);
}
ngOnInit(): void {
@@ -86,8 +93,8 @@ export class PrivateComponent implements OnInit {
}
- selectUserHandler(phone: string): void {
- this.selectedUser = this.userList.find(user => user.phone === phone);
+ selectUserHandler(password: string): void {
+ this.selectedUser = this.userList.find(user => user.password === password);
this.roomId = this.selectedUser.roomId[this.currentUser.id];
this.messageArray = [];
@@ -140,4 +147,3 @@ export class PrivateComponent implements OnInit {
}
}
-
diff --git a/frontend/src/app/services/auth/auth.service.ts b/frontend/src/app/services/auth/auth.service.ts
index 4d12fa3..01ff8d9 100644
--- a/frontend/src/app/services/auth/auth.service.ts
+++ b/frontend/src/app/services/auth/auth.service.ts
@@ -8,29 +8,28 @@ import {Observable} from "rxjs";
})
export class AuthService {
- // @ts-ignore
+
// @ts-ignore
public roomId: string;
// @ts-ignore
- public messageText: string;
- public messageArray: {user: string, message: string}[] = [];
- private storageArray = [];
+ public name: string;
+ // @ts-ignore
+ public login: string;
// @ts-ignore
public showScreen: boolean;
// @ts-ignore
- public phone: string;
+ public password: string;
// @ts-ignore
public currentUser;
- // @ts-ignore
- public selectedUser;
public userList = [
{
id: 1,
name: 'Yuki Vachot',
- phone: '0608020103',
+ login: 'yuki',
+ password: 'vachot1',
roomId: {
2: 'room-1',
3: 'room-2',
@@ -40,7 +39,8 @@ export class AuthService {
{
id: 2,
name: 'Wilfried Vallee',
- phone: '0604080701',
+ login: 'wilfried',
+ password: 'vallee2',
roomId: {
1: 'room-1',
3: 'room-4',
@@ -50,7 +50,8 @@ export class AuthService {
{
id: 3,
name: 'Khai Phan',
- phone: '0603050960',
+ login: 'khai',
+ password: 'phan3',
roomId: {
1: 'room-2',
2: 'room-4',
@@ -60,20 +61,23 @@ export class AuthService {
];
constructor() {}
- sendAuthentication(phone: string): boolean {
- this.phone = phone;
- this.currentUser = this.userList.find(user => user.phone === this.phone.toString());
- this.userList = this.userList.filter((user) => user.phone !== this.phone.toString());
- //console.log("2 -", this.currentUser.phone);
- console.log("3 -", this.phone);
+
+ sendAuthentication(login:string, password: string): boolean {
+ this.login = login;
+ this.password = password;
+ this.currentUser = this.userList.find(user => user.password === this.password.toString());
+ this.userList = this.userList.filter((user) => user.password !== this.password.toString());
if(this.currentUser) {
this.showScreen = true;
- console.log("user : TRUE", this.phone.toString());
} else {
- console.log("error user", this.phone.toString());
+ console.log("Password Error", this.password.toString());
}
return this.showScreen ;
}
+ sendAuth(password: string): any {
+ this.password = password;
+ return this.currentUser ;
+ }
}
diff --git a/frontend/src/app/services/chat/chat.service.ts b/frontend/src/app/services/chat/chat.service.ts
index 5dd7852..7501961 100644
--- a/frontend/src/app/services/chat/chat.service.ts
+++ b/frontend/src/app/services/chat/chat.service.ts
@@ -35,6 +35,34 @@ export class ChatService {
});
}
+ newUserJoined()
+ {
+ let observable = new Observable<{user:String, message:String}>(observer=>{
+ this.socket.on('new user joined', (data)=>{
+ observer.next(data);
+ });
+ return () => {this.socket.disconnect();}
+ });
+
+ return observable;
+ }
+
+ // @ts-ignore
+ leaveRoom(data){
+ this.socket.emit('leave',data);
+ }
+
+ userLeftRoom(){
+ let observable = new Observable<{user:String, message:String}>(observer=>{
+ this.socket.on('left room', (data)=>{
+ observer.next(data);
+ });
+ return () => {this.socket.disconnect();}
+ });
+
+ return observable;
+ }
+
getStorage() {
const storage = localStorage.getItem('chats');
return storage ? JSON.parse(storage) : [];
diff --git a/frontend/src/assets/image/fond.png b/frontend/src/assets/image/fond.png
new file mode 100644
index 0000000..595581d
Binary files /dev/null and b/frontend/src/assets/image/fond.png differ
diff --git a/frontend/src/assets/image/user.png b/frontend/src/assets/image/user.png
index 595581d..3540bdc 100644
Binary files a/frontend/src/assets/image/user.png and b/frontend/src/assets/image/user.png differ