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

53 lines
1.6 KiB
TypeScript
Raw Normal View History

2019-01-27 14:58:56 -05:00
import {Component, ViewEncapsulation} from '@angular/core';
import {Router, 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';
2018-05-22 20:27:07 -04:00
import {BehaviorSubject} from 'rxjs';
import {NotificationService} from '../../model/notification.service';
import {QueryService} from '../../model/query.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 {
public readonly user: BehaviorSubject<UserDTO>;
2020-01-09 20:22:42 +01:00
public readonly authenticationRequired = Config.Client.authenticationRequired;
public readonly title = Config.Client.applicationTitle;
public collapsed = true;
2016-05-16 23:15:03 +02:00
constructor(private authService: AuthenticationService,
2018-05-13 16:59:57 -04:00
public notificationService: NotificationService,
public queryService: QueryService,
private router: Router) {
this.user = this.authService.user;
}
2016-05-01 10:28:05 +02:00
2017-07-07 22:54:18 +02:00
isAdmin(): boolean {
2017-07-07 22:54:18 +02:00
return this.user.value && this.user.value.role >= UserRoles.Admin;
}
isFacesAvailable(): boolean {
return Config.Client.Faces.enabled && this.user.value && this.user.value.role >= Config.Client.Faces.readAccessMinRole;
}
isLinkActive(url: string): boolean {
return this.router.url.startsWith(url);
}
logout(): void {
this.authService.logout();
}
2021-05-28 21:01:59 +02:00
isAlbumsAvailable(): boolean {
return Config.Client.Album.enabled;
}
}