Replace bootstrap button toggle with material in fraction stats

pull/40/head
HardiReady 2018-07-01 13:03:51 +02:00
parent d1ba6170ba
commit 7b58adad60
4 changed files with 89 additions and 85 deletions

View File

@ -9,12 +9,12 @@ 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';
import {LogsService} from '../services/logs/logs.service'; import {LogsService} from '../services/logs/logs.service';
import {MatExpansionModule, MatFormFieldModule} from '@angular/material'; import {MatButtonToggleModule, MatExpansionModule, MatFormFieldModule} from '@angular/material';
@NgModule({ @NgModule({
declarations: statsRoutingComponents, declarations: statsRoutingComponents,
imports: [CommonModule, SharedModule, statsRouterModule, NgxChartsModule, ButtonsModule.forRoot(), NgxDatatableModule, imports: [CommonModule, SharedModule, statsRouterModule, NgxChartsModule, NgxDatatableModule, MatExpansionModule,
MatExpansionModule, MatFormFieldModule], MatButtonToggleModule],
providers: [WarService, CampaignService, PlayerService, LogsService] providers: [WarService, CampaignService, PlayerService, LogsService]
}) })
export class StatsModule { export class StatsModule {

View File

@ -1,16 +1,32 @@
.btn-dark { .chart-select-group {
background: #4b4b4b; display: flex;
color: #f5f5f5; width: 945px;
border-color: #000; margin: auto;
} }
.btn-dark:hover { .chart-select-group > mat-button-toggle {
background: #4b4b4b;
color: #f5f5f5;
border: 1px solid #000;
}
.chart-select-group > mat-button-toggle:hover {
background: #afafaf; background: #afafaf;
color: #f5f5f5; color: #f5f5f5;
} }
.btn-dark.active { mat-button-toggle.mat-button-toggle-checked {
background: #222222; background: #222222 !important;
}
:host /deep/ label.mat-button-toggle-label {
margin: 2px 0 !important;
}
:host /deep/ div.mat-button-toggle-label-content {
line-height: 25px !important;
margin-bottom: 0 !important;
font-weight: normal !important;
} }
.chart-container { .chart-container {
@ -21,12 +37,3 @@
padding: 15px; padding: 15px;
float: left; float: left;
} }
.chart-select-group {
width: 980px;
margin: auto;
}
/*.dropdown-menu > li > a {*/
/*cursor: pointer;*/
/*}*/

View File

@ -1,45 +1,38 @@
<!--<div class="btn-group" style="position: absolute; margin-left: 5%;" dropdown>-->
<!--<button dropdownToggle type="button" class="btn btn-default dropdown-toggle dropdown-toggle-split">-->
<!--{{dataMode}} <span class="caret"></span>-->
<!--</button>-->
<!--<ul *dropdownMenu class="dropdown-menu" role="menu">-->
<!--<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(0, 'Summe')">Summe</a></li>-->
<!--<li class="divider dropdown-divider"></li>-->
<!--<li class="disabled" role="menuitem">-->
<!--<a class="dropdown-item" style="cursor: default!important;">Interval:</a>-->
<!--</li>-->
<!--<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(1, '1 Minute')">1 Minute</a></li>-->
<!--<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(5, '5 Minuten')">5 Minuten</a></li>-->
<!--<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(10, '10 Minuten')">10 Minuten</a>-->
<!--<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(20, '20 Minuten')">20 Minuten</a>-->
<!--<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(40, '40 Minuten')">40 Minuten</a>-->
<!--</li>-->
<!--</ul>-->
<!--</div>-->
<div class="fade-in" xmlns="http://www.w3.org/1999/html"> <div class="fade-in" xmlns="http://www.w3.org/1999/html">
<div class="chart-select-group">
<div class="btn-group" (click)="selectChart()"> <mat-button-toggle-group class="chart-select-group"
<label class="btn btn-default btn-dark" [(ngModel)]="chartSelectModel" #group="matButtonToggleGroup"
btnRadio="{{labelPoints}}">{{labelPoints}}</label> [(ngModel)]="activeChartSelect"
<label class="btn btn-default btn-dark" [(ngModel)]="chartSelectModel" (change)="selectChart(group.value)">
btnRadio="{{labelBudget}}">{{labelBudget}}</label> <!--this does not work with ngFor due to deselect bug of ng-material-->
<label class="btn btn-default btn-dark" [(ngModel)]="chartSelectModel" <mat-button-toggle value="{{labels.points}}">
btnRadio="{{labelKill}}">{{labelKill}}</label> {{labels.points}}
<label class="btn btn-default btn-dark" [(ngModel)]="chartSelectModel" </mat-button-toggle>
btnRadio="{{labelFriendlyFire}}">{{labelFriendlyFire}}</label> <mat-button-toggle value="{{labels.budget}}">
<label class="btn btn-default btn-dark" [(ngModel)]="chartSelectModel" {{labels.budget}}
btnRadio="{{labelVehicle}}">{{labelVehicle}}</label> </mat-button-toggle>
<label class="btn btn-default btn-dark" [(ngModel)]="chartSelectModel" <mat-button-toggle value="{{labels.kill}}">
btnRadio="{{labelRevive}}">{{labelRevive}}</label> {{labels.kill}}
<label class="btn btn-default btn-dark" [(ngModel)]="chartSelectModel" </mat-button-toggle>
btnRadio="{{labelStabilize}}">{{labelStabilize}}</label> <mat-button-toggle value="{{labels.friendlyFire}}">
<label class="btn btn-default btn-dark" [(ngModel)]="chartSelectModel" {{labels.friendlyFire}}
btnRadio="{{labelTransport}}">{{labelTransport}}</label> </mat-button-toggle>
<label class="btn btn-default btn-dark" [(ngModel)]="chartSelectModel" <mat-button-toggle value="{{labels.vehicle}}">
btnRadio="{{labelFlag}}">{{labelFlag}}</label> {{labels.vehicle}}
</div> </mat-button-toggle>
</div> <mat-button-toggle value="{{labels.revive}}">
{{labels.revive}}
</mat-button-toggle>
<mat-button-toggle value="{{labels.stabilize}}">
{{labels.stabilize}}
</mat-button-toggle>
<mat-button-toggle value="{{labels.transport}}">
{{labels.transport}}
</mat-button-toggle>
<mat-button-toggle value="{{labels.flag}}">
{{labels.flag}}
</mat-button-toggle>
</mat-button-toggle-group>
<div *ngIf="showLineChart" class="chart-container"> <div *ngIf="showLineChart" class="chart-container">
<ngx-charts-line-chart <ngx-charts-line-chart

View File

@ -24,7 +24,7 @@ export class FractionStatsComponent implements OnInit, OnChanges {
initialized: any; initialized: any;
public chartSelectModel: string; public activeChartSelect: string;
lineChartData: any[] = []; lineChartData: any[] = [];
areaChartData: any[] = []; areaChartData: any[] = [];
@ -44,16 +44,19 @@ export class FractionStatsComponent implements OnInit, OnChanges {
Fraction.COLOR_BLUFOR_DARK, Fraction.COLOR_OPFOR_DARK, Fraction.COLOR_BLUFOR_GREY, Fraction.COLOR_OPFOR_GREY] Fraction.COLOR_BLUFOR_DARK, Fraction.COLOR_OPFOR_DARK, Fraction.COLOR_BLUFOR_GREY, Fraction.COLOR_OPFOR_GREY]
}; };
labelPoints = 'Punkte'; readonly labels = {
labelBudget = 'Budget'; points: 'Punkte',
labelKill = 'Abschüsse'; budget: 'Budget',
labelFriendlyFire = 'Friendly Fire'; kill: 'Abschüsse',
labelVehicle = 'Fahrzeug Abschüsse'; friendlyFire: 'Friendly Fire',
labelTransport = 'Lufttransport'; vehicle: 'Fahrzeug Abschüsse',
labelRevive = 'Revive'; transport: 'Lufttransport',
labelStabilize = 'Stabilisiert'; revive: 'Revive',
labelFlag = 'Flaggenbesitz'; stabilize: 'Stabilisiert',
lineChartLabel: string = this.labelPoints; flag: 'Flaggenbesitz'
};
lineChartLabel: string = this.labels.points;
showLineChart = true; showLineChart = true;
stepCurve = d3.curveStepAfter; stepCurve = d3.curveStepAfter;
@ -84,7 +87,7 @@ export class FractionStatsComponent implements OnInit, OnChanges {
flag: false flag: false
}; };
Object.assign(this, [this.lineChartData, this.areaChartData]); Object.assign(this, [this.lineChartData, this.areaChartData]);
this.chartSelectModel = this.labelPoints; this.activeChartSelect = this.labels.points;
this.startDateObj = new Date(this.war.date); this.startDateObj = new Date(this.war.date);
this.startDateObj.setHours(0); this.startDateObj.setHours(0);
@ -93,39 +96,40 @@ export class FractionStatsComponent implements OnInit, OnChanges {
} }
} }
selectChart() { selectChart(newSelection) {
if (this.chartSelectModel !== this.labelFlag) { this.activeChartSelect = newSelection;
if (this.activeChartSelect !== this.labels.flag) {
this.showLineChart = true; this.showLineChart = true;
this.lineChartLabel = this.chartSelectModel; this.lineChartLabel = this.activeChartSelect;
switch (this.chartSelectModel) { switch (this.activeChartSelect) {
case this.labelPoints: case this.labels.points:
this.lineChartData = this.tmpPointData; this.lineChartData = this.tmpPointData;
break; break;
case this.labelBudget: case this.labels.budget:
this.initBudgetData(); this.initBudgetData();
this.lineChartData = this.tmpBudgetData; this.lineChartData = this.tmpBudgetData;
break; break;
case this.labelKill: case this.labels.kill:
this.initKillData(); this.initKillData();
this.lineChartData = this.tmpKillData; this.lineChartData = this.tmpKillData;
break; break;
case this.labelFriendlyFire: case this.labels.friendlyFire:
this.initKillData(); this.initKillData();
this.lineChartData = this.tmpFrienlyFireData; this.lineChartData = this.tmpFrienlyFireData;
break; break;
case this.labelVehicle: case this.labels.vehicle:
this.initVehicleData(); this.initVehicleData();
this.lineChartData = this.tmpVehicleData; this.lineChartData = this.tmpVehicleData;
break; break;
case this.labelRevive: case this.labels.revive:
this.initRevive(); this.initRevive();
this.lineChartData = this.tmpReviveData; this.lineChartData = this.tmpReviveData;
break; break;
case this.labelStabilize: case this.labels.stabilize:
this.initRevive(); this.initRevive();
this.lineChartData = this.tmpStabilizeData; this.lineChartData = this.tmpStabilizeData;
break; break;
case this.labelTransport: case this.labels.transport:
this.initTransportData(); this.initTransportData();
this.lineChartData = this.tmpTransportData; this.lineChartData = this.tmpTransportData;
break; break;
@ -141,7 +145,7 @@ export class FractionStatsComponent implements OnInit, OnChanges {
this.initializeTempCollections(); this.initializeTempCollections();
this.initPointData(); this.initPointData();
this.showLineChart = true; this.showLineChart = true;
this.lineChartLabel = this.labelPoints; this.lineChartLabel = this.labels.points;
this.lineChartData = this.tmpPointData; this.lineChartData = this.tmpPointData;
} }