diff --git a/static/src/app/app.component.html b/static/src/app/app.component.html index 5a5f99c..732a112 100644 --- a/static/src/app/app.component.html +++ b/static/src/app/app.component.html @@ -48,6 +48,9 @@
diff --git a/static/src/app/request/sql-dashboard/sql-dashboard.component.ts b/static/src/app/request/sql-dashboard/sql-dashboard.component.ts new file mode 100644 index 0000000..7a8a0f2 --- /dev/null +++ b/static/src/app/request/sql-dashboard/sql-dashboard.component.ts @@ -0,0 +1,60 @@ +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; + } +}