2019-02-19 20:29:37 +01:00
|
|
|
import {Component, OnInit} from '@angular/core';
|
2018-07-08 13:28:21 +02:00
|
|
|
import {Award, User} from '../../models/model-interfaces';
|
2018-03-07 11:56:50 +01:00
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
2018-07-08 13:28:21 +02:00
|
|
|
import {UserService} from '../../services/army-management/user.service';
|
2018-03-07 11:56:50 +01:00
|
|
|
import {Subscription} from 'rxjs/Subscription';
|
2018-07-08 13:28:21 +02:00
|
|
|
import {AwardingService} from '../../services/army-management/awarding.service';
|
|
|
|
import {Fraction} from '../../utils/fraction.enum';
|
2018-07-28 19:13:30 +02:00
|
|
|
import {Location} from '@angular/common';
|
2017-05-18 14:32:51 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'army-member',
|
|
|
|
templateUrl: './army-member.component.html',
|
2019-02-19 20:29:37 +01:00
|
|
|
styleUrls: ['./army-member.component.scss']
|
2017-05-18 14:32:51 +02:00
|
|
|
})
|
2018-07-28 19:13:30 +02:00
|
|
|
export class ArmyMemberComponent implements OnInit {
|
2017-05-18 14:32:51 +02:00
|
|
|
|
|
|
|
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,
|
2018-07-28 19:13:30 +02:00
|
|
|
private location: Location) {
|
2017-05-18 14:32:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.subscription = this.route.params
|
2018-02-26 09:04:27 +01:00
|
|
|
.map(params => params['id'])
|
2018-03-08 09:44:35 +01:00
|
|
|
.filter(id => id !== undefined)
|
2018-02-26 09:04:27 +01:00
|
|
|
.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;
|
|
|
|
}));
|
|
|
|
});
|
2017-05-18 14:32:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
backToOverview() {
|
2018-07-22 13:09:51 +02:00
|
|
|
this.location.back();
|
2017-05-18 14:32:51 +02:00
|
|
|
}
|
|
|
|
}
|