diff --git a/frontend/src/app/private/private.component.ts b/frontend/src/app/private/private.component.ts
index 49c9b88..b1a4812 100644
--- a/frontend/src/app/private/private.component.ts
+++ b/frontend/src/app/private/private.component.ts
@@ -2,6 +2,8 @@ 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";
+import {MessageService} from "../services/message/message.service";
+import {MatTableDataSource} from "@angular/material/table";
@Component({
@@ -11,42 +13,7 @@ import {AuthService} from "../services/auth/auth.service";
})
export class PrivateComponent implements OnInit {
- public userList = [
- {
- id: 1,
- name: 'Yuki Vachot',
- login: 'yuki',
- password: 'vachot1',
- roomId: {
- 2: 'room-1',
- 3: 'room-2',
- 4: 'room-3'
- }
- },
- {
- id: 2,
- name: 'Wilfried Vallee',
- login: 'wilfried',
- password: 'vallee2',
- roomId: {
- 1: 'room-1',
- 3: 'room-4',
- 4: 'room-5'
- }
- },
- {
- id: 3,
- name: 'Khai Phan',
- login: 'khai',
- password: 'phan3',
- roomId: {
- 1: 'room-2',
- 2: 'room-4',
- 4: 'room-6'
- }
- }
- ];
-
+ dataSource = new MatTableDataSource();
// @ts-ignore
public roomId: string;
// @ts-ignore
@@ -69,81 +36,88 @@ export class PrivateComponent implements OnInit {
constructor(
private Auth: AuthService,
private chatService: ChatService,
+ private MS: MessageService
) {
- 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 {
- this.chatService.getMessage()
- .subscribe((data: {user: string, message: string}) => {
- this.messageArray.push(data);
- if (this.roomId) {
- setTimeout( () => {
- this.storageArray = this.chatService.getStorage();
- //@ts-ignore
- const storeIndex = this.storageArray.findIndex((storage) => storage.roomId === this.roomId);
- //@ts-ignore
- this.messageArray = this.storageArray[storeIndex].chats;
- }, 500);
- }
- });
+ this.MS.sendMessage('Cours/CoursGet', {}).subscribe( send => {
+ console.log(send.data);
+ this.dataSource.data = send.data as userList[];
+ });
+
+ // this.chatService.getMessage()
+ // .subscribe((data: {user: string, message: string}) => {
+ // this.messageArray.push(data);
+ // if (this.roomId) {
+ // setTimeout( () => {
+ // this.storageArray = this.chatService.getStorage();
+ // //@ts-ignore
+ // const storeIndex = this.storageArray.findIndex((storage) => storage.roomId === this.roomId);
+ // //@ts-ignore
+ // this.messageArray = this.storageArray[storeIndex].chats;
+ // }, 500);
+ // }
+ // });
}
- selectUserHandler(password: string): void {
- this.selectedUser = this.userList.find(user => user.password === password);
- this.roomId = this.selectedUser.roomId[this.currentUser.id];
- this.messageArray = [];
-
- this.storageArray = this.chatService.getStorage();
- // @ts-ignore
- const storeIndex = this.storageArray.findIndex((storage) => storage.roomId === this.roomId);
-
- if (storeIndex > -1) {
- // @ts-ignore
- this.messageArray = this.storageArray[storeIndex].chats;
- }
-
- this.join(this.currentUser.name, this.roomId);
- }
+ // selectUserHandler(login: string): void {
+ // this.login = login;
+ // this.selectedUser = this.userList.find(user => user.password === password);
+ // this.roomId = this.selectedUser.roomId[this.currentUser.id];
+ // this.messageArray = [];
+ //
+ // // this.storageArray = this.chatService.getStorage();
+ // // // @ts-ignore
+ // // const storeIndex = this.storageArray.findIndex((storage) => storage.roomId === this.roomId);
+ // //
+ // // if (storeIndex > -1) {
+ // // // @ts-ignore
+ // // this.messageArray = this.storageArray[storeIndex].chats;
+ // // }
+ //
+ // this.join(this.login);
+ // }
join(username: string, roomId: string): void {
- this.chatService.joinRoom({user: username, room: roomId});
+ this.chatService.joinRoom({user: username});
}
sendMessage(): void {
this.chatService.sendMessage({
user: this.currentUser.name,
- room: this.roomId,
message: this.messageText
});
- this.storageArray = this.chatService.getStorage();
- // @ts-ignore
- const storeIndex = this.storageArray.findIndex((storage) => storage.roomId === this.roomId);
-
- if (storeIndex > -1) {
- // @ts-ignore
- this.storageArray[storeIndex].chats.push({
- user: this.currentUser.name,
- message: this.messageText
- })
- } else {
- const updateStorage = {
- roomId: this.roomId,
- chats: [{
- user: this.currentUser.name,
- message: this.messageText
- }]
- };
- // @ts-ignore
- this.storageArray.push(updateStorage);
- }
- this.chatService.setStorage(this.storageArray);
+ // this.storageArray = this.chatService.getStorage();
+ // // @ts-ignore
+ // const storeIndex = this.storageArray.findIndex((storage) => storage.roomId === this.roomId);
+ //
+ // if (storeIndex > -1) {
+ // // @ts-ignore
+ // this.storageArray[storeIndex].chats.push({
+ // user: this.currentUser.name,
+ // message: this.messageText
+ // })
+ // } else {
+ // const updateStorage = {
+ // roomId: this.roomId,
+ // chats: [{
+ // user: this.currentUser.name,
+ // message: this.messageText
+ // }]
+ // };
+ // // @ts-ignore
+ // this.storageArray.push(updateStorage);
+ // }
+ // this.chatService.setStorage(this.storageArray);
this.messageText = '';
}
}
+
+export interface userList {
+ login: string;
+}
diff --git a/frontend/src/app/services/auth/auth.service.ts b/frontend/src/app/services/auth/auth.service.ts
index 01ff8d9..a740fe4 100644
--- a/frontend/src/app/services/auth/auth.service.ts
+++ b/frontend/src/app/services/auth/auth.service.ts
@@ -1,5 +1,7 @@
import { Injectable } from '@angular/core';
import {Observable} from "rxjs";
+import {JSdata, MessageService} from "../message/message.service";
+import {HttpClient} from "@angular/common/http";
@@ -10,74 +12,31 @@ import {Observable} from "rxjs";
export class AuthService {
// @ts-ignore
- public roomId: string;
- // @ts-ignore
- public name: string;
- // @ts-ignore
- public login: string;
+ islog: boolean;
- // @ts-ignore
- public showScreen: boolean;
- // @ts-ignore
- public password: string;
- // @ts-ignore
- public currentUser;
+ constructor(
+ private http: HttpClient,
+ private MS: MessageService
+ ) {}
- public userList = [
- {
- id: 1,
- name: 'Yuki Vachot',
- login: 'yuki',
- password: 'vachot1',
- roomId: {
- 2: 'room-1',
- 3: 'room-2',
- 4: 'room-3'
- }
- },
- {
- id: 2,
- name: 'Wilfried Vallee',
- login: 'wilfried',
- password: 'vallee2',
- roomId: {
- 1: 'room-1',
- 3: 'room-4',
- 4: 'room-5'
- }
- },
- {
- id: 3,
- name: 'Khai Phan',
- login: 'khai',
- password: 'phan3',
- roomId: {
- 1: 'room-2',
- 2: 'room-4',
- 4: 'room-6'
- }
+ sendAuthentication(login: string, password: string): Observable {
+ const data = new FormData();
+ if (login !== null && login !== undefined && password !== null && password !== undefined) {
+ data.append(login, password);
}
- ];
-
- constructor() {}
-
- 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;
- } else {
- console.log("Password Error", this.password.toString());
- }
- return this.showScreen ;
+ return this.MS.sendMessage('checkLogin', {
+ login : login,
+ Password: password
+ });
}
- sendAuth(password: string): any {
- this.password = password;
- return this.currentUser ;
+ finalizeAuthentication(data: JSdata): void{
+ if (data.status === 'ok') {
+ this.islog = true;
+ } else {
+ this.islog = false;
+ }
}
}
diff --git a/frontend/src/environments/environment.ts b/frontend/src/environments/environment.ts
index f56ff47..4385f27 100644
--- a/frontend/src/environments/environment.ts
+++ b/frontend/src/environments/environment.ts
@@ -3,7 +3,8 @@
// The list of file replacements can be found in `angular.json`.
export const environment = {
- production: false
+ production: false,
+ urlCL: 'http://service-authentication:3000'
};
/*