1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00
pigallery2/frontend/app/frame/frame.component.ts

44 lines
1.3 KiB
TypeScript
Raw Normal View History

2016-05-09 17:04:56 +02:00
import {Component, ViewEncapsulation} from "@angular/core";
2016-12-26 23:36:38 +01:00
import {RouterLink} from "@angular/router";
2016-05-16 23:15:03 +02:00
import {AuthenticationService} from "../model/network/authentication.service";
2017-07-07 22:54:18 +02:00
import {UserDTO, UserRoles} from "../../../common/entities/UserDTO";
2017-06-04 15:25:08 +02:00
import {Config} from "../../../common/config/public/Config";
2017-07-03 19:17:49 +02:00
import {BehaviorSubject} from "rxjs/BehaviorSubject";
2017-07-09 14:23:50 +02:00
import {NotificationService} from "../model/notification.service";
2016-05-09 17:04:56 +02:00
@Component({
selector: 'app-frame',
templateUrl: './frame.component.html',
2017-06-21 21:16:04 +02:00
styleUrls: ['./frame.component.css'],
providers: [RouterLink],
encapsulation: ViewEncapsulation.Emulated
})
2016-05-09 17:04:56 +02:00
export class FrameComponent {
2017-07-03 19:17:49 +02:00
user: BehaviorSubject<UserDTO>;
authenticationRequired: boolean = false;
2017-07-06 22:54:36 +02:00
public title: string;
2017-07-07 22:54:18 +02:00
isIn: boolean = false;
2016-05-16 23:15:03 +02:00
2017-07-09 14:23:50 +02:00
constructor(private _authService: AuthenticationService,
public notificationService: NotificationService) {
2017-07-03 19:17:49 +02:00
this.user = this._authService.user;
this.authenticationRequired = Config.Client.authenticationRequired;
2017-07-06 22:54:36 +02:00
this.title = Config.Client.applicationTitle;
}
2016-05-01 10:28:05 +02:00
2017-07-07 22:54:18 +02:00
toggleState() { // click handler
this.isIn = !this.isIn;
}
isAdmin() {
return this.user.value && this.user.value.role >= UserRoles.Admin;
}
logout() {
this._authService.logout();
}
}