2017-07-08 21:56:11 +02:00
|
|
|
import {Component} from "@angular/core";
|
2017-10-01 20:24:35 +02:00
|
|
|
import {ActivatedRoute, Router} from "@angular/router";
|
2017-08-06 10:42:37 +02:00
|
|
|
import {WarService} from "../../services/war-service/war.service";
|
2017-09-13 11:49:34 +02:00
|
|
|
import {War} from "../../models/model-interfaces";
|
2017-07-08 21:56:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'war-detail',
|
|
|
|
templateUrl: './war-detail.component.html',
|
2017-10-02 19:29:53 +02:00
|
|
|
styleUrls: ['./war-detail.component.css', '../../style/list-entry.css']
|
2017-07-08 21:56:11 +02:00
|
|
|
})
|
|
|
|
export class WarDetailComponent {
|
|
|
|
|
|
|
|
war: War = {players: []};
|
|
|
|
|
|
|
|
fractionRadioSelect: string;
|
|
|
|
|
2017-09-12 15:44:12 +02:00
|
|
|
playerChart: any[] = [];
|
2017-07-09 17:08:32 +02:00
|
|
|
|
2017-09-13 11:49:34 +02:00
|
|
|
cellHeight = 40;
|
|
|
|
|
2017-09-12 15:44:12 +02:00
|
|
|
rows = [];
|
2017-07-09 17:08:32 +02:00
|
|
|
|
2017-09-13 11:49:34 +02:00
|
|
|
reorderable: boolean = false;
|
|
|
|
|
|
|
|
customClasses = {
|
|
|
|
sortAscending: 'glyphicon glyphicon-triangle-top',
|
|
|
|
sortDescending: 'glyphicon glyphicon-triangle-bottom',
|
|
|
|
};
|
2017-07-30 16:25:11 +02:00
|
|
|
|
2017-08-06 10:42:37 +02:00
|
|
|
constructor(private route: ActivatedRoute,
|
2017-10-01 20:24:35 +02:00
|
|
|
private router: Router,
|
2017-08-06 10:42:37 +02:00
|
|
|
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
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
filterPlayersByFraction(fraction: string) {
|
|
|
|
if (fraction) {
|
2017-09-13 11:49:34 +02:00
|
|
|
this.rows = this.war.players.filter((player) => {
|
2017-07-08 21:56:11 +02:00
|
|
|
return player.fraction === fraction;
|
|
|
|
})
|
|
|
|
} else {
|
2017-09-13 11:49:34 +02:00
|
|
|
this.rows = this.war.players;
|
2017-07-08 21:56:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-02 20:03:42 +02:00
|
|
|
selectPlayerDetail(player) {
|
|
|
|
if (player && player.selected && player.selected.length > 0) {
|
|
|
|
this.router.navigate(['../../campaign-player/' + this.war.campaign + '/' + player.selected[0].name],
|
|
|
|
{relativeTo: this.route});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-08 21:56:11 +02:00
|
|
|
}
|