Fix Highscore link and overview after redirect from edit campaign

pull/46/head
HardiReady 2018-10-08 00:03:01 +02:00
parent 1be757bbc1
commit c9fce51ef6
2 changed files with 18 additions and 19 deletions

View File

@ -16,8 +16,6 @@ import {PlayerUtils} from '../../../utils/player-utils';
})
export class StatisticHighScoreComponent implements OnInit {
@Input() campaigns;
id = '';
searchTerm = new FormControl();
@ -31,8 +29,7 @@ export class StatisticHighScoreComponent implements OnInit {
readonly fraction = Fraction;
constructor(private route: ActivatedRoute,
private playerService: PlayerService,
private campaignService: CampaignService) {
private playerService: PlayerService) {
}
ngOnInit() {
@ -40,9 +37,7 @@ export class StatisticHighScoreComponent implements OnInit {
.map(params => params['id'])
.subscribe((id) => {
this.id = id;
this.campaignService.getAllCampaignsWithWars().subscribe(campaigns => {
this.initData();
});
this.initData();
});
const searchTermStream = this.searchTerm.valueChanges.debounceTime(400);

View File

@ -46,9 +46,9 @@ export class StatisticOverviewComponent implements OnInit {
.map(params => params['id'])
.subscribe((id) => {
this.id = id;
this.campaignService.getAllCampaignsWithWars().subscribe(campaigns => {
this.initWars(campaigns);
});
this.campaignService.getAllCampaignsWithWars().subscribe(campaigns => {
this.initWars(campaigns);
});
});
}
@ -91,36 +91,40 @@ export class StatisticOverviewComponent implements OnInit {
const playersObj = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR);
for (let i = wars.length - 1; i >= 0; i--) {
const war = wars[i];
if (!war) {
continue;
}
const j = wars.length - i - 1;
const warDate = (this.id === 'all') ? new Date(wars[i].date) : ChartUtils.getShortDateString(wars[i].date);
const warDate = (this.id === 'all') ? new Date(war.date) : ChartUtils.getShortDateString(war.date);
pointsObj[0].series.push({
name: warDate,
value: wars[i].ptBlufor
value: war.ptBlufor
});
pointsObj[1].series.push({
name: warDate,
value: wars[i].ptOpfor
value: war.ptOpfor
});
pointsSumObj[0].series.push({
name: warDate,
value: pointsSumObj[0].series[j - 1] ?
pointsSumObj[0].series[j - 1].value + wars[i].ptBlufor :
wars[i].ptBlufor
pointsSumObj[0].series[j - 1].value + war.ptBlufor :
war.ptBlufor
});
pointsSumObj[1].series.push({
name: warDate,
value: pointsSumObj[1].series[j - 1]
? pointsSumObj[1].series[j - 1].value + wars[i].ptOpfor :
wars[i].ptOpfor
? pointsSumObj[1].series[j - 1].value + war.ptOpfor :
war.ptOpfor
});
playersObj[0].series.push({
name: warDate,
value: wars[i].playersBlufor
value: war.playersBlufor
});
playersObj[1].series.push({
name: warDate,
value: wars[i].playersOpfor
value: war.playersOpfor
});
}