opt-cc/static/src/app/army/army-member/army-member.component.ts

53 lines
1.5 KiB
TypeScript
Raw Normal View History

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';
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';
@Component({
selector: 'army-member',
templateUrl: './army-member.component.html',
styleUrls: ['./army-member.component.scss']
})
2018-07-28 19:13:30 +02:00
export class ArmyMemberComponent implements OnInit {
user: User = {};
awards: Award[] = [];
signatureUrl;
isCopied = false;
2017-11-08 14:54:04 +01:00
readonly fraction = Fraction;
2019-03-03 18:09:20 +01:00
readonly displayedColumns = ['award-graphics', 'title', 'reason', 'date'];
constructor(private router: Router,
private route: ActivatedRoute,
private userService: UserService,
private awardingService: AwardingService,
2018-07-28 19:13:30 +02:00
private location: Location) {
}
ngOnInit() {
2019-03-03 18:09:20 +01:00
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.location.back();
}
}