diff --git a/api/routes/logs.js b/api/routes/logs.js index 18913ed..52dcd1e 100644 --- a/api/routes/logs.js +++ b/api/routes/logs.js @@ -5,6 +5,7 @@ const express = require('express'); const logger = require('debug')('cc:logs'); const routerHandling = require('../middleware/router-handling'); +const decimalToTimeString = require('../tools/util').decimalToTimeString; // Mongoose Model using mongoDB const LogBudgetModel = require('../models/logs/budget'); @@ -25,7 +26,13 @@ function processLogRequest(model, filter, res, next) { err.status = require('./http-codes').notfound; return next(err) } - res.locals.items = log; + const updatedTimeItems = []; + for (let i =0; i - +
- - I've got an HTML heading, and a select callback. Pretty cool! + +
+ + +
+
+ + +
diff --git a/static/src/app/statistic/war-detail/war-detail.component.ts b/static/src/app/statistic/war-detail/war-detail.component.ts index 46b83a6..3992d53 100644 --- a/static/src/app/statistic/war-detail/war-detail.component.ts +++ b/static/src/app/statistic/war-detail/war-detail.component.ts @@ -31,10 +31,32 @@ export class WarDetailComponent { sortDescending: 'glyphicon glyphicon-triangle-bottom', }; + 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; + constructor(private route: ActivatedRoute, private router: Router, - private warService: WarService) { - Object.assign(this, this.playerChart) + private warService: WarService, + private logsService: LogsService) { } ngOnInit() { @@ -55,6 +77,7 @@ export class WarDetailComponent { "value": war.playersBlufor } ]; + Object.assign(this, [this.playerChart, this.pointData, this.budgetData]); this.scrollOverviewTop(); }); } @@ -84,7 +107,72 @@ export class WarDetailComponent { } loadFractionData() { - console.log('load data from server') + 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; + } } } diff --git a/static/src/assets/fraction-btn.png b/static/src/assets/fraction-btn.png new file mode 100644 index 0000000..9d2c68e Binary files /dev/null and b/static/src/assets/fraction-btn.png differ diff --git a/static/src/assets/scoreboard-btn.png b/static/src/assets/scoreboard-btn.png new file mode 100644 index 0000000..9f01646 Binary files /dev/null and b/static/src/assets/scoreboard-btn.png differ