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

49 lines
1.3 KiB
TypeScript
Raw Normal View History

2018-07-28 19:13:30 +02:00
import {Component, 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';
2019-02-27 23:13:23 +01:00
import {BaseConfig} from '../app.config';
import {Observable} from 'rxjs';
@Component({
2018-03-08 10:17:10 +01:00
selector: 'cc-army',
templateUrl: './army.component.html',
styleUrls: ['./army.component.scss']
})
2018-07-28 19:13:30 +02:00
export class ArmyComponent implements OnInit {
2019-02-27 23:13:23 +01:00
readonly fraction = Fraction;
2018-04-02 13:20:44 +02:00
army: Army[] = [{}, {}];
2019-02-27 23:13:23 +01:00
singleViewSelected = this.fraction.BLUFOR;
isSmallLayout;
constructor(private router: Router,
private route: ActivatedRoute,
2018-07-28 19:13:30 +02:00
private armyService: ArmyService) {
}
ngOnInit() {
this.armyService.getArmies().subscribe(army => {
this.army = army;
});
2019-02-27 23:13:23 +01:00
this.isSmallLayout = (window.innerWidth <= BaseConfig.responsive.breakpointSmallPx);
Observable.fromEvent(window, 'resize').subscribe(event => {
this.isSmallLayout = event.target['innerWidth'] <= BaseConfig.responsive.breakpointSmallPx;
});
};
select(memberId) {
2018-07-28 19:13:30 +02:00
this.router.navigate(['member', memberId], {relativeTo: this.route});
}
2019-02-27 23:13:23 +01:00
singleViewSwitch(switchFraction: Fraction) {
this.singleViewSelected = switchFraction;
}
}