2017-10-15 12:56:16 +02:00
|
|
|
import {Component, ElementRef, ViewChild} from "@angular/core";
|
2017-10-01 20:24:35 +02:00
|
|
|
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
|
|
|
|
2017-10-28 22:50:54 +02:00
|
|
|
pointData: any[] = [];
|
|
|
|
budgetData: any[] = [];
|
|
|
|
|
|
|
|
colorScheme = {
|
|
|
|
domain: ['#0000FF', '#B22222']
|
|
|
|
};
|
|
|
|
|
|
|
|
yAxisLabelPoints = 'Punkte';
|
|
|
|
yAxisLabelBudget = 'Budget';
|
|
|
|
|
|
|
|
gradient = false;
|
|
|
|
yAxis = true;
|
|
|
|
xAxis = true;
|
|
|
|
legend = false;
|
|
|
|
legendTitle = false;
|
|
|
|
showXAxisLabel = false;
|
|
|
|
showYAxisLabel = true;
|
|
|
|
autoscale = true;
|
|
|
|
timeline = false;
|
|
|
|
roundDomains = true;
|
|
|
|
fractionInitialized: boolean = false;
|
|
|
|
|
2017-08-06 10:42:37 +02:00
|
|
|
constructor(private route: ActivatedRoute,
|
2017-10-01 20:24:35 +02:00
|
|
|
private router: Router,
|
2017-10-28 22:50:54 +02:00
|
|
|
private warService: WarService,
|
|
|
|
private logsService: LogsService) {
|
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-28 22:50:54 +02:00
|
|
|
Object.assign(this, [this.playerChart, this.pointData, this.budgetData]);
|
2017-10-15 12:56:16 +02:00
|
|
|
this.scrollOverviewTop();
|
2017-07-08 21:56:11 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-08 12:17:21 +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() {
|
2017-10-28 22:50:54 +02:00
|
|
|
if (!this.fractionInitialized) {
|
|
|
|
const tmpPointData = [
|
|
|
|
{
|
|
|
|
"name": "NATO",
|
|
|
|
"series": []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "CSAT",
|
|
|
|
"series": []
|
|
|
|
}
|
|
|
|
];
|
|
|
|
const tmpBudgetData = JSON.parse(JSON.stringify(tmpPointData));
|
|
|
|
const tmpKillData = JSON.parse(JSON.stringify(tmpPointData));
|
|
|
|
const tmpFrienlyFireData = JSON.parse(JSON.stringify(tmpPointData));
|
|
|
|
const tmpTransportData = JSON.parse(JSON.stringify(tmpPointData));
|
|
|
|
const tmpReviveData = JSON.parse(JSON.stringify(tmpPointData));
|
|
|
|
const tmpStabilizeData = JSON.parse(JSON.stringify(tmpPointData));
|
|
|
|
const tmpFlagCaptureData = JSON.parse(JSON.stringify(tmpPointData));
|
|
|
|
|
|
|
|
// POINTS
|
|
|
|
this.logsService.getPointsLogs(this.war._id).subscribe((data) => {
|
|
|
|
data.forEach(pointEntry => {
|
|
|
|
const dateObj = new Date(this.war.date);
|
|
|
|
const time = pointEntry.time.split(':');
|
|
|
|
dateObj.setHours(time[0]);
|
|
|
|
dateObj.setMinutes(time[1]);
|
|
|
|
tmpPointData[0].series.push({
|
|
|
|
"name": dateObj,
|
|
|
|
"value": pointEntry.ptBlufor
|
|
|
|
});
|
|
|
|
tmpPointData[1].series.push({
|
|
|
|
"name": dateObj,
|
|
|
|
"value": pointEntry.ptOpfor
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.pointData = tmpPointData;
|
|
|
|
});
|
|
|
|
|
|
|
|
// BUDGET
|
|
|
|
this.logsService.getBudgetLogs(this.war._id).subscribe((data) => {
|
|
|
|
const dateObj = new Date(this.war.date);
|
|
|
|
dateObj.setHours(0);
|
|
|
|
dateObj.setMinutes(0);
|
|
|
|
tmpBudgetData[0].series.push({
|
|
|
|
"name": dateObj,
|
|
|
|
"value": this.war.budgetBlufor
|
|
|
|
});
|
|
|
|
tmpBudgetData[1].series.push({
|
|
|
|
"name": dateObj,
|
|
|
|
"value": this.war.budgetOpfor
|
|
|
|
});
|
|
|
|
data.forEach(budgetEntry => {
|
|
|
|
const time = budgetEntry.time.split(':');
|
|
|
|
const dateObj = new Date(this.war.date);
|
|
|
|
dateObj.setHours(time[0]);
|
|
|
|
dateObj.setMinutes(time[1]);
|
|
|
|
tmpBudgetData[budgetEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
|
|
|
|
"name": dateObj,
|
|
|
|
"value": budgetEntry.newBudget
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.budgetData = tmpBudgetData;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.fractionInitialized = true;
|
|
|
|
}
|
2017-10-28 20:25:58 +02:00
|
|
|
}
|
|
|
|
|
2017-07-08 21:56:11 +02:00
|
|
|
}
|