From 8fe42de825ce04a6acfa98cff8301f1e9085e174 Mon Sep 17 00:00:00 2001 From: NyxiumYuuki Date: Tue, 1 Jun 2021 22:31:11 +0200 Subject: [PATCH] Dialog Create Room --- .../create-room-dialog.component.html | 13 ++++++ .../create-room-dialog.component.scss | 0 .../create-room-dialog.component.spec.ts | 25 +++++++++++ .../create-room-dialog.component.ts | 42 +++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 frontend/src/app/create-room-dialog/create-room-dialog.component.html create mode 100644 frontend/src/app/create-room-dialog/create-room-dialog.component.scss create mode 100644 frontend/src/app/create-room-dialog/create-room-dialog.component.spec.ts create mode 100644 frontend/src/app/create-room-dialog/create-room-dialog.component.ts diff --git a/frontend/src/app/create-room-dialog/create-room-dialog.component.html b/frontend/src/app/create-room-dialog/create-room-dialog.component.html new file mode 100644 index 0000000..67c26a8 --- /dev/null +++ b/frontend/src/app/create-room-dialog/create-room-dialog.component.html @@ -0,0 +1,13 @@ +

New room

+ +
+
+

Saisissez un nouveau nom de room

+ +
+
+
Erreur : {{errorMessage}}
+
+ + +
diff --git a/frontend/src/app/create-room-dialog/create-room-dialog.component.scss b/frontend/src/app/create-room-dialog/create-room-dialog.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/frontend/src/app/create-room-dialog/create-room-dialog.component.spec.ts b/frontend/src/app/create-room-dialog/create-room-dialog.component.spec.ts new file mode 100644 index 0000000..4fdc384 --- /dev/null +++ b/frontend/src/app/create-room-dialog/create-room-dialog.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CreateRoomDialogComponent } from './create-room-dialog.component'; + +describe('CreateRoomDialogComponent', () => { + let component: CreateRoomDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ CreateRoomDialogComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(CreateRoomDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/create-room-dialog/create-room-dialog.component.ts b/frontend/src/app/create-room-dialog/create-room-dialog.component.ts new file mode 100644 index 0000000..7191f90 --- /dev/null +++ b/frontend/src/app/create-room-dialog/create-room-dialog.component.ts @@ -0,0 +1,42 @@ +import {Component, Inject, OnInit} from '@angular/core'; +import {MessageService} from "../services/message/message.service"; +import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; +import {environment} from "../../environments/environment"; + +export interface CreateRoomDialogData { + owner: string; +} + +@Component({ + selector: 'app-create-room-dialog', + templateUrl: './create-room-dialog.component.html', + styleUrls: ['./create-room-dialog.component.scss'] +}) +export class CreateRoomDialogComponent{ + + newRoomName = ''; + errorMessage = ''; + + constructor( + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: CreateRoomDialogData, + @Inject(MessageService) private messageService: MessageService) { } + + onNoClick(): void { + this.dialogRef.close(); + } + + onCreateRoom(){ + this.messageService.sendMessage(environment.urlCPR, "conversations/newRoom", {owner: this.data.owner, roomName: this.newRoomName}).subscribe(data => { + if (data.status !== 'ok') { + console.log(data.data.reason); + this.errorMessage = data.data.reason; + } + else{ + this.dialogRef.close({ + data: data.data + }); + } + }); + } +}