Add and connect new page for rank/decoration trace

pull/43/head
HardiReady 2018-07-21 12:03:50 +02:00
parent ed87dd5df1
commit 6ac4fc5a66
17 changed files with 116 additions and 24 deletions

View File

@ -26,6 +26,7 @@ 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,
@ -51,7 +52,8 @@ import {MatSnackBarModule} from '@angular/material';
routingProviders, routingProviders,
CookieService, CookieService,
SnackBarService, SnackBarService,
SpinnerService SpinnerService,
DataTraceService,
], ],
declarations: [ declarations: [
AppComponent, AppComponent,

View File

@ -13,12 +13,12 @@ h1, h3 {
.decoration-overview-container { .decoration-overview-container {
max-width: 1782px; max-width: 1782px;
min-width: 927px; min-width: 927px;
margin:auto;
position: relative; position: relative;
margin: auto auto 25px;
} }
.fraction-global { .fraction-global {
display: flow-root; display: inline-block;
} }
.fraction-global > h3 { .fraction-global > h3 {
@ -29,12 +29,12 @@ h1, h3 {
float: left; float: left;
width: 50%; width: 50%;
padding-right:81px; padding-right:81px;
margin-bottom: 135px; margin-bottom: 70px;
} }
.fraction-right { .fraction-right {
float: right; float: right;
width: 50%; width: 50%;
padding-left:81px; padding-left:81px;
margin-bottom: 135px; margin-bottom: 70px;
} }

View File

@ -1,24 +1,27 @@
<div class="decoration-overview-container"> <div class="decoration-overview-container">
<h1>Übersicht über alle Auszeichnungen</h1> <h1>Übersicht über alle Auszeichnungen</h1>
<div class="fraction-global">
<h3>Global</h3>
<cc-decoration-panel *ngFor="let decoration of decorationsGlobal"
[decoration]="decoration">
</cc-decoration-panel>
</div>
<div class="fraction-left"> <div class="fraction-left">
<h3 [style.color]="fraction.COLOR_BLUFOR">{{fraction.BLUFOR}}</h3> <h3 [style.color]="fraction.COLOR_BLUFOR">{{fraction.BLUFOR}}</h3>
<cc-decoration-panel *ngFor="let decoration of decorationsBlufor" <cc-decoration-panel *ngFor="let decoration of decorationsBlufor"
[decoration]="decoration"> [decoration]="decoration"
(select)="select($event)">
</cc-decoration-panel> </cc-decoration-panel>
</div> </div>
<div class="fraction-right"> <div class="fraction-right">
<h3 [style.color]="fraction.COLOR_OPFOR">{{fraction.OPFOR}}</h3> <h3 [style.color]="fraction.COLOR_OPFOR">{{fraction.OPFOR}}</h3>
<cc-decoration-panel *ngFor="let decoration of decorationsOpfor" <cc-decoration-panel *ngFor="let decoration of decorationsOpfor"
[decoration]="decoration"> [decoration]="decoration"
(select)="select($event)">
</cc-decoration-panel>
</div>
<div class="fraction-global">
<h3>Global</h3>
<cc-decoration-panel *ngFor="let decoration of decorationsGlobal"
[decoration]="decoration"
(select)="select($event)">
</cc-decoration-panel> </cc-decoration-panel>
</div> </div>
</div> </div>

View File

@ -7,6 +7,7 @@ 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({
@ -29,6 +30,7 @@ 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) {
} }
@ -45,6 +47,11 @@ export class DecorationOverviewComponent implements OnInit, OnDestroy {
}); });
}; };
select(decoration: Decoration) {
this.dataTraceService.setData(decoration);
this.router.navigate(['../find'], {relativeTo: this.route});
}
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

@ -6,6 +6,7 @@
padding: 0; padding: 0;
overflow: hidden; overflow: hidden;
float: left; float: left;
cursor: pointer;
} }
.decoration-card:hover { .decoration-card:hover {

View File

@ -1,4 +1,4 @@
<mat-card class="decoration-card"> <mat-card class="decoration-card" (click)="selectDecoration()">
<div class="image-head"> <div class="image-head">
<img src="resource/decoration/{{decoration._id}}.png" <img src="resource/decoration/{{decoration._id}}.png"
alt="{{decoration.name}}" alt="{{decoration.name}}"

View File

@ -1,4 +1,4 @@
import {Component, Input} from '@angular/core'; import {Component, EventEmitter, Input, Output} from '@angular/core';
import {Decoration} from '../../../models/model-interfaces'; import {Decoration} from '../../../models/model-interfaces';
import {Fraction} from '../../../utils/fraction.enum'; import {Fraction} from '../../../utils/fraction.enum';
@ -13,8 +13,11 @@ export class DecorationPanelComponent {
@Input() decoration: Decoration; @Input() decoration: Decoration;
@Output() select = new EventEmitter();
readonly fraction = Fraction; readonly fraction = Fraction;
constructor() { selectDecoration() {
this.select.emit(this.decoration);
} }
} }

View File

@ -6,11 +6,12 @@ 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] providers: [DecorationService, RankService, DataTraceService]
}) })
export class PublicModule { export class PublicModule {
static routes = pubRouterModule; static routes = pubRouterModule;

View File

@ -4,6 +4,7 @@ import {ModuleWithProviders} from '@angular/core';
import {DecorationOverviewComponent} from './decoration-overview/decoration-overview.component'; import {DecorationOverviewComponent} from './decoration-overview/decoration-overview.component';
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';
export const publicRoutes: Routes = [ export const publicRoutes: Routes = [
{ {
@ -16,10 +17,15 @@ export const publicRoutes: Routes = [
component: DecorationOverviewComponent, component: DecorationOverviewComponent,
outlet: 'right' outlet: 'right'
}, },
{
path: 'find',
component: TraceOverviewComponent,
outlet: 'right'
},
]; ];
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]; DecorationPanelComponent, TraceOverviewComponent];

View File

@ -8,6 +8,7 @@ table {
:host /deep/ tr.mat-row:hover { :host /deep/ tr.mat-row:hover {
background: #ffffff; background: #ffffff;
cursor: pointer;
} }
td > img { td > img {

View File

@ -17,7 +17,7 @@
</ng-container> </ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="selectRow(row)"></tr>
</table> </table>
</div> </div>
@ -37,7 +37,7 @@
</ng-container> </ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="selectRow(row)"></tr>
</table> </table>
</div> </div>

View File

@ -3,9 +3,10 @@ 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 {AppConfig, 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({
@ -26,6 +27,7 @@ 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) {
} }
@ -41,6 +43,11 @@ export class RankOverviewComponent implements OnInit, OnDestroy {
}); });
}; };
selectRow(row: Rank) {
this.dataTraceService.setData(row);
this.router.navigate(['../find'], {relativeTo: this.route});
}
ngOnDestroy() { ngOnDestroy() {
if (!this.router.url.includes(RouteConfig.overviewPath)) { if (!this.router.url.includes(RouteConfig.overviewPath)) {

View File

@ -0,0 +1,46 @@
import {Component, Inject, Input, OnDestroy, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {DOCUMENT} from '@angular/common';
import {Fraction} from '../../utils/fraction.enum';
import {CSSHelpers} from '../../utils/global.helpers';
import {RouteConfig} from '../../app.config';
import {RankService} from '../../services/army-management/rank.service';
import {DataTraceService} from '../../services/army-service/data-trace.service';
import {Decoration, Rank} from '../../models/model-interfaces';
@Component({
selector: 'cc-trace-overview',
templateUrl: './trace-overview.component.html',
styleUrls: ['./trace-overview.component.css']
})
export class TraceOverviewComponent implements OnInit, OnDestroy {
traceItem: Rank | Decoration;
displayedColumns: string[] = ['picture', 'name'];
readonly fraction = Fraction;
constructor(private router: Router,
private route: ActivatedRoute,
private rankService: RankService,
private dataTraceService: DataTraceService,
@Inject(DOCUMENT) private document) {
this.traceItem = this.dataTraceService.getData();
}
ngOnInit() {
// set background image css
this.document.getElementById('right').setAttribute('style', CSSHelpers.getBackgroundCSS('../assets/bg.jpg'));
console.log(typeof this.traceItem);
};
ngOnDestroy() {
if (!this.router.url.includes(RouteConfig.overviewPath)) {
this.document.getElementById('right').setAttribute('style', '');
}
}
}

View File

@ -16,4 +16,3 @@ export class ArmyService {
} }
} }

View File

@ -0,0 +1,16 @@
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;
}
}