2018-07-29 20:59:09 +02:00
|
|
|
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';
|
2017-08-06 10:42:37 +02:00
|
|
|
|
|
|
|
@Component({
|
2018-03-08 10:17:10 +01:00
|
|
|
selector: 'cc-stats',
|
2017-08-06 10:42:37 +02:00
|
|
|
templateUrl: './stats.component.html',
|
|
|
|
styleUrls: ['./stats.component.css']
|
|
|
|
})
|
2018-07-29 20:59:09 +02:00
|
|
|
export class StatisticComponent implements OnInit {
|
|
|
|
|
|
|
|
selectedCampaign: Campaign = {};
|
|
|
|
|
|
|
|
campaigns: Campaign[] = [];
|
|
|
|
|
2018-07-30 20:43:47 +02:00
|
|
|
collapsed: boolean = false;
|
|
|
|
|
2018-07-29 20:59:09 +02:00
|
|
|
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});
|
2017-08-06 10:42:37 +02:00
|
|
|
}
|
2018-07-30 20:43:47 +02:00
|
|
|
|
|
|
|
toggleCollapse() {
|
|
|
|
this.collapsed = !this.collapsed;
|
|
|
|
setTimeout(_ => {
|
|
|
|
window.dispatchEvent(new Event('resize'));
|
|
|
|
});
|
|
|
|
}
|
2017-08-06 10:42:37 +02:00
|
|
|
}
|