69 lines
2.1 KiB
TypeScript
69 lines
2.1 KiB
TypeScript
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
|
import {BaseConfig, RouteConfig} from '../../app.config';
|
|
import {environment} from '../../../environments/environment';
|
|
import {LoginService} from '../../services/app-user-service/login-service';
|
|
import {PromotionService} from '../../services/army-management/promotion.service';
|
|
import {AwardingService} from '../../services/army-management/awarding.service';
|
|
import {SettingsService} from '../../services/settings.service';
|
|
import {TranslateService} from '@ngx-translate/core';
|
|
|
|
declare function require(url: string);
|
|
|
|
@Component({
|
|
selector: 'app-header',
|
|
templateUrl: 'navigation-header.component.html',
|
|
styleUrls: ['navigation-header.component.scss']
|
|
})
|
|
export class NavigationHeaderComponent implements OnInit {
|
|
|
|
@Output() sidenavToggle = new EventEmitter();
|
|
|
|
@Output() userLogout = new EventEmitter();
|
|
|
|
@Input() currentUrl;
|
|
|
|
readonly features = environment.features;
|
|
|
|
readonly availableLanguages = BaseConfig.i18n.availableLanguages;
|
|
|
|
readonly version = require('./../../../../../package.json').version;
|
|
|
|
readonly config = RouteConfig;
|
|
|
|
language;
|
|
|
|
constructor(public loginService: LoginService,
|
|
private promotionService: PromotionService,
|
|
private awardingService: AwardingService,
|
|
private translate: TranslateService,
|
|
private settingsService: SettingsService) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.settingsService.getLanguage().subscribe((language) => {
|
|
this.language = language;
|
|
this.translate.setDefaultLang(language)
|
|
});
|
|
if (this.loginService.hasPermission(2)) {
|
|
const fraction = this.loginService.getCurrentUser().squad.fraction;
|
|
this.promotionService.checkUnconfirmedPromotions(fraction);
|
|
this.awardingService.checkUnprocessedAwards(fraction);
|
|
}
|
|
}
|
|
|
|
public onToggleSidenav() {
|
|
this.sidenavToggle.emit();
|
|
};
|
|
|
|
public doUserLogout() {
|
|
this.userLogout.emit()
|
|
};
|
|
|
|
setLanguage(language: string) {
|
|
if (language) {
|
|
this.language = language;
|
|
this.settingsService.setLanguage(language);
|
|
}
|
|
}
|
|
}
|