opt-cc/static/src/app/statistic/war-detail/war-detail.component.ts

64 lines
1.5 KiB
TypeScript
Raw Normal View History

2017-07-08 21:56:11 +02:00
import {Component} from "@angular/core";
2017-07-14 23:50:58 +02:00
import {ActivatedRoute, Router} from "@angular/router";
import {WarService} from "../../services/war-service/war.service";
import {LoginService} from "../../services/login-service/login-service";
import {Player, War} from "../../models/model-interfaces";
2017-07-08 21:56:11 +02:00
@Component({
selector: 'war-detail',
templateUrl: './war-detail.component.html',
styleUrls: ['./war-detail.component.css']
})
export class WarDetailComponent {
war: War = {players: []};
players: Player[] = [];
fractionRadioSelect: string;
2017-07-09 17:08:32 +02:00
sortBy = "kill";
sortOrder = "desc";
2017-07-30 16:25:11 +02:00
playerChart: any[] = [];
constructor(private route: ActivatedRoute,
private warService: WarService) {
2017-07-30 16:25:11 +02:00
Object.assign(this, this.playerChart)
2017-07-08 21:56:11 +02:00
}
ngOnInit() {
this.route.params
.map(params => params['id'])
.filter(id => id != undefined)
.flatMap(id => this.warService.getWar(id))
.subscribe(war => {
this.war = war;
this.players = war.players;
2017-07-30 16:25:11 +02:00
this.playerChart = [
{
"name": "CSAT",
"value": war.playersOpfor
},
{
"name": "NATO",
"value": war.playersBlufor
}
];
2017-07-08 21:56:11 +02:00
});
}
filterPlayersByFraction(fraction: string) {
if (fraction) {
this.players = this.war.players.filter((player) => {
return player.fraction === fraction;
})
} else {
this.players = this.war.players;
}
}
}