2018-03-31 03:30:30 +08:00
|
|
|
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';
|
|
|
|
import {NotificationService} from '../model/notification.service';
|
2018-05-14 04:59:57 +08:00
|
|
|
import {ShareService} from '../gallery/share.service';
|
2016-05-09 23:04:56 +08:00
|
|
|
|
2016-04-26 21:10:05 +08:00
|
|
|
@Component({
|
2017-06-11 04:32:56 +08:00
|
|
|
selector: 'app-frame',
|
|
|
|
templateUrl: './frame.component.html',
|
2017-06-22 03:16:04 +08:00
|
|
|
styleUrls: ['./frame.component.css'],
|
2017-06-11 04:32:56 +08:00
|
|
|
providers: [RouterLink],
|
|
|
|
encapsulation: ViewEncapsulation.Emulated
|
2016-04-26 21:10:05 +08:00
|
|
|
})
|
2016-05-09 23:04:56 +08:00
|
|
|
export class FrameComponent {
|
|
|
|
|
2017-07-04 01:17:49 +08:00
|
|
|
user: BehaviorSubject<UserDTO>;
|
2018-05-04 06:23:48 +08:00
|
|
|
authenticationRequired = false;
|
2017-07-07 04:54:36 +08:00
|
|
|
public title: string;
|
2018-05-14 04:59:57 +08:00
|
|
|
collapsed = true;
|
2016-05-17 05:15:03 +08:00
|
|
|
|
2017-07-09 20:23:50 +08:00
|
|
|
constructor(private _authService: AuthenticationService,
|
2018-05-14 04:59:57 +08:00
|
|
|
public notificationService: NotificationService,
|
|
|
|
public _shareService: ShareService) {
|
2017-07-04 01:17:49 +08:00
|
|
|
this.user = this._authService.user;
|
2017-06-11 04:32:56 +08:00
|
|
|
this.authenticationRequired = Config.Client.authenticationRequired;
|
2017-07-07 04:54:36 +08:00
|
|
|
this.title = Config.Client.applicationTitle;
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-05-01 16:28:05 +08:00
|
|
|
|
2017-07-08 04:54:18 +08:00
|
|
|
toggleState() { // click handler
|
2018-05-14 04:59:57 +08:00
|
|
|
this.collapsed = !this.collapsed;
|
2017-07-08 04:54:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
isAdmin() {
|
|
|
|
return this.user.value && this.user.value.role >= UserRoles.Admin;
|
|
|
|
}
|
|
|
|
|
2016-07-07 18:19:08 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
logout() {
|
|
|
|
this._authService.logout();
|
|
|
|
}
|
2016-04-26 21:10:05 +08:00
|
|
|
}
|
|
|
|
|