2019-01-27 14:58:56 -05:00
|
|
|
import {Component, ViewEncapsulation} from '@angular/core';
|
2021-04-11 15:59:30 +02:00
|
|
|
import {Router, RouterLink} from '@angular/router';
|
2019-03-03 10:30:12 +01:00
|
|
|
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';
|
2019-03-03 10:30:12 +01:00
|
|
|
import {NotificationService} from '../../model/notification.service';
|
|
|
|
import {QueryService} from '../../model/query.service';
|
2016-05-09 17:04:56 +02:00
|
|
|
|
2016-04-26 15:10:05 +02:00
|
|
|
@Component({
|
2017-06-10 22:32:56 +02:00
|
|
|
selector: 'app-frame',
|
|
|
|
templateUrl: './frame.component.html',
|
2017-06-21 21:16:04 +02:00
|
|
|
styleUrls: ['./frame.component.css'],
|
2017-06-10 22:32:56 +02:00
|
|
|
providers: [RouterLink],
|
|
|
|
encapsulation: ViewEncapsulation.Emulated
|
2016-04-26 15:10:05 +02:00
|
|
|
})
|
2016-05-09 17:04:56 +02:00
|
|
|
export class FrameComponent {
|
|
|
|
|
2021-04-11 15:59:30 +02:00
|
|
|
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;
|
2021-04-11 15:59:30 +02:00
|
|
|
public collapsed = true;
|
2016-05-16 23:15:03 +02:00
|
|
|
|
2021-04-11 15:59:30 +02:00
|
|
|
constructor(private authService: AuthenticationService,
|
2018-05-13 16:59:57 -04:00
|
|
|
public notificationService: NotificationService,
|
2021-04-11 15:59:30 +02:00
|
|
|
public queryService: QueryService,
|
|
|
|
private router: Router) {
|
|
|
|
this.user = this.authService.user;
|
2017-06-10 22:32:56 +02:00
|
|
|
}
|
2016-05-01 10:28:05 +02:00
|
|
|
|
2017-07-07 22:54:18 +02:00
|
|
|
|
2021-04-11 15:59:30 +02:00
|
|
|
isAdmin(): boolean {
|
2017-07-07 22:54:18 +02:00
|
|
|
return this.user.value && this.user.value.role >= UserRoles.Admin;
|
|
|
|
}
|
|
|
|
|
2021-04-11 15:59:30 +02:00
|
|
|
isFacesAvailable(): boolean {
|
2020-09-05 16:06:11 +02:00
|
|
|
return Config.Client.Faces.enabled && this.user.value && this.user.value.role >= Config.Client.Faces.readAccessMinRole;
|
|
|
|
}
|
|
|
|
|
2021-04-11 15:59:30 +02:00
|
|
|
isLinkActive(url: string): boolean {
|
|
|
|
return this.router.url.startsWith(url);
|
|
|
|
}
|
2016-07-07 12:19:08 +02:00
|
|
|
|
2021-04-11 15:59:30 +02:00
|
|
|
logout(): void {
|
|
|
|
this.authService.logout();
|
2017-06-10 22:32:56 +02:00
|
|
|
}
|
2021-04-11 15:59:30 +02:00
|
|
|
|
2021-05-28 21:01:59 +02:00
|
|
|
isAlbumsAvailable(): boolean {
|
|
|
|
return Config.Client.Album.enabled;
|
|
|
|
}
|
2016-04-26 15:10:05 +02:00
|
|
|
}
|
|
|
|
|