From 0c7d8c771620b8b65d7825455a78f929622bdc17 Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Fri, 6 Oct 2017 21:41:59 +0200 Subject: [PATCH] Make overview and war stats available via direct url --- static/src/app/army/army.component.html | 2 +- .../overview/stats-overview.component.ts | 17 +++++++++++++---- .../statistic/war-list/war-list.component.ts | 13 ++++++++++++- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/static/src/app/army/army.component.html b/static/src/app/army/army.component.html index 6c1809b..43a117b 100644 --- a/static/src/app/army/army.component.html +++ b/static/src/app/army/army.component.html @@ -1,4 +1,4 @@ -
+

Übersicht über alle Spieler, Squads und Armeen

diff --git a/static/src/app/statistic/overview/stats-overview.component.ts b/static/src/app/statistic/overview/stats-overview.component.ts index a390b79..8487a47 100644 --- a/static/src/app/statistic/overview/stats-overview.component.ts +++ b/static/src/app/statistic/overview/stats-overview.component.ts @@ -20,7 +20,7 @@ export class StatisticOverviewComponent { pointData: any[] = []; pointSumData: any[] = []; playerData: any[] = []; - currentData : any[]; + currentData: any[] = []; activeSlideIndex; colorScheme = { @@ -78,9 +78,18 @@ export class StatisticOverviewComponent { goToSlide(index: number) { switch (index) { - case 0: this.currentData = this.pointSumData; this.yAxisLabel="Gesamtpunkte"; break; - case 1: this.currentData = this.pointData; this.yAxisLabel="Punkte"; break; - case 2: this.currentData = this.playerData; this.yAxisLabel="Anzahl Spieler"; break; + case 0: + this.currentData = this.pointSumData; + this.yAxisLabel = "Gesamtpunkte"; + break; + case 1: + this.currentData = this.pointData; + this.yAxisLabel = "Punkte"; + break; + case 2: + this.currentData = this.playerData; + this.yAxisLabel = "Anzahl Spieler"; + break; } this.activeSlideIndex = index; diff --git a/static/src/app/statistic/war-list/war-list.component.ts b/static/src/app/statistic/war-list/war-list.component.ts index 9fdcfca..17d39a3 100644 --- a/static/src/app/statistic/war-list/war-list.component.ts +++ b/static/src/app/statistic/war-list/war-list.component.ts @@ -4,6 +4,7 @@ import {Campaign, War} from "../../models/model-interfaces"; import {WarService} from "../../services/war-service/war.service"; import {LoginService} from "../../services/login-service/login-service"; import {CampaignService} from "../../services/campaign-service/campaign.service"; +import {RouteConfig} from "../../app.config"; @Component({ selector: 'war-list', @@ -25,9 +26,19 @@ export class WarListComponent implements OnInit { ngOnInit() { this.campaignService.getAllCampaigns().subscribe((items) => { + const subPathWar = 'war/'; + const subPathOverview = 'overview/'; this.campaignService.campaigns = items; this.campaigns = items; - this.selectOverview(this.campaigns[0]._id); + + const url = this.router.url; + if (url.endsWith(RouteConfig.statsPath)) { + this.selectOverview(this.campaigns[0]._id); + } else if (url.indexOf(subPathWar) !== -1) { + this.selectedWarId = url.substring(url.lastIndexOf(subPathWar) + subPathWar.length, url.lastIndexOf(")")); + } else if (url.indexOf(subPathOverview) !== -1) { + this.selectedWarId = url.substring(url.lastIndexOf(subPathOverview) + subPathOverview.length, url.lastIndexOf(")")); + } }); }