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
|
|
|
|
2017-11-04 20:46:05 +01:00
|
|
|
initialized;
|
|
|
|
|
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';
|
2017-11-04 15:58:48 +01:00
|
|
|
lineChartLabel: string = this.labelPoints;
|
2017-11-03 12:51:58 +01:00
|
|
|
|
|
|
|
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-11-03 21:31:03 +01:00
|
|
|
startDateObj;
|
|
|
|
|
2017-11-03 14:43:04 +01:00
|
|
|
dataMode: string = 'Summe';
|
2017-11-03 21:31:03 +01:00
|
|
|
dataInterval: number = 0;
|
|
|
|
logData;
|
2017-11-03 14:43:04 +01: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
|
|
|
|
2017-11-04 20:46:05 +01:00
|
|
|
this.initialized = {
|
|
|
|
basic: false,
|
|
|
|
budget: false,
|
|
|
|
kill: false,
|
|
|
|
revive: false,
|
|
|
|
transport: false,
|
|
|
|
flag: false
|
|
|
|
};
|
2017-11-03 12:51:58 +01:00
|
|
|
Object.assign(this, [this.playerChart, this.lineChartData, this.areaChartData]);
|
|
|
|
this.chartSelectModel = this.labelPoints;
|
|
|
|
|
2017-11-03 21:31:03 +01:00
|
|
|
this.startDateObj = new Date(this.war.date);
|
|
|
|
this.startDateObj.setHours(0);
|
|
|
|
this.startDateObj.setMinutes(1);
|
|
|
|
|
2017-11-03 14:43:04 +01:00
|
|
|
this.fractionRadioSelect = undefined;
|
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:
|
2017-11-04 20:46:05 +01:00
|
|
|
this.initBudgetData();
|
2017-11-03 12:51:58 +01:00
|
|
|
this.lineChartData = this.tmpBudgetData;
|
|
|
|
break;
|
|
|
|
case this.labelKill:
|
2017-11-04 20:46:05 +01:00
|
|
|
this.initKillData();
|
2017-11-03 12:51:58 +01:00
|
|
|
this.lineChartData = this.tmpKillData;
|
|
|
|
break;
|
|
|
|
case this.labelFriendlyFire:
|
2017-11-04 20:46:05 +01:00
|
|
|
this.initKillData();
|
2017-11-03 12:51:58 +01:00
|
|
|
this.lineChartData = this.tmpFrienlyFireData;
|
|
|
|
break;
|
|
|
|
case this.labelRevive:
|
2017-11-04 20:46:05 +01:00
|
|
|
this.initRevive();
|
2017-11-03 12:51:58 +01:00
|
|
|
this.lineChartData = this.tmpReviveData;
|
|
|
|
break;
|
|
|
|
case this.labelStabilize:
|
2017-11-04 20:46:05 +01:00
|
|
|
this.initRevive();
|
2017-11-03 12:51:58 +01:00
|
|
|
this.lineChartData = this.tmpStabilizeData;
|
|
|
|
break;
|
|
|
|
case this.labelTransport:
|
2017-11-04 20:46:05 +01:00
|
|
|
this.initTransportData();
|
2017-11-03 12:51:58 +01:00
|
|
|
this.lineChartData = this.tmpTransportData;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2017-11-04 20:46:05 +01:00
|
|
|
this.initFlagHoldData();
|
2017-11-03 12:51:58 +01:00
|
|
|
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-11-03 14:43:04 +01:00
|
|
|
toggleDataMode(interval, entryString) {
|
2017-11-03 21:31:03 +01:00
|
|
|
this.dataInterval = interval;
|
2017-11-03 14:43:04 +01:00
|
|
|
this.dataMode = entryString;
|
2017-11-03 21:31:03 +01:00
|
|
|
this.initTransportData();
|
|
|
|
this.lineChartData = this.tmpTransportData;
|
2017-11-03 14:43:04 +01:00
|
|
|
}
|
|
|
|
|
2017-10-28 20:25:58 +02:00
|
|
|
loadFractionData() {
|
2017-11-04 20:46:05 +01:00
|
|
|
if (this.initialized.basic) {
|
2017-11-02 18:54:26 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-10-28 22:50:54 +02:00
|
|
|
|
2017-11-04 15:58:48 +01:00
|
|
|
this.initializeTempCollections();
|
2017-11-02 18:54:26 +01:00
|
|
|
|
|
|
|
this.logsService.getFullLog(this.war._id).subscribe((data) => {
|
2017-11-03 21:31:03 +01:00
|
|
|
this.logData = data;
|
|
|
|
this.initPointData();
|
2017-11-04 20:46:05 +01:00
|
|
|
this.showLineChart = true;
|
|
|
|
this.lineChartLabel = this.labelPoints;
|
|
|
|
this.lineChartData = this.tmpPointData;
|
|
|
|
this.initialized.basic = true;
|
2017-11-03 21:31:03 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
initPointData() {
|
|
|
|
this.logData.points.forEach(pointEntry => {
|
|
|
|
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-04 20:46:05 +01:00
|
|
|
this.addFinalTimeData(this.tmpPointData);
|
2017-11-03 21:31:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
initBudgetData() {
|
2017-11-04 20:46:05 +01:00
|
|
|
if (this.initialized.budget) {
|
|
|
|
return;
|
|
|
|
}
|
2017-11-04 15:58:48 +01:00
|
|
|
this.logData.budget.forEach(budgetEntry => {
|
|
|
|
const budgetEntryDate = new Date(budgetEntry.time);
|
2017-11-03 21:31:03 +01:00
|
|
|
const fractionChange = budgetEntry.fraction === 'BLUFOR' ? 0 : 1;
|
|
|
|
const fractionOld = budgetEntry.fraction !== 'BLUFOR' ? 0 : 1;
|
|
|
|
|
2017-11-04 15:58:48 +01:00
|
|
|
if (WarDetailComponent.isTwoMinutesAhead(budgetEntryDate, this.tmpBudgetData)) {
|
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-11-04 15:58:48 +01:00
|
|
|
});
|
2017-11-04 20:46:05 +01:00
|
|
|
this.addFinalTimeData(this.tmpBudgetData);
|
|
|
|
this.initialized.budget = true;
|
2017-11-03 21:31:03 +01:00
|
|
|
}
|
2017-10-29 17:36:55 +01:00
|
|
|
|
2017-11-03 21:31:03 +01:00
|
|
|
initKillData() {
|
2017-11-04 21:16:15 +01:00
|
|
|
if (this.initialized.kill) {
|
2017-11-04 20:46:05 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-11-04 15:58:48 +01:00
|
|
|
let killCountBlufor = 0, killCountOpfor = 0, ffKillCountBlufor = 0, ffKillCountOpfor = 0;
|
|
|
|
|
|
|
|
for (const {killEntry, index} of this.logData.kill.map((killEntry, index) => ({killEntry, index}))) {
|
|
|
|
const killEntryDate = new Date(killEntry.time);
|
2017-11-03 21:31:03 +01:00
|
|
|
if (killEntry.friendlyFire === false) {
|
|
|
|
if (killEntry.fraction === 'BLUFOR') {
|
|
|
|
killCountBlufor++;
|
2017-11-04 15:58:48 +01:00
|
|
|
}
|
|
|
|
if (killEntry.fraction === 'OPFOR') {
|
2017-11-03 21:31:03 +01:00
|
|
|
killCountOpfor++;
|
|
|
|
}
|
2017-11-04 15:58:48 +01:00
|
|
|
if (WarDetailComponent.isTwoMinutesAhead(killEntryDate, this.tmpKillData)) {
|
|
|
|
this.tmpKillData[0].series.push(ChartUtils.getSeriesEntry(killEntryDate, killCountBlufor));
|
|
|
|
this.tmpKillData[1].series.push(ChartUtils.getSeriesEntry(killEntryDate, killCountOpfor));
|
2017-11-03 21:31:03 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (killEntry.fraction === 'BLUFOR') {
|
|
|
|
ffKillCountBlufor++;
|
2017-11-04 15:58:48 +01:00
|
|
|
}
|
|
|
|
if (killEntry.fraction === 'OPFOR') {
|
2017-11-03 21:31:03 +01:00
|
|
|
ffKillCountOpfor++;
|
|
|
|
}
|
2017-11-04 15:58:48 +01:00
|
|
|
if (WarDetailComponent.isTwoMinutesAhead(killEntryDate, this.tmpFrienlyFireData)) {
|
|
|
|
this.tmpFrienlyFireData[0].series.push(ChartUtils.getSeriesEntry(killEntryDate, ffKillCountBlufor));
|
|
|
|
this.tmpFrienlyFireData[1].series.push(ChartUtils.getSeriesEntry(killEntryDate, ffKillCountOpfor));
|
2017-11-02 18:54:26 +01:00
|
|
|
}
|
2017-11-03 21:31:03 +01:00
|
|
|
}
|
2017-11-04 15:58:48 +01:00
|
|
|
if (index === this.logData.kill.length - 1) {
|
|
|
|
this.tmpKillData[0].series.push(ChartUtils.getSeriesEntry(killEntryDate, killCountBlufor));
|
|
|
|
this.tmpKillData[1].series.push(ChartUtils.getSeriesEntry(killEntryDate, killCountOpfor));
|
|
|
|
this.tmpFrienlyFireData[0].series.push(ChartUtils.getSeriesEntry(killEntryDate, ffKillCountBlufor));
|
|
|
|
this.tmpFrienlyFireData[1].series.push(ChartUtils.getSeriesEntry(killEntryDate, ffKillCountOpfor));
|
|
|
|
}
|
2017-11-03 21:31:03 +01:00
|
|
|
}
|
2017-11-04 20:46:05 +01:00
|
|
|
|
|
|
|
this.addFinalTimeData(this.tmpKillData);
|
|
|
|
this.addFinalTimeData(this.tmpFrienlyFireData)
|
|
|
|
this.initialized.kill = true;
|
2017-11-03 21:31:03 +01:00
|
|
|
}
|
2017-11-02 19:40:16 +01:00
|
|
|
|
2017-11-03 21:31:03 +01:00
|
|
|
initRevive() {
|
2017-11-04 20:46:05 +01:00
|
|
|
if (this.initialized.revive) {
|
|
|
|
return;
|
|
|
|
}
|
2017-11-03 21:31:03 +01:00
|
|
|
let reviveCountBlufor = 0, reviveCountOpfor = 0, stabilizeCountBlufor = 0, stabilizeCountOpfor = 0;
|
2017-11-04 15:58:48 +01:00
|
|
|
for (const {reviveEntry, index} of this.logData.revive.map((reviveEntry, index) => ({reviveEntry, index}))) {
|
|
|
|
const reviveEntryDate = new Date(reviveEntry.time);
|
2017-11-03 21:31:03 +01:00
|
|
|
if (reviveEntry.stabilized === false) {
|
|
|
|
if (reviveEntry.fraction === 'BLUFOR') {
|
|
|
|
reviveCountBlufor++;
|
|
|
|
} else {
|
|
|
|
reviveCountOpfor++;
|
|
|
|
}
|
2017-11-04 15:58:48 +01:00
|
|
|
if (WarDetailComponent.isTwoMinutesAhead(reviveEntryDate, this.tmpReviveData)) {
|
|
|
|
this.tmpReviveData[0].series.push(ChartUtils.getSeriesEntry(reviveEntryDate, reviveCountBlufor));
|
|
|
|
this.tmpReviveData[1].series.push(ChartUtils.getSeriesEntry(reviveEntryDate, reviveCountOpfor));
|
2017-11-03 21:31:03 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (reviveEntry.fraction === 'BLUFOR') {
|
|
|
|
stabilizeCountBlufor++;
|
2017-11-02 18:54:26 +01:00
|
|
|
} else {
|
2017-11-03 21:31:03 +01:00
|
|
|
stabilizeCountOpfor++;
|
|
|
|
}
|
2017-11-04 15:58:48 +01:00
|
|
|
if (WarDetailComponent.isTwoMinutesAhead(reviveEntryDate, this.tmpStabilizeData)) {
|
|
|
|
this.tmpStabilizeData[0].series.push(ChartUtils.getSeriesEntry(reviveEntryDate, stabilizeCountBlufor));
|
|
|
|
this.tmpStabilizeData[1].series.push(ChartUtils.getSeriesEntry(reviveEntryDate, stabilizeCountOpfor));
|
2017-11-02 18:54:26 +01:00
|
|
|
}
|
2017-11-03 21:31:03 +01:00
|
|
|
}
|
2017-11-04 15:58:48 +01:00
|
|
|
if (index === this.logData.revive.length - 1) {
|
|
|
|
this.tmpReviveData[0].series.push(ChartUtils.getSeriesEntry(reviveEntryDate, reviveCountBlufor));
|
|
|
|
this.tmpReviveData[1].series.push(ChartUtils.getSeriesEntry(reviveEntryDate, reviveCountOpfor));
|
|
|
|
this.tmpStabilizeData[0].series.push(ChartUtils.getSeriesEntry(reviveEntryDate, stabilizeCountBlufor));
|
|
|
|
this.tmpStabilizeData[1].series.push(ChartUtils.getSeriesEntry(reviveEntryDate, stabilizeCountOpfor));
|
|
|
|
}
|
2017-11-03 21:31:03 +01:00
|
|
|
}
|
2017-11-04 20:46:05 +01:00
|
|
|
this.addFinalTimeData(this.tmpReviveData);
|
|
|
|
this.addFinalTimeData(this.tmpStabilizeData);
|
|
|
|
this.initialized.revive = true;
|
2017-11-03 21:31:03 +01:00
|
|
|
}
|
2017-10-30 08:59:08 +01:00
|
|
|
|
2017-11-03 21:31:03 +01:00
|
|
|
initTransportData() {
|
2017-11-04 20:46:05 +01:00
|
|
|
if (this.initialized.transport) {
|
|
|
|
return;
|
|
|
|
}
|
2017-11-03 21:31:03 +01:00
|
|
|
let transportCountBlufor = 0, transportCountOpfor = 0;
|
2017-11-04 15:58:48 +01:00
|
|
|
for (const {transportEntry, index} of this.logData.transport.map((transportEntry, index) => ({
|
|
|
|
transportEntry,
|
|
|
|
index
|
|
|
|
}))) {
|
|
|
|
const transportEntryDate = new Date(transportEntry.time);
|
2017-11-03 21:31:03 +01:00
|
|
|
if (transportEntry.fraction === 'BLUFOR') {
|
|
|
|
transportCountBlufor++;
|
|
|
|
} else {
|
|
|
|
transportCountOpfor++;
|
|
|
|
}
|
2017-11-04 15:58:48 +01:00
|
|
|
if (WarDetailComponent.isTwoMinutesAhead(transportEntryDate, this.tmpTransportData) || index === this.logData.transport.length - 1) {
|
|
|
|
this.tmpTransportData[0].series.push(ChartUtils.getSeriesEntry(transportEntryDate, transportCountBlufor));
|
|
|
|
this.tmpTransportData[1].series.push(ChartUtils.getSeriesEntry(transportEntryDate, transportCountOpfor));
|
2017-11-03 21:31:03 +01:00
|
|
|
}
|
|
|
|
}
|
2017-11-04 20:46:05 +01:00
|
|
|
this.addFinalTimeData(this.tmpTransportData);
|
|
|
|
this.initialized.transport = true;
|
|
|
|
|
2017-11-03 21:31:03 +01:00
|
|
|
}
|
2017-11-02 18:54:26 +01:00
|
|
|
|
2017-11-03 21:31:03 +01:00
|
|
|
initFlagHoldData() {
|
2017-11-04 20:46:05 +01:00
|
|
|
if (this.initialized.flag) {
|
|
|
|
return;
|
|
|
|
}
|
2017-11-03 21:31:03 +01:00
|
|
|
let flagStatusBlufor = true;
|
|
|
|
let flagStatusOpfor = true;
|
|
|
|
this.tmpFlagCaptureData[0].series.push(ChartUtils.getSeriesEntry(this.startDateObj, flagStatusBlufor));
|
|
|
|
this.tmpFlagCaptureData[1].series.push(ChartUtils.getSeriesEntry(this.startDateObj, flagStatusOpfor));
|
|
|
|
|
|
|
|
this.logData.flag.forEach(flagEntry => {
|
|
|
|
if (flagEntry.flagFraction === 'BLUFOR') {
|
2017-11-04 20:46:05 +01:00
|
|
|
flagStatusBlufor = !flagEntry.capture;
|
2017-11-03 21:31:03 +01:00
|
|
|
} else {
|
|
|
|
flagStatusOpfor = !flagEntry.capture;
|
|
|
|
}
|
|
|
|
this.tmpFlagCaptureData[flagEntry.flagFraction === 'BLUFOR' ? 0 : 1].series.push(
|
2017-11-04 20:46:05 +01:00
|
|
|
ChartUtils.getSeriesEntry(new Date(flagEntry.time), flagEntry.flagFraction === 'BLUFOR' ? flagStatusBlufor : flagStatusOpfor)
|
2017-11-03 21:31:03 +01:00
|
|
|
)
|
2017-11-02 18:54:26 +01:00
|
|
|
});
|
2017-11-04 20:46:05 +01:00
|
|
|
|
|
|
|
this.addFinalTimeData(this.tmpFlagCaptureData);
|
|
|
|
this.initialized.flag = true;
|
2017-10-28 20:25:58 +02:00
|
|
|
}
|
|
|
|
|
2017-11-04 15:58:48 +01:00
|
|
|
private static isTwoMinutesAhead(entryDate: Date, tmpData: any): boolean {
|
|
|
|
return entryDate.getTime() >= tmpData[0].series[tmpData[0].series.length - 1].name.getTime() + (1.5 * 60000)
|
|
|
|
}
|
|
|
|
|
|
|
|
initializeTempCollections() {
|
|
|
|
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');
|
|
|
|
|
|
|
|
[this.tmpKillData, this.tmpFrienlyFireData, this.tmpReviveData, this.tmpStabilizeData, this.tmpTransportData].forEach(tmp => {
|
|
|
|
[0, 1].forEach(index => {
|
|
|
|
tmp[index].series.push(ChartUtils.getSeriesEntry(this.startDateObj, 0));
|
|
|
|
})
|
|
|
|
});
|
|
|
|
this.tmpBudgetData[0].series.push(ChartUtils.getSeriesEntry(this.startDateObj, this.war.budgetBlufor));
|
|
|
|
this.tmpBudgetData[1].series.push(ChartUtils.getSeriesEntry(this.startDateObj, this.war.budgetOpfor));
|
2017-11-03 21:31:03 +01:00
|
|
|
}
|
|
|
|
|
2017-11-04 20:46:05 +01:00
|
|
|
addFinalTimeData(tmpCollection) {
|
|
|
|
const endDate = new Date(this.war.endDate);
|
|
|
|
if (tmpCollection === this.tmpBudgetData) {
|
|
|
|
this.tmpBudgetData[0].series.push(ChartUtils.getSeriesEntry(endDate, this.war.endBudgetBlufor));
|
|
|
|
this.tmpBudgetData[1].series.push(ChartUtils.getSeriesEntry(endDate, this.war.endBudgetOpfor));
|
|
|
|
} else {
|
2017-10-30 08:59:08 +01:00
|
|
|
for (let j in [0, 1]) {
|
2017-11-04 20:46:05 +01:00
|
|
|
if (tmpCollection[j].series[tmpCollection[j].series.length - 1].name < endDate) {
|
|
|
|
tmpCollection[j].series.push(ChartUtils.getSeriesEntry(endDate, tmpCollection[j].series[tmpCollection[j].series.length - 1].value));
|
2017-10-30 08:59:08 +01:00
|
|
|
}
|
|
|
|
}
|
2017-11-04 20:46:05 +01:00
|
|
|
}
|
2017-10-30 08:59:08 +01:00
|
|
|
}
|
|
|
|
|
2017-07-08 21:56:11 +02:00
|
|
|
}
|