2018-03-31 03:30:30 +08: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';
|
|
|
|
import {I18n} from '@ngx-translate/i18n-polyfill';
|
2018-03-30 08:30:23 +08:00
|
|
|
|
2016-04-26 21:10:05 +08:00
|
|
|
@Component({
|
2018-05-04 07:17:08 +08:00
|
|
|
selector: 'app-admin',
|
2017-06-11 04:32:56 +08:00
|
|
|
templateUrl: './admin.component.html',
|
|
|
|
styleUrls: ['./admin.component.css']
|
2016-04-26 21:10:05 +08:00
|
|
|
})
|
2016-05-02 03:30:43 +08:00
|
|
|
export class AdminComponent implements OnInit {
|
|
|
|
|
2017-07-15 23:29:40 +08:00
|
|
|
simplifiedMode = true;
|
2018-03-30 08:30:23 +08:00
|
|
|
text = {
|
2018-03-31 03:30:30 +08:00
|
|
|
Advanced: 'Advanced',
|
|
|
|
Simplified: 'Simplified'
|
2018-03-30 08:30:23 +08:00
|
|
|
};
|
2017-07-15 23:29:40 +08:00
|
|
|
|
2017-07-09 20:23:50 +08:00
|
|
|
constructor(private _authService: AuthenticationService,
|
2017-07-15 18:47:11 +08:00
|
|
|
private _navigation: NavigationService,
|
2018-03-30 08:30:23 +08:00
|
|
|
public notificationService: NotificationService,
|
|
|
|
public i18n: I18n) {
|
2018-03-31 03:30:30 +08:00
|
|
|
this.text.Advanced = i18n('Advanced');
|
|
|
|
this.text.Simplified = i18n('Simplified');
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-04-26 21:10:05 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
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();
|
2017-06-11 04:32:56 +08:00
|
|
|
return;
|
2016-04-26 21:10:05 +08:00
|
|
|
}
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-04-26 21:10:05 +08:00
|
|
|
|
2017-07-14 15:28:52 +08:00
|
|
|
public getCss(type: NotificationType) {
|
|
|
|
switch (type) {
|
|
|
|
case NotificationType.error:
|
2018-03-31 03:30:30 +08:00
|
|
|
return 'danger';
|
2017-07-14 15:28:52 +08:00
|
|
|
case NotificationType.warning:
|
2018-03-31 03:30:30 +08:00
|
|
|
return 'warning';
|
2017-07-14 15:28:52 +08:00
|
|
|
case NotificationType.info:
|
2018-03-31 03:30:30 +08:00
|
|
|
return 'info';
|
2017-07-14 15:28:52 +08:00
|
|
|
}
|
2018-03-31 03:30:30 +08:00
|
|
|
return 'info';
|
2017-07-14 15:28:52 +08:00
|
|
|
}
|
|
|
|
|
2016-04-26 21:10:05 +08:00
|
|
|
}
|
|
|
|
|
2016-05-03 20:29:24 +08:00
|
|
|
|
|
|
|
|