2016-05-04 23:20:21 +08:00
|
|
|
import {Component, OnInit} from "@angular/core";
|
2016-12-27 06:36:38 +08:00
|
|
|
import {AuthenticationService} from "../model/network/authentication.service";
|
|
|
|
import {Router} from "@angular/router";
|
2016-12-27 23:09:47 +08:00
|
|
|
import {UserRoles} from "../../../common/entities/UserDTO";
|
2017-06-04 21:25:08 +08:00
|
|
|
import {Config} from "../../../common/config/public/Config";
|
2017-07-09 20:23:50 +08:00
|
|
|
import {NotificationService} from "../model/notification.service";
|
|
|
|
import {NotificationType} from "../../../common/entities/NotificationDTO";
|
2016-04-26 21:10:05 +08:00
|
|
|
@Component({
|
2017-06-11 04:32:56 +08:00
|
|
|
selector: 'admin',
|
|
|
|
templateUrl: './admin.component.html',
|
|
|
|
styleUrls: ['./admin.component.css']
|
2016-04-26 21:10:05 +08:00
|
|
|
})
|
2016-05-02 03:30:43 +08:00
|
|
|
export class AdminComponent implements OnInit {
|
2017-06-11 04:32:56 +08:00
|
|
|
userManagementEnable: boolean = false;
|
2016-05-02 03:30:43 +08:00
|
|
|
|
2017-07-09 20:23:50 +08:00
|
|
|
NotificationType: any;
|
|
|
|
|
|
|
|
constructor(private _authService: AuthenticationService,
|
|
|
|
private _router: Router,
|
|
|
|
public notificationService: NotificationService) {
|
2017-06-11 04:32:56 +08:00
|
|
|
this.userManagementEnable = Config.Client.authenticationRequired;
|
2017-07-09 20:23:50 +08:00
|
|
|
this.NotificationType = NotificationType;
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-04-26 21:10:05 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
ngOnInit() {
|
2017-07-08 18:43:42 +08:00
|
|
|
if (!this._authService.isAuthenticated()
|
|
|
|
|| this._authService.user.value.role < UserRoles.Admin) {
|
2017-06-11 04:32:56 +08:00
|
|
|
this._router.navigate(['login']);
|
|
|
|
return;
|
2016-04-26 21:10:05 +08:00
|
|
|
}
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-04-26 21:10:05 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-03 20:29:24 +08:00
|
|
|
|
|
|
|
|