Add campaign overview id
parent
8319b79e1f
commit
7890ef76fb
|
@ -11,7 +11,7 @@ export interface User {
|
||||||
_id?: string;
|
_id?: string;
|
||||||
boardUserId?: number;
|
boardUserId?: number;
|
||||||
username?: string;
|
username?: string;
|
||||||
squad?: any; //Squad or string
|
squad?: any; //Squad or id-string
|
||||||
rank?: Rank;
|
rank?: Rank;
|
||||||
awards?: Award[];
|
awards?: Award[];
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,11 @@ export interface Player {
|
||||||
respawn?: number;
|
respawn?: number;
|
||||||
flagTouch?: number;
|
flagTouch?: number;
|
||||||
}
|
}
|
||||||
|
export interface Campaign {
|
||||||
|
_id?: string;
|
||||||
|
title?: string;
|
||||||
|
wars?: War[];
|
||||||
|
}
|
||||||
export interface War {
|
export interface War {
|
||||||
_id?: string;
|
_id?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
import {Injectable} from "@angular/core";
|
import {Injectable} from "@angular/core";
|
||||||
import {War} from "../../models/model-interfaces";
|
import {Campaign, War} from "../../models/model-interfaces";
|
||||||
import {AppConfig} from "../../app.config";
|
import {AppConfig} from "../../app.config";
|
||||||
import {HttpClient} from "../http-client";
|
import {HttpClient} from "../http-client";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class WarService {
|
export class WarService {
|
||||||
|
|
||||||
|
campaigns :Campaign[];
|
||||||
|
|
||||||
constructor(private http: HttpClient,
|
constructor(private http: HttpClient,
|
||||||
private config: AppConfig) {
|
private config: AppConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllWars() {
|
getAllCampaigns() {
|
||||||
return this.http.get(this.config.apiWarPath)
|
return this.http.get(this.config.apiWarPath)
|
||||||
.map(res => res.json())
|
.map(res => res.json())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
import {Component} from "@angular/core";
|
import {Component} from "@angular/core";
|
||||||
import {WarService} from "../../services/war-service/war.service";
|
import {WarService} from "../../services/war-service/war.service";
|
||||||
|
import {Campaign, War} from "../../models/model-interfaces";
|
||||||
|
import {WarListComponent} from "../war-list/war-list.component";
|
||||||
|
import {ActivatedRoute} from "@angular/router";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'stats-overview',
|
selector: 'stats-overview',
|
||||||
templateUrl: './stats-overview.component.html',
|
templateUrl: './stats-overview.component.html',
|
||||||
styleUrls: ['./stats-overview.component.css']
|
styleUrls: ['./stats-overview.component.css'],
|
||||||
|
inputs: ['campaigns']
|
||||||
})
|
})
|
||||||
export class StatisticOverviewComponent {
|
export class StatisticOverviewComponent {
|
||||||
|
|
||||||
|
@ -16,13 +20,39 @@ export class StatisticOverviewComponent {
|
||||||
domain: ['#0000FF', '#B22222']
|
domain: ['#0000FF', '#B22222']
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(private warService: WarService) {
|
constructor(private route: ActivatedRoute,
|
||||||
|
private warService: WarService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.warService.getAllWars().subscribe(items => {
|
this.route.params
|
||||||
this.initChart(items);
|
.map(params => params['id'])
|
||||||
})
|
.subscribe((id) => {
|
||||||
|
console.log(id);
|
||||||
|
|
||||||
|
if (this.warService.campaigns) {
|
||||||
|
this.initWars(this.warService.campaigns, id);
|
||||||
|
} else {
|
||||||
|
this.warService.getAllCampaigns().subscribe(campaigns => {
|
||||||
|
this.initWars(campaigns, id);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initWars(campaigns, id) {
|
||||||
|
let wars = [];
|
||||||
|
let itemsProcessed = 0;
|
||||||
|
|
||||||
|
campaigns
|
||||||
|
.filter(campaign => id === 'all' || campaign._id === id)
|
||||||
|
.forEach(campaign => {
|
||||||
|
wars = wars.concat(campaign.wars);
|
||||||
|
itemsProcessed++;
|
||||||
|
if (itemsProcessed === campaigns.length) {
|
||||||
|
this.initChart(wars);
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
initChart(wars: any[]) {
|
initChart(wars: any[]) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ export const statsRoutes: Routes = [{
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'overview',
|
path: 'overview/:id',
|
||||||
component: StatisticOverviewComponent,
|
component: StatisticOverviewComponent,
|
||||||
outlet: 'right'
|
outlet: 'right'
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,12 +16,13 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<accordion [closeOthers]="oneAtATime">
|
<accordion [closeOthers]="oneAtATime" *ngFor="let campaign of campaigns">
|
||||||
<accordion-group #group>
|
<accordion-group>
|
||||||
<div accordion-heading>
|
<div accordion-heading>
|
||||||
Return to Hell in a Bowl
|
{{campaign.title}}
|
||||||
|
<span class="pull-right">▼</span>
|
||||||
</div>
|
</div>
|
||||||
<div *ngFor="let war of wars">
|
<div *ngFor="let war of campaign.wars">
|
||||||
<pjm-war-item
|
<pjm-war-item
|
||||||
[war]="war"
|
[war]="war"
|
||||||
(warDelete)="deleteWar(war)"
|
(warDelete)="deleteWar(war)"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {Component, OnInit} from "@angular/core";
|
import {Component, OnInit} from "@angular/core";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {War} from "../../models/model-interfaces";
|
import {Campaign, War} from "../../models/model-interfaces";
|
||||||
import {WarService} from "../../services/war-service/war.service";
|
import {WarService} from "../../services/war-service/war.service";
|
||||||
import {LoginService} from "../../services/login-service/login-service";
|
import {LoginService} from "../../services/login-service/login-service";
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export class WarListComponent implements OnInit {
|
||||||
|
|
||||||
selectedWarId: string | number = '0';
|
selectedWarId: string | number = '0';
|
||||||
|
|
||||||
wars: War[] = [];
|
campaigns: Campaign[] = [];
|
||||||
|
|
||||||
public oneAtATime: boolean = true;
|
public oneAtATime: boolean = true;
|
||||||
|
|
||||||
|
@ -24,9 +24,10 @@ export class WarListComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.warService.getAllWars().subscribe((items) => {
|
this.warService.getAllCampaigns().subscribe((items) => {
|
||||||
this.wars = items;
|
this.warService.campaigns = items;
|
||||||
this.router.navigate([{outlets: {'right': ['overview']}}], {relativeTo: this.route});
|
this.campaigns = items;
|
||||||
|
this.router.navigate([{outlets: {'right': ['overview', 'all']}}], {relativeTo: this.route});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ export class WarListComponent implements OnInit {
|
||||||
if (this.selectedWarId === war._id) {
|
if (this.selectedWarId === war._id) {
|
||||||
this.selectOverview();
|
this.selectOverview();
|
||||||
}
|
}
|
||||||
this.wars.splice(this.wars.indexOf(war), 1);
|
this.campaigns.splice(this.campaigns.indexOf(war), 1);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue