61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
|
import {Component, OnInit, ViewChild} from '@angular/core';
|
||
|
import {ActivatedRoute, Router} from '@angular/router';
|
||
|
import {Promotion, Rank} from '../../models/model-interfaces';
|
||
|
import {NgForm} from '@angular/forms';
|
||
|
import {UserService} from '../../services/army-management/user.service';
|
||
|
import {RankService} from '../../services/army-management/rank.service';
|
||
|
import {PromotionService} from '../../services/army-management/promotion.service';
|
||
|
import {LoginService} from '../../services/app-user-service/login-service';
|
||
|
import {AwardingService} from "../../services/army-management/awarding.service";
|
||
|
|
||
|
|
||
|
@Component({
|
||
|
templateUrl: './sql-dashboard.component.html',
|
||
|
styleUrls: ['./sql-dashboard.component.css', '../../style/overview.css'],
|
||
|
})
|
||
|
export class SqlDashboardComponent implements OnInit {
|
||
|
|
||
|
@ViewChild(NgForm) form: NgForm;
|
||
|
|
||
|
ranks: Rank[];
|
||
|
|
||
|
promotions: Promotion[] = [];
|
||
|
|
||
|
awards = [];
|
||
|
|
||
|
constructor(private router: Router,
|
||
|
private route: ActivatedRoute,
|
||
|
private rankService: RankService,
|
||
|
private userService: UserService,
|
||
|
private promotionService: PromotionService,
|
||
|
private awardingService: AwardingService,
|
||
|
private loginService: LoginService) {
|
||
|
}
|
||
|
|
||
|
ngOnInit() {
|
||
|
const currentUser = this.loginService.getCurrentUser();
|
||
|
|
||
|
this.promotionService.getSquadPromotions(currentUser.squad._id).subscribe(promotions => {
|
||
|
this.promotions = promotions.filter(promotion => promotion.confirmed === 0);
|
||
|
});
|
||
|
|
||
|
this.userService.findUsers('', undefined, currentUser.squad._id).subscribe(users => {
|
||
|
users.forEach(user => {
|
||
|
this.awardingService.getUserAwardings(user._id).subscribe(awardings => {
|
||
|
const unprocessedUserAwardings = awardings.filter(award => award.confirmed === 0);
|
||
|
this.awards = this.awards.concat(unprocessedUserAwardings);
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|
||
|
this.rankService.findRanks('', currentUser.squad.fraction).subscribe(ranks => {
|
||
|
this.ranks = ranks;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
cancel() {
|
||
|
this.router.navigate(['..'], {relativeTo: this.route});
|
||
|
return false;
|
||
|
}
|
||
|
}
|