You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
frontend/src/app/app.component.ts

36 lines
1.1 KiB
TypeScript

4 years ago
import { Component, Renderer2 } from '@angular/core';
import { ColorThemeService } from './services/colorTheme.service';
4 years ago
import { AuthService } from './services/auth.service';
import { Router } from '@angular/router';
4 years ago
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
4 years ago
})
export class AppComponent {
4 years ago
title = 'fLotte-fRontend';
4 years ago
darkThemeIsActive: boolean = false;
4 years ago
loggedIn = false;
4 years ago
constructor(
private renderer: Renderer2,
4 years ago
private themeService: ColorThemeService,
private authService: AuthService,
private router: Router,
4 years ago
) {
this.renderer.addClass(document.body, 'mat-app-background'); //so the background color changes dependent on current theme
this.themeService.load();
4 years ago
this.darkThemeIsActive = this.themeService.currentActive() === 'dark-theme';
4 years ago
this.authService.loggedIn.subscribe((value) => (this.loggedIn = value));
4 years ago
}
changeTheme(event) {
this.themeService.update(event.checked ? 'dark-theme' : 'light-theme');
4 years ago
}
logout() {
this.authService.logout().subscribe().add(() => this.router.navigate(['login']));
}
4 years ago
}