diff --git a/frontend/src/app/change-password/change-password.component.html b/frontend/src/app/change-password/change-password.component.html
new file mode 100644
index 0000000..876ce22
--- /dev/null
+++ b/frontend/src/app/change-password/change-password.component.html
@@ -0,0 +1 @@
+
change-password works!
diff --git a/frontend/src/app/change-password/change-password.component.scss b/frontend/src/app/change-password/change-password.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/frontend/src/app/change-password/change-password.component.spec.ts b/frontend/src/app/change-password/change-password.component.spec.ts
new file mode 100644
index 0000000..0776cae
--- /dev/null
+++ b/frontend/src/app/change-password/change-password.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ChangePasswordComponent } from './change-password.component';
+
+describe('ChangePasswordComponent', () => {
+ let component: ChangePasswordComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ ChangePasswordComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(ChangePasswordComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/change-password/change-password.component.ts b/frontend/src/app/change-password/change-password.component.ts
new file mode 100644
index 0000000..21a5a50
--- /dev/null
+++ b/frontend/src/app/change-password/change-password.component.ts
@@ -0,0 +1,15 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+ selector: 'app-change-password',
+ templateUrl: './change-password.component.html',
+ styleUrls: ['./change-password.component.scss']
+})
+export class ChangePasswordComponent implements OnInit {
+
+ constructor() { }
+
+ ngOnInit(): void {
+ }
+
+}
diff --git a/frontend/src/app/chat/chat.component.html b/frontend/src/app/chat/chat.component.html
new file mode 100644
index 0000000..648387e
--- /dev/null
+++ b/frontend/src/app/chat/chat.component.html
@@ -0,0 +1,2 @@
+
+
diff --git a/frontend/src/app/chat/chat.component.scss b/frontend/src/app/chat/chat.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/frontend/src/app/chat/chat.component.spec.ts b/frontend/src/app/chat/chat.component.spec.ts
new file mode 100644
index 0000000..7d7548c
--- /dev/null
+++ b/frontend/src/app/chat/chat.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ChatComponent } from './chat.component';
+
+describe('ChatComponent', () => {
+ let component: ChatComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ ChatComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(ChatComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/chat/chat.component.ts b/frontend/src/app/chat/chat.component.ts
new file mode 100644
index 0000000..3328187
--- /dev/null
+++ b/frontend/src/app/chat/chat.component.ts
@@ -0,0 +1,15 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+ selector: 'app-chat',
+ templateUrl: './chat.component.html',
+ styleUrls: ['./chat.component.scss']
+})
+export class ChatComponent implements OnInit {
+
+ constructor() { }
+
+ ngOnInit(): void {
+ }
+
+}
diff --git a/frontend/src/app/message/message.component.html b/frontend/src/app/message/message.component.html
new file mode 100644
index 0000000..18f5b61
--- /dev/null
+++ b/frontend/src/app/message/message.component.html
@@ -0,0 +1,22 @@
+
diff --git a/frontend/src/app/message/message.component.scss b/frontend/src/app/message/message.component.scss
new file mode 100644
index 0000000..b715cc3
--- /dev/null
+++ b/frontend/src/app/message/message.component.scss
@@ -0,0 +1,3 @@
+#messages { list-style-type: none; margin: 0; padding: 0; }
+#messages > li { padding: 0.5rem 1rem; }
+#messages > li:nth-child(odd) { background: #efefef; }
diff --git a/frontend/src/app/message/message.component.spec.ts b/frontend/src/app/message/message.component.spec.ts
new file mode 100644
index 0000000..03cb616
--- /dev/null
+++ b/frontend/src/app/message/message.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { MessageComponent } from './message.component';
+
+describe('MessageComponent', () => {
+ let component: MessageComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ MessageComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(MessageComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/message/message.component.ts b/frontend/src/app/message/message.component.ts
new file mode 100644
index 0000000..b7a13b0
--- /dev/null
+++ b/frontend/src/app/message/message.component.ts
@@ -0,0 +1,113 @@
+import {Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from '@angular/core';
+import {ChatInfo, ChatService} from "../services/chat/chat.service";
+import {DatePipe} from "@angular/common";
+import {environment} from "../../environments/environment";
+import {MessageService} from "../services/message/message.service";
+
+@Component({
+ selector: 'app-message',
+ templateUrl: './message.component.html',
+ styleUrls: ['./message.component.scss']
+})
+export class MessageComponent implements OnInit, OnChanges {
+
+ public username = sessionStorage.getItem('login');
+ public msg = '';
+ public roomId = '';
+
+ // @ts-ignore
+ @Input() room: string;
+
+ // @ts-ignore
+ @ViewChild('ulMessages') ulMsg: ElementRef;
+
+ // @ts-ignore
+ @ViewChild('scrollContainer') scrollContainer: ElementRef;
+
+ constructor(private chatservice: ChatService, private pipe: DatePipe, private messageservice: MessageService) {
+ }
+
+ ngOnInit() {
+ }
+
+ ngOnChanges(changes: SimpleChanges){
+ //console.log('ngOnChange :'+this.room);
+ this.chatservice.leaveRoom();
+ // @ts-ignore
+ document.getElementById('messages').innerHTML = '';
+ if(this.room === 'General' || this.room === 'general'){
+ this.room = 'general';
+ this.chatservice.setUrl(environment.urlCG);
+ this.chatservice.setRoom(this.room);
+ this.chatServiceOnNewMessage(this.room);
+ }
+ else{
+ this.chatservice.setUrl(environment.urlCPR);
+ this.messageservice.sendMessage(environment.urlCPR,"conversations/getConv",{
+ sender: this.username,
+ receiver: this.room,
+ }).subscribe(data => {
+ if (data.status !== 'ok') {
+ console.log(data.data.reason);
+ } else {
+ if(data.data === null){
+ this.messageservice.sendMessage(environment.urlCPR, "conversations/newConv", {
+ sender: this.username,
+ receiver: this.room,
+ }).subscribe(data2 => {
+ if (data2.status !== 'ok') {
+ console.log(data2.data.reason);
+ } else {
+ //console.log(data.data);
+ this.roomId = data2.data._id;
+ this.chatservice.setRoom(this.roomId)
+ this.chatServiceOnNewMessage(this.roomId);
+ }
+ });
+ }
+ else{
+ if(typeof data.data !== 'undefined' && typeof data.data._id !== 'undefined'){
+ //console.log(data.data);
+ this.roomId = data.data._id;
+ this.chatservice.setRoom(this.roomId);
+ this.chatServiceOnNewMessage(this.roomId);
+ }
+ }
+ }
+ });
+ }
+ }
+
+ chatServiceOnNewMessage(room: string){
+ this.chatservice.onNewMessage(room).subscribe((infos: ChatInfo[]) => {
+ for(let data of infos){
+ if(data !== undefined && data.date !== undefined){
+ if(data.username === 'Server'){
+ this.ulMsg.nativeElement.insertAdjacentHTML('beforeend', ''+data.message+'');
+ }
+ else{
+ this.ulMsg.nativeElement.insertAdjacentHTML('beforeend','['+this.pipe.transform(data.date, 'dd/MM/yyyy HH:MM:ss')+'] '+data.username+' : '+data.message+'');
+ }
+ }
+ }
+ this.scrollContainer.nativeElement.scrollTop = this.scrollContainer.nativeElement.scrollHeight;
+ });
+ }
+
+ sendButtonClick(){
+ //console.log('Button working');
+ if(this.msg && this.username && this.room){
+ if(this.room === 'general'){
+ //console.log("sendButton general");
+ this.chatservice.sendMessage(this.username, this.room, this.msg);
+ //console.log(this.username, this.room, this.msg);
+ }
+ else{
+ //console.log("sendButton private");
+ this.chatservice.sendMessage(this.username, this.roomId, this.msg);
+ //console.log(this.username, this.roomId, this.msg);
+ }
+ this.msg = '';
+ }
+ }
+}
diff --git a/frontend/src/app/navbar/navbar.component.html b/frontend/src/app/navbar/navbar.component.html
new file mode 100644
index 0000000..6bbf8ee
--- /dev/null
+++ b/frontend/src/app/navbar/navbar.component.html
@@ -0,0 +1 @@
+navbar works!
diff --git a/frontend/src/app/navbar/navbar.component.scss b/frontend/src/app/navbar/navbar.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/frontend/src/app/navbar/navbar.component.spec.ts b/frontend/src/app/navbar/navbar.component.spec.ts
new file mode 100644
index 0000000..f8ccd6f
--- /dev/null
+++ b/frontend/src/app/navbar/navbar.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { NavbarComponent } from './navbar.component';
+
+describe('NavbarComponent', () => {
+ let component: NavbarComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ NavbarComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(NavbarComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/navbar/navbar.component.ts b/frontend/src/app/navbar/navbar.component.ts
new file mode 100644
index 0000000..6a9bec8
--- /dev/null
+++ b/frontend/src/app/navbar/navbar.component.ts
@@ -0,0 +1,15 @@
+import { Component, OnInit } from '@angular/core';
+
+@Component({
+ selector: 'app-navbar',
+ templateUrl: './navbar.component.html',
+ styleUrls: ['./navbar.component.scss']
+})
+export class NavbarComponent implements OnInit {
+
+ constructor() { }
+
+ ngOnInit(): void {
+ }
+
+}
diff --git a/frontend/src/app/private/private.component.html b/frontend/src/app/private/private.component.html
new file mode 100644
index 0000000..d29a1c4
--- /dev/null
+++ b/frontend/src/app/private/private.component.html
@@ -0,0 +1,12 @@
+
diff --git a/frontend/src/app/private/private.component.scss b/frontend/src/app/private/private.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/frontend/src/app/private/private.component.spec.ts b/frontend/src/app/private/private.component.spec.ts
new file mode 100644
index 0000000..f2a3e2f
--- /dev/null
+++ b/frontend/src/app/private/private.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { PrivateComponent } from './private.component';
+
+describe('PrivateComponent', () => {
+ let component: PrivateComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ PrivateComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(PrivateComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/private/private.component.ts b/frontend/src/app/private/private.component.ts
new file mode 100644
index 0000000..6b54b24
--- /dev/null
+++ b/frontend/src/app/private/private.component.ts
@@ -0,0 +1,50 @@
+import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
+import {environment} from "../../environments/environment";
+import {ChatService} from "../services/chat/chat.service";
+import {MessageService} from "../services/message/message.service";
+
+@Component({
+ selector: 'app-private',
+ templateUrl: './private.component.html',
+ styleUrls: ['./private.component.scss']
+})
+export class PrivateComponent implements OnInit {
+
+ public username = sessionStorage.getItem('login');
+ public roomSelected = 'general';
+
+ // @ts-ignore
+ @ViewChild('userList') userList: ElementRef;
+
+ constructor(private chatservice: ChatService, private messageservice: MessageService) {}
+
+ ngOnInit(): void {
+ this.messageservice.sendMessage(environment.urlCL,'getUsers', {username: this.username}).subscribe(
+ data => {
+ if (data.status !== 'ok'){
+ console.log(data.data.reason);
+ }
+ else{
+ //console.log(data.data);
+ //data.data = data.data.concat(data.data).concat(data.data).concat(data.data).concat(data.data).concat(data.data).concat(data.data).concat(data.data).concat(data.data);
+ for(let user of data.data){
+ if(user !== undefined && user.login !== undefined){
+ this.userList.nativeElement.insertAdjacentHTML('beforeend', '
'+user.login+'
');
+ }
+ }
+ }
+ }
+ );
+ }
+
+ selectRoom(event: Event): void {
+ if((event.target as Element).className !== 'user-list-card'){
+ const room = (event.target as Element).textContent;
+ //console.log(room);
+ if(room !== '' && room !== null) {
+ this.roomSelected = room;
+ }
+ }
+ }
+
+}
diff --git a/frontend/src/app/register/register.component.html b/frontend/src/app/register/register.component.html
new file mode 100644
index 0000000..2ded07b
--- /dev/null
+++ b/frontend/src/app/register/register.component.html
@@ -0,0 +1,24 @@
+
+
+
+
+
{{errorMessage}}
+
{{succesMessage}}
+
diff --git a/frontend/src/app/register/register.component.scss b/frontend/src/app/register/register.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/frontend/src/app/register/register.component.spec.ts b/frontend/src/app/register/register.component.spec.ts
new file mode 100644
index 0000000..f6db869
--- /dev/null
+++ b/frontend/src/app/register/register.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { RegisterComponent } from './register.component';
+
+describe('RegisterComponent', () => {
+ let component: RegisterComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ RegisterComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(RegisterComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/frontend/src/app/register/register.component.ts b/frontend/src/app/register/register.component.ts
new file mode 100644
index 0000000..7ea75cc
--- /dev/null
+++ b/frontend/src/app/register/register.component.ts
@@ -0,0 +1,41 @@
+import { Component, OnInit } from '@angular/core';
+import {MessageService} from "../services/message/message.service";
+import {environment} from "../../environments/environment";
+
+@Component({
+ selector: 'app-register',
+ templateUrl: './register.component.html',
+ styleUrls: ['./register.component.scss']
+})
+export class RegisterComponent implements OnInit {
+
+ login2 = '';
+ password2 = '';
+ password4 = '';
+ errorMessage = '';
+ succesMessage = '';
+
+ constructor(private messageService: MessageService) { }
+
+ ngOnInit(): void {
+
+ }
+
+ register(): void {
+ if(this.password4 !== this.password2){
+ console.log("error");
+ this.errorMessage = 'Les mots de passe ne sont pas identiques.';
+ }
+ else {
+ this.messageService.sendMessage(environment.urlCL,"register",{username: this.login2, password: this.password2}).subscribe(data => {
+ if (data.status !== 'ok') {
+ console.log(data.data.reason);
+ this.errorMessage = data.data.reason;
+ } else {
+ //console.log(data.data);
+ this.succesMessage = data.data;
+ }
+ });
+ }
+ }
+}