1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/frontend/app/admin/admin.component.ts

45 lines
1.2 KiB
TypeScript
Raw Normal View History

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