opt-cc/static/src/app/statistic/highscore/highscore.component.ts

48 lines
1.2 KiB
TypeScript

import {Component} from "@angular/core";
import {ActivatedRoute} from "@angular/router";
import {PlayerService} from "../../services/logs/player.service";
import {CampaignService} from "../../services/logs/campaign.service";
@Component({
selector: 'stats-highscore',
templateUrl: './highscore.component.html',
styleUrls: ['./highscore.component.css', '../../style/list-entry.css', '../../style/overview.css'],
inputs: ['campaigns']
})
export class StatisticHighScoreComponent {
id = "";
title = "";
constructor(private route: ActivatedRoute,
private playerService: PlayerService,
private campaignService: CampaignService) {
}
ngOnInit() {
this.route.params
.map(params => params['id'])
.subscribe((id) => {
this.id = id;
if (this.campaignService.campaigns) {
this.initData();
} else {
this.campaignService.getAllCampaigns().subscribe(campaigns => {
this.initData()
})
}
});
}
initData() {
this.title = this.campaignService.campaigns
.filter(camp => camp._id === this.id).pop().title;
this.playerService.getCampaignHighscore(this.id).subscribe(players => {
console.log(players);
})
}
}