49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { Component, OnInit } from "@angular/core";
|
|
import { Router } from "@angular/router";
|
|
|
|
import { User } from "../models/user";
|
|
import { environment } from "../environments/environment";
|
|
|
|
import { AuthenticationService } from "../services/authentication.service";
|
|
import { ServiceComm } from "../services/service-comm.service";
|
|
|
|
@Component({
|
|
selector: "app-root",
|
|
templateUrl: "./app.component.html",
|
|
styleUrls: ["./app.component.css"]
|
|
})
|
|
export class AppComponent implements OnInit {
|
|
public title = "app";
|
|
public showMenu = false;
|
|
public currentUser: User;
|
|
public version: string = environment.version;
|
|
|
|
constructor(
|
|
private router: Router,
|
|
private authenticationService: AuthenticationService,
|
|
private serviceComm: ServiceComm
|
|
) {
|
|
this.authenticationService.currentUser.subscribe(
|
|
x => (this.currentUser = x)
|
|
);
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.serviceComm.componentTitle.subscribe(title => (this.title = title));
|
|
}
|
|
|
|
toggleMenu() {
|
|
this.showMenu = !this.showMenu;
|
|
}
|
|
|
|
show() {
|
|
return this.authenticationService.currentUserValue != undefined;
|
|
}
|
|
|
|
logout() {
|
|
this.authenticationService.logout();
|
|
this.showMenu = !this.showMenu;
|
|
this.router.navigate(["/login"], { skipLocationChange: true });
|
|
}
|
|
}
|