1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00
pigallery2/frontend/app/ui/admin/admin.component.ts

56 lines
1.6 KiB
TypeScript
Raw Normal View History

2018-03-30 15:30:30 -04:00
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';
2018-03-30 15:30:30 -04:00
import {I18n} from '@ngx-translate/i18n-polyfill';
import {Config} from '../../../../common/config/public/Config';
2018-03-29 20:30:23 -04:00
@Component({
2018-05-03 19:17:08 -04:00
selector: 'app-admin',
templateUrl: './admin.component.html',
styleUrls: ['./admin.component.css']
})
export class AdminComponent implements OnInit {
2019-08-20 12:54:45 +02:00
simplifiedMode = false;
2018-03-29 20:30:23 -04:00
text = {
2018-03-30 15:30:30 -04:00
Advanced: 'Advanced',
Simplified: 'Simplified'
2018-03-29 20:30:23 -04:00
};
appVersion = Config.Client.appVersion;
2017-07-15 17:29:40 +02:00
2017-07-09 14:23:50 +02:00
constructor(private _authService: AuthenticationService,
2017-07-15 12:47:11 +02:00
private _navigation: NavigationService,
2018-03-29 20:30:23 -04:00
public notificationService: NotificationService,
public i18n: I18n) {
2018-03-30 15:30:30 -04:00
this.text.Advanced = i18n('Advanced');
this.text.Simplified = i18n('Simplified');
}
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();
return;
}
}
2017-07-14 09:28:52 +02:00
public getCss(type: NotificationType) {
switch (type) {
case NotificationType.error:
2018-03-30 15:30:30 -04:00
return 'danger';
2017-07-14 09:28:52 +02:00
case NotificationType.warning:
2018-03-30 15:30:30 -04:00
return 'warning';
2017-07-14 09:28:52 +02:00
case NotificationType.info:
2018-03-30 15:30:30 -04:00
return 'info';
2017-07-14 09:28:52 +02:00
}
2018-03-30 15:30:30 -04:00
return 'info';
2017-07-14 09:28:52 +02:00
}
}