opt-cc/static/src/app/app.component.ts

53 lines
1.5 KiB
TypeScript
Raw Normal View History

2017-09-03 12:49:59 +02:00
import {Component} from '@angular/core';
2017-09-09 06:00:25 +02:00
import {NavigationEnd, NavigationStart, Router} from '@angular/router';
2017-05-10 11:04:06 +02:00
import {LoginService} from './services/login-service/login-service';
import {PromotionService} from "./services/promotion-service/promotion.service";
import {AwardingService} from "./services/awarding-service/awarding.service";
import {RouteConfig} from "./app.config";
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 {
config = RouteConfig;
2017-09-09 06:00:25 +02:00
loading: boolean = false;
constructor(public loginService: LoginService,
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;
2017-10-14 15:26:05 +02:00
// if (!router.url.includes('right')) {
// window.scrollTo(0, 0);
// }
2017-09-09 06:00:25 +02:00
}
});
2017-05-10 11:04:06 +02:00
}
ngOnInit() {
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();
this.router.navigate([RouteConfig.overviewPath]);
2017-05-10 11:04:06 +02:00
return false;
}
}