Add public decoration table (CC-38)

pull/43/head
HardiReady 2018-07-18 21:15:42 +02:00
parent 14901883e6
commit 783d30e91e
4 changed files with 89 additions and 76 deletions

View File

@ -1,75 +1,42 @@
.squad-layout { table {
overflow: hidden; width: 100%;
padding: 5px 15px 5px 15px; margin-bottom: 20px;
} }
.row { :host /deep/ table.mat-table {
clear: both; background: rgba(255, 255, 255, 0.6);
}
.squad-cell {
display: table-cell;
padding: 5px;
}
.colored-row {
background: rgb(34, 34, 34);
}
.title-row {
border-radius: 12px 12px 0 0;
}
.footer-row {
border-radius: 0 0 12px 12px;
}
.middle-row {
min-height: 120px;
border: rgb(34, 34, 34);
background-color: rgba(255, 255, 255, 0.88);
border-left-style: solid;
border-right-style: solid;
}
.title {
color: whitesmoke;
font-weight: bold;
font-size: 14px;
}
.name-cell {
display: inherit;
margin-left: 200px;
} }
h1 { h1 {
text-align: center; text-align: center;
margin-bottom: 30px;
} }
img { td > img {
position: absolute; margin: 5px 2px;
margin-top: 8px;
margin-left: 25px;
} }
.member-link { .mat-column-image {
cursor: pointer; width: 160px;
text-decoration: underline;
} }
.army-head { .mat-column-fraction {
font-weight: bolder; width: 90px;
text-align: center text-indent: 10px;
} }
.member-count { .mat-column-description {
margin-top: 15px; width: 55%;
padding: 8px;
text-align: center;
font-weight: bold;
color: whitesmoke;
background: #222222;
border-radius: 12px;
} }
tr.mat-row:hover {
background: rgba(231, 231, 231, 0.6);
}
:host /deep/ table.fixed-header-table > thead {
position: fixed;
display: inherit;
width: 1100px;
background: white;
top: 50px;
}

View File

@ -1,18 +1,44 @@
<div style="width: 1100px; margin:auto; position: relative;"> <div style="width: 1100px; margin:auto; position: relative;">
<h1>Übersicht über alle Ränge</h1> <h1>Übersicht über alle Auszeichnungen</h1>
<div class="pull-left" style="width: 45%;"> <table mat-table
<h3 class="army-head" [style.color]="fraction.COLOR_BLUFOR">{{fraction.BLUFOR}}</h3> [dataSource]="rows"
<div class="squad-layout" *ngFor="let decoration of decorations"> [class.fixed-header-table]="hasFixedTableHeader"
{{decoration.name}} class="mat-elevation-z8">
</div>
</div>
<div class="pull-right" style="width: 45%;"> <ng-container matColumnDef="{{columnMap[0].prop}}">
<h3 class="army-head" [style.color]="fraction.COLOR_OPFOR">{{fraction.OPFOR}}</h3> <th mat-header-cell *matHeaderCellDef>{{columnMap[0].head}}</th>
<div class="squad-layout" *ngFor="let decoration of decorations"> <td mat-cell *matCellDef="let element">
{{decoration.name}} <img src="resource/decoration/{{element._id}}.png"
</div> matTooltip="{{element.name}}"
</div> alt="{{element.name}}">
</td>
</ng-container>
<ng-container matColumnDef="{{columnMap[1].prop}}">
<th mat-header-cell *matHeaderCellDef>{{columnMap[1].head}}</th>
<td mat-cell *matCellDef="let element">{{element[columnMap[1].prop]}}</td>
</ng-container>
<ng-container matColumnDef="{{columnMap[2].prop}}">
<th mat-header-cell *matHeaderCellDef>{{columnMap[2].head}}</th>
<td mat-cell *matCellDef="let element"
[style.color]="element['fraction'] === 'BLUFOR' ?
fraction.COLOR_BLUFOR :
element['fraction'] === 'OPFOR' ? fraction.COLOR_OPFOR : '#666666'">
{{element[columnMap[2].prop] === 'BLUFOR'?
'NATO' :
element[columnMap[2].prop] === 'OPFOR' ? 'CSAT' : 'GLOBAL'}}
</td>
</ng-container>
<ng-container matColumnDef="{{columnMap[3].prop}}">
<th mat-header-cell *matHeaderCellDef>{{columnMap[3].head}}</th>
<td mat-cell *matCellDef="let element">{{element[columnMap[3].prop]}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
</div> </div>

View File

@ -1,4 +1,4 @@
import {Component, Inject, OnDestroy, OnInit} from '@angular/core'; import {Component, HostListener, Inject, OnDestroy, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {DOCUMENT} from '@angular/common'; import {DOCUMENT} from '@angular/common';
@ -16,7 +16,20 @@ import {DecorationService} from '../../services/army-management/decoration.servi
}) })
export class DecorationOverviewComponent implements OnInit, OnDestroy { export class DecorationOverviewComponent implements OnInit, OnDestroy {
decorations: Decoration[]; rows: Decoration[];
columnMap = [
{prop: 'image', head: 'Abbildung'},
{prop: 'name', head: 'Bezeichnung'},
{prop: 'fraction', head: 'Fraktion'},
{prop: 'description', head: 'Beschreibung'}
];
displayedColumns = this.columnMap.map(col => col.prop);
tableHeaderFixedVal = 100;
hasFixedTableHeader = false;
readonly fraction = Fraction; readonly fraction = Fraction;
@ -30,13 +43,19 @@ export class DecorationOverviewComponent implements OnInit, OnDestroy {
// set background image css // set background image css
this.document.getElementById('right').setAttribute('style', CSSHelpers.getBackgroundCSS('../assets/bg.jpg')); this.document.getElementById('right').setAttribute('style', CSSHelpers.getBackgroundCSS('../assets/bg.jpg'));
// init rank data // init decoration data
this.decorationService.findDecorations() this.decorationService.findDecorations()
.subscribe(decorations => { .subscribe(decorations => {
this.decorations = decorations; this.rows = decorations;
}); });
}; };
@HostListener('window:scroll', [])
onWindowScroll() {
this.hasFixedTableHeader = document.body.scrollTop > this.tableHeaderFixedVal
|| document.documentElement.scrollTop > this.tableHeaderFixedVal;
}
ngOnDestroy() { ngOnDestroy() {
if (!this.router.url.includes(RouteConfig.overviewPath)) { if (!this.router.url.includes(RouteConfig.overviewPath)) {
this.document.getElementById('right').setAttribute('style', ''); this.document.getElementById('right').setAttribute('style', '');

View File

@ -5,6 +5,7 @@ import {RankService} from '../services/army-management/rank.service';
import {pubRouterModule, pubRoutingComponents} from './public.routing'; import {pubRouterModule, pubRoutingComponents} from './public.routing';
import {DecorationService} from '../services/army-management/decoration.service'; import {DecorationService} from '../services/army-management/decoration.service';
import {MatTableModule} from '@angular/material/table'; import {MatTableModule} from '@angular/material/table';
import {MatSortModule} from '@angular/material';
@NgModule({ @NgModule({