From 24fcb05f70eb223c9af38b50cc1087cef46a9e8b Mon Sep 17 00:00:00 2001 From: HardiReady Date: Sun, 10 Feb 2019 10:33:25 +0100 Subject: [PATCH] Add translations for server stats charts (CC-80) --- .../server-stats/server-stats.component.ts | 51 +++++++++++-------- static/src/assets/i18n/statistics/de.json | 4 ++ static/src/assets/i18n/statistics/en.json | 3 ++ 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/static/src/app/statistic/war/server-stats/server-stats.component.ts b/static/src/app/statistic/war/server-stats/server-stats.component.ts index 235d73e..bae03f8 100644 --- a/static/src/app/statistic/war/server-stats/server-stats.component.ts +++ b/static/src/app/statistic/war/server-stats/server-stats.component.ts @@ -5,10 +5,10 @@ import {ChartUtils} from '../../../utils/chart-utils'; @Component({ - selector: 'cc-server-statistics', - templateUrl: './server-stats.component.html', - styleUrls: ['./server-stats.component.css', '../../../style/list-entry.css', '../../../style/hide-scrollbar.css'] -}) + selector: 'cc-server-statistics', + templateUrl: './server-stats.component.html', + styleUrls: ['./server-stats.component.css', '../../../style/list-entry.css', '../../../style/hide-scrollbar.css'] + }) export class ServerStatsComponent implements OnInit, OnChanges { @ViewChild('overview') private overviewContainer: ElementRef; @@ -42,6 +42,7 @@ export class ServerStatsComponent implements OnInit, OnChanges { }; readonly labelsAsString = Object.keys(this.labels) .map((key) => this.labels[key]); + lineChartSeriesLabels; gradient = false; yAxis = true; @@ -53,7 +54,7 @@ export class ServerStatsComponent implements OnInit, OnChanges { autoscale = true; timeline = false; roundDomains = true; - colorScheme = { + colorScheme = { name: 'nightLights', selectable: false, group: 'Ordinal', @@ -72,7 +73,13 @@ export class ServerStatsComponent implements OnInit, OnChanges { ngOnChanges(changes: SimpleChanges) { if ((changes.war || changes.performanceData) && this.performanceData) { - this.initializeChartData(); + this.translate.get([ + 'stats.performance.select.timeline.label.minimum', + 'stats.performance.select.timeline.label.average', + 'stats.performance.select.timeline.label.maximum']).subscribe((res) => { + const resValues = Object.keys(res).map(val => res[val]); + this.initializeChartData(resValues[2], resValues[0], resValues[1]); + }); Object.assign(this, [this.barChartData]); this.activeChartSelect = this.labels.singleAvg; } @@ -107,10 +114,10 @@ export class ServerStatsComponent implements OnInit, OnChanges { } } - initializeChartData() { - this.tmpAvgTimeline = ChartUtils.getMultiDataArray('min', 'avg', 'max'); - this.tmpMinTimeline = ChartUtils.getMultiDataArray('min', 'avg', 'max'); - this.tmpServerTimeline = ChartUtils.getMultiDataArray('min', 'avg'); + initializeChartData(labelMax: string, labelMin: string, labelAvg: string) { + this.tmpAvgTimeline = ChartUtils.getMultiDataArray(labelMax, labelAvg, labelMin); + this.tmpMinTimeline = ChartUtils.getMultiDataArray(labelMax, labelAvg, labelMin); + this.tmpServerTimeline = ChartUtils.getMultiDataArray(labelAvg, labelMin); const diffMs = (new Date(this.war.endDate).getTime() - new Date(this.war.date).getTime()); const warDurationMinutes = Math.round(diffMs / 60000); @@ -150,33 +157,33 @@ export class ServerStatsComponent implements OnInit, OnChanges { // SERVER TIMELINE DATA for (let i = 0; i < entry.avgFps.length && i < warDurationMinutes; i++) { const currDate = new Date(dateObj.getTime() + i * 60000); - this.tmpServerTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, entry.minFps[i])); - this.tmpServerTimeline[1].series.push(ChartUtils.getSeriesEntry(currDate, entry.avgFps[i])); + this.tmpServerTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, entry.avgFps[i])); + this.tmpServerTimeline[1].series.push(ChartUtils.getSeriesEntry(currDate, entry.minFps[i])); } } this.tmpSingleAvg.push({ - name: entry.entityName, - value: entry.singleAvgFps - }); + name: entry.entityName, + value: entry.singleAvgFps + }); this.tmpSingleMin.push({ - name: entry.entityName, - value: entry.singleMinFps - }); + name: entry.entityName, + value: entry.singleMinFps + }); }); tmpAvgArray = tmpAvgArray.map(x => Math.round(x / this.performanceData.length)); for (let i = 0; i < tmpAvgArray.length; i++) { const currDate = new Date(dateObj.getTime() + i * 60000); - this.tmpAvgTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, tmpAvgMin[i])); + this.tmpAvgTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, tmpAvgMax[i])); this.tmpAvgTimeline[1].series.push(ChartUtils.getSeriesEntry(currDate, tmpAvgArray[i])); - this.tmpAvgTimeline[2].series.push(ChartUtils.getSeriesEntry(currDate, tmpAvgMax[i])); + this.tmpAvgTimeline[2].series.push(ChartUtils.getSeriesEntry(currDate, tmpAvgMin[i])); } tmpMinArray = tmpMinArray.map(x => Math.round(x / this.performanceData.length)); for (let i = 0; i < tmpMinArray.length; i++) { const currDate = new Date(dateObj.getTime() + i * 60000); - this.tmpMinTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, tmpMinMin[i])); + this.tmpMinTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, tmpMinMax[i])); this.tmpMinTimeline[1].series.push(ChartUtils.getSeriesEntry(currDate, tmpMinArray[i])); - this.tmpMinTimeline[2].series.push(ChartUtils.getSeriesEntry(currDate, tmpMinMax[i])); + this.tmpMinTimeline[2].series.push(ChartUtils.getSeriesEntry(currDate, tmpMinMin[i])); } this.tmpSingleAvg.sort((a, b) => a.value - b.value); this.tmpSingleMin.sort((a, b) => a.value - b.value); diff --git a/static/src/assets/i18n/statistics/de.json b/static/src/assets/i18n/statistics/de.json index 509e70f..6105f77 100644 --- a/static/src/assets/i18n/statistics/de.json +++ b/static/src/assets/i18n/statistics/de.json @@ -34,6 +34,10 @@ "stats.performance.select.timeline.avg": "Verlauf FPS Durchschnitt", "stats.performance.select.timeline.min": "Verlauf FPS Minimum", "stats.performance.select.timeline.server": "Server FPS", + "stats.performance.select.timeline.label.minimum": "Minimum", + "stats.performance.select.timeline.label.average": "Mittelwert", + "stats.performance.select.timeline.label.maximum": "Maximum", + "stats.player.detail.headline": "Kampagnendetails - {{name}}", "stats.player.detail.button.back": "Zurück", diff --git a/static/src/assets/i18n/statistics/en.json b/static/src/assets/i18n/statistics/en.json index e45df1e..67bb20b 100644 --- a/static/src/assets/i18n/statistics/en.json +++ b/static/src/assets/i18n/statistics/en.json @@ -42,6 +42,9 @@ "stats.performance.select.timeline.avg": "Timeline FPS Average", "stats.performance.select.timeline.min": "Timeline FPS Minimum", "stats.performance.select.timeline.server": "Server FPS", + "stats.performance.select.timeline.label.minimum": "Minimum", + "stats.performance.select.timeline.label.average": "Average", + "stats.performance.select.timeline.label.maximum": "Maximum", "stats.player.detail.headline": "Campaign Details - {{name}}", "stats.player.detail.button.back": "Back",