2018-04-02 13:22:04 +02:00
|
|
|
import {Component, OnInit, ViewChild} from '@angular/core';
|
2018-03-07 11:56:50 +01:00
|
|
|
import {ActivatedRoute} from '@angular/router';
|
2018-04-29 10:07:20 +02:00
|
|
|
import {WarService} from '../../../services/logs/war.service';
|
|
|
|
import {War} from '../../../models/model-interfaces';
|
|
|
|
import {ChartUtils} from '../../../utils/chart-utils';
|
|
|
|
import {Fraction} from '../../../utils/fraction.enum';
|
|
|
|
import {LogsService} from '../../../services/logs/logs.service';
|
|
|
|
import {ScoreboardComponent} from '../scoreboard/scoreboard.component';
|
2017-07-08 21:56:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'war-detail',
|
2018-04-29 10:12:27 +02:00
|
|
|
templateUrl: './war-header.component.html',
|
2019-02-22 08:14:46 +01:00
|
|
|
styleUrls: ['./war-header.component.scss']
|
2017-07-08 21:56:11 +02:00
|
|
|
})
|
2018-04-29 10:12:27 +02:00
|
|
|
export class WarHeaderComponent implements OnInit {
|
2017-07-08 21:56:11 +02:00
|
|
|
|
2017-11-08 14:37:13 +01:00
|
|
|
readonly fraction = Fraction;
|
2017-11-07 14:02:49 +01:00
|
|
|
|
2017-11-12 19:27:26 +01:00
|
|
|
war: War;
|
2017-10-29 17:36:55 +01:00
|
|
|
|
2018-04-02 13:20:44 +02:00
|
|
|
@ViewChild('scoreboard') scoreBoardComponent: ScoreboardComponent;
|
|
|
|
|
2017-11-13 13:49:47 +01:00
|
|
|
logData;
|
2017-07-09 17:08:32 +02:00
|
|
|
|
2019-02-09 21:55:13 +01:00
|
|
|
fractionStatsInitialized: boolean;
|
|
|
|
|
|
|
|
performanceData;
|
|
|
|
|
|
|
|
performanceStatsInitialized: boolean;
|
|
|
|
|
2017-11-13 15:45:12 +01:00
|
|
|
singlePlayerView: number;
|
|
|
|
|
|
|
|
playerDetailName: string;
|
|
|
|
|
2017-11-13 13:49:47 +01:00
|
|
|
tab: number;
|
2017-09-13 11:49:34 +02:00
|
|
|
|
2017-11-13 13:49:47 +01:00
|
|
|
fractionFilterSelected: string;
|
2017-07-09 17:08:32 +02:00
|
|
|
|
2017-11-13 13:49:47 +01:00
|
|
|
playerChart: any[] = [];
|
2017-09-13 11:49:34 +02:00
|
|
|
|
2017-11-13 13:49:47 +01:00
|
|
|
colorScheme = {
|
|
|
|
domain: [Fraction.COLOR_OPFOR, Fraction.COLOR_BLUFOR]
|
2017-09-13 11:49:34 +02:00
|
|
|
};
|
2017-07-30 16:25:11 +02:00
|
|
|
|
2017-08-06 10:42:37 +02:00
|
|
|
constructor(private route: ActivatedRoute,
|
2017-11-13 13:49:47 +01:00
|
|
|
private warService: WarService,
|
|
|
|
private logsService: LogsService) {
|
2017-07-08 21:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2017-11-13 13:49:47 +01:00
|
|
|
this.route.params
|
2018-02-26 09:04:27 +01:00
|
|
|
.map(params => params['id'])
|
2018-03-07 11:56:50 +01:00
|
|
|
.filter(id => id !== undefined)
|
2018-02-26 09:04:27 +01:00
|
|
|
.flatMap(id => this.warService.getWar(id))
|
|
|
|
.subscribe(war => {
|
|
|
|
this.war = war;
|
|
|
|
|
|
|
|
this.switchTab(0);
|
|
|
|
this.fractionStatsInitialized = false;
|
|
|
|
this.fractionFilterSelected = undefined;
|
|
|
|
|
2018-10-14 15:56:52 +02:00
|
|
|
this.playerChart =
|
|
|
|
ChartUtils.getSingleDataArray(Fraction.OPFOR, war.playersOpfor, Fraction.BLUFOR, war.playersBlufor);
|
2018-02-26 09:04:27 +01:00
|
|
|
Object.assign(this, [this.playerChart]);
|
2018-03-07 11:56:50 +01:00
|
|
|
});
|
2017-11-03 12:51:58 +01:00
|
|
|
}
|
|
|
|
|
2017-11-13 13:49:47 +01:00
|
|
|
switchTab(index: number) {
|
|
|
|
this.tab = index;
|
|
|
|
if (index === 1 && !this.fractionStatsInitialized) {
|
|
|
|
this.logsService.getFullLog(this.war._id).subscribe(log => {
|
|
|
|
this.logData = log;
|
|
|
|
this.fractionStatsInitialized = true;
|
|
|
|
});
|
2017-11-04 20:46:05 +01:00
|
|
|
}
|
2019-02-09 21:55:13 +01:00
|
|
|
if (index === 3 && !this.performanceStatsInitialized) {
|
|
|
|
this.logsService.getPerformanceLogs(this.war._id).subscribe(log => {
|
|
|
|
this.performanceData = log;
|
|
|
|
this.performanceStatsInitialized = true;
|
|
|
|
});
|
|
|
|
}
|
2017-11-13 15:45:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* called by EventEmitter,
|
|
|
|
* @param event with fields: 'view' (0 = war-detail, 1 = campaign-detail); 'player' = player name
|
|
|
|
*/
|
|
|
|
switchToPlayerTab(event) {
|
|
|
|
this.singlePlayerView = event.view;
|
|
|
|
this.playerDetailName = event.player;
|
|
|
|
this.switchTab(2);
|
2017-11-04 15:58:48 +01:00
|
|
|
}
|
|
|
|
|
2017-11-12 19:27:26 +01:00
|
|
|
filterPlayersByFraction(fraction?: string) {
|
2017-11-13 13:49:47 +01:00
|
|
|
this.fractionFilterSelected = fraction;
|
2017-10-30 08:59:08 +01:00
|
|
|
}
|
2017-07-08 21:56:11 +02:00
|
|
|
}
|