68 lines
2.1 KiB
TypeScript
68 lines
2.1 KiB
TypeScript
import {Component, Inject} from '@angular/core';
|
|
import {Award, User} from '../models/model-interfaces';
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
import {UserService} from '../services/army-management/user.service';
|
|
import {Subscription} from 'rxjs/Subscription';
|
|
import {RouteConfig} from '../app.config';
|
|
import {AwardingService} from '../services/army-management/awarding.service';
|
|
import {Fraction} from '../utils/fraction.enum';
|
|
import {DOCUMENT} from '@angular/common';
|
|
import {CSSHelpers} from '../global.helpers';
|
|
|
|
|
|
@Component({
|
|
selector: 'army-member',
|
|
templateUrl: './army-member.component.html',
|
|
styleUrls: ['./army-member.component.css']
|
|
})
|
|
export class ArmyMemberComponent {
|
|
|
|
subscription: Subscription;
|
|
|
|
user: User = {};
|
|
|
|
awards: Award[] = [];
|
|
|
|
signatureUrl;
|
|
|
|
isCopied = false;
|
|
|
|
readonly fraction = Fraction;
|
|
|
|
constructor(private router: Router,
|
|
private route: ActivatedRoute,
|
|
private userService: UserService,
|
|
private awardingService: AwardingService,
|
|
@Inject(DOCUMENT) private document) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
// set background image css
|
|
this.document.getElementById('right').setAttribute('style', CSSHelpers.getBackgroundCSS('../assets/bg.jpg'));
|
|
|
|
this.subscription = this.route.params
|
|
.map(params => params['id'])
|
|
.filter(id => id != undefined)
|
|
.flatMap(id => this.userService.getUser(id))
|
|
.subscribe(user => {
|
|
this.user = user;
|
|
this.signatureUrl = window.location.origin + '/resource/signature/' + user._id + '.png';
|
|
this.awardingService.getUserAwardings(user._id).subscribe((awards => {
|
|
this.awards = awards;
|
|
}));
|
|
});
|
|
|
|
};
|
|
|
|
ngOnDestroy() {
|
|
if (this.router.url !== '/' + RouteConfig.overviewPath) {
|
|
this.document.getElementById('right').setAttribute('style', '');
|
|
}
|
|
}
|
|
|
|
backToOverview() {
|
|
this.router.navigate([RouteConfig.overviewPath]);
|
|
}
|
|
|
|
}
|