53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import {Component} 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";
|
|
|
|
|
|
@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;
|
|
|
|
constructor(private router: Router,
|
|
private route: ActivatedRoute,
|
|
private userService: UserService,
|
|
private awardingService: AwardingService) {
|
|
}
|
|
|
|
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;
|
|
this.signatureUrl = window.location.origin + '/resource/signature/' + user._id + '.png';
|
|
this.awardingService.getUserAwardings(user._id).subscribe((awards => {
|
|
this.awards = awards;
|
|
}));
|
|
});
|
|
|
|
};
|
|
|
|
backToOverview() {
|
|
this.router.navigate([RouteConfig.overviewPath]);
|
|
}
|
|
|
|
}
|