2017-11-03 12:51:58 +01:00
|
|
|
///<reference path="../../utils/chart-utils.ts"/>
|
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-10-29 17:36:55 +01:00
|
|
|
import {TabsetComponent} from "ngx-bootstrap";
|
|
|
|
import * as d3 from "d3";
|
2017-11-02 19:40:16 +01:00
|
|
|
import {ChartUtils} from "../../utils/chart-utils";
|
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 {
|
|
|
|
|
2017-10-29 17:36:55 +01:00
|
|
|
@ViewChild('overview') private overviewContainer: ElementRef;
|
|
|
|
|
|
|
|
@ViewChild('staticTabs') staticTabs: TabsetComponent;
|
|
|
|
|
2017-07-08 21:56:11 +02:00
|
|
|
war: War = {players: []};
|
|
|
|
|
2017-11-03 12:51:58 +01:00
|
|
|
public chartSelectModel: string;
|
|
|
|
|
2017-07-08 21:56:11 +02:00
|
|
|
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-11-03 12:51:58 +01:00
|
|
|
lineChartData: any[] = [];
|
|
|
|
areaChartData: any[] = [];
|
2017-10-29 17:36:55 +01:00
|
|
|
|
|
|
|
tmpPointData;
|
|
|
|
tmpBudgetData;
|
|
|
|
tmpKillData;
|
|
|
|
tmpFrienlyFireData;
|
|
|
|
tmpTransportData;
|
|
|
|
tmpReviveData;
|
|
|
|
tmpStabilizeData;
|
|
|
|
tmpFlagCaptureData;
|
2017-10-28 22:50:54 +02:00
|
|
|
|
|
|
|
colorScheme = {
|
|
|
|
domain: ['#0000FF', '#B22222']
|
|
|
|
};
|
|
|
|
|
2017-11-03 12:51:58 +01:00
|
|
|
labelPoints = 'Punkte';
|
|
|
|
labelBudget = 'Budget';
|
|
|
|
labelKill = 'Kills';
|
|
|
|
labelFriendlyFire = 'FriendlyFire';
|
|
|
|
labelTransport = 'Lufttransport';
|
|
|
|
labelRevive = 'Revive';
|
|
|
|
labelStabilize = 'Stabilisiert';
|
|
|
|
labelFlag = 'Flaggenbesitz';
|
|
|
|
lineChartLabel = this.labelPoints;
|
|
|
|
|
|
|
|
showLineChart = true;
|
2017-10-29 17:36:55 +01:00
|
|
|
stepCurve = d3.curveStepAfter;
|
2017-10-28 22:50:54 +02:00
|
|
|
gradient = false;
|
|
|
|
yAxis = true;
|
|
|
|
xAxis = true;
|
|
|
|
legend = false;
|
|
|
|
legendTitle = false;
|
|
|
|
showXAxisLabel = false;
|
|
|
|
showYAxisLabel = true;
|
|
|
|
autoscale = true;
|
|
|
|
timeline = false;
|
|
|
|
roundDomains = true;
|
2017-10-29 17:36:55 +01:00
|
|
|
fractionChartsInitialized: boolean = false;
|
2017-10-28 22:50:54 +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-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-11-03 12:51:58 +01:00
|
|
|
this.playerChart = ChartUtils.getSingleDataArray('CSAT', war.playersOpfor, 'NATO', war.playersBlufor);
|
2017-10-29 17:36:55 +01:00
|
|
|
|
|
|
|
this.fractionChartsInitialized = false;
|
2017-11-03 12:51:58 +01:00
|
|
|
Object.assign(this, [this.playerChart, this.lineChartData, this.areaChartData]);
|
|
|
|
this.chartSelectModel = this.labelPoints;
|
|
|
|
|
2017-10-29 17:36:55 +01:00
|
|
|
this.staticTabs.tabs[0].active = true;
|
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-11-03 12:51:58 +01:00
|
|
|
selectChart() {
|
|
|
|
if (this.chartSelectModel !== this.labelFlag) {
|
|
|
|
this.showLineChart = true;
|
|
|
|
this.lineChartLabel = this.chartSelectModel;
|
|
|
|
switch (this.chartSelectModel) {
|
|
|
|
case this.labelPoints:
|
|
|
|
this.lineChartData = this.tmpPointData;
|
|
|
|
break;
|
|
|
|
case this.labelBudget:
|
|
|
|
this.lineChartData = this.tmpBudgetData;
|
|
|
|
break;
|
|
|
|
case this.labelKill:
|
|
|
|
this.lineChartData = this.tmpKillData;
|
|
|
|
break;
|
|
|
|
case this.labelFriendlyFire:
|
|
|
|
this.lineChartData = this.tmpFrienlyFireData;
|
|
|
|
break;
|
|
|
|
case this.labelRevive:
|
|
|
|
this.lineChartData = this.tmpReviveData;
|
|
|
|
break;
|
|
|
|
case this.labelStabilize:
|
|
|
|
this.lineChartData = this.tmpStabilizeData;
|
|
|
|
break;
|
|
|
|
case this.labelTransport:
|
|
|
|
this.lineChartData = this.tmpTransportData;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.showLineChart = false;
|
|
|
|
this.areaChartData = this.tmpFlagCaptureData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-11-02 18:54:26 +01:00
|
|
|
if (this.fractionChartsInitialized) {
|
|
|
|
return;
|
|
|
|
}
|
2017-10-28 22:50:54 +02:00
|
|
|
|
2017-11-03 12:51:58 +01:00
|
|
|
this.tmpPointData = ChartUtils.getMultiDataArray('NATO', 'CSAT');
|
|
|
|
this.tmpBudgetData = ChartUtils.getMultiDataArray('NATO', 'CSAT');
|
|
|
|
this.tmpKillData = ChartUtils.getMultiDataArray('NATO', 'CSAT');
|
|
|
|
this.tmpFrienlyFireData = ChartUtils.getMultiDataArray('NATO', 'CSAT');
|
|
|
|
this.tmpTransportData = ChartUtils.getMultiDataArray('NATO', 'CSAT');
|
|
|
|
this.tmpReviveData = ChartUtils.getMultiDataArray('NATO', 'CSAT');
|
|
|
|
this.tmpStabilizeData = ChartUtils.getMultiDataArray('NATO', 'CSAT');
|
|
|
|
this.tmpFlagCaptureData = ChartUtils.getMultiDataArray('NATO', 'CSAT');
|
|
|
|
|
2017-11-02 19:40:16 +01:00
|
|
|
const newFractionGraphEntry = (entry: any, val1: any, val2: any) => {
|
|
|
|
return ChartUtils.getSeriesEntry(new Date(entry.time), entry.fraction === 'BLUFOR' ? val1 : val2);
|
2017-11-02 18:54:26 +01:00
|
|
|
};
|
2017-10-29 17:36:55 +01:00
|
|
|
|
2017-11-02 18:54:26 +01:00
|
|
|
const startDateObj = new Date(this.war.date);
|
|
|
|
startDateObj.setHours(0);
|
|
|
|
startDateObj.setMinutes(1);
|
|
|
|
|
|
|
|
[this.tmpKillData, this.tmpFrienlyFireData, this.tmpReviveData, this.tmpStabilizeData, this.tmpTransportData].forEach(tmp => {
|
|
|
|
[0, 1].forEach(index => {
|
2017-11-02 19:40:16 +01:00
|
|
|
tmp[index].series.push(ChartUtils.getSeriesEntry(startDateObj, 0));
|
2017-11-02 18:54:26 +01:00
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
let killCountBlufor = 0, killCountOpfor = 0, ffKillCountBlufor = 0, ffKillCountOpfor = 0, reviveCountBlufor = 0,
|
|
|
|
reviveCountOpfor = 0, stabilizeCountBlufor = 0, stabilizeCountOpfor = 0, transportCountBlufor = 0,
|
|
|
|
transportCountOpfor = 0;
|
|
|
|
|
|
|
|
this.logsService.getFullLog(this.war._id).subscribe((data) => {
|
|
|
|
// POINTS
|
|
|
|
data.points.forEach(pointEntry => {
|
2017-11-02 19:40:16 +01:00
|
|
|
this.tmpPointData[0].series.push(ChartUtils.getSeriesEntry(new Date(pointEntry.time), pointEntry.ptBlufor));
|
|
|
|
this.tmpPointData[1].series.push(ChartUtils.getSeriesEntry(new Date(pointEntry.time), pointEntry.ptOpfor));
|
2017-11-02 18:54:26 +01:00
|
|
|
});
|
2017-10-29 17:36:55 +01:00
|
|
|
|
2017-11-02 18:54:26 +01:00
|
|
|
// BUDGET
|
2017-11-02 19:40:16 +01:00
|
|
|
this.tmpBudgetData[0].series.push(ChartUtils.getSeriesEntry(startDateObj, this.war.budgetBlufor));
|
|
|
|
this.tmpBudgetData[1].series.push(ChartUtils.getSeriesEntry(startDateObj, this.war.budgetOpfor));
|
2017-11-02 18:54:26 +01:00
|
|
|
// This adds an entry for both fractions on every event
|
|
|
|
for (let i = 0; i < data.budget.length; i++) {
|
|
|
|
const budgetEntry = data.budget[i];
|
|
|
|
const fractionChange = budgetEntry.fraction === 'BLUFOR' ? 0 : 1;
|
|
|
|
const fractionOld = budgetEntry.fraction !== 'BLUFOR' ? 0 : 1;
|
|
|
|
|
2017-11-02 19:40:16 +01:00
|
|
|
this.tmpBudgetData[fractionChange].series.push(ChartUtils.getSeriesEntry(new Date(budgetEntry.time), budgetEntry.newBudget));
|
|
|
|
this.tmpBudgetData[fractionOld].series.push(ChartUtils.getSeriesEntry(new Date(budgetEntry.time),
|
|
|
|
this.tmpBudgetData[fractionOld].series[this.tmpBudgetData[fractionOld].series.length - 1].value));
|
2017-11-02 18:54:26 +01:00
|
|
|
}
|
2017-10-29 17:36:55 +01:00
|
|
|
|
2017-11-02 18:54:26 +01:00
|
|
|
// KILLS & FRIENDLY FIRE
|
|
|
|
data.kill.forEach(killEntry => {
|
2017-11-02 19:40:16 +01:00
|
|
|
if (killEntry.friendlyFire === false) {
|
|
|
|
if (killEntry.fraction === 'BLUFOR') {
|
2017-11-02 18:54:26 +01:00
|
|
|
killCountBlufor++;
|
2017-10-29 17:36:55 +01:00
|
|
|
} else {
|
2017-11-02 19:40:16 +01:00
|
|
|
killCountOpfor++;
|
2017-10-29 17:36:55 +01:00
|
|
|
}
|
2017-11-02 19:40:16 +01:00
|
|
|
this.tmpKillData[0].series.push(ChartUtils.getSeriesEntry(new Date(killEntry.time), killCountBlufor));
|
|
|
|
this.tmpKillData[1].series.push(ChartUtils.getSeriesEntry(new Date(killEntry.time), killCountOpfor));
|
2017-11-02 18:54:26 +01:00
|
|
|
} else {
|
2017-11-02 19:40:16 +01:00
|
|
|
if (killEntry.fraction === 'BLUFOR') {
|
|
|
|
ffKillCountBlufor++;
|
2017-10-29 17:36:55 +01:00
|
|
|
} else {
|
2017-11-02 18:54:26 +01:00
|
|
|
ffKillCountOpfor++;
|
2017-10-29 17:36:55 +01:00
|
|
|
}
|
2017-11-02 19:40:16 +01:00
|
|
|
this.tmpFrienlyFireData[0].series.push(ChartUtils.getSeriesEntry(new Date(killEntry.time), ffKillCountBlufor));
|
|
|
|
this.tmpFrienlyFireData[1].series.push(ChartUtils.getSeriesEntry(new Date(killEntry.time), ffKillCountOpfor));
|
2017-11-02 18:54:26 +01:00
|
|
|
}
|
|
|
|
});
|
2017-10-28 22:50:54 +02:00
|
|
|
|
2017-11-02 19:40:16 +01:00
|
|
|
|
2017-11-02 18:54:26 +01:00
|
|
|
// REVIVE & STABILIZE
|
|
|
|
data.revive.forEach(reviveEntry => {
|
2017-11-02 19:40:16 +01:00
|
|
|
if (reviveEntry.stabilized === false) {
|
|
|
|
if (reviveEntry.fraction === 'BLUFOR') {
|
2017-11-02 18:54:26 +01:00
|
|
|
reviveCountBlufor++;
|
2017-10-29 17:36:55 +01:00
|
|
|
} else {
|
2017-11-02 19:40:16 +01:00
|
|
|
reviveCountOpfor++;
|
2017-10-29 17:36:55 +01:00
|
|
|
}
|
2017-11-02 19:40:16 +01:00
|
|
|
this.tmpReviveData[0].series.push(ChartUtils.getSeriesEntry(new Date(reviveEntry.time), reviveCountBlufor));
|
|
|
|
this.tmpReviveData[1].series.push(ChartUtils.getSeriesEntry(new Date(reviveEntry.time), reviveCountOpfor));
|
2017-11-02 18:54:26 +01:00
|
|
|
} else {
|
2017-11-02 19:40:16 +01:00
|
|
|
if (reviveEntry.fraction === 'BLUFOR') {
|
|
|
|
stabilizeCountBlufor++;
|
2017-11-02 18:54:26 +01:00
|
|
|
} else {
|
|
|
|
stabilizeCountOpfor++;
|
|
|
|
}
|
2017-11-02 19:40:16 +01:00
|
|
|
this.tmpStabilizeData[0].series.push(ChartUtils.getSeriesEntry(new Date(reviveEntry.time), stabilizeCountBlufor));
|
|
|
|
this.tmpStabilizeData[1].series.push(ChartUtils.getSeriesEntry(new Date(reviveEntry.time), stabilizeCountOpfor));
|
2017-11-02 18:54:26 +01:00
|
|
|
}
|
|
|
|
});
|
2017-10-30 08:59:08 +01:00
|
|
|
|
2017-11-02 18:54:26 +01:00
|
|
|
// TRANSPORT
|
|
|
|
data.transport.forEach(transportEntry => {
|
|
|
|
if (transportEntry.fraction === 'BLUFOR') {
|
|
|
|
transportCountBlufor++;
|
|
|
|
} else {
|
|
|
|
transportCountOpfor++;
|
|
|
|
}
|
2017-11-02 19:40:16 +01:00
|
|
|
this.tmpTransportData[0].series.push(ChartUtils.getSeriesEntry(new Date(transportEntry.time), transportCountBlufor));
|
|
|
|
this.tmpTransportData[1].series.push(ChartUtils.getSeriesEntry(new Date(transportEntry.time), transportCountOpfor));
|
2017-11-02 18:54:26 +01:00
|
|
|
});
|
2017-10-29 17:36:55 +01:00
|
|
|
|
2017-11-02 18:54:26 +01:00
|
|
|
// FLAG
|
|
|
|
let flagStatusBlufor = true;
|
|
|
|
let flagStatusOpfor = true;
|
2017-11-02 19:40:16 +01:00
|
|
|
this.tmpFlagCaptureData[0].series.push(ChartUtils.getSeriesEntry(startDateObj, flagStatusBlufor));
|
|
|
|
this.tmpFlagCaptureData[1].series.push(ChartUtils.getSeriesEntry(startDateObj, flagStatusOpfor));
|
2017-11-02 18:54:26 +01:00
|
|
|
|
|
|
|
data.flag.forEach(flagEntry => {
|
|
|
|
if (flagEntry.flagFraction === 'BLUFOR') {
|
|
|
|
flagStatusBlufor = !flagEntry.capture
|
|
|
|
} else {
|
|
|
|
flagStatusOpfor = !flagEntry.capture;
|
|
|
|
}
|
|
|
|
this.tmpFlagCaptureData[flagEntry.flagFraction === 'BLUFOR' ? 0 : 1].series.push(
|
2017-11-02 19:40:16 +01:00
|
|
|
newFractionGraphEntry(flagEntry, flagStatusBlufor, flagStatusOpfor)
|
2017-11-02 18:54:26 +01:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.addFinalTimeDataEntriesAndPopulate(new Date(this.war.endDate));
|
|
|
|
|
|
|
|
this.fractionChartsInitialized = true;
|
|
|
|
});
|
2017-10-28 20:25:58 +02:00
|
|
|
}
|
|
|
|
|
2017-10-30 08:59:08 +01:00
|
|
|
addFinalTimeDataEntriesAndPopulate(endDate) {
|
|
|
|
[this.tmpPointData, this.tmpBudgetData, this.tmpTransportData, this.tmpReviveData, this.tmpStabilizeData,
|
|
|
|
this.tmpKillData, this.tmpFrienlyFireData, this.tmpFlagCaptureData].forEach(tmp => {
|
|
|
|
for (let j in [0, 1]) {
|
2017-11-02 11:22:27 +01:00
|
|
|
if (tmp[j].series[tmp[j].series.length - 1].name < endDate) {
|
2017-11-02 19:40:16 +01:00
|
|
|
tmp[j].series.push(ChartUtils.getSeriesEntry(endDate, tmp[j].series[tmp[j].series.length - 1].value));
|
2017-10-30 08:59:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2017-11-03 12:51:58 +01:00
|
|
|
|
|
|
|
this.showLineChart = true;
|
|
|
|
this.lineChartLabel = this.labelPoints;
|
|
|
|
this.lineChartData = this.tmpPointData;
|
2017-10-30 08:59:08 +01:00
|
|
|
}
|
|
|
|
|
2017-07-08 21:56:11 +02:00
|
|
|
}
|