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";
|
2016-12-27 17:09:47 +02:00
|
|
|
import {UserRoles} from "../../../common/entities/UserDTO";
|
2017-07-09 14:23:50 +02:00
|
|
|
import {NotificationService} from "../model/notification.service";
|
|
|
|
import {NotificationType} from "../../../common/entities/NotificationDTO";
|
2017-07-15 12:47:11 +02:00
|
|
|
import {NavigationService} from "../model/navigation.service";
|
2016-04-26 15:10:05 +02:00
|
|
|
@Component({
|
2017-06-10 22:32:56 +02:00
|
|
|
selector: 'admin',
|
|
|
|
templateUrl: './admin.component.html',
|
|
|
|
styleUrls: ['./admin.component.css']
|
2016-04-26 15:10:05 +02:00
|
|
|
})
|
2016-05-01 21:30:43 +02:00
|
|
|
export class AdminComponent implements OnInit {
|
|
|
|
|
2017-07-15 17:29:40 +02:00
|
|
|
simplifiedMode = true;
|
|
|
|
|
2017-07-09 14:23:50 +02:00
|
|
|
constructor(private _authService: AuthenticationService,
|
2017-07-15 12:47:11 +02:00
|
|
|
private _navigation: NavigationService,
|
2017-07-09 14:23:50 +02:00
|
|
|
public notificationService: NotificationService) {
|
2017-06-10 22:32:56 +02:00
|
|
|
}
|
2016-04-26 15:10:05 +02:00
|
|
|
|
2017-06-10 22:32:56 +02:00
|
|
|
ngOnInit() {
|
2017-07-08 12:43:42 +02:00
|
|
|
if (!this._authService.isAuthenticated()
|
|
|
|
|| this._authService.user.value.role < UserRoles.Admin) {
|
2017-07-15 12:47:11 +02:00
|
|
|
this._navigation.toLogin();
|
2017-06-10 22:32:56 +02:00
|
|
|
return;
|
2016-04-26 15:10:05 +02:00
|
|
|
}
|
2017-06-10 22:32:56 +02:00
|
|
|
}
|
2016-04-26 15:10:05 +02:00
|
|
|
|
2017-07-14 09:28:52 +02:00
|
|
|
public getCss(type: NotificationType) {
|
|
|
|
switch (type) {
|
|
|
|
case NotificationType.error:
|
|
|
|
return "danger";
|
|
|
|
case NotificationType.warning:
|
|
|
|
return "warning";
|
|
|
|
case NotificationType.info:
|
|
|
|
return "info";
|
|
|
|
}
|
|
|
|
return "info";
|
|
|
|
}
|
|
|
|
|
2016-04-26 15:10:05 +02:00
|
|
|
}
|
|
|
|
|
2016-05-03 14:29:24 +02:00
|
|
|
|
|
|
|
|