Loading web/src/app/app.component.html +5 −0 Original line number Diff line number Diff line <h1>{{title}}</h1> <mat-action-row> <button mat-button color="primary" [disabled]="isAuthenticated" (click)="handleLogInClick()">Log in</button> <button mat-button color="primary" [disabled]="!isAuthenticated" (click)="handleLogOutClick()">Log out</button> </mat-action-row> <router-outlet></router-outlet> web/src/app/app.component.ts +42 −0 Original line number Diff line number Diff line import { Component } from '@angular/core'; import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; import { LogInDialogComponent } from './components/log-in-dialog/log-in-dialog.component'; import { AuthServiceService } from './services/auth-service.service'; @Component({ selector: 'app-root', Loading @@ -7,4 +10,43 @@ import { Component } from '@angular/core'; }) export class AppComponent { title = 'Ice Hockey Manager'; isAuthenticated: boolean = false; constructor( private dialog: MatDialog, private authService: AuthServiceService ) { } ngOnInit(): void { this.refreshAuth(); } refreshAuth(): void { this.authService.isAuthenticated() .subscribe(isAuthenticated => this.isAuthenticated = isAuthenticated); } handleLogInClick() { const dialogConfig = new MatDialogConfig(); dialogConfig.data = { }; const dialogRef = this.dialog.open(LogInDialogComponent, dialogConfig); dialogRef.afterClosed().subscribe(data => this.onLogInClose(data)); } onLogInClose(data: boolean | null): void { if (data != null || data) { this.refreshAuth(); } } handleLogOutClick() { this.authService.logOut() .subscribe( (success: boolean) => { if (success) { this.refreshAuth(); } }); } } web/src/app/app.module.ts +5 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { TeamManagementDashboardComponent } from './components/team-management-dashboard/team-management-dashboard.component'; import { HireNewPlayerDialogComponent } from './components/hire-new-player-dialog/hire-new-player-dialog.component'; import { HireVeteranPlayerDialogComponent } from './components/hire-veteran-player-dialog/hire-veteran-player-dialog.component'; import { LogInFormComponent } from './components/log-in-form/log-in-form.component'; import { LogInDialogComponent } from './components/log-in-dialog/log-in-dialog.component'; @NgModule({ declarations: [ Loading @@ -43,7 +45,9 @@ import { HireVeteranPlayerDialogComponent } from './components/hire-veteran-play UpdateGameWinnerFormComponent, TeamManagementDashboardComponent, HireNewPlayerDialogComponent, HireVeteranPlayerDialogComponent HireVeteranPlayerDialogComponent, LogInFormComponent, LogInDialogComponent ], imports: [ BrowserModule, Loading web/src/app/components/components.module.ts +5 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ import { UpdateGameWinnerFormComponent } from './update-game-winner-form/update- import { TeamManagementDashboardComponent } from './team-management-dashboard/team-management-dashboard.component'; import { HireNewPlayerDialogComponent } from './hire-new-player-dialog/hire-new-player-dialog.component'; import { HireVeteranPlayerDialogComponent } from './hire-veteran-player-dialog/hire-veteran-player-dialog.component'; import { LogInFormComponent } from './log-in-form/log-in-form.component'; import { LogInDialogComponent } from './log-in-dialog/log-in-dialog.component'; @NgModule({ Loading @@ -36,7 +38,9 @@ import { HireVeteranPlayerDialogComponent } from './hire-veteran-player-dialog/h UpdateGameWinnerFormComponent, TeamManagementDashboardComponent, HireNewPlayerDialogComponent, HireVeteranPlayerDialogComponent HireVeteranPlayerDialogComponent, LogInFormComponent, LogInDialogComponent ], imports: [ CommonModule Loading web/src/app/components/log-in-dialog/log-in-dialog.component.css 0 → 100644 +0 −0 Empty file added. Loading
web/src/app/app.component.html +5 −0 Original line number Diff line number Diff line <h1>{{title}}</h1> <mat-action-row> <button mat-button color="primary" [disabled]="isAuthenticated" (click)="handleLogInClick()">Log in</button> <button mat-button color="primary" [disabled]="!isAuthenticated" (click)="handleLogOutClick()">Log out</button> </mat-action-row> <router-outlet></router-outlet>
web/src/app/app.component.ts +42 −0 Original line number Diff line number Diff line import { Component } from '@angular/core'; import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; import { LogInDialogComponent } from './components/log-in-dialog/log-in-dialog.component'; import { AuthServiceService } from './services/auth-service.service'; @Component({ selector: 'app-root', Loading @@ -7,4 +10,43 @@ import { Component } from '@angular/core'; }) export class AppComponent { title = 'Ice Hockey Manager'; isAuthenticated: boolean = false; constructor( private dialog: MatDialog, private authService: AuthServiceService ) { } ngOnInit(): void { this.refreshAuth(); } refreshAuth(): void { this.authService.isAuthenticated() .subscribe(isAuthenticated => this.isAuthenticated = isAuthenticated); } handleLogInClick() { const dialogConfig = new MatDialogConfig(); dialogConfig.data = { }; const dialogRef = this.dialog.open(LogInDialogComponent, dialogConfig); dialogRef.afterClosed().subscribe(data => this.onLogInClose(data)); } onLogInClose(data: boolean | null): void { if (data != null || data) { this.refreshAuth(); } } handleLogOutClick() { this.authService.logOut() .subscribe( (success: boolean) => { if (success) { this.refreshAuth(); } }); } }
web/src/app/app.module.ts +5 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { TeamManagementDashboardComponent } from './components/team-management-dashboard/team-management-dashboard.component'; import { HireNewPlayerDialogComponent } from './components/hire-new-player-dialog/hire-new-player-dialog.component'; import { HireVeteranPlayerDialogComponent } from './components/hire-veteran-player-dialog/hire-veteran-player-dialog.component'; import { LogInFormComponent } from './components/log-in-form/log-in-form.component'; import { LogInDialogComponent } from './components/log-in-dialog/log-in-dialog.component'; @NgModule({ declarations: [ Loading @@ -43,7 +45,9 @@ import { HireVeteranPlayerDialogComponent } from './components/hire-veteran-play UpdateGameWinnerFormComponent, TeamManagementDashboardComponent, HireNewPlayerDialogComponent, HireVeteranPlayerDialogComponent HireVeteranPlayerDialogComponent, LogInFormComponent, LogInDialogComponent ], imports: [ BrowserModule, Loading
web/src/app/components/components.module.ts +5 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ import { UpdateGameWinnerFormComponent } from './update-game-winner-form/update- import { TeamManagementDashboardComponent } from './team-management-dashboard/team-management-dashboard.component'; import { HireNewPlayerDialogComponent } from './hire-new-player-dialog/hire-new-player-dialog.component'; import { HireVeteranPlayerDialogComponent } from './hire-veteran-player-dialog/hire-veteran-player-dialog.component'; import { LogInFormComponent } from './log-in-form/log-in-form.component'; import { LogInDialogComponent } from './log-in-dialog/log-in-dialog.component'; @NgModule({ Loading @@ -36,7 +38,9 @@ import { HireVeteranPlayerDialogComponent } from './hire-veteran-player-dialog/h UpdateGameWinnerFormComponent, TeamManagementDashboardComponent, HireNewPlayerDialogComponent, HireVeteranPlayerDialogComponent HireVeteranPlayerDialogComponent, LogInFormComponent, LogInDialogComponent ], imports: [ CommonModule Loading