mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import {Component, ViewEncapsulation} from "@angular/core";
|
|
import {RouterLink} from "@angular/router";
|
|
import {AuthenticationService} from "../model/network/authentication.service";
|
|
import {UserDTO, UserRoles} from "../../../common/entities/UserDTO";
|
|
import {Config} from "../../../common/config/public/Config";
|
|
import {BehaviorSubject} from "rxjs/BehaviorSubject";
|
|
|
|
@Component({
|
|
selector: 'app-frame',
|
|
templateUrl: './frame.component.html',
|
|
styleUrls: ['./frame.component.css'],
|
|
providers: [RouterLink],
|
|
encapsulation: ViewEncapsulation.Emulated
|
|
})
|
|
export class FrameComponent {
|
|
|
|
user: BehaviorSubject<UserDTO>;
|
|
authenticationRequired: boolean = false;
|
|
public title: string;
|
|
isIn: boolean = false;
|
|
|
|
constructor(private _authService: AuthenticationService) {
|
|
this.user = this._authService.user;
|
|
this.authenticationRequired = Config.Client.authenticationRequired;
|
|
this.title = Config.Client.applicationTitle;
|
|
}
|
|
|
|
toggleState() { // click handler
|
|
this.isIn = !this.isIn;
|
|
}
|
|
|
|
isAdmin() {
|
|
return this.user.value && this.user.value.role >= UserRoles.Admin;
|
|
}
|
|
|
|
|
|
logout() {
|
|
this._authService.logout();
|
|
}
|
|
}
|
|
|