2016-04-26 21:10:05 +08:00
|
|
|
///<reference path="../../browser.d.ts"/>
|
|
|
|
|
2016-05-04 23:20:21 +08:00
|
|
|
import {Component, OnInit} from "@angular/core";
|
2016-05-01 00:01:54 +08:00
|
|
|
import {AuthenticationService} from "../model/network/authentication.service.ts";
|
2016-05-04 23:20:21 +08:00
|
|
|
import {Router} from "@angular/router-deprecated";
|
2016-04-26 21:10:05 +08:00
|
|
|
import {FrameComponent} from "../frame/frame.component";
|
2016-07-09 21:08:36 +08:00
|
|
|
import {UserRoles} from "../../../common/entities/User";
|
2016-05-04 23:20:21 +08:00
|
|
|
import {FORM_DIRECTIVES} from "@angular/common";
|
2016-05-09 23:04:56 +08:00
|
|
|
import {StringifyRole} from "./../pipes/StringifyRolePipe";
|
2016-07-07 18:26:36 +08:00
|
|
|
import {Config} from "../config/Config";
|
2016-07-09 21:08:36 +08:00
|
|
|
import {UserMangerSettingsComponent} from "../settings/usermanager/usermanager.settings.component";
|
2016-05-02 03:30:43 +08:00
|
|
|
|
2016-04-26 21:10:05 +08:00
|
|
|
@Component({
|
|
|
|
selector: 'admin',
|
|
|
|
templateUrl: 'app/admin/admin.component.html',
|
2016-05-02 03:30:43 +08:00
|
|
|
styleUrls: ['app/admin/admin.component.css'],
|
2016-07-09 21:08:36 +08:00
|
|
|
directives: [FrameComponent, FORM_DIRECTIVES, UserMangerSettingsComponent],
|
2016-05-03 20:29:24 +08:00
|
|
|
pipes: [StringifyRole]
|
2016-04-26 21:10:05 +08:00
|
|
|
})
|
2016-05-02 03:30:43 +08:00
|
|
|
export class AdminComponent implements OnInit {
|
2016-07-07 18:26:36 +08:00
|
|
|
userManagementEnable:boolean = false;
|
2016-05-02 03:30:43 +08:00
|
|
|
|
2016-07-09 21:08:36 +08:00
|
|
|
constructor(private _authService:AuthenticationService, private _router:Router) {
|
2016-07-07 18:26:36 +08:00
|
|
|
this.userManagementEnable = Config.Client.authenticationRequired;
|
2016-04-26 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
2016-05-02 03:30:43 +08:00
|
|
|
ngOnInit() {
|
|
|
|
if (!this._authService.isAuthenticated() || this._authService.getUser().role < UserRoles.Admin) {
|
2016-04-26 21:10:05 +08:00
|
|
|
this._router.navigate(['Login']);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-03 20:29:24 +08:00
|
|
|
|
|
|
|
|