From a8cc5c3cd4161ca3afb06e37094fc3161a2dd3ae Mon Sep 17 00:00:00 2001 From: Mark Wittpoth Date: Sun, 10 Dec 2017 13:55:13 +0100 Subject: [PATCH] Filled the header with content Login / Register Button if logged out Dropdown with Logout Button if logged in --- .../src/app/header/header.component.html | 56 ++++++++++++------- .../src/app/header/header.component.ts | 36 +++++++++++- .../src/app/login/login.component.html | 4 +- 3 files changed, 74 insertions(+), 22 deletions(-) diff --git a/web/angular/src/app/header/header.component.html b/web/angular/src/app/header/header.component.html index e300236..2c40686 100644 --- a/web/angular/src/app/header/header.component.html +++ b/web/angular/src/app/header/header.component.html @@ -1,27 +1,45 @@ diff --git a/web/angular/src/app/header/header.component.ts b/web/angular/src/app/header/header.component.ts index 625ee17..014af22 100644 --- a/web/angular/src/app/header/header.component.ts +++ b/web/angular/src/app/header/header.component.ts @@ -1,4 +1,8 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import {BehaviorSubject} from "rxjs/BehaviorSubject"; +import {AuthService, AuthState} from "../auth.service"; +import {User} from "../../api/models/user.model"; +import {ConsoleService} from "../console.service"; @Component({ selector: 'app-header', @@ -8,9 +12,39 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core'; }) export class HeaderComponent implements OnInit { - constructor() { } + AuthState = AuthState; + + login: string; + password: string; + + constructor(private consoleService: ConsoleService, private authService: AuthService) { } ngOnInit() { + this.login = this.authService.getLogin(); } + getUser(): BehaviorSubject { + return this.authService.user; + } + + getAuthState(): BehaviorSubject { + return this.authService.state; + } + + getError(): BehaviorSubject { + return this.authService.error; + } + + requestLogin(): void { + this.authService.setCredential(this.login, this.password); + this.authService.requestLogin(); + } + + requestLogout(): void { + this.authService.requestLogout(); + this.login = null; + this.password = null; + } + + } diff --git a/web/angular/src/app/login/login.component.html b/web/angular/src/app/login/login.component.html index ccee111..4ccce58 100644 --- a/web/angular/src/app/login/login.component.html +++ b/web/angular/src/app/login/login.component.html @@ -28,7 +28,7 @@
- +
@@ -42,4 +42,4 @@
- \ No newline at end of file +