Use new endpoint for sql dashboard

pull/37/head
HardiReady 2018-06-18 20:44:18 +02:00
parent 43a3f219b3
commit 0af2ebc1e7
6 changed files with 16 additions and 30 deletions

View File

@ -90,7 +90,8 @@ awarding.route('/unprocessed/:squadId')
return next();
}
const squadUserIds = users.map(user => mongoose.Types.ObjectId(user._id));
AwardingModel.find({userId: {$in: squadUserIds}, confirmed: 0}, (err, awards) => {
AwardingModel.find({userId: {$in: squadUserIds}, confirmed: 0}).populate('decorationId').populate('proposer', resultSet).populate('userId')
.exec((err, awards) => {
res.locals.items = awards;
next();
});

View File

@ -5,6 +5,7 @@ export class AppConfig {
public readonly apiAppUserPath = this.apiUrl + '/account/';
public readonly apiAuthenticationPath = this.apiUrl + '/authenticate';
public readonly apiAwardPath = this.apiUrl + '/awardings';
public readonly apiAwardSquadPath = this.apiUrl + '/awardings/unprocessed';
public readonly apiCampaignPath = this.apiUrl + '/campaigns';
public readonly apiDecorationPath = this.apiUrl + '/decorations/';
public readonly apiLogsPath = this.apiUrl + '/logs';

View File

@ -6,10 +6,6 @@
padding: 5px;
}
.trash {
cursor: pointer;
}
.table {
overflow-wrap: break-word;
table-layout: fixed;
@ -23,11 +19,6 @@
padding: 5px;
}
.form-group {
width: 25%;
min-width: 300px;
}
h3 {
margin: 80px 0 20px -20px;
}

View File

@ -1,4 +1,4 @@
<form #form="ngForm" class="overview">
<div class="overview">
<h3>SQL Dashboard</h3>
<div class="table-container">
@ -75,6 +75,4 @@
</tbody>
</table>
</div>
</form>
</div>

View File

@ -1,8 +1,6 @@
import {Component, OnInit, ViewChild} from '@angular/core';
import {Component, OnInit} 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 {Award, Promotion, Rank} from '../../models/model-interfaces';
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';
@ -15,18 +13,15 @@ import {AwardingService} from '../../services/army-management/awarding.service';
})
export class SqlDashboardComponent implements OnInit {
@ViewChild(NgForm) form: NgForm;
ranks: Rank[];
promotions: Promotion[] = [];
promotions: Promotion[];
awards = [];
awards: Award[];
constructor(private router: Router,
private route: ActivatedRoute,
private rankService: RankService,
private userService: UserService,
private promotionService: PromotionService,
private awardingService: AwardingService,
private loginService: LoginService) {
@ -39,13 +34,8 @@ export class SqlDashboardComponent implements OnInit {
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.awardingService.getUnprocessedSquadAwards(currentUser.squad._id).subscribe(awards => {
this.awards = awards;
});
this.rankService.findRanks('', currentUser.squad.fraction).subscribe(ranks => {

View File

@ -25,6 +25,11 @@ export class AwardingService {
});
}
getUnprocessedSquadAwards(squadId?: string) {
return this.http.get(this.config.apiAwardSquadPath.concat('/').concat(squadId))
.map(res => res.json());
}
/**
* get awards array with populated decorations
*/