Compare commits
4 Commits
1bf7d17615
...
8c27f1b454
Author | SHA1 | Date |
---|---|---|
HardiReady | 8c27f1b454 | |
HardiReady | a6b6677eb7 | |
HardiReady | 0af2ebc1e7 | |
HardiReady | 43a3f219b3 |
|
@ -58,3 +58,15 @@ Create a new awarding proposal, that needs to be approved by higher permission l
|
|||
+ Response 201 (application/json; charset=utf-8)
|
||||
|
||||
+ Attributes (Awarding, fixed-type)
|
||||
|
||||
### Get Unprocessed Squad Awardings [GET /awardings/unprocessed/{squadId}]
|
||||
|
||||
List all awardings that are requested and in pending decision status
|
||||
|
||||
+ Parameters
|
||||
+ squadId: `5aba54eaeadcce6332c6a774` (string, required) - unique id of the squad in which awardings are requested
|
||||
|
||||
|
||||
+ Response 200 (application/json; charset=utf-8)
|
||||
|
||||
+ Attributes (array[AwardingPopulated], fixed-type)
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
// modules
|
||||
const express = require('express');
|
||||
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
// HTTP status codes by name
|
||||
const codes = require('./http-codes');
|
||||
|
||||
|
@ -10,9 +12,11 @@ const routerHandling = require('../middleware/router-handling');
|
|||
|
||||
const apiAuthenticationMiddleware = require('../middleware/auth-middleware');
|
||||
const checkHl = require('../middleware/permission-check').checkHl;
|
||||
const checkSql = require('../middleware/permission-check').checkSql;
|
||||
|
||||
// Mongoose Model using mongoDB
|
||||
const AwardingModel = require('../models/awarding');
|
||||
const UserModel = require('../models/user');
|
||||
|
||||
// result set for proposer(appUser) population
|
||||
const resultSet = {
|
||||
|
@ -77,8 +81,26 @@ awarding.route('/')
|
|||
|
||||
.all(routerHandling.httpMethodNotAllowed);
|
||||
|
||||
awarding.route('/:id')
|
||||
awarding.route('/unprocessed/:squadId')
|
||||
.get(apiAuthenticationMiddleware, checkSql, (req, res, next) => {
|
||||
const filter = {squadId: req.params.squadId};
|
||||
UserModel.find(filter, (err, users) => {
|
||||
if (!users || users.length === 0) {
|
||||
return next();
|
||||
}
|
||||
const squadUserIds = users.map((user) => new mongoose.Types.ObjectId(user._id));
|
||||
AwardingModel.find({userId: {$in: squadUserIds}, confirmed: 0})
|
||||
.populate('decorationId')
|
||||
.populate('proposer', resultSet)
|
||||
.populate('userId')
|
||||
.exec((err, awards) => {
|
||||
res.locals.items = awards;
|
||||
next();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
awarding.route('/:id')
|
||||
.patch(apiAuthenticationMiddleware, checkHl, (req, res, next) => {
|
||||
if (!req.body || (req.body._id && req.body._id !== req.params.id)) {
|
||||
// little bit different as in PUT. :id does not need to be in data, but if the _id and url id must match
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
<li routerLinkActive="active">
|
||||
<a href="https://www.opt4.net/dashboard" class="link">Zum Forum</a>
|
||||
</li>
|
||||
<li *ngIf="!loginService.isLoggedIn()" routerLinkActive="active">
|
||||
<a routerLink='{{config.loginPath}}' class="link">Login</a>
|
||||
</li>
|
||||
<li routerLinkActive="active">
|
||||
<a routerLink='{{config.overviewPath}}' class="link">Armeeübersicht</a>
|
||||
</li>
|
||||
|
@ -87,6 +84,9 @@
|
|||
<li *ngIf="loginService.isLoggedIn()" class="link" style="cursor: pointer">
|
||||
<a (click)="logout()">Abmelden</a>
|
||||
</li>
|
||||
<li *ngIf="!loginService.isLoggedIn()" routerLinkActive="active">
|
||||
<a routerLink='{{config.loginPath}}' class="link">Login</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<form class="form-signin" (ngSubmit)="login(userName.value, password.value)">
|
||||
|
||||
<div class="row">
|
||||
<div class="row" style="position: absolute;width: 400px;left: 40%;">
|
||||
<h2 style="text-align: center;" class="form-signin-heading">Anmelden</h2>
|
||||
|
||||
<label for="inputEmail" class="sr-only">Benutzername</label>
|
||||
|
@ -23,7 +23,5 @@
|
|||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue