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
2018-03-29 20:30:23 -04:00

54 lines
1.4 KiB
TypeScript

import {Component, OnInit} from "@angular/core";
import {AuthenticationService} from "../model/network/authentication.service";
import {UserRoles} from "../../../common/entities/UserDTO";
import {NotificationService} from "../model/notification.service";
import {NotificationType} from "../../../common/entities/NotificationDTO";
import {NavigationService} from "../model/navigation.service";
import {I18n} from "@ngx-translate/i18n-polyfill";
@Component({
selector: 'admin',
templateUrl: './admin.component.html',
styleUrls: ['./admin.component.css']
})
export class AdminComponent implements OnInit {
simplifiedMode = true;
text = {
Advanced: "Advanced",
Simplified: "Simplified"
};
constructor(private _authService: AuthenticationService,
private _navigation: NavigationService,
public notificationService: NotificationService,
public i18n: I18n) {
this.text.Advanced = i18n("Advanced");
this.text.Simplified = i18n("Simplified");
}
ngOnInit() {
if (!this._authService.isAuthenticated()
|| this._authService.user.value.role < UserRoles.Admin) {
this._navigation.toLogin();
return;
}
}
public getCss(type: NotificationType) {
switch (type) {
case NotificationType.error:
return "danger";
case NotificationType.warning:
return "warning";
case NotificationType.info:
return "info";
}
return "info";
}
}