diff --git a/src/app/components/home/new-landing/new-landing.component.html b/src/app/components/home/new-landing/new-landing.component.html index ee605c7b99eb4ae95c4ea2a6e526e8b1a2831085..0ef05f5c94f5b33a0cad526d00ba9de6d071337d 100644 --- a/src/app/components/home/new-landing/new-landing.component.html +++ b/src/app/components/home/new-landing/new-landing.component.html @@ -2,15 +2,10 @@ <form> <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="10px"> <mat-form-field class="number"> - <input matInput #roomId placeholder="Join Session!" maxlength="8" [matAutocomplete]="auto"/> + <input matInput #roomId placeholder="Join Session!" maxlength="8"/> <mat-hint align="end">{{roomId.value.length}} / 8</mat-hint> - <mat-autocomplete #auto="matAutocomplete"> - <mat-option *ngFor="let session of sessions" [value]="session.id"> - {{session.name}} - </mat-option> - </mat-autocomplete> </mat-form-field> - <button mat-fab color="primary" type="submit" (click)="login()"> + <button mat-fab color="primary" type="submit" (click)="joinRoom(roomId.value)"> <mat-icon>input</mat-icon> </button> </div> diff --git a/src/app/components/home/new-landing/new-landing.component.ts b/src/app/components/home/new-landing/new-landing.component.ts index 43fab4e43f49f425af73226d0c8fcae82daee549..35116f0dc67d30a6fea19a6f9458ce8bc23b5893 100644 --- a/src/app/components/home/new-landing/new-landing.component.ts +++ b/src/app/components/home/new-landing/new-landing.component.ts @@ -4,16 +4,7 @@ import { MatDialog } from '@angular/material'; import { AuthenticationService } from '../../../services/http/authentication.service'; import { User } from '../../../models/user'; import { UserRole } from '../../../models/user-roles.enum'; - -export class Session { - name: string; - id: number; - - constructor(name: string, id: number) { - this.id = id; - this.name = name; - } -} +import { Router } from '@angular/router'; @Component({ selector: 'app-new-landing', @@ -22,17 +13,14 @@ export class Session { }) export class NewLandingComponent implements OnInit { - sessions: Session[] = new Array<Session>(); user: User; constructor(public authenticationService: AuthenticationService, + private router: Router, public dialog: MatDialog) { } ngOnInit() { - this.sessions[0] = new Session('Angular', 98299243); - this.sessions[1] = new Session('Typescript', 52009627); - this.sessions[2] = new Session('Angular', 48590407); this.authenticationService.watchUser.subscribe(newUser => this.user = newUser); } @@ -42,9 +30,13 @@ export class NewLandingComponent implements OnInit { }); } - login(): void { + joinRoom(id: number) { if (!this.user) { - this.authenticationService.guestLogin(UserRole.PARTICIPANT).subscribe(); + this.authenticationService.guestLogin(UserRole.PARTICIPANT).subscribe(loggedIn => { + if (loggedIn === 'true') { + this.router.navigate([`/participant/room/${id}`]); + } + }); } } }