53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import {Component} from '@angular/core';
|
|
import {NavigationEnd, NavigationStart, Router} from '@angular/router';
|
|
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 {RouteConfig} from './app.config';
|
|
|
|
declare function require(url: string);
|
|
|
|
@Component({
|
|
selector: 'app-root',
|
|
templateUrl: 'app.component.html',
|
|
styleUrls: ['app.component.css', 'style/load-indicator.css']
|
|
})
|
|
export class AppComponent {
|
|
|
|
config = RouteConfig;
|
|
|
|
loading: boolean = false;
|
|
|
|
version = 'v' + require('./../../../package.json').version;
|
|
|
|
constructor(public loginService: LoginService,
|
|
private promotionService: PromotionService,
|
|
private awardingService: AwardingService,
|
|
private router: Router) {
|
|
router.events.subscribe(event => {
|
|
if (event instanceof NavigationStart) {
|
|
this.loading = true;
|
|
}
|
|
if (event instanceof NavigationEnd) {
|
|
this.loading = false;
|
|
}
|
|
});
|
|
}
|
|
|
|
ngOnInit() {
|
|
if (this.loginService.hasPermission(2)) {
|
|
const fraction = this.loginService.getCurrentUser().squad.fraction;
|
|
this.promotionService.checkUnconfirmedPromotions(fraction);
|
|
this.awardingService.checkUnprocessedAwards(fraction);
|
|
}
|
|
}
|
|
|
|
logout() {
|
|
this.loginService.logout();
|
|
this.router.navigate([RouteConfig.overviewPath]);
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|