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-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: []};
|
|
|
|
|
|
|
|
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-10-28 22:50:54 +02:00
|
|
|
pointData: any[] = [];
|
|
|
|
budgetData: any[] = [];
|
2017-10-29 17:36:55 +01:00
|
|
|
killData: any[] = [];
|
|
|
|
friendlyFireData: any[] = [];
|
|
|
|
transportData: any[] = [];
|
|
|
|
reviveData: any[] = [];
|
|
|
|
stabilizedData: any[] = [];
|
|
|
|
flagData: any[] = [];
|
|
|
|
|
|
|
|
tmpPointData;
|
|
|
|
tmpBudgetData;
|
|
|
|
tmpKillData;
|
|
|
|
tmpFrienlyFireData;
|
|
|
|
tmpTransportData;
|
|
|
|
tmpReviveData;
|
|
|
|
tmpStabilizeData;
|
|
|
|
tmpFlagCaptureData;
|
2017-10-28 22:50:54 +02:00
|
|
|
|
|
|
|
colorScheme = {
|
|
|
|
domain: ['#0000FF', '#B22222']
|
|
|
|
};
|
|
|
|
|
|
|
|
yAxisLabelPoints = 'Punkte';
|
|
|
|
yAxisLabelBudget = 'Budget';
|
2017-10-29 17:36:55 +01:00
|
|
|
yAxisLabelKill = 'Kills';
|
|
|
|
yAxisLabelFriendlyFire = 'FriendlyFire';
|
|
|
|
yAxisLabelTransport = 'Lufttransport';
|
|
|
|
yAxisLabelRevive = 'Revive';
|
|
|
|
yAxisLabelStabilize = 'Stabilisiert';
|
|
|
|
yAxisLabelFlag = 'Flaggenbesitz';
|
2017-10-28 22:50:54 +02:00
|
|
|
|
2017-10-29 17:36:55 +01:00
|
|
|
monotoneYCurve = d3.curveMonotoneY;
|
|
|
|
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-07-30 16:25:11 +02:00
|
|
|
this.playerChart = [
|
|
|
|
{
|
|
|
|
"name": "CSAT",
|
|
|
|
"value": war.playersOpfor
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "NATO",
|
|
|
|
"value": war.playersBlufor
|
|
|
|
}
|
|
|
|
];
|
2017-10-29 17:36:55 +01:00
|
|
|
this.tmpPointData = [
|
|
|
|
{
|
|
|
|
"name": "NATO",
|
|
|
|
"series": []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "CSAT",
|
|
|
|
"series": []
|
|
|
|
}
|
|
|
|
];
|
|
|
|
this.tmpBudgetData = JSON.parse(JSON.stringify(this.tmpPointData));
|
|
|
|
this.tmpKillData = JSON.parse(JSON.stringify(this.tmpPointData));
|
|
|
|
this.tmpFrienlyFireData = JSON.parse(JSON.stringify(this.tmpPointData));
|
|
|
|
this.tmpTransportData = JSON.parse(JSON.stringify(this.tmpPointData));
|
|
|
|
this.tmpReviveData = JSON.parse(JSON.stringify(this.tmpPointData));
|
|
|
|
this.tmpStabilizeData = JSON.parse(JSON.stringify(this.tmpPointData));
|
|
|
|
this.tmpFlagCaptureData = JSON.parse(JSON.stringify(this.tmpPointData));
|
|
|
|
|
|
|
|
Object.assign(this, [this.playerChart, this.pointData, this.budgetData, this.killData,
|
|
|
|
this.friendlyFireData, this.transportData, this.reviveData, this.stabilizedData, this.flagData]);
|
|
|
|
|
|
|
|
this.fractionChartsInitialized = false;
|
|
|
|
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-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-29 17:36:55 +01:00
|
|
|
if (!this.fractionChartsInitialized) {
|
|
|
|
const startDateObj = new Date(this.war.date);
|
|
|
|
startDateObj.setHours(0);
|
|
|
|
startDateObj.setMinutes(1);
|
|
|
|
|
|
|
|
this.logsService.getFullLog(this.war._id).subscribe((data) => {
|
|
|
|
// POINTS
|
|
|
|
data.points.forEach(pointEntry => {
|
2017-10-28 22:50:54 +02:00
|
|
|
const dateObj = new Date(this.war.date);
|
|
|
|
const time = pointEntry.time.split(':');
|
|
|
|
dateObj.setHours(time[0]);
|
|
|
|
dateObj.setMinutes(time[1]);
|
2017-10-29 17:36:55 +01:00
|
|
|
this.tmpPointData[0].series.push({
|
|
|
|
"name": new Date(pointEntry.time),
|
2017-10-28 22:50:54 +02:00
|
|
|
"value": pointEntry.ptBlufor
|
|
|
|
});
|
2017-10-29 17:36:55 +01:00
|
|
|
this.tmpPointData[1].series.push({
|
|
|
|
"name": new Date(pointEntry.time),
|
2017-10-28 22:50:54 +02:00
|
|
|
"value": pointEntry.ptOpfor
|
|
|
|
});
|
|
|
|
});
|
2017-10-29 17:36:55 +01:00
|
|
|
this.pointData = this.tmpPointData;
|
2017-10-28 22:50:54 +02:00
|
|
|
|
2017-10-29 17:36:55 +01:00
|
|
|
// BUDGET
|
|
|
|
this.tmpBudgetData[0].series.push({
|
|
|
|
"name": startDateObj,
|
2017-10-28 22:50:54 +02:00
|
|
|
"value": this.war.budgetBlufor
|
|
|
|
});
|
2017-10-29 17:36:55 +01:00
|
|
|
this.tmpBudgetData[1].series.push({
|
|
|
|
"name": startDateObj,
|
2017-10-28 22:50:54 +02:00
|
|
|
"value": this.war.budgetOpfor
|
|
|
|
});
|
2017-10-29 17:36:55 +01:00
|
|
|
data.budget.forEach(budgetEntry => {
|
|
|
|
this.tmpBudgetData[budgetEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
|
|
|
|
"name": new Date(budgetEntry.time),
|
2017-10-28 22:50:54 +02:00
|
|
|
"value": budgetEntry.newBudget
|
|
|
|
});
|
|
|
|
});
|
2017-10-29 17:36:55 +01:00
|
|
|
this.budgetData = this.tmpBudgetData;
|
|
|
|
|
|
|
|
// KILLS
|
|
|
|
let killCountBlufor = 0;
|
|
|
|
let killCountOpfor = 0;
|
|
|
|
let ffKillCountBlufor = 0;
|
|
|
|
let ffKillCountOpfor = 0;
|
|
|
|
this.tmpKillData[0].series.push({
|
|
|
|
"name": startDateObj,
|
|
|
|
"value": killCountBlufor
|
|
|
|
});
|
|
|
|
this.tmpKillData[1].series.push({
|
|
|
|
"name": startDateObj,
|
|
|
|
"value": killCountOpfor
|
|
|
|
});
|
|
|
|
this.tmpFrienlyFireData[0].series.push({
|
|
|
|
"name": startDateObj,
|
|
|
|
"value": ffKillCountBlufor
|
|
|
|
});
|
|
|
|
this.tmpFrienlyFireData[1].series.push({
|
|
|
|
"name": startDateObj,
|
|
|
|
"value": ffKillCountOpfor
|
|
|
|
});
|
|
|
|
|
|
|
|
data.kill.forEach(killEntry => {
|
|
|
|
if (killEntry.fraction === 'BLUFOR') {
|
|
|
|
if (killEntry.friendlyFire === false) {
|
|
|
|
killCountBlufor++;
|
|
|
|
} else {
|
|
|
|
ffKillCountBlufor++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (killEntry.friendlyFire === false) {
|
|
|
|
killCountOpfor++;
|
|
|
|
} else {
|
|
|
|
ffKillCountOpfor++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.tmpKillData[killEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
|
|
|
|
"name": new Date(killEntry.time),
|
|
|
|
"value": killEntry.fraction === 'BLUFOR' ? killCountBlufor : killCountOpfor
|
|
|
|
});
|
|
|
|
this.tmpFrienlyFireData[killEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
|
|
|
|
"name": new Date(killEntry.time),
|
|
|
|
"value": killEntry.fraction === 'BLUFOR' ? ffKillCountBlufor : ffKillCountOpfor
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.killData = this.tmpKillData;
|
|
|
|
this.friendlyFireData = this.tmpFrienlyFireData;
|
|
|
|
|
|
|
|
// TRANSPORT
|
|
|
|
let transportCountBlufor = 0;
|
|
|
|
let transportCountOpfor = 0;
|
|
|
|
this.tmpTransportData[0].series.push({
|
|
|
|
"name": startDateObj,
|
|
|
|
"value": transportCountBlufor
|
|
|
|
});
|
|
|
|
this.tmpTransportData[1].series.push({
|
|
|
|
"name": startDateObj,
|
|
|
|
"value": transportCountOpfor
|
|
|
|
});
|
|
|
|
|
|
|
|
data.transport.forEach(transportEntry => {
|
|
|
|
if (transportEntry.fraction === 'BLUFOR') {
|
|
|
|
transportCountBlufor++;
|
|
|
|
} else {
|
|
|
|
transportCountOpfor++;
|
|
|
|
}
|
|
|
|
this.tmpTransportData[transportEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
|
|
|
|
"name": new Date(transportEntry.time),
|
|
|
|
"value": transportEntry.fraction === 'BLUFOR' ? transportCountBlufor : transportCountOpfor
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.transportData = this.tmpTransportData;
|
|
|
|
|
|
|
|
// REVIVE & STABILIZE
|
|
|
|
let reviveCountBlufor = 0;
|
|
|
|
let reviveCountOpfor = 0;
|
|
|
|
let stabilizeCountBlufor = 0;
|
|
|
|
let stabilizeCountOpfor = 0;
|
|
|
|
this.tmpReviveData[0].series.push({
|
|
|
|
"name": startDateObj,
|
|
|
|
"value": reviveCountBlufor
|
|
|
|
});
|
|
|
|
this.tmpReviveData[1].series.push({
|
|
|
|
"name": startDateObj,
|
|
|
|
"value": reviveCountOpfor
|
|
|
|
});
|
|
|
|
this.tmpStabilizeData[0].series.push({
|
|
|
|
"name": startDateObj,
|
|
|
|
"value": stabilizeCountBlufor
|
|
|
|
});
|
|
|
|
this.tmpStabilizeData[1].series.push({
|
|
|
|
"name": startDateObj,
|
|
|
|
"value": stabilizeCountOpfor
|
|
|
|
});
|
|
|
|
data.revive.forEach(reviveEntry => {
|
|
|
|
if (reviveEntry.fraction === 'BLUFOR') {
|
|
|
|
if (reviveEntry.stabilized === false) {
|
|
|
|
reviveCountBlufor++;
|
|
|
|
} else {
|
|
|
|
reviveCountOpfor++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (reviveEntry.stabilized === false) {
|
|
|
|
stabilizeCountBlufor++;
|
|
|
|
} else {
|
|
|
|
stabilizeCountOpfor++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.tmpReviveData[reviveEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
|
|
|
|
"name": new Date(reviveEntry.time),
|
|
|
|
"value": reviveEntry.fraction === 'BLUFOR' ? reviveCountBlufor : reviveCountOpfor
|
|
|
|
});
|
|
|
|
this.tmpStabilizeData[reviveEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
|
|
|
|
"name": new Date(reviveEntry.time),
|
|
|
|
"value": reviveEntry.fraction === 'BLUFOR' ? stabilizeCountBlufor : stabilizeCountOpfor
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.reviveData = this.tmpReviveData;
|
|
|
|
this.stabilizedData = this.tmpStabilizeData;
|
|
|
|
|
|
|
|
|
|
|
|
// FLAG
|
|
|
|
let flagStatusBlufor = 1;
|
|
|
|
let flagStatusOpfor = 1;
|
|
|
|
this.tmpFlagCaptureData[0].series.push({
|
|
|
|
"name": startDateObj,
|
|
|
|
"value": flagStatusBlufor
|
|
|
|
});
|
|
|
|
this.tmpFlagCaptureData[1].series.push({
|
|
|
|
"name": startDateObj,
|
|
|
|
"value": flagStatusOpfor
|
|
|
|
});
|
2017-10-28 22:50:54 +02:00
|
|
|
|
2017-10-29 17:36:55 +01:00
|
|
|
data.flag.forEach(flagEntry => {
|
|
|
|
if (flagEntry.flagFraction === 'BLUFOR') {
|
|
|
|
flagStatusBlufor = flagEntry.capture ? 0 : 1
|
|
|
|
} else {
|
|
|
|
flagStatusOpfor = flagEntry.capture ? 0 : 1;
|
|
|
|
}
|
|
|
|
this.tmpFlagCaptureData[flagEntry.flagFraction === 'BLUFOR' ? 0 : 1].series.push({
|
|
|
|
"name": new Date(flagEntry.time),
|
|
|
|
"value": flagEntry.flagFraction === 'BLUFOR' ? flagStatusBlufor : flagStatusOpfor
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.flagData = this.tmpFlagCaptureData;
|
|
|
|
|
|
|
|
this.fractionChartsInitialized = true;
|
|
|
|
});
|
2017-10-28 22:50:54 +02:00
|
|
|
}
|
2017-10-28 20:25:58 +02:00
|
|
|
}
|
|
|
|
|
2017-07-08 21:56:11 +02:00
|
|
|
}
|