2017-05-18 14:32:51 +02:00
|
|
|
import {Component} 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";
|
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,
|
|
|
|
private awardingService: AwardingService) {
|
2017-05-18 14:32:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
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
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
backToOverview() {
|
2017-08-01 23:52:10 +02:00
|
|
|
this.router.navigate([RouteConfig.overviewPath]);
|
2017-05-18 14:32:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|