diff --git a/.gitignore b/.gitignore index 952f982..f6b5c0c 100644 --- a/.gitignore +++ b/.gitignore @@ -45,7 +45,7 @@ Thumbs.db .directory # Internal Data -public/ +/public/ mongodb-data/ server/resource/ server/apib/dredd/data/tmp-resource diff --git a/static/src/app/app.component.ts b/static/src/app/app.component.ts index b4e4785..c321351 100644 --- a/static/src/app/app.component.ts +++ b/static/src/app/app.component.ts @@ -52,6 +52,7 @@ export class AppComponent implements OnInit { 'stats-fraction': 'stats/fraction-btn', 'stats-player': 'stats/player-stats-btn', 'stats-scoreboard': 'stats/scoreboard-btn', + 'stats-performance': 'stats/performance-stats-btn', // --SCOREBOARD-- 'death': 'stats/scoreboard/death', 'flagTouch': 'stats/scoreboard/flag-touch', diff --git a/static/src/app/statistic/stats.routing.ts b/static/src/app/statistic/stats.routing.ts index 05bf844..edbe058 100644 --- a/static/src/app/statistic/stats.routing.ts +++ b/static/src/app/statistic/stats.routing.ts @@ -13,6 +13,7 @@ import {WarHeaderComponent} from './war/war-header/war-header.component'; import {LoginGuardMT} from '../login'; import {CampaignNavigationComponent} from './campaign/campaign-navigation/campaign-navigation.component'; import {StatisticOverviewComponent} from './campaign/overview/campaign-overview.component'; +import {ServerStatsComponent} from './war/server-stats/server-stats.component'; export const statsRoutes: Routes = [ @@ -69,5 +70,6 @@ export const statsRouterModule: ModuleWithProviders = RouterModule.forChild(stat export const statsRoutingComponents = [StatisticComponent, StatisticOverviewComponent, StatisticHighScoreComponent, CampaignSubmitComponent, WarListComponent, WarSubmitComponent, WarHeaderComponent, ScoreboardComponent, - FractionStatsComponent, CampaignPlayerDetailComponent, WarItemComponent, CampaignNavigationComponent]; + FractionStatsComponent, CampaignPlayerDetailComponent, WarItemComponent, CampaignNavigationComponent, + ServerStatsComponent]; diff --git a/static/src/app/statistic/war/server-stats/server-stats.component.css b/static/src/app/statistic/war/server-stats/server-stats.component.css new file mode 100644 index 0000000..8b96911 --- /dev/null +++ b/static/src/app/statistic/war/server-stats/server-stats.component.css @@ -0,0 +1,37 @@ +.chart-select-group { + display: flex; + width: fit-content; + margin: auto; +} + +:host /deep/ mat-button-toggle { + color: #666666; + background: #e7e7e7; +} + +:host /deep/ mat-button-toggle:hover { + background: #afafaf; +} + +:host /deep/ mat-button-toggle.mat-button-toggle-checked { + background: #ffffff; +} + +:host /deep/ label.mat-button-toggle-label { + margin: 2px 0; +} + +:host /deep/ div.mat-button-toggle-label-content { + line-height: 25px; + margin-bottom: 0; + font-weight: normal; +} + +.chart-container { + width: 95%; + margin: 2%; + min-width: 900px; + height: 50vh; + padding: 15px; + float: left; +} diff --git a/static/src/app/statistic/war/server-stats/server-stats.component.html b/static/src/app/statistic/war/server-stats/server-stats.component.html new file mode 100644 index 0000000..452c16c --- /dev/null +++ b/static/src/app/statistic/war/server-stats/server-stats.component.html @@ -0,0 +1,28 @@ +
+ + + + {{label | translate}} + + + +
+ + +
+
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 new file mode 100644 index 0000000..ea131ba --- /dev/null +++ b/static/src/app/statistic/war/server-stats/server-stats.component.ts @@ -0,0 +1,115 @@ +import {Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from '@angular/core'; +import {ChartUtils} from '../../../utils/chart-utils'; +import {War} from '../../../models/model-interfaces'; +import {TranslateService} from '@ngx-translate/core'; + + +@Component({ + 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; + + @Input() war: War; + + @Input() performanceData: any; + + startDateObj: Date; + + initialized: any; + + public activeChartSelect: string; + + lineChartData: any[] = []; + + tmpPointData; + tmpBudgetData; + tmpKillData; + tmpFrienlyFireData; + tmpVehicleData; + tmpTransportData; + tmpReviveData; + tmpStabilizeData; + tmpFlagCaptureData; + + readonly labels = { + points: 'stats.fraction.select.points', + budget: 'stats.fraction.select.budget', + kill: 'stats.fraction.select.kills', + friendlyFire: 'stats.fraction.select.friendly.fire', + vehicle: 'stats.fraction.select.vehicle.kills', + }; + readonly labelsAsString = Object.keys(this.labels) + .map((key) => this.labels[key]); + + lineChartLabel: string; + + gradient = false; + yAxis = true; + xAxis = true; + legend = false; + legendTitle = false; + showXAxisLabel = false; + showYAxisLabel = true; + autoscale = true; + timeline = false; + roundDomains = true; + + constructor(private translate: TranslateService) { + } + + ngOnInit() { + this.setLineChartLabel(this.labels.points); + } + + ngOnChanges(changes: SimpleChanges) { + if (changes.war || changes.performanceData) { + this.initialized = { + budget: false, + kill: false, + revive: false, + transport: false, + flag: false + }; + Object.assign(this, [this.lineChartData]); + this.activeChartSelect = this.labels.points; + + this.startDateObj = new Date(this.war.date); + this.startDateObj.setHours(0); + this.startDateObj.setMinutes(1); + } + } + + selectChart(newSelection) { + this.activeChartSelect = newSelection; + this.setLineChartLabel(this.activeChartSelect); + console.log('############### apply data ##################'); + } + + 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 { + for (let j = 0; j < tmpCollection.length; j++) { + // mayBe check is needed for logs that are simply not existent in older wars, i.e. vehicleKills + const maybeLast = tmpCollection[j].series[tmpCollection[j].series.length - 1]; + if (maybeLast && maybeLast.name < endDate) { + tmpCollection[j].series.push( + ChartUtils.getSeriesEntry(endDate, tmpCollection[j].series[tmpCollection[j].series.length - 1].value) + ); + } + } + } + } + + setLineChartLabel(i18n: string) { + this.translate.get(i18n).subscribe((translated) => { + this.lineChartLabel = translated; + }); + } +} diff --git a/static/src/app/statistic/war/war-header/war-header.component.css b/static/src/app/statistic/war/war-header/war-header.component.css index 7623793..605fbc3 100644 --- a/static/src/app/statistic/war/war-header/war-header.component.css +++ b/static/src/app/statistic/war/war-header/war-header.component.css @@ -16,7 +16,7 @@ form.tab-control { } span.tab-control { - margin: 4px 67px; + margin: 4px 30px 4px 55px; padding: 4px 16px; } @@ -39,8 +39,12 @@ span.tab-control { vertical-align: middle; } +:host/deep/.mat-icon-stats-performance g { + stroke: #666666; +} + .nav-tabs { - width: 920px; + width: 1000px; margin: auto; clear: both; border-bottom: 0; diff --git a/static/src/app/statistic/war/war-header/war-header.component.html b/static/src/app/statistic/war/war-header/war-header.component.html index 81e1d7b..e617a1b 100644 --- a/static/src/app/statistic/war/war-header/war-header.component.html +++ b/static/src/app/statistic/war/war-header/war-header.component.html @@ -48,6 +48,12 @@ {{'stats.scoreboard.tab.player' | translate}} +
  • @@ -100,6 +106,11 @@ [playerName]="playerDetailName" (switchTab)="switchTab($event)"> + +
    diff --git a/static/src/assets/i18n/statistics/de.json b/static/src/assets/i18n/statistics/de.json index beae2a7..5282f8a 100644 --- a/static/src/assets/i18n/statistics/de.json +++ b/static/src/assets/i18n/statistics/de.json @@ -41,6 +41,7 @@ "stats.scoreboard.tab.scoreboard": "Scoreboard", "stats.scoreboard.tab.fractions": "Fraktionen", "stats.scoreboard.tab.player": "Spieler", + "stats.scoreboard.tab.performance": "Performance", "stats.scoreboard.fraction.filter.all": "Alle", "stats.scoreboard.header.player": "Spieler", "stats.scoreboard.header.fraction": "Fraktion", diff --git a/static/src/assets/i18n/statistics/en.json b/static/src/assets/i18n/statistics/en.json index f412529..cc4509e 100644 --- a/static/src/assets/i18n/statistics/en.json +++ b/static/src/assets/i18n/statistics/en.json @@ -49,6 +49,7 @@ "stats.scoreboard.tab.scoreboard": "Scoreboard", "stats.scoreboard.tab.fractions": "Fractions", "stats.scoreboard.tab.player": "Player", + "stats.scoreboard.tab.performance": "Performance", "stats.scoreboard.fraction.filter.all": "All", "stats.scoreboard.header.player": "Player", "stats.scoreboard.header.fraction": "Fraction", diff --git a/static/src/assets/icon/stats/performance-stats-btn.svg b/static/src/assets/icon/stats/performance-stats-btn.svg new file mode 100644 index 0000000..550d130 --- /dev/null +++ b/static/src/assets/icon/stats/performance-stats-btn.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + +