2018-01-16 19:46:28 +01:00
|
|
|
import {Component, Inject} from "@angular/core";
|
2017-10-14 19:58:34 +02:00
|
|
|
import {Award, User} from "../models/model-interfaces";
|
2017-05-18 14:32:51 +02:00
|
|
|
import {ActivatedRoute, Router} from "@angular/router";
|
2017-10-22 18:06:37 +02:00
|
|
|
import {UserService} from "../services/army-management/user.service";
|
2017-05-18 14:32:51 +02:00
|
|
|
import {Subscription} from "rxjs/Subscription";
|
2017-09-03 12:49:59 +02:00
|
|
|
import {RouteConfig} from "../app.config";
|
2017-10-22 18:06:37 +02:00
|
|
|
import {AwardingService} from "../services/army-management/awarding.service";
|
2017-11-08 14:54:04 +01:00
|
|
|
import {Fraction} from "../utils/fraction.enum";
|
2018-01-16 19:46:28 +01:00
|
|
|
import {DOCUMENT} from "@angular/common";
|
2018-01-21 11:38:54 +01:00
|
|
|
import {CSSHelpers} from "../global.helpers";
|
2017-05-18 14:32:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'army-member',
|
|
|
|
templateUrl: './army-member.component.html',
|
|
|
|
styleUrls: ['./army-member.component.css']
|
|
|
|
})
|
|
|
|
export class ArmyMemberComponent {
|
|
|
|
|
|
|
|
subscription: Subscription;
|
|
|
|
|
|
|
|
user: User = {};
|
|
|
|
|
2017-10-14 19:58:34 +02:00
|
|
|
awards: Award[] = [];
|
|
|
|
|
2017-05-19 00:45:43 +02:00
|
|
|
signatureUrl;
|
|
|
|
|
|
|
|
isCopied = false;
|
|
|
|
|
2017-11-08 14:54:04 +01:00
|
|
|
readonly fraction = Fraction;
|
|
|
|
|
2017-05-18 14:32:51 +02:00
|
|
|
constructor(private router: Router,
|
|
|
|
private route: ActivatedRoute,
|
2017-10-14 19:58:34 +02:00
|
|
|
private userService: UserService,
|
2018-01-16 19:46:28 +01:00
|
|
|
private awardingService: AwardingService,
|
|
|
|
@Inject(DOCUMENT) private document) {
|
2017-05-18 14:32:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2018-01-16 19:46:28 +01:00
|
|
|
// set background image css
|
2018-01-21 11:38:54 +01:00
|
|
|
this.document.getElementById('right').setAttribute('style', CSSHelpers.getBackgroundCSS('../assets/bg.jpg'));
|
2018-01-16 19:46:28 +01:00
|
|
|
|
2017-05-18 14:32:51 +02:00
|
|
|
this.subscription = this.route.params
|
|
|
|
.map(params => params['id'])
|
|
|
|
.filter(id => id != undefined)
|
|
|
|
.flatMap(id => this.userService.getUser(id))
|
|
|
|
.subscribe(user => {
|
|
|
|
this.user = user;
|
2017-05-19 00:45:43 +02:00
|
|
|
this.signatureUrl = window.location.origin + '/resource/signature/' + user._id + '.png';
|
2017-10-14 19:58:34 +02:00
|
|
|
this.awardingService.getUserAwardings(user._id).subscribe((awards => {
|
|
|
|
this.awards = awards;
|
|
|
|
}));
|
2017-05-18 14:32:51 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-01-16 19:46:28 +01:00
|
|
|
ngOnDestroy() {
|
2018-01-21 11:38:54 +01:00
|
|
|
if (this.router.url !== '/' + RouteConfig.overviewPath) {
|
|
|
|
this.document.getElementById('right').setAttribute('style', '');
|
|
|
|
}
|
2018-01-16 19:46:28 +01:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:32:51 +02:00
|
|
|
backToOverview() {
|
2017-08-01 23:52:10 +02:00
|
|
|
this.router.navigate([RouteConfig.overviewPath]);
|
2017-05-18 14:32:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|