49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import {Component, OnInit} from '@angular/core';
|
|
import {Campaign} from '../models/model-interfaces';
|
|
import {CampaignService} from '../services/logs/campaign.service';
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
@Component({
|
|
selector: 'cc-stats',
|
|
templateUrl: './stats.component.html',
|
|
styleUrls: ['./stats.component.css']
|
|
})
|
|
export class StatisticComponent implements OnInit {
|
|
|
|
selectedCampaign: Campaign = {};
|
|
|
|
campaigns: Campaign[] = [];
|
|
|
|
collapsed: boolean = false;
|
|
|
|
constructor(private campaignService: CampaignService,
|
|
private router: Router,
|
|
private route: ActivatedRoute) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.campaignService.getAllCampaignsWithWars().subscribe((campaigns) => {
|
|
this.campaigns = campaigns;
|
|
this.campaignService.campaigns = campaigns;
|
|
this.switchCampaign(campaigns[0])
|
|
});
|
|
}
|
|
|
|
switchCampaign(campaign) {
|
|
this.selectedCampaign = campaign;
|
|
if (campaign._id === 'all' || this.router.url.includes('/overview/all')) {
|
|
setTimeout(_ => {
|
|
window.dispatchEvent(new Event('resize'));
|
|
});
|
|
}
|
|
this.router.navigate([{outlets: {'right': ['overview', campaign._id]}}], {relativeTo: this.route});
|
|
}
|
|
|
|
toggleCollapse() {
|
|
this.collapsed = !this.collapsed;
|
|
setTimeout(_ => {
|
|
window.dispatchEvent(new Event('resize'));
|
|
});
|
|
}
|
|
}
|