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

50 lines
1.4 KiB
TypeScript
Raw Normal View History

2018-03-08 09:44:35 +01:00
import {Component, Inject, OnDestroy, OnInit} from '@angular/core';
2018-03-07 11:56:50 +01:00
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 '../utils/global.helpers';
@Component({
2018-03-08 10:17:10 +01:00
selector: 'cc-army',
templateUrl: './army.component.html',
styleUrls: ['./army.component.css']
})
2018-03-08 09:44:35 +01:00
export class ArmyComponent implements OnInit, OnDestroy {
2018-04-02 13:20:44 +02:00
army: Army[] = [{}, {}];
2017-11-08 14:54:04 +01:00
readonly fraction = Fraction;
constructor(private router: Router,
private route: ActivatedRoute,
2018-01-13 15:03:12 +01:00
private armyService: ArmyService,
@Inject(DOCUMENT) private document) {
}
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
this.armyService.getArmy()
2018-02-26 09:04:27 +01:00
.subscribe(army => {
this.army = army;
});
};
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
}
select(memberId) {
this.router.navigate([{outlets: {'right': ['member', memberId]}}], {relativeTo: this.route});
}
}