2019-01-27 14:58:56 -05:00
|
|
|
import {Component, ViewEncapsulation} from '@angular/core';
|
2018-03-30 15:30:30 -04:00
|
|
|
import {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 {
|
|
|
|
|
2017-07-03 19:17:49 +02:00
|
|
|
user: BehaviorSubject<UserDTO>;
|
2018-05-03 18:23:48 -04:00
|
|
|
authenticationRequired = false;
|
2017-07-06 22:54:36 +02:00
|
|
|
public title: string;
|
2018-05-13 16:59:57 -04:00
|
|
|
collapsed = true;
|
2019-07-21 16:39:52 +02:00
|
|
|
facesEnabled = Config.Client.Faces.enabled;
|
2016-05-16 23:15:03 +02:00
|
|
|
|
2017-07-09 14:23:50 +02:00
|
|
|
constructor(private _authService: AuthenticationService,
|
2018-05-13 16:59:57 -04:00
|
|
|
public notificationService: NotificationService,
|
2018-05-26 20:49:55 -04:00
|
|
|
public queryService: QueryService) {
|
2017-07-03 19:17:49 +02:00
|
|
|
this.user = this._authService.user;
|
2017-06-10 22:32:56 +02:00
|
|
|
this.authenticationRequired = Config.Client.authenticationRequired;
|
2017-07-06 22:54:36 +02:00
|
|
|
this.title = Config.Client.applicationTitle;
|
2017-06-10 22:32:56 +02:00
|
|
|
}
|
2016-05-01 10:28:05 +02:00
|
|
|
|
2017-07-07 22:54:18 +02:00
|
|
|
toggleState() { // click handler
|
2018-05-13 16:59:57 -04:00
|
|
|
this.collapsed = !this.collapsed;
|
2017-07-07 22:54:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
isAdmin() {
|
|
|
|
return this.user.value && this.user.value.role >= UserRoles.Admin;
|
|
|
|
}
|
|
|
|
|
2016-07-07 12:19:08 +02:00
|
|
|
|
2017-06-10 22:32:56 +02:00
|
|
|
logout() {
|
|
|
|
this._authService.logout();
|
|
|
|
}
|
2016-04-26 15:10:05 +02:00
|
|
|
}
|
|
|
|
|