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

47 lines
1.4 KiB
TypeScript
Raw Normal View History

2017-05-10 11:04:06 +02:00
import {Component, Inject, Optional} from '@angular/core';
import {Router} from '@angular/router';
2017-05-10 11:04:06 +02:00
import {LoginService} from './services/login-service/login-service';
import {AUTH_ENABLED} from './app.tokens';
2017-07-08 22:50:01 +02:00
import {WarService} from "./services/war-service/war.service";
import {War} from "./models/model-interfaces";
import {PromotionService} from "./services/promotion-service/promotion.service";
import {AwardingService} from "./services/awarding-service/awarding.service";
2017-05-10 11:04:06 +02:00
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css']
})
export class AppComponent {
2017-07-08 22:50:01 +02:00
wars: War[] = [];
2017-05-10 11:04:06 +02:00
constructor(@Optional() @Inject(AUTH_ENABLED) public authEnabled,
private loginService: LoginService,
2017-07-08 22:50:01 +02:00
private warService: WarService,
private promotionService: PromotionService,
private awardingService: AwardingService,
private router: Router) {
2017-05-10 11:04:06 +02:00
}
ngOnInit() {
2017-07-08 22:50:01 +02:00
this.warService.getAllWars().subscribe((wars) => {
this.wars = wars;
});
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(['cc-overview']);
2017-05-10 11:04:06 +02:00
return false;
}
}