Add tracing result pages for ranks/awards and connect to user detail pages

pull/43/head
HardiReady 2018-07-22 13:09:51 +02:00
parent b3b166d283
commit 78cc61232b
20 changed files with 206 additions and 65 deletions

View File

@ -26,7 +26,6 @@ import {SnackBarService} from './services/user-interface/snack-bar/snack-bar.ser
import {HttpClientModule} from '@angular/common/http'; import {HttpClientModule} from '@angular/common/http';
import {SpinnerService} from './services/user-interface/spinner/spinner.service'; import {SpinnerService} from './services/user-interface/spinner/spinner.service';
import {MatSnackBarModule} from '@angular/material'; import {MatSnackBarModule} from '@angular/material';
import {DataTraceService} from './services/army-service/data-trace.service';
@NgModule({ @NgModule({
imports: [SharedModule, BrowserModule, BrowserAnimationsModule, appRouting, HttpModule, HttpClientModule, imports: [SharedModule, BrowserModule, BrowserAnimationsModule, appRouting, HttpModule, HttpClientModule,
@ -53,7 +52,6 @@ import {DataTraceService} from './services/army-service/data-trace.service';
CookieService, CookieService,
SnackBarService, SnackBarService,
SpinnerService, SpinnerService,
DataTraceService,
], ],
declarations: [ declarations: [
AppComponent, AppComponent,

View File

@ -6,10 +6,9 @@ import {Subscription} from 'rxjs/Subscription';
import {RouteConfig} from '../../app.config'; import {RouteConfig} from '../../app.config';
import {AwardingService} from '../../services/army-management/awarding.service'; import {AwardingService} from '../../services/army-management/awarding.service';
import {Fraction} from '../../utils/fraction.enum'; import {Fraction} from '../../utils/fraction.enum';
import {DOCUMENT} from '@angular/common'; import {DOCUMENT, Location} from '@angular/common';
import {CSSHelpers} from '../../utils/global.helpers'; import {CSSHelpers} from '../../utils/global.helpers';
@Component({ @Component({
selector: 'army-member', selector: 'army-member',
templateUrl: './army-member.component.html', templateUrl: './army-member.component.html',
@ -33,6 +32,7 @@ export class ArmyMemberComponent implements OnInit, OnDestroy {
private route: ActivatedRoute, private route: ActivatedRoute,
private userService: UserService, private userService: UserService,
private awardingService: AwardingService, private awardingService: AwardingService,
private location: Location,
@Inject(DOCUMENT) private document) { @Inject(DOCUMENT) private document) {
} }
@ -61,7 +61,6 @@ export class ArmyMemberComponent implements OnInit, OnDestroy {
} }
backToOverview() { backToOverview() {
this.router.navigate([RouteConfig.overviewPath]); this.location.back();
} }
} }

View File

@ -7,7 +7,6 @@ import {CSSHelpers} from '../../utils/global.helpers';
import {RouteConfig} from '../../app.config'; import {RouteConfig} from '../../app.config';
import {Decoration} from '../../models/model-interfaces'; import {Decoration} from '../../models/model-interfaces';
import {DecorationService} from '../../services/army-management/decoration.service'; import {DecorationService} from '../../services/army-management/decoration.service';
import {DataTraceService} from '../../services/army-service/data-trace.service';
@Component({ @Component({
@ -30,7 +29,6 @@ export class DecorationOverviewComponent implements OnInit, OnDestroy {
constructor(private router: Router, constructor(private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private decorationService: DecorationService, private decorationService: DecorationService,
private dataTraceService: DataTraceService,
@Inject(DOCUMENT) private document) { @Inject(DOCUMENT) private document) {
} }
@ -48,8 +46,7 @@ export class DecorationOverviewComponent implements OnInit, OnDestroy {
}; };
select(decoration: Decoration) { select(decoration: Decoration) {
this.dataTraceService.setData(decoration); this.router.navigate(['../find/award', decoration._id], {relativeTo: this.route});
this.router.navigate(['../find'], {relativeTo: this.route});
} }
ngOnDestroy() { ngOnDestroy() {

View File

@ -15,6 +15,10 @@
box-shadow: 0 0 18px 2px #666666; box-shadow: 0 0 18px 2px #666666;
} }
.decoration-description {
text-align: left;
}
.decoration-card:hover .decoration-description { .decoration-card:hover .decoration-description {
background: #ffffff; background: #ffffff;
position: relative; position: relative;

View File

@ -6,12 +6,11 @@ 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 {MatCardModule} from '@angular/material/card'; import {MatCardModule} from '@angular/material/card';
import {DataTraceService} from '../services/army-service/data-trace.service';
@NgModule({ @NgModule({
declarations: pubRoutingComponents, declarations: pubRoutingComponents,
imports: [CommonModule, SharedModule, MatTableModule, MatCardModule, pubRouterModule], imports: [CommonModule, SharedModule, MatTableModule, MatCardModule, pubRouterModule],
providers: [DecorationService, RankService, DataTraceService] providers: [DecorationService, RankService]
}) })
export class PublicModule { export class PublicModule {
static routes = pubRouterModule; static routes = pubRouterModule;

View File

@ -5,6 +5,7 @@ import {DecorationOverviewComponent} from './decoration-overview/decoration-over
import {PublicComponent} from './public.component'; import {PublicComponent} from './public.component';
import {DecorationPanelComponent} from './decoration-overview/decoration-panel/decoration-panel.component'; import {DecorationPanelComponent} from './decoration-overview/decoration-panel/decoration-panel.component';
import {TraceOverviewComponent} from './trace-overview/trace-overview.component'; import {TraceOverviewComponent} from './trace-overview/trace-overview.component';
import {RankPanelComponent} from './rank-overview/rank-panel/rank-panel.component';
export const publicRoutes: Routes = [ export const publicRoutes: Routes = [
{ {
@ -18,7 +19,12 @@ export const publicRoutes: Routes = [
outlet: 'right' outlet: 'right'
}, },
{ {
path: 'find', path: 'find/rank/:id',
component: TraceOverviewComponent,
outlet: 'right'
},
{
path: 'find/award/:id',
component: TraceOverviewComponent, component: TraceOverviewComponent,
outlet: 'right' outlet: 'right'
}, },
@ -27,5 +33,5 @@ export const publicRoutes: Routes = [
export const pubRouterModule: ModuleWithProviders = RouterModule.forChild(publicRoutes); export const pubRouterModule: ModuleWithProviders = RouterModule.forChild(publicRoutes);
export const pubRoutingComponents = [PublicComponent, RankOverviewComponent, DecorationOverviewComponent, export const pubRoutingComponents = [PublicComponent, RankOverviewComponent, DecorationOverviewComponent,
DecorationPanelComponent, TraceOverviewComponent]; DecorationPanelComponent, TraceOverviewComponent, RankPanelComponent];

View File

@ -3,10 +3,9 @@ import {ActivatedRoute, Router} from '@angular/router';
import {DOCUMENT} from '@angular/common'; import {DOCUMENT} from '@angular/common';
import {Fraction} from '../../utils/fraction.enum'; import {Fraction} from '../../utils/fraction.enum';
import {CSSHelpers} from '../../utils/global.helpers'; import {CSSHelpers} from '../../utils/global.helpers';
import {AppConfig, RouteConfig} from '../../app.config'; import {RouteConfig} from '../../app.config';
import {Rank} from '../../models/model-interfaces'; import {Rank} from '../../models/model-interfaces';
import {RankService} from '../../services/army-management/rank.service'; import {RankService} from '../../services/army-management/rank.service';
import {DataTraceService} from '../../services/army-service/data-trace.service';
@Component({ @Component({
@ -27,7 +26,6 @@ export class RankOverviewComponent implements OnInit, OnDestroy {
constructor(private router: Router, constructor(private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private rankService: RankService, private rankService: RankService,
private dataTraceService: DataTraceService,
@Inject(DOCUMENT) private document) { @Inject(DOCUMENT) private document) {
} }
@ -43,9 +41,8 @@ export class RankOverviewComponent implements OnInit, OnDestroy {
}); });
}; };
selectRow(row: Rank) { selectRow(rank: Rank) {
this.dataTraceService.setData(row); this.router.navigate(['../find/rank', rank._id], {relativeTo: this.route});
this.router.navigate(['../find'], {relativeTo: this.route});
} }

View File

@ -0,0 +1,30 @@
.rank-card {
background: rgba(255, 255, 255, 0.87);
width: 275px;
height: 160px;
margin: 6px;
padding: 0;
overflow: hidden;
float: left;
cursor: pointer;
}
.rank-card:hover {
background: #ffffff;
overflow: visible;
box-shadow: 0 0 18px 2px #666666;
}
.rank-image {
float: left;
padding: 20px 20px 20px 25px;
}
.rank-name {
width: 169px;
height: 100%;
display: table-cell;
padding-top: 36%;
word-break: break-all;
word-wrap: break-word;
}

View File

@ -0,0 +1,11 @@
<mat-card class="rank-card" (click)="selectRank()">
<mat-card-content>
<div class="rank-image">
<img src="resource/rank/{{rank._id}}.png"
alt="{{rank.name}}">
</div>
<div class="rank-name">
{{rank.name}}
</div>
</mat-card-content>
</mat-card>

View File

@ -0,0 +1,21 @@
import {Component, EventEmitter, Input, Output} from '@angular/core';
import {Rank} from '../../../models/model-interfaces';
import {Fraction} from '../../../utils/fraction.enum';
@Component({
selector: 'cc-rank-panel',
templateUrl: './rank-panel.component.html',
styleUrls: ['./rank-panel.component.css']
})
export class RankPanelComponent {
@Input() rank: Rank;
@Output() select = new EventEmitter();
readonly fraction = Fraction;
selectRank() {
this.select.emit(this.rank);
}
}

View File

@ -0,0 +1,37 @@
.tracer-container {
text-align: center;
max-width: 1100px;
min-width: 800px;
position: relative;
margin: auto auto 25px;
height: calc(100vh - 95px);
}
.show-panel {
display: inline-block;
margin: inherit;
}
.decoration-show-panel {
height: 250px;
}
.user-table-container {
height: 100%;
}
table.mat-table {
width: 50%;
margin: auto;
text-align: left;
background: rgba(255, 255, 255, 0.6);
}
table.mat-table:hover {
background: rgba(255, 255, 255, 0.6);
}
:host /deep/ tr.mat-row:hover {
background: #ffffff;
cursor: pointer;
}

View File

@ -0,0 +1,40 @@
<div class="tracer-container">
<h1>Alle aktiven Teilnehmer mit {{isRank ? 'Rang' : 'Auszeichnung'}}</h1>
<div class="show-panel"
*ngIf="isRank">
<cc-rank-panel [rank]="traceItem">
</cc-rank-panel>
</div>
<div class="show-panel decoration-show-panel"
*ngIf="!isRank">
<cc-decoration-panel [decoration]="traceItem">
</cc-decoration-panel>
</div>
<div class="user-table-container">
<table mat-table [dataSource]="users" class="mat-elevation-z8">
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef>Name</th>
<td mat-cell *matCellDef="let element">{{element.username}}</td>
</ng-container>
<ng-container matColumnDef="fraction">
<th mat-header-cell *matHeaderCellDef>Fraktion</th>
<td mat-cell *matCellDef="let element"
[style.color]="traceItem.fraction === 'BLUFOR' ? fraction.COLOR_BLUFOR :fraction.COLOR_OPFOR">
{{element.squadId.fraction === 'BLUFOR' ? fraction.BLUFOR : fraction.OPFOR}}
</td>
</ng-container>
<ng-container matColumnDef="squadName">
<th mat-header-cell *matHeaderCellDef>Squad</th>
<td mat-cell *matCellDef="let element">{{element.squadId.name}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="selectUser(row)"></tr>
</table>
</div>
</div>

View File

@ -1,12 +1,13 @@
import {Component, Inject, Input, OnDestroy, OnInit} from '@angular/core'; import {Component, 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';
import {Fraction} from '../../utils/fraction.enum'; import {Fraction} from '../../utils/fraction.enum';
import {CSSHelpers} from '../../utils/global.helpers'; import {CSSHelpers} from '../../utils/global.helpers';
import {RouteConfig} from '../../app.config'; import {RouteConfig} from '../../app.config';
import {Decoration, Rank, User} from '../../models/model-interfaces';
import {UserService} from '../../services/army-management/user.service';
import {RankService} from '../../services/army-management/rank.service'; import {RankService} from '../../services/army-management/rank.service';
import {DataTraceService} from '../../services/army-service/data-trace.service'; import {DecorationService} from '../../services/army-management/decoration.service';
import {Decoration, Rank} from '../../models/model-interfaces';
@Component({ @Component({
@ -16,36 +17,54 @@ import {Decoration, Rank} from '../../models/model-interfaces';
}) })
export class TraceOverviewComponent implements OnInit, OnDestroy { export class TraceOverviewComponent implements OnInit, OnDestroy {
traceItem: Rank | Decoration; traceItem: Rank | Decoration = {};
displayedColumns: string[] = ['picture', 'name']; users: User[];
isRank = true;
displayedColumns: string[] = ['name', 'fraction', 'squadName'];
readonly fraction = Fraction; readonly fraction = Fraction;
constructor(private router: Router, constructor(private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private userService: UserService,
private rankService: RankService, private rankService: RankService,
private dataTraceService: DataTraceService, private decorationService: DecorationService,
@Inject(DOCUMENT) private document) { @Inject(DOCUMENT) private document) {
this.traceItem = this.dataTraceService.getData();
} }
ngOnInit() { ngOnInit() {
// 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'));
this.route.params.subscribe(params => {
const itemId = params.id;
if (this.router.url.includes('find/award/')) {
if (this.traceItem.hasOwnProperty('isMedal')) { // Award
// Decoration this.isRank = false;
const decorationItem = <Decoration> this.traceItem console.log(itemId);
console.log("DECORATION"); this.decorationService.getDecoration(itemId).subscribe(decoration => {
} else if (this.traceItem.hasOwnProperty('level')) { this.traceItem = decoration;
console.log(decoration)
});
} else if (this.router.url.includes('find/rank/')) {
// Rank // Rank
const rankItem = <Rank> this.traceItem this.isRank = true;
console.log("RANK"); this.rankService.getRank(itemId).subscribe(rank => {
this.traceItem = rank;
this.userService.findUsers('', rank.fraction).subscribe(users => {
this.users = users.filter(user => user.rankLvl === rank.level);
});
});
} }
});
}; };
selectUser(user) {
this.router.navigate(['overview', {outlets: {'right': ['member', user._id]}}]);
}
ngOnDestroy() { ngOnDestroy() {
if (!this.router.url.includes(RouteConfig.overviewPath)) { if (!this.router.url.includes(RouteConfig.overviewPath)) {

View File

@ -37,7 +37,7 @@ export class RankService {
return this.ranks$; return this.ranks$;
} }
getRank(id: number | string): Observable<Decoration> { getRank(id: number | string): Observable<Rank> {
return this.http.get(this.config.apiRankPath + id) return this.http.get(this.config.apiRankPath + id)
.map(res => res.json()); .map(res => res.json());
} }

View File

@ -1,16 +0,0 @@
import {Injectable} from '@angular/core';
import {Decoration, Rank} from '../../models/model-interfaces';
@Injectable()
export class DataTraceService {
data: Rank | Decoration = {};
setData(data: Rank | Decoration) {
this.data = data;
}
getData(): Rank | Decoration {
return this.data;
}
}

View File

@ -113,5 +113,4 @@ export class CampaignPlayerDetailComponent implements OnInit {
navigateBack() { navigateBack() {
this.switchTab.emit(0); this.switchTab.emit(0);
} }
} }

View File

@ -16,7 +16,7 @@
<ng-container matColumnDef="{{tableHead[1].prop}}"> <ng-container matColumnDef="{{tableHead[1].prop}}">
<th mat-header-cell *matHeaderCellDef mat-sort-header="{{tableHead[1].prop}}">{{tableHead[1].head}}</th> <th mat-header-cell *matHeaderCellDef mat-sort-header="{{tableHead[1].prop}}">{{tableHead[1].head}}</th>
<td mat-cell *matCellDef="let element"> {{element.fraction}}</td> <td mat-cell *matCellDef="let element">{{element.fraction === 'BLUFOR' ? fraction.BLUFOR : fraction.OPFOR}}</td>
</ng-container> </ng-container>
<ng-container *ngFor="let column of tableHead.slice(2, tableHead.length)" matColumnDef="{{column.prop}}"> <ng-container *ngFor="let column of tableHead.slice(2, tableHead.length)" matColumnDef="{{column.prop}}">