Compare commits

..

No commits in common. "2747ea41c6f30230c74b494998ace203fc13b04e" and "cb7146446280d8a72da41d99e5e7716ef0bd459b" have entirely different histories.

15 changed files with 342 additions and 309 deletions

View File

@ -1,5 +1,5 @@
<div class="overview fade-in" style="padding: 70px 1% 0 1%;" xmlns="http://www.w3.org/1999/html"> <div class="overview fade-in" style="padding: 70px 1% 0 1%;" xmlns="http://www.w3.org/1999/html">
<h2 class="pull-left">Kampagnendetails - {{campaignPlayer.name}}</h2> <h2 class="pull-left">Spielerstatistik - {{campaignPlayer.name}}</h2>
<h2 class="pull-right">{{campaignPlayer.campaign.title}} Kampagne</h2> <h2 class="pull-right">{{campaignPlayer.campaign.title}} Kampagne</h2>
<span class="btn btn-default btn-back" (click)="navigateBack()">< Zurück</span> <span class="btn btn-default btn-back" (click)="navigateBack()">< Zurück</span>

View File

@ -4,7 +4,7 @@ import {SharedModule} from "../shared.module";
import {statsRouterModule, statsRoutingComponents} from "./stats.routing"; import {statsRouterModule, statsRoutingComponents} from "./stats.routing";
import {WarService} from "../services/logs/war.service"; import {WarService} from "../services/logs/war.service";
import {NgxChartsModule} from "@swimlane/ngx-charts"; import {NgxChartsModule} from "@swimlane/ngx-charts";
import {AccordionModule, ButtonsModule} from "ngx-bootstrap"; import {AccordionModule, BsDropdownModule, ButtonsModule, TabsModule} from "ngx-bootstrap";
import {CampaignService} from "../services/logs/campaign.service"; import {CampaignService} from "../services/logs/campaign.service";
import {NgxDatatableModule} from "@swimlane/ngx-datatable"; import {NgxDatatableModule} from "@swimlane/ngx-datatable";
import {PlayerService} from "../services/logs/player.service"; import {PlayerService} from "../services/logs/player.service";
@ -13,7 +13,7 @@ import {LogsService} from "../services/logs/logs.service";
@NgModule({ @NgModule({
declarations: statsRoutingComponents, declarations: statsRoutingComponents,
imports: [CommonModule, SharedModule, statsRouterModule, NgxChartsModule, imports: [CommonModule, SharedModule, statsRouterModule, NgxChartsModule,
AccordionModule.forRoot(), ButtonsModule.forRoot(), NgxDatatableModule], AccordionModule.forRoot(), BsDropdownModule.forRoot(), ButtonsModule.forRoot(), TabsModule.forRoot(), NgxDatatableModule],
providers: [WarService, CampaignService, PlayerService, LogsService] providers: [WarService, CampaignService, PlayerService, LogsService]
}) })
export class StatsModule { export class StatsModule {

View File

@ -1,15 +1,15 @@
import {RouterModule, Routes} from "@angular/router"; import {RouterModule, Routes} from "@angular/router";
import {StatisticComponent} from "./stats.component"; import {StatisticComponent} from "./stats.component";
import {WarDetailComponent} from "./war-detail/war-detail.component";
import {WarSubmitComponent} from "./war-submit/war-submit.component";
import {WarListComponent} from "./war-list/war-list.component"; import {WarListComponent} from "./war-list/war-list.component";
import {StatisticOverviewComponent} from "./overview/stats-overview.component"; import {StatisticOverviewComponent} from "./overview/stats-overview.component";
import {WarItemComponent} from "./war-list/war-item.component"; import {WarItemComponent} from "./war-list/war-item.component";
import {ModuleWithProviders} from "@angular/core"; import {ModuleWithProviders} from "@angular/core";
import {CampaignSubmitComponent} from "./campaign-submit/campaign-submit.component"; import {CampaignSubmitComponent} from "./campaign-submit/campaign-submit.component";
import {CampaignPlayerDetailComponent} from "./campaign-player-detail/campaign-player-detail.component"; import {CampaignPlayerDetailComponent} from "./campaign-player-detail/campaign-player-detail.component";
import {WarDetailComponent} from "./war-detail/war-detail.component"; import {WarDetailHeaderComponent} from "./war-detail-header/war-detail-header.component";
import {ScoreboardComponent} from "./war-detail/scoreboard/scoreboard.component"; import {WarDetailFractionComponent} from "./war-detail-fraction/war-detail-fraction.component";
import {WarSubmitComponent} from "./war-submit/war-submit.component";
import {FractionStatsComponent} from "./war-detail/fraction-stats/fraction-stats.component";
export const statsRoutes: Routes = [{ export const statsRoutes: Routes = [{
@ -38,7 +38,7 @@ export const statsRoutes: Routes = [{
}, },
{ {
path: 'war/:id', path: 'war/:id',
component: WarDetailComponent, component: WarDetailHeaderComponent,
outlet: 'right' outlet: 'right'
}, },
{ {
@ -50,6 +50,6 @@ export const statsRoutes: Routes = [{
export const statsRouterModule: ModuleWithProviders = RouterModule.forChild(statsRoutes); export const statsRouterModule: ModuleWithProviders = RouterModule.forChild(statsRoutes);
export const statsRoutingComponents = [StatisticComponent, StatisticOverviewComponent, CampaignSubmitComponent, export const statsRoutingComponents = [StatisticComponent, StatisticOverviewComponent, CampaignSubmitComponent,
WarListComponent, WarSubmitComponent, WarDetailComponent, ScoreboardComponent, FractionStatsComponent, WarListComponent, WarSubmitComponent, WarDetailHeaderComponent, WarDetailComponent, WarDetailFractionComponent,
CampaignPlayerDetailComponent, WarItemComponent]; CampaignPlayerDetailComponent, WarItemComponent];

View File

@ -1,17 +1,18 @@
import {Component, ElementRef, SimpleChanges, ViewChild} from "@angular/core"; import {Component, ElementRef, SimpleChanges, ViewChild} from "@angular/core";
import {LogsService} from "../../services/logs/logs.service";
import * as d3 from "d3"; import * as d3 from "d3";
import {ChartUtils} from "../../../utils/chart-utils"; import {ChartUtils} from "../../utils/chart-utils";
import {Fraction} from "../../../utils/fraction.enum"; import {Fraction} from "../../utils/fraction.enum";
import {War} from "../../../models/model-interfaces"; import {War} from "../../models/model-interfaces";
@Component({ @Component({
selector: 'war-detail-fraction', selector: 'war-detail-fraction',
templateUrl: './fraction-stats.component.html', templateUrl: './war-detail-fraction.component.html',
inputs: ['war', 'logData'], inputs: ['war'],
styleUrls: ['./fraction-stats.component.css', '../../../style/list-entry.css', '../../../style/hide-scrollbar.css'] styleUrls: ['./war-detail-fraction.component.css', '../../style/list-entry.css', '../../style/hide-scrollbar.css']
}) })
export class FractionStatsComponent { export class WarDetailFractionComponent {
readonly fraction = Fraction; readonly fraction = Fraction;
@ -66,14 +67,14 @@ export class FractionStatsComponent {
timeline = false; timeline = false;
roundDomains = true; roundDomains = true;
constructor() { constructor(private logsService: LogsService) {
} }
ngOnInit() { ngOnInit() {
} }
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
if (changes.war || changes.logData) { if (changes.war) {
this.initialized = { this.initialized = {
budget: false, budget: false,
kill: false, kill: false,
@ -133,10 +134,14 @@ export class FractionStatsComponent {
loadFractionData() { loadFractionData() {
this.initializeTempCollections(); this.initializeTempCollections();
this.initPointData();
this.showLineChart = true; this.logsService.getFullLog(this.war._id).subscribe((data) => {
this.lineChartLabel = this.labelPoints; this.logData = data;
this.lineChartData = this.tmpPointData; this.initPointData();
this.showLineChart = true;
this.lineChartLabel = this.labelPoints;
this.lineChartData = this.tmpPointData;
});
} }
initPointData() { initPointData() {

View File

@ -0,0 +1,33 @@
.war-header-container {
width: 920px;
min-height: 205px;
margin: auto;
}
.head-field {
font-size: 24px;
margin-top: 10px;
margin-bottom: 10px;
}
.war-header {
border-bottom: thin solid lightgrey;
}
.nav-tabs > li.active > a {
background: #222222;
}
.nav-tabs > li > a {
background: #4b4b4b;
}
.nav-tabs > li:not(.active) > a:hover {
background: #afafaf;
color: #f5f5f5;
}
.nav-link {
cursor: pointer !important;
color: #FFF !important;
}

View File

@ -0,0 +1,73 @@
<div *ngIf="war" class="war-header fade-in" xmlns="http://www.w3.org/1999/html">
<div class="war-header-container">
<h2>{{war.title}} - vom {{war.date | date: 'dd.MM.yyyy'}}</h2>
<div class="pull-left head-field" style="width: 250px">
<h4>Endpunktestand:</h4>
<span [style.color]="fraction.COLOR_BLUFOR" style="font-weight: bold; margin-right: 10px">{{fraction.BLUFOR}} {{war.ptBlufor}}</span>
<span style="font-size: x-large">|</span>
<span [style.color]="fraction.COLOR_OPFOR" style="font-weight: bold; margin-left: 10px;">{{war.ptOpfor}} {{fraction.OPFOR}}</span>
</div>
<div class="pull-left head-field " style="padding-left: 140px;">
<h4 style="margin-bottom: 0;">Teilnehmer:</h4>
<ngx-charts-pie-chart
[view]="[120, 120]"
[scheme]="colorScheme"
[results]="playerChart"
[legend]="false"
[explodeSlices]="false"
[labels]="false"
[doughnut]="false"
[gradient]="false">
</ngx-charts-pie-chart>
</div>
<div class="pull-left " style="padding-left: 150px; padding-top:15px">
<a class="btn btn-default" style="margin: 20px" target="_blank" href="resource/logs/{{war._id}}/clean.log">Logfile
anzeigen</a>
<form class="form-group">
<label class="radio-inline">
<input type="radio" name="fractSelect"
[checked]="(fractionFilterSelected == undefined) ? 'true' : 'false'"
[(ngModel)]="fractionFilterSelected"
(change)="filterPlayersByFraction()">Alle
</label>
<label class="radio-inline">
<input type="radio" name="fractSelect" value="BLUFOR"
[(ngModel)]="fractionFilterSelected"
#fractRadioBufor
(change)="filterPlayersByFraction(fractRadioBufor.value)">{{fraction.BLUFOR}}
</label>
<label class="radio-inline">
<input type="radio" name="fractSelect" value="OPFOR"
[(ngModel)]="fractionFilterSelected"
#fractRadioOpfor
(change)="filterPlayersByFraction(fractRadioOpfor.value)">{{fraction.OPFOR}}
</label>
<br>
</form>
</div>
</div>
<ul class="nav nav-tabs" style="width:980px; margin:auto">
<li class="nav-item" [ngClass]="{active :tab === 0}" (click)="tab = 0">
<a class="nav-link"><img src="../../../assets/scoreboard-btn.png"> Scoreboard</a>
</li>
<li class="nav-item" [ngClass]="{active :tab === 1}" (click)="tab = 1">
<a class="nav-link"><img src="../../../assets/fraction-btn.png"> Fraktionen</a>
</li>
</ul>
<div *ngIf="war">
<war-detail
*ngIf="tab===0"
[war]="war"
[fractionFilterSelected]="fractionFilterSelected">
</war-detail>
<war-detail-fraction
*ngIf="tab===1"
[war]="war">
</war-detail-fraction>
</div>
</div>

View File

@ -0,0 +1,52 @@
import {Component} from "@angular/core";
import {ActivatedRoute} from "@angular/router";
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";
@Component({
selector: 'war-detail-header',
templateUrl: './war-detail-header.component.html',
styleUrls: ['./war-detail-header.component.css', '../../style/list-entry.css', '../../style/hide-scrollbar.css']
})
export class WarDetailHeaderComponent {
readonly fraction = Fraction;
war: War;
tab: number;
fractionFilterSelected: string;
playerChart: any[] = [];
colorScheme = {
domain: [Fraction.COLOR_OPFOR, Fraction.COLOR_BLUFOR]
};
constructor(private route: ActivatedRoute,
private warService: WarService) {
}
ngOnInit() {
this.route.params
.map(params => params['id'])
.filter(id => id != undefined)
.flatMap(id => this.warService.getWar(id))
.subscribe(war => {
this.tab = 0;
this.war = war;
this.fractionFilterSelected = undefined;
this.playerChart = ChartUtils.getSingleDataArray(Fraction.OPFOR, war.playersOpfor, Fraction.BLUFOR, war.playersBlufor);
Object.assign(this, [this.playerChart]);
})
}
filterPlayersByFraction(fraction?: string) {
this.fractionFilterSelected = fraction;
}
}

View File

@ -1,42 +0,0 @@
.player-name {
font-weight: bold;
}
/* ########### DATATABLE ########### */
:host /deep/ .datatable-header {
background: #222222;
font-weight: 700;
border-radius: 10px 10px 0 0;
color: white;
}
:host /deep/ span.datatable-header-cell-label, :host /deep/ div.datatable-body-cell-label {
padding-left: 8px;
}
:host /deep/ .ngx-datatable .datatable-header {
/*vertical center alignment*/
display: table-cell;
vertical-align: middle;
}
:host /deep/ .ngx-datatable .datatable-body .datatable-body-row > div {
/*vertical alignment*/
position: relative;
top: 10px;
}
:host /deep/ .datatable-body-row {
color: #222222;
border-bottom: 1px solid grey;
}
:host /deep/ .datatable-body-row:hover {
background-color: #f7f7f7;
}
.in-table-btn {
position: absolute;
margin-top: -5px;
}

View File

@ -1,42 +0,0 @@
<div #overview class="fade-in" xmlns="http://www.w3.org/1999/html">
<ngx-datatable
style="width:1020px; margin:auto"
[rows]="rows"
[sorts]="[{prop: 'kill', dir: 'desc'}]"
[reorderable]="reorderable"
[messages]="{emptyMessage: 'Loading...'}"
[headerHeight]="cellHeight"
[rowHeight]="cellHeight"
[cssClasses]='customClasses'
[selectionType]="'single'">
<ngx-datatable-column name="Spieler" prop="name" [width]="210" style="padding-left:10px">
<ng-template ngx-datatable-cell-template let-row="row" let-value="value">
<span class="player-name"
[style.color]="row['fraction'] === 'BLUFOR' ? fraction.COLOR_BLUFOR : fraction.COLOR_OPFOR">
{{value}}
</span>
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column name="Fraktion" prop="fraction" [width]="100">
<ng-template ngx-datatable-cell-template let-value="value">
{{value === 'BLUFOR' ? fraction.BLUFOR : fraction.OPFOR}}
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column [width]="90" name="Kills" prop="kill"></ngx-datatable-column>
<ngx-datatable-column [width]="104" name="FriendlyFire" prop="friendlyFire"></ngx-datatable-column>
<ngx-datatable-column [width]="80" name="Revive" prop="revive"></ngx-datatable-column>
<ngx-datatable-column [width]="100" name="Eroberung" prop="flagTouch"></ngx-datatable-column>
<ngx-datatable-column [width]="70" name="Tod" prop="death"></ngx-datatable-column>
<ngx-datatable-column [width]="90" name="Respawn" prop="respawn"></ngx-datatable-column>
<ngx-datatable-column [width]="80" name="" prop="name">
<ng-template ngx-datatable-cell-template let-value="value">
<span class="btn btn-sm btn-default in-table-btn disabled">Detail</span>
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column [width]="80" name="" prop="name">
<ng-template ngx-datatable-cell-template let-value="value">
<span class="btn btn-sm btn-default in-table-btn" (click)="selectPlayerDetail(value)">Gesamt</span>
</ng-template>
</ngx-datatable-column>
</ngx-datatable>
</div>

View File

@ -1,72 +0,0 @@
import {Component, ElementRef, SimpleChanges, ViewChild} from "@angular/core";
import {ActivatedRoute, Router} from "@angular/router";
import {War} from "../../../models/model-interfaces";
import {Fraction} from "../../../utils/fraction.enum";
@Component({
selector: 'scoreboard',
templateUrl: './scoreboard.component.html',
inputs: ['war', 'fractionFilterSelected'],
styleUrls: ['./scoreboard.component.css', '../../../style/list-entry.css', '../../../style/hide-scrollbar.css']
})
export class ScoreboardComponent {
readonly fraction = Fraction;
@ViewChild('overview') private overviewContainer: ElementRef;
war: War;
fractionFilterSelected: string;
cellHeight = 40;
rows = [];
reorderable: boolean = false;
customClasses = {
sortAscending: 'glyphicon glyphicon-triangle-top',
sortDescending: 'glyphicon glyphicon-triangle-bottom',
};
constructor(private route: ActivatedRoute,
private router: Router) {
}
ngOnInit() {
}
selectPlayerDetail(playerName: string) {
this.router.navigate(['../../campaign-player/' + this.war.campaign + '/' + playerName],
{relativeTo: this.route});
}
ngOnChanges(changes: SimpleChanges) {
if (changes.war) {
this.rows = changes.war.currentValue.players;
}
if (changes.fractionFilterSelected) {
this.filterPlayersByFraction(this.fractionFilterSelected)
}
this.scrollOverviewTop();
}
scrollOverviewTop() {
try {
this.overviewContainer.nativeElement.scrollTop = 0;
} catch (err) {
}
}
filterPlayersByFraction(fraction?: string) {
if (fraction) {
this.rows = this.war.players.filter((player) => {
return player.fraction === fraction;
})
} else {
this.rows = this.war.players;
}
}
}

View File

@ -1,7 +1,7 @@
.war-header-container { .vertical-spacer {
width: 920px; height: 205px;
min-height: 205px; float: left;
margin: auto; width: 4%;
} }
.head-field { .head-field {
@ -10,32 +10,99 @@
margin-bottom: 10px; margin-bottom: 10px;
} }
.war-header { @media screen and (min-width: 1500px) {
border-bottom: thin solid lightgrey; .vertical-spacer {
width: 15%;
}
} }
.nav-tabs > li.active > a { @media screen and (min-width: 2000px) {
.vertical-spacer {
width: 20%;
}
}
.overview {
overflow-y: scroll;
overflow-x: hidden;
border-left: thin solid lightgrey;
bottom: 20px;
height: 100vh;
}
.player-name {
font-weight: bold;
}
/* ########### DATATABLE ########### */
:host /deep/ .datatable-header {
background: #222222; background: #222222;
font-weight: 700;
border-radius: 10px 10px 0 0;
color: white;
} }
.nav-tabs { :host /deep/ span.datatable-header-cell-label, :host /deep/ div.datatable-body-cell-label {
border-bottom: 0; padding-left: 8px;
} }
.nav-tabs > li > a { :host /deep/ .ngx-datatable .datatable-header {
/*vertical center alignment*/
display: table-cell;
vertical-align: middle;
}
:host /deep/ .ngx-datatable .datatable-body .datatable-body-row > div {
/*vertical alignment*/
position: relative;
top: 10px;
}
:host /deep/ .datatable-body-row {
color: #222222;
border-bottom: 1px solid grey;
cursor: pointer;
}
:host /deep/ .datatable-body-row:hover {
background-color: #f7f7f7;
}
/* ########### CHART-TAB ######## */
.btn-dark {
background: #4b4b4b; background: #4b4b4b;
color: #f5f5f5;
border-color: #000;
} }
.nav-tabs > li:not(.active) > a:hover { .btn-dark:hover {
background: #afafaf; background: #afafaf;
color: #f5f5f5; color: #f5f5f5;
} }
.nav-link { .btn-dark.active {
cursor: pointer !important; background: #222222;
color: #FFF !important;
} }
.nav-tabs > li.deactivated > a.nav-link{ .chart-container {
cursor: not-allowed!important; width: 95%;
margin: 2%;
min-width: 900px;
height: 600px;
padding: 15px;
float: left;
} }
.chart-select-group {
width: 50%;
margin: auto;
position: inherit;
display: block;
vertical-align: middle;
}
/*.dropdown-menu > li > a {*/
/*cursor: pointer;*/
/*}*/

View File

@ -1,78 +1,33 @@
<div *ngIf="war" class="war-header fade-in" xmlns="http://www.w3.org/1999/html"> <div #overview class="overview fade-in" xmlns="http://www.w3.org/1999/html">
<div class="war-header-container"> <ngx-datatable
<h2>{{war.title}} - vom {{war.date | date: 'dd.MM.yyyy'}}</h2> style="width:980px; margin:auto"
<div class="pull-left head-field" style="width: 250px"> [rows]="rows"
<h4>Endpunktestand:</h4> [sorts]="[{prop: 'kill', dir: 'desc'}]"
<span [style.color]="fraction.COLOR_BLUFOR" style="font-weight: bold; margin-right: 10px">{{fraction.BLUFOR}} {{war.ptBlufor}}</span> [reorderable]="reorderable"
<span style="font-size: x-large">|</span> [messages]="{emptyMessage: 'Loading...'}"
<span [style.color]="fraction.COLOR_OPFOR" style="font-weight: bold; margin-left: 10px;">{{war.ptOpfor}} {{fraction.OPFOR}}</span> [headerHeight]="cellHeight"
</div> [rowHeight]="cellHeight"
[cssClasses]='customClasses'
<div class="pull-left head-field " style="padding-left: 140px;"> [selectionType]="'single'"
<h4 style="margin-bottom: 0;">Teilnehmer:</h4> (select)="selectPlayerDetail($event)">
<ngx-charts-pie-chart <ngx-datatable-column name="Spieler" prop="name" [width]="210" style="padding-left:10px">
[view]="[120, 120]" <ng-template ngx-datatable-cell-template let-row="row" let-value="value">
[scheme]="colorScheme" <span class="player-name"
[results]="playerChart" [style.color]="row['fraction'] === 'BLUFOR' ? fraction.COLOR_BLUFOR : fraction.COLOR_OPFOR">
[legend]="false" {{value}}
[explodeSlices]="false" </span>
[labels]="false" </ng-template>
[doughnut]="false" </ngx-datatable-column>
[gradient]="false"> <ngx-datatable-column name="Fraktion" prop="fraction" [width]="100">
</ngx-charts-pie-chart> <ng-template ngx-datatable-cell-template let-value="value">
</div> {{value === 'BLUFOR' ? fraction.BLUFOR : fraction.OPFOR}}
</ng-template>
<div class="pull-left " style="padding-left: 150px; padding-top:15px"> </ngx-datatable-column>
<a class="btn btn-default" style="margin: 20px" target="_blank" href="resource/logs/{{war._id}}/clean.log">Logfile <ngx-datatable-column [width]="90" name="Kills" prop="kill"></ngx-datatable-column>
anzeigen</a> <ngx-datatable-column [width]="110" name="FriendlyFire" prop="friendlyFire"></ngx-datatable-column>
<form class="form-group" *ngIf="tab === 0"> <ngx-datatable-column [width]="100" name="Revive" prop="revive"></ngx-datatable-column>
<label class="radio-inline"> <ngx-datatable-column [width]="100" name="Eroberung" prop="flagTouch"></ngx-datatable-column>
<input type="radio" name="fractSelect" <ngx-datatable-column [width]="100" name="Tod" prop="death"></ngx-datatable-column>
[checked]="(fractionFilterSelected == undefined) ? 'true' : 'false'" <ngx-datatable-column [width]="100" name="Respawn" prop="respawn"></ngx-datatable-column>
[(ngModel)]="fractionFilterSelected" </ngx-datatable>
(change)="filterPlayersByFraction()">Alle
</label>
<label class="radio-inline">
<input type="radio" name="fractSelect" value="BLUFOR"
[(ngModel)]="fractionFilterSelected"
#fractRadioBufor
(change)="filterPlayersByFraction(fractRadioBufor.value)">{{fraction.BLUFOR}}
</label>
<label class="radio-inline">
<input type="radio" name="fractSelect" value="OPFOR"
[(ngModel)]="fractionFilterSelected"
#fractRadioOpfor
(change)="filterPlayersByFraction(fractRadioOpfor.value)">{{fraction.OPFOR}}
</label>
<br>
</form>
</div>
</div>
<ul class="nav nav-tabs" style="width:980px; margin:auto">
<li class="nav-item" [ngClass]="{active :tab === 0}" (click)="switchTab(0)">
<a class="nav-link"><img src="../../../assets/scoreboard-btn.png"> Scoreboard</a>
</li>
<li class="nav-item" [ngClass]="{active :tab === 1}" (click)="switchTab(1)">
<a class="nav-link"><img src="../../../assets/fraction-btn.png"> Fraktionen</a>
</li>
<li class="nav-item" [ngClass]="{active :tab === 2, deactivated :tab !== 2} ">
<a class="nav-link"><img src="../../../assets/player-stats-btn.png"> Player</a>
</li>
</ul>
<!--Sub-Components (=TABS)-->
<div *ngIf="war">
<scoreboard
*ngIf="tab === 0"
[war]="war"
[fractionFilterSelected]="fractionFilterSelected">
</scoreboard>
<war-detail-fraction
*ngIf="tab === 1 && logData"
[war]="war"
[logData]="logData">
</war-detail-fraction>
</div>
</div> </div>

View File

@ -1,71 +1,75 @@
import {Component} from "@angular/core"; import {Component, ElementRef, SimpleChanges, ViewChild} from "@angular/core";
import {ActivatedRoute} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {WarService} from "../../services/logs/war.service";
import {War} from "../../models/model-interfaces"; import {War} from "../../models/model-interfaces";
import {ChartUtils} from "../../utils/chart-utils";
import {Fraction} from "../../utils/fraction.enum"; import {Fraction} from "../../utils/fraction.enum";
import {LogsService} from "../../services/logs/logs.service";
@Component({ @Component({
selector: 'war-detail', selector: 'war-detail',
templateUrl: './war-detail.component.html', templateUrl: './war-detail.component.html',
inputs: ['war', 'fractionFilterSelected'],
styleUrls: ['./war-detail.component.css', '../../style/list-entry.css', '../../style/hide-scrollbar.css'] styleUrls: ['./war-detail.component.css', '../../style/list-entry.css', '../../style/hide-scrollbar.css']
}) })
export class WarDetailComponent { export class WarDetailComponent {
readonly fraction = Fraction; readonly fraction = Fraction;
@ViewChild('overview') private overviewContainer: ElementRef;
war: War; war: War;
logData;
tab: number;
fractionStatsInitialized: boolean;
fractionFilterSelected: string; fractionFilterSelected: string;
playerChart: any[] = []; cellHeight = 40;
colorScheme = { rows = [];
domain: [Fraction.COLOR_OPFOR, Fraction.COLOR_BLUFOR]
reorderable: boolean = false;
customClasses = {
sortAscending: 'glyphicon glyphicon-triangle-top',
sortDescending: 'glyphicon glyphicon-triangle-bottom',
}; };
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private warService: WarService, private router: Router) {
private logsService: LogsService) {
} }
ngOnInit() { ngOnInit() {
this.route.params
.map(params => params['id'])
.filter(id => id != undefined)
.flatMap(id => this.warService.getWar(id))
.subscribe(war => {
this.war = war;
this.tab = 0;
this.fractionStatsInitialized = false;
this.fractionFilterSelected = undefined;
this.playerChart = ChartUtils.getSingleDataArray(Fraction.OPFOR, war.playersOpfor, Fraction.BLUFOR, war.playersBlufor);
Object.assign(this, [this.playerChart]);
})
} }
switchTab(index: number) { selectPlayerDetail(player) {
this.tab = index; if (player && player.selected && player.selected.length > 0) {
if (index === 1 && !this.fractionStatsInitialized) { this.router.navigate(['../../campaign-player/' + this.war.campaign + '/' + player.selected[0].name],
this.logsService.getFullLog(this.war._id).subscribe(log => { {relativeTo: this.route});
this.logData = log; }
this.fractionStatsInitialized = true; }
});
ngOnChanges(changes: SimpleChanges) {
if (changes.war) {
this.rows = changes.war.currentValue.players;
}
if (changes.fractionFilterSelected) {
this.filterPlayersByFraction(this.fractionFilterSelected)
}
this.scrollOverviewTop();
}
scrollOverviewTop() {
try {
this.overviewContainer.nativeElement.scrollTop = 0;
} catch (err) {
} }
} }
filterPlayersByFraction(fraction?: string) { filterPlayersByFraction(fraction?: string) {
this.fractionFilterSelected = fraction; if (fraction) {
this.rows = this.war.players.filter((player) => {
return player.fraction === fraction;
})
} else {
this.rows = this.war.players;
}
} }
} }