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

74 lines
1.7 KiB
TypeScript
Raw Normal View History

2017-07-08 21:56:11 +02:00
import {Component} from "@angular/core";
2017-09-03 12:49:59 +02:00
import {ActivatedRoute} from "@angular/router";
import {WarService} from "../../services/war-service/war.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-09-12 15:44:12 +02:00
playerChart: any[] = [];
2017-07-09 17:08:32 +02:00
2017-09-12 15:44:12 +02:00
rows = [];
2017-07-09 17:08:32 +02:00
2017-09-12 15:44:12 +02:00
columns = [];
2017-07-30 16:25:11 +02:00
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;
2017-09-12 15:44:12 +02:00
this.rows = 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
});
2017-09-12 15:44:12 +02:00
this.columns = [
{prop: 'name', name: 'Spieler'},
{prop: 'fraction', name: 'Fraktion'},
{prop: 'kill', name: 'Kills'},
{prop: 'friendlyFire', name: 'FriendlyFire'},
{prop: 'revive', name: 'Revive'},
{prop: 'flagTouch', name: 'Eroberung'},
{prop: 'death', name: 'Tod'},
{prop: 'respawn', name: 'Respawn'}
];
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;
}
}
}