2016-05-04 17:20:21 +02:00
|
|
|
import {Component, OnInit} from "@angular/core";
|
2016-12-27 00:36:38 +02:00
|
|
|
import {AuthenticationService} from "../model/network/authentication.service";
|
|
|
|
import {Router} from "@angular/router";
|
2016-12-27 17:09:47 +02:00
|
|
|
import {UserRoles} from "../../../common/entities/UserDTO";
|
2016-07-07 12:26:36 +02:00
|
|
|
import {Config} from "../config/Config";
|
2016-04-26 15:10:05 +02:00
|
|
|
@Component({
|
|
|
|
selector: 'admin',
|
|
|
|
templateUrl: 'app/admin/admin.component.html',
|
2016-12-27 00:36:38 +02:00
|
|
|
styleUrls: ['app/admin/admin.component.css']
|
2016-04-26 15:10:05 +02:00
|
|
|
})
|
2016-05-01 21:30:43 +02:00
|
|
|
export class AdminComponent implements OnInit {
|
2016-12-27 00:36:38 +02:00
|
|
|
userManagementEnable: boolean = false;
|
2016-05-01 21:30:43 +02:00
|
|
|
|
2016-12-27 00:36:38 +02:00
|
|
|
constructor(private _authService: AuthenticationService, private _router: Router) {
|
2016-07-07 12:26:36 +02:00
|
|
|
this.userManagementEnable = Config.Client.authenticationRequired;
|
2016-04-26 15:10:05 +02:00
|
|
|
}
|
|
|
|
|
2016-05-01 21:30:43 +02:00
|
|
|
ngOnInit() {
|
|
|
|
if (!this._authService.isAuthenticated() || this._authService.getUser().role < UserRoles.Admin) {
|
2016-12-27 17:09:47 +02:00
|
|
|
this._router.navigate(['login']);
|
2016-04-26 15:10:05 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-03 14:29:24 +02:00
|
|
|
|
|
|
|
|