2017-10-20 23:42:41 +02:00
|
|
|
import {Component} from '@angular/core';
|
2017-09-09 06:00:25 +02:00
|
|
|
import {NavigationEnd, NavigationStart, Router} from '@angular/router';
|
2017-10-22 18:06:37 +02:00
|
|
|
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";
|
2017-08-01 23:52:10 +02:00
|
|
|
import {RouteConfig} from "./app.config";
|
2017-05-10 11:04:06 +02:00
|
|
|
|
2017-10-14 18:43:00 +02:00
|
|
|
declare function require(url: string);
|
|
|
|
|
2017-05-10 11:04:06 +02:00
|
|
|
@Component({
|
|
|
|
selector: 'app-root',
|
|
|
|
templateUrl: 'app.component.html',
|
2017-09-09 06:00:25 +02:00
|
|
|
styleUrls: ['app.component.css', 'style/load-indicator.css']
|
2017-05-10 11:04:06 +02:00
|
|
|
})
|
|
|
|
export class AppComponent {
|
|
|
|
|
2017-08-01 23:52:10 +02:00
|
|
|
config = RouteConfig;
|
|
|
|
|
2017-09-09 06:00:25 +02:00
|
|
|
loading: boolean = false;
|
|
|
|
|
2017-10-15 12:56:16 +02:00
|
|
|
version = 'v' + require('./../../../package.json').version;
|
2017-10-14 18:43:00 +02:00
|
|
|
|
2017-10-15 12:56:16 +02:00
|
|
|
constructor(public loginService: LoginService,
|
2017-07-23 10:57:46 +02:00
|
|
|
private promotionService: PromotionService,
|
|
|
|
private awardingService: AwardingService,
|
|
|
|
private router: Router) {
|
2017-09-09 06:00:25 +02:00
|
|
|
router.events.subscribe(event => {
|
|
|
|
if (event instanceof NavigationStart) {
|
|
|
|
this.loading = true;
|
|
|
|
}
|
|
|
|
if (event instanceof NavigationEnd) {
|
|
|
|
this.loading = false;
|
2018-01-21 11:38:54 +01:00
|
|
|
if (router.url.includes(RouteConfig.overviewPath)) {
|
2017-10-15 12:56:16 +02:00
|
|
|
window.scrollTo({left: 0, top: 0, behavior: 'smooth'});
|
|
|
|
}
|
2017-09-09 06:00:25 +02:00
|
|
|
}
|
|
|
|
});
|
2017-05-10 11:04:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2017-07-23 10:57:46 +02:00
|
|
|
if (this.loginService.hasPermission(2)) {
|
|
|
|
const fraction = this.loginService.getCurrentUser().squad.fraction;
|
2017-07-27 16:38:35 +02:00
|
|
|
this.promotionService.checkUnconfirmedPromotions(fraction);
|
|
|
|
this.awardingService.checkUnprocessedAwards(fraction);
|
2017-05-10 11:04:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
logout() {
|
|
|
|
this.loginService.logout();
|
2017-08-01 23:52:10 +02:00
|
|
|
this.router.navigate([RouteConfig.overviewPath]);
|
2017-05-10 11:04:06 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|