2018-03-07 11:56:50 +01:00
|
|
|
import {Component, Inject} from '@angular/core';
|
|
|
|
import {Army} from '../models/model-interfaces';
|
|
|
|
import {ArmyService} from '../services/army-service/army.service';
|
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
import {Fraction} from '../utils/fraction.enum';
|
|
|
|
import {DOCUMENT} from '@angular/common';
|
|
|
|
import {RouteConfig} from '../app.config';
|
|
|
|
import {CSSHelpers} from '../global.helpers';
|
2017-05-11 21:46:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'army',
|
|
|
|
templateUrl: './army.component.html',
|
|
|
|
styleUrls: ['./army.component.css']
|
|
|
|
})
|
|
|
|
export class ArmyComponent {
|
|
|
|
|
2017-11-07 14:02:49 +01:00
|
|
|
army: Army = {BLUFOR: {squads: [], memberCount: 0}, OPFOR: {squads: [], memberCount: 0}};
|
|
|
|
|
2017-11-08 14:54:04 +01:00
|
|
|
readonly fraction = Fraction;
|
2017-05-11 21:46:28 +02:00
|
|
|
|
2017-05-18 14:32:51 +02:00
|
|
|
constructor(private router: Router,
|
|
|
|
private route: ActivatedRoute,
|
2018-01-13 15:03:12 +01:00
|
|
|
private armyService: ArmyService,
|
|
|
|
@Inject(DOCUMENT) private document) {
|
2017-05-11 21:46:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2018-01-13 15:03:12 +01:00
|
|
|
// set background image css
|
2018-01-21 11:38:54 +01:00
|
|
|
this.document.getElementById('right').setAttribute('style', CSSHelpers.getBackgroundCSS('../assets/bg.jpg'));
|
2018-01-13 15:03:12 +01:00
|
|
|
|
|
|
|
// init army data
|
2017-05-11 21:46:28 +02:00
|
|
|
this.armyService.getArmy()
|
2018-02-26 09:04:27 +01:00
|
|
|
.subscribe(army => {
|
|
|
|
this.army = army;
|
|
|
|
});
|
2017-05-11 21:46:28 +02:00
|
|
|
};
|
2017-05-18 14:32:51 +02:00
|
|
|
|
2018-01-13 15:03:12 +01:00
|
|
|
ngOnDestroy() {
|
2018-01-21 11:50:22 +01:00
|
|
|
if (!this.router.url.includes(RouteConfig.overviewPath)) {
|
2018-01-21 11:38:54 +01:00
|
|
|
this.document.getElementById('right').setAttribute('style', '');
|
|
|
|
}
|
2018-01-13 15:03:12 +01:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:32:51 +02:00
|
|
|
select(memberId) {
|
2017-10-03 18:30:29 +02:00
|
|
|
this.router.navigate([{outlets: {'right': ['member', memberId]}}], {relativeTo: this.route});
|
2017-05-18 14:32:51 +02:00
|
|
|
}
|
|
|
|
|
2017-05-11 21:46:28 +02:00
|
|
|
}
|