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

91 lines
2.2 KiB
TypeScript
Raw Normal View History

2017-10-15 12:56:16 +02:00
import {Component, ElementRef, ViewChild} from "@angular/core";
import {ActivatedRoute, Router} from "@angular/router";
2017-10-22 18:06:37 +02:00
import {WarService} from "../../services/logs/war.service";
2017-09-13 11:49:34 +02:00
import {War} from "../../models/model-interfaces";
2017-10-22 18:06:37 +02:00
import {LogsService} from "../../services/logs/logs.service";
2017-07-08 21:56:11 +02:00
@Component({
selector: 'war-detail',
templateUrl: './war-detail.component.html',
2017-10-07 09:38:02 +02:00
styleUrls: ['./war-detail.component.css', '../../style/list-entry.css', '../../style/hide-scrollbar.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-10-15 12:56:16 +02:00
@ViewChild('overview') private overviewContainer: ElementRef;
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
constructor(private route: ActivatedRoute,
private router: Router,
2017-10-24 20:21:06 +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-10-15 12:56:16 +02:00
this.scrollOverviewTop();
2017-07-08 21:56:11 +02:00
});
}
filterPlayersByFraction(fraction?: string) {
2017-07-08 21:56:11 +02:00
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-10-15 12:56:16 +02:00
scrollOverviewTop() {
try {
this.overviewContainer.nativeElement.scrollTop = 0;
} catch (err) {
}
}
2017-10-28 20:25:58 +02:00
loadFractionData() {
console.log('load data from server')
}
2017-07-08 21:56:11 +02:00
}