Reimplement selector components for stats to go responsive

pull/58/head
HardiReady 2019-02-27 22:42:03 +01:00
parent 04ff22fafc
commit 9dc21dd6c7
24 changed files with 356 additions and 124 deletions

View File

@ -22,4 +22,14 @@ mat-sidenav {
&:hover {
background: #101010;
}
@media all and (max-width: 959px) {
bottom: 0;
left: 0;
width: 100vw;
border-radius: 3px 3px 0 0;
background: #101010;
min-height: 34px;
height: 3vw;
}
}

View File

@ -8,7 +8,7 @@ h1 {
.decoration-overview-container {
position: relative;
z-index: 0;
margin: auto 140px 30px;
margin: auto 4vw 0;
}
@media all and (max-width: 959px) {
@ -73,6 +73,10 @@ h1 {
background: #222222;;
box-shadow: #666666 2px 2px 8px;
& > div:hover {
color: #ffffff;
}
@media all and (max-width: 959px) {
width: 100%;
height: 50px

View File

@ -52,8 +52,9 @@ img.img-medal {
}
img.img-ribbon {
padding-top: 10%;
width: 55%;
padding-top: 20px;
width: 60%;
max-width: 130px;
}
.gradient {

View File

@ -22,6 +22,7 @@
h3 {
margin-top: 0;
font-size: 18px;
}
.mat-column-picture {
@ -30,6 +31,7 @@
.mat-column-name {
max-width: 7.5vw;
overflow: hidden;
}
td.mat-cell:first-child {

View File

@ -1,11 +1,12 @@
<div class="scroll-btn"
<div *ngIf="!isSmallLayout">
<div class="scroll-btn"
*ngIf="isLeftScrollVisible"
(mouseenter)="setRepeater(-10)"
(mouseleave)="clearRepeater()">
<mat-icon svgIcon="chevron-left"></mat-icon>
</div>
</div>
<div class="campaign-horizontal-list" #horizontalList>
<div class="campaign-horizontal-list" #horizontalList>
<div class="campaign-entry"
[ngClass]="{active : selectedCampaignId === 'all'}"
(click)="select({_id:'all'})">
@ -36,12 +37,33 @@
</mat-menu>
</span>
</div>
</div>
</div>
<div class="scroll-btn scroll-btn-right"
<div class="scroll-btn scroll-btn-right"
*ngIf="isRightScrollVisible"
(mouseenter)="setRepeater(10)"
(mouseleave)="clearRepeater()">
<mat-icon svgIcon="chevron-right"></mat-icon>
</div>
</div>
<div *ngIf="isSmallLayout" class="campaign-select-small">
<mat-list-item [matMenuTriggerFor]="menuCampaign">
<div matline class="select-menu-text">
<span *ngIf="selectedCampaignId === 'all'">{{'stats.campaign.title.all.time.overview' | translate}}</span>
<span *ngIf="selectedCampaignId !== 'all' && selectedCampaign">{{selectedCampaign.title}}</span>
<span class="caret"></span>
</div>
</mat-list-item>
<mat-menu #menuCampaign="matMenu">
<button mat-menu-item (click)="select({_id:'all'})">
{{'stats.campaign.title.all.time.overview' | translate}}
</button>
<mat-divider></mat-divider>
<button mat-menu-item *ngFor="let campaign of campaigns$ | async"
(click)="select(campaign)">
{{campaign.title}}
</button>
</mat-menu>
</div>

View File

@ -6,7 +6,7 @@
}
.scroll-btn-right {
top: 50px;
top: 0;
left: calc(100vw - 50px);
}
@ -36,10 +36,6 @@
float: left;
background: #424242;
color: #9d9d9d;
@media all and (max-width: 959px) {
min-width: 33%;
}
}
.active {
@ -51,3 +47,21 @@
.campaign-entry:hover {
border-bottom: 3px solid #ffd740;
}
.campaign-select-small {
background: #424242;
height: 3em;
color: #9d9d9d;
text-align: center;
border-bottom: 1px solid #9d9d9d;
.select-menu-text {
font-size: 16px;
}
}
:host /deep/ div.mat-list-item-content {
height: 100%;
padding: 10px;
cursor: pointer;
}

View File

@ -1,12 +1,4 @@
import {
Component,
ElementRef,
EventEmitter,
Input,
OnInit,
Output,
ViewChild
} from '@angular/core';
import {Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild} from '@angular/core';
import {Campaign} from '../../../models/model-interfaces';
import {LoginService} from '../../../services/app-user-service/login-service';
import {Observable} from 'rxjs';
@ -17,12 +9,14 @@ import {CampaignService} from '../../../services/logs/campaign.service';
templateUrl: './campaign-navigation.component.html',
styleUrls: ['./campaign-navigation.component.scss']
})
export class CampaignNavigationComponent implements OnInit {
export class CampaignNavigationComponent implements OnInit, OnChanges {
campaigns$: Observable<Campaign[]>;
@Input() selectedCampaignId;
@Input() isSmallLayout;
@Output() campaignSelect = new EventEmitter();
@Output() campaignEdit = new EventEmitter();
@ -31,6 +25,8 @@ export class CampaignNavigationComponent implements OnInit {
@ViewChild('horizontalList', {read: ElementRef}) public panel: ElementRef<any>;
selectedCampaign;
isLeftScrollVisible = false;
isRightScrollVisible = true;
@ -48,8 +44,18 @@ export class CampaignNavigationComponent implements OnInit {
});
}
ngOnChanges() {
this.campaigns$.subscribe(campaigns => {
const campaignIdx = campaigns.findIndex(c => c._id === this.selectedCampaignId);
if (campaignIdx !== -1) {
this.selectedCampaign = campaigns[campaignIdx];
}
});
}
select(campaign) {
if (campaign && campaign._id) {
this.selectedCampaign = campaign;
this.selectedCampaignId = campaign._id;
this.campaignSelect.emit(campaign);
}

View File

@ -14,6 +14,7 @@ h2 {
.search-field {
width: 40%;
min-width: $highscore-table-width;
margin: 50px 0 50px 8%;
}

View File

@ -4,21 +4,25 @@
height: 650px;
margin: auto;
padding-left: 5%;
}
@media all and (max-width: 959px) {
@media all and (max-width: 959px) {
.slide-chart-container {
width: 100%;
min-width: unset;
padding-top: 105px;
}
}
.chart-select-group {
@media all and (max-width: 959px) {
.chart-select-group {
display: inline-grid;
width: 70%;
text-align: center;
margin-left: 10%;
}
.chart-select-group /deep/ button.mat-button-toggle-button {
width: 100%;
}
}
mat-button-toggle.mat-button-toggle-checked {

View File

@ -1,20 +1,22 @@
<div>
<campaign-navigation
[selectedCampaignId]="selectedCampaign._id"
[isSmallLayout]="isSmallLayout"
(campaignSelect)="switchCampaign($event)"
(campaignEdit)="editCampaign($event)"
(campaignDelete)="deleteCampaign($event)">
</campaign-navigation>
</div>
<div class="side-bar"
[ngClass]="{collapsed: collapsed}"
[style.display]="selectedCampaign._id === 'all' ? 'none' : 'block'">
<div [ngClass]="{collapsed: collapsed}"
[style.display]="selectedCampaign._id === 'all' ? 'none' : 'block'"
class="side-bar">
<war-list
[collapsed]="collapsed"
[campaign]="selectedCampaign">
[campaign]="selectedCampaign"
[isSmallLayout]="isSmallLayout">
</war-list>
<div class="button-container" *ngIf="collapseBtnVisible">
<div *ngIf="!isSmallLayout" class="button-container">
<button mat-icon-button
class="sidebar-toggle-btn"
(click)="toggleCollapse()">

View File

@ -1,6 +1,10 @@
.side-bar {
width: 20%;
float: left;
@media all and (max-width: 959px) {
width: 100%;
}
}
.collapsed {
@ -10,13 +14,13 @@
.button-container {
position: relative;
z-index: 100;
}
.button-container > button {
& > button {
position: fixed;
top: calc(100vh - 35px);
left: -10px;
background: #424242;
border: 1px solid #dadada;
box-shadow: #ffd740 0 0 3px;
}
}

View File

@ -21,7 +21,7 @@ export class StatisticComponent implements OnInit {
collapsed = false;
collapseBtnVisible = true;
isSmallLayout = false;
constructor(private campaignService: CampaignService,
private warService: WarService,
@ -40,17 +40,9 @@ export class StatisticComponent implements OnInit {
this.resolveCampaignFromUrl();
});
if (window.innerWidth <= BaseConfig.responsive.breakpointPx) {
this.collapsed = true;
this.collapseBtnVisible = false;
}
this.isSmallLayout = window.innerWidth <= BaseConfig.responsive.breakpointPx;
Observable.fromEvent(window, 'resize').subscribe(event => {
if (event.target['innerWidth'] <= BaseConfig.responsive.breakpointPx) {
this.collapsed = true;
this.collapseBtnVisible = false;
} else {
this.collapseBtnVisible = true;
}
this.isSmallLayout = event.target['innerWidth'] <= BaseConfig.responsive.breakpointPx;
});
}

View File

@ -7,10 +7,10 @@ import {NgxChartsModule} from '@swimlane/ngx-charts';
import {CampaignService} from '../services/logs/campaign.service';
import {PlayerService} from '../services/logs/player.service';
import {LogsService} from '../services/logs/logs.service';
import {MatButtonToggleModule, MatMenuModule, MatSortModule, MatTableModule} from '@angular/material';
import {MatButtonToggleModule, MatListModule, MatMenuModule, MatSortModule, MatTableModule} from '@angular/material';
import {HttpClient} from '@angular/common/http';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/statistics/', '.json');
@ -27,6 +27,7 @@ export function createTranslateLoader(http: HttpClient) {
MatTableModule,
MatSortModule,
MatMenuModule,
MatListModule,
statsRouterModule,
TranslateModule.forChild({

View File

@ -38,3 +38,18 @@
padding: 15px;
float: left;
}
@media all and (max-width: 959px) {
.chart-container {
width: 150%;
min-width: 0;
height: 70vh
}
.chart-select-group {
background: #dadada;
max-width: fit-content;
width: 200%;
flex-wrap: wrap;
}
}

View File

@ -20,6 +20,8 @@ export class FractionStatsComponent implements OnInit, OnChanges {
@Input() logData: any;
@Input() isSmallLayout: boolean;
startDateObj: Date;
initialized: any;

View File

@ -33,8 +33,24 @@
.mat-column-vehicleHeavy, .mat-column-vehicleAir, .mat-column-travelDistance, .mat-column-driverDistance,
.mat-column-death, .mat-column-respawn, .mat-column-interact {
flex: 0 0 62px;
@media all and (max-width: 959px) {
flex: 0 0 50px;
}
}
:host /deep/ .mat-table .mat-icon {
color: #666666;
}
@media all and (max-width: 959px) {
.mat-column-name {
flex: 0 0 160px;
word-wrap: break-word;
white-space: pre-wrap;
}
.mat-header-row, .scoreboard-table {
width: 768px;
}
}

View File

@ -20,6 +20,8 @@ export class ScoreboardComponent implements OnChanges {
@Input() fractionFilterSelected: string;
@Input() isSmallLayout: boolean;
@Output() playerTabSwitch = new EventEmitter();
tableHead = PlayerUtils.attributeDisplayNames;
@ -47,8 +49,16 @@ export class ScoreboardComponent implements OnChanges {
}
ngOnChanges(changes: SimpleChanges) {
if (changes.war) {
if (changes['isSmallLayout'] && changes['isSmallLayout'].previousValue != changes['isSmallLayout'].currentValue) {
const colIdxFraction = this.displayedColumns.findIndex(c => c === 'fraction');
if (this.isSmallLayout) {
this.displayedColumns.splice(colIdxFraction, 1);
} else if (colIdxFraction === -1) {
this.displayedColumns.splice(1, 0, 'fraction');
}
}
if (changes.war) {
changes.war.currentValue.players
.filter(player => !player.initalized)
.forEach(player => {

View File

@ -38,3 +38,12 @@
padding: 15px;
float: left;
}
@media all and (max-width: 959px) {
.chart-container {
width: 200%;
margin: 1%;
min-width: 0;
height: 80vh
}
}

View File

@ -9,7 +9,7 @@
style="font-weight: bold; margin-left: 10px;">{{war.ptOpfor}} {{fraction.OPFOR}}</span>
</div>
<div class="pull-left head-field " style="padding-left: 100px;">
<div class="pull-left head-field-pie-chart">
<h4 class="pull-left" style="margin-bottom: 0;">{{'stats.scoreboard.participants' | translate}}</h4>
<ngx-charts-pie-chart
class="pull-left"
@ -24,7 +24,7 @@
</ngx-charts-pie-chart>
</div>
<div class="pull-left " style="padding-left: 100px; padding-top:15px">
<div class="btn-clean-log">
<a class="btn btn-default" style="margin: 20px" target="_blank" href="resource/logs/{{war._id}}/clean.log">
{{'stats.scoreboard.show.logs' | translate}}
</a>
@ -83,7 +83,9 @@
{{fraction.OPFOR}}
</label>
</form>
<span class="btn btn-default pull-left tab-control" (click)="scoreBoardComponent.exportCSV()">
<span class="btn btn-default pull-left tab-control"
*ngIf="!isSmallLayout"
(click)="scoreBoardComponent.exportCSV()">
{{'stats.scoreboard.download.csv' | translate}}
</span>
</div>
@ -97,12 +99,14 @@
#scoreboard
[war]="war"
[fractionFilterSelected]="fractionFilterSelected"
[isSmallLayout]="isSmallLayout"
(playerTabSwitch)="switchToPlayerTab($event)">
</cc-scoreboard>
<war-detail-fraction
*ngIf="tab === 1 && logData"
[war]="war"
[logData]="logData">
[logData]="logData"
[isSmallLayout]="isSmallLayout">
</war-detail-fraction>
<campaign-player-detail
*ngIf="tab === 2 && singlePlayerView === 1"

View File

@ -1,6 +1,10 @@
@import url('../../../style/list-entry.scss');
@import url('../../../style/hide-scrollbar.scss');
.war-header {
padding-left: 1.5vw;
}
.war-header-container {
width: 920px;
min-height: 165px;
@ -14,6 +18,11 @@
margin-bottom: 10px;
}
.head-field-pie-chart {
@extend .head-field;
padding-left: 100px;
}
form.tab-control {
padding: 10px;
}
@ -80,3 +89,33 @@ span.tab-control {
cursor: pointer !important;
color: #666666 !important;
}
.btn-clean-log {
padding-left: 100px;
padding-top: 15px;
float: left;
}
@media all and (max-width: 959px) {
.war-header {
position: relative;
overflow: auto;
margin-bottom: 34px; /*do not cover anything with back to top bar*/
}
.war-header-container, .nav-tabs {
width: 768px;
}
.head-field-pie-chart {
padding-left: 0;
}
.nav-tabs > li:last-child {
margin-left: 25px;
}
div.btn-clean-log {
padding-left: 57px;
}
}

View File

@ -6,6 +6,8 @@ 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';
import {BaseConfig} from '../../../app.config';
import {Observable} from 'rxjs';
@Component({
@ -37,6 +39,8 @@ export class WarHeaderComponent implements OnInit {
fractionFilterSelected: string;
isSmallLayout = false;
playerChart: any[] = [];
colorScheme = {
@ -64,6 +68,11 @@ export class WarHeaderComponent implements OnInit {
ChartUtils.getSingleDataArray(Fraction.OPFOR, war.playersOpfor, Fraction.BLUFOR, war.playersBlufor);
Object.assign(this, [this.playerChart]);
});
this.isSmallLayout = window.innerWidth <= BaseConfig.responsive.breakpointPx;
Observable.fromEvent(window, 'resize').subscribe(event => {
this.isSmallLayout = event.target['innerWidth'] <= BaseConfig.responsive.breakpointPx;
});
}
switchTab(index: number) {

View File

@ -1,13 +1,14 @@
<div class="war-list-header" *ngIf="!collapsed && loginService.hasPermission(3)">
<div *ngIf="!isSmallLayout">
<div class="war-list-header" *ngIf="!collapsed && loginService.hasPermission(3)">
<button mat-stroked-button (click)="selectNewCampaign()">
{{'stats.sidebar.campaign.add' | translate}}
</button>
<button mat-stroked-button (click)="selectNewWar()">
{{'stats.sidebar.battle.add' | translate}}
</button>
</div>
</div>
<div class="list-header"
<div class="list-header"
[ngClass]="{selected : selectedWarId == campaign._id}" (click)="selectOverview(campaign._id)">
<div class="select-indicator-container">
<div class="select-indicator"></div>
@ -16,9 +17,9 @@
matTooltipPosition="right"
svgIcon="stats-chart"></mat-icon>
<span *ngIf="!collapsed">{{'stats.sidebar.overview' | translate}}</span>
</div>
</div>
<div class="list-header"
<div class="list-header"
[ngClass]="{selected : selectedWarId == campaign._id + highscore}" (click)="selectHighscore(campaign._id)">
<div class="select-indicator-container">
<div class="select-indicator"></div>
@ -27,16 +28,16 @@
matTooltipPosition="right"
svgIcon="highscore"></mat-icon>
<span *ngIf="!collapsed">{{'stats.sidebar.highscore' | translate}}</span>
</div>
</div>
<div class="list-header-battles">
<div class="list-header-battles">
<mat-icon [matTooltip]="collapsed ? toolTipTranslation['stats.sidebar.battles'] : ''"
matTooltipPosition="right"
svgIcon="battle"></mat-icon>
<span *ngIf="!collapsed">{{'stats.sidebar.battles' | translate}}</span>
</div>
</div>
<div class="battle-list">
<div class="battle-list">
<div *ngFor="let war of campaign.wars$ | async">
<cc-war-item
[war]="war"
@ -50,4 +51,29 @@
<div class="fill-vertical-border"
[ngClass]="{collapsed: collapsed}">
</div>
</div>
</div>
<div class="war-select-small" *ngIf="isSmallLayout">
<mat-list-item [matMenuTriggerFor]="menuWars">
<div matline class="select-menu-text">
<span *ngIf="selectedWarId === (campaign._id + highscore)">{{'stats.sidebar.highscore' | translate}}</span>
<span *ngIf="selectedWarId === campaign._id">{{'stats.sidebar.overview' | translate}}</span>
<span *ngIf="selectedWar">{{selectedWar.title}}</span>
<span class="caret"></span>
</div>
</mat-list-item>
<mat-menu #menuWars="matMenu">
<button mat-menu-item (click)="selectOverview(campaign._id)">
{{'stats.sidebar.overview' | translate}}
</button>
<button mat-menu-item (click)="selectHighscore(campaign._id)">
{{'stats.sidebar.highscore' | translate}}
</button>
<mat-divider></mat-divider>
<button mat-menu-item *ngFor="let war of campaign.wars$ | async"
(click)="selectWar(war._id)">
{{war.title}}
</button>
</mat-menu>
</div>

View File

@ -98,6 +98,24 @@
}
}
.war-select-small {
background: #424242;
height: 3em;
color: #9d9d9d;
text-align: center;
.select-menu-text {
font-size: 16px;
}
}
:host /deep/ div.mat-list-item-content {
height: 100%;
padding: 10px;
cursor: pointer;
}
/* Table Scrollbar BEGIN */
.battle-list::-webkit-scrollbar {

View File

@ -18,8 +18,12 @@ export class WarListComponent implements OnChanges {
@Input() collapsed: boolean;
@Input() isSmallLayout: boolean;
selectedWarId: string | number;
selectedWar: War;
changeCount = 0;
toolTipTranslation = {};
@ -65,15 +69,30 @@ export class WarListComponent implements OnChanges {
} else if (changes.campaign) {
this.selectOverview(this.campaign._id);
}
this.fetchSelectedWar(this.selectedWarId);
}
fetchSelectedWar(newSelect) {
this.campaign.wars$.subscribe(wars => {
const warIdx = wars.findIndex(w => w._id === newSelect);
if (warIdx !== -1) {
this.selectedWar = wars[warIdx];
} else {
this.selectedWar = null;
}
});
}
selectNewCampaign() {
this.selectedWarId = null;
this.selectedWar = null;
this.router.navigate([{outlets: {'right': ['campaign']}}], {relativeTo: this.route});
}
selectWar(warId) {
if (this.selectedWarId !== warId) {
this.fetchSelectedWar(warId);
this.selectedWarId = warId;
this.router.navigate([{outlets: {'right': ['war', warId]}}], {relativeTo: this.route});
}
@ -82,6 +101,7 @@ export class WarListComponent implements OnChanges {
selectOverview(campaignId) {
if (this.selectedWarId !== campaignId) {
this.selectedWarId = campaignId;
this.selectedWar = null;
this.router.navigate([{outlets: {'right': ['overview', campaignId]}}], {relativeTo: this.route});
}
}
@ -89,6 +109,7 @@ export class WarListComponent implements OnChanges {
selectHighscore(campaignId) {
if (this.selectedWarId !== campaignId + this.highscore) {
this.selectedWarId = campaignId + this.highscore;
this.selectedWar = null;
this.router.navigate([{outlets: {'right': ['highscore', campaignId]}}], {relativeTo: this.route});
}
}