From 24f46b0f3cb7412eba2c83d072e0fdf65edce759 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Sat, 28 Oct 2017 22:50:54 +0200 Subject: [PATCH] Add points and budget time graphs --- api/routes/logs.js | 9 +- static/src/app/models/model-interfaces.ts | 4 + static/src/app/services/logs/logs.service.ts | 1 - .../war-detail/war-detail.component.css | 11 +- .../war-detail/war-detail.component.html | 43 +++++++- .../war-detail/war-detail.component.ts | 94 +++++++++++++++++- static/src/assets/fraction-btn.png | Bin 0 -> 1412 bytes static/src/assets/scoreboard-btn.png | Bin 0 -> 797 bytes 8 files changed, 151 insertions(+), 11 deletions(-) create mode 100644 static/src/assets/fraction-btn.png create mode 100644 static/src/assets/scoreboard-btn.png 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 0000000000000000000000000000000000000000..9d2c68ede8884c97e72914933d7ffa9a22709295 GIT binary patch literal 1412 zcmV-~1$+95P)xiiznmVvfxmLgCLEhRB5%3?s#A1Irk z2qa)bgj!-``#~fmvIGcQ1hf@UsDe=;xP`bx*(^dq11-e>724Vj+d`q8cG~IOd;Gz) zcDd7OOf;T9H#z6t^Pcy9@ArN05p-jSgtTZN33wbB3#3R>?|aVuqgG_NJR0&+y;M(x z3nRPOaOAGYKT{QQ&u)P30a5{H+j(i~ecT zJ*?J)0k;f8iuy{^p1$bH&skRMN(Zo(XC`ng7-)BfDr8t6wdvr;!$%(ikWYqSEE3Z4 zfaFjcOR1C7BRJ!>01Z+pot1mBe^-n%y8{X^{^?}u>wN&|LM2kstPcpdgxRl!c_-jN zOc!^_(v(QUL{$~i7fz(E&P%=FXK(c_7MEP+Pk$q-g={1crTFLVPkv%S%Us)I?(Z7Z zWZ0nItXnyi3zv!*HYk>l>Z*C)TY@440$5)D8xx$-q{j@zFJ&k27{&Jvkk!gKkTRA+ z5<(!P#k$C;_o4{Vy0Hy7(Qp^7eFWPH?(pz2hXAxdaYzlu z)btx2b+u<+=tW!e^-J? z%|?1mJkNM*DQotUsE70J-C_zF>zVmbZ>C1YAuRqtm@p=(B6{RzAj(2j)Oox(9CqeT zA5F%Fm$5rEHtqS2o5j^U_f#_1w(o>67jDhL^`<&DR^H;i;X??x-sIuanhKteh(S}@ zi_MGb)_}ep@Q8|VVoE3|uBNf6ncZ2Z*tX+qFeTVEGWULuEv6?^oOX=BH+7~Tn~?3& zM<`HZHWR0|FD~K22-iBt7KRRtW6f*Nk~pLf10U{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