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)
|
+ Response 201 (application/json; charset=utf-8)
|
||||||
|
|
||||||
+ Attributes (Awarding, fixed-type)
|
+ 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
|
// modules
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
|
||||||
|
const mongoose = require('mongoose');
|
||||||
|
|
||||||
// HTTP status codes by name
|
// HTTP status codes by name
|
||||||
const codes = require('./http-codes');
|
const codes = require('./http-codes');
|
||||||
|
|
||||||
|
@ -10,9 +12,11 @@ const routerHandling = require('../middleware/router-handling');
|
||||||
|
|
||||||
const apiAuthenticationMiddleware = require('../middleware/auth-middleware');
|
const apiAuthenticationMiddleware = require('../middleware/auth-middleware');
|
||||||
const checkHl = require('../middleware/permission-check').checkHl;
|
const checkHl = require('../middleware/permission-check').checkHl;
|
||||||
|
const checkSql = require('../middleware/permission-check').checkSql;
|
||||||
|
|
||||||
// Mongoose Model using mongoDB
|
// Mongoose Model using mongoDB
|
||||||
const AwardingModel = require('../models/awarding');
|
const AwardingModel = require('../models/awarding');
|
||||||
|
const UserModel = require('../models/user');
|
||||||
|
|
||||||
// result set for proposer(appUser) population
|
// result set for proposer(appUser) population
|
||||||
const resultSet = {
|
const resultSet = {
|
||||||
|
@ -77,8 +81,26 @@ awarding.route('/')
|
||||||
|
|
||||||
.all(routerHandling.httpMethodNotAllowed);
|
.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) => {
|
.patch(apiAuthenticationMiddleware, checkHl, (req, res, next) => {
|
||||||
if (!req.body || (req.body._id && req.body._id !== req.params.id)) {
|
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
|
// 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">
|
<li routerLinkActive="active">
|
||||||
<a href="https://www.opt4.net/dashboard" class="link">Zum Forum</a>
|
<a href="https://www.opt4.net/dashboard" class="link">Zum Forum</a>
|
||||||
</li>
|
</li>
|
||||||
<li *ngIf="!loginService.isLoggedIn()" routerLinkActive="active">
|
|
||||||
<a routerLink='{{config.loginPath}}' class="link">Login</a>
|
|
||||||
</li>
|
|
||||||
<li routerLinkActive="active">
|
<li routerLinkActive="active">
|
||||||
<a routerLink='{{config.overviewPath}}' class="link">Armeeübersicht</a>
|
<a routerLink='{{config.overviewPath}}' class="link">Armeeübersicht</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -87,6 +84,9 @@
|
||||||
<li *ngIf="loginService.isLoggedIn()" class="link" style="cursor: pointer">
|
<li *ngIf="loginService.isLoggedIn()" class="link" style="cursor: pointer">
|
||||||
<a (click)="logout()">Abmelden</a>
|
<a (click)="logout()">Abmelden</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li *ngIf="!loginService.isLoggedIn()" routerLinkActive="active">
|
||||||
|
<a routerLink='{{config.loginPath}}' class="link">Login</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,6 +5,7 @@ export class AppConfig {
|
||||||
public readonly apiAppUserPath = this.apiUrl + '/account/';
|
public readonly apiAppUserPath = this.apiUrl + '/account/';
|
||||||
public readonly apiAuthenticationPath = this.apiUrl + '/authenticate';
|
public readonly apiAuthenticationPath = this.apiUrl + '/authenticate';
|
||||||
public readonly apiAwardPath = this.apiUrl + '/awardings';
|
public readonly apiAwardPath = this.apiUrl + '/awardings';
|
||||||
|
public readonly apiAwardSquadPath = this.apiUrl + '/awardings/unprocessed';
|
||||||
public readonly apiCampaignPath = this.apiUrl + '/campaigns';
|
public readonly apiCampaignPath = this.apiUrl + '/campaigns';
|
||||||
public readonly apiDecorationPath = this.apiUrl + '/decorations/';
|
public readonly apiDecorationPath = this.apiUrl + '/decorations/';
|
||||||
public readonly apiLogsPath = this.apiUrl + '/logs';
|
public readonly apiLogsPath = this.apiUrl + '/logs';
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<form class="form-signin" (ngSubmit)="login(userName.value, password.value)">
|
<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>
|
<h2 style="text-align: center;" class="form-signin-heading">Anmelden</h2>
|
||||||
|
|
||||||
<label for="inputEmail" class="sr-only">Benutzername</label>
|
<label for="inputEmail" class="sr-only">Benutzername</label>
|
||||||
|
@ -23,7 +23,5 @@
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.trash {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table {
|
.table {
|
||||||
overflow-wrap: break-word;
|
overflow-wrap: break-word;
|
||||||
table-layout: fixed;
|
table-layout: fixed;
|
||||||
|
@ -23,11 +19,6 @@
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-group {
|
|
||||||
width: 25%;
|
|
||||||
min-width: 300px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
margin: 80px 0 20px -20px;
|
margin: 80px 0 20px -20px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<form #form="ngForm" class="overview">
|
<div class="overview">
|
||||||
<h3>SQL Dashboard</h3>
|
<h3>SQL Dashboard</h3>
|
||||||
|
|
||||||
<div class="table-container">
|
<div class="table-container">
|
||||||
|
@ -75,6 +75,4 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</form>
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {Promotion, Rank} from '../../models/model-interfaces';
|
import {Award, 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 {RankService} from '../../services/army-management/rank.service';
|
||||||
import {PromotionService} from '../../services/army-management/promotion.service';
|
import {PromotionService} from '../../services/army-management/promotion.service';
|
||||||
import {LoginService} from '../../services/app-user-service/login-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 {
|
export class SqlDashboardComponent implements OnInit {
|
||||||
|
|
||||||
@ViewChild(NgForm) form: NgForm;
|
|
||||||
|
|
||||||
ranks: Rank[];
|
ranks: Rank[];
|
||||||
|
|
||||||
promotions: Promotion[] = [];
|
promotions: Promotion[];
|
||||||
|
|
||||||
awards = [];
|
awards: Award[];
|
||||||
|
|
||||||
constructor(private router: Router,
|
constructor(private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private rankService: RankService,
|
private rankService: RankService,
|
||||||
private userService: UserService,
|
|
||||||
private promotionService: PromotionService,
|
private promotionService: PromotionService,
|
||||||
private awardingService: AwardingService,
|
private awardingService: AwardingService,
|
||||||
private loginService: LoginService) {
|
private loginService: LoginService) {
|
||||||
|
@ -39,13 +34,8 @@ export class SqlDashboardComponent implements OnInit {
|
||||||
this.promotions = promotions.filter(promotion => promotion.confirmed === 0);
|
this.promotions = promotions.filter(promotion => promotion.confirmed === 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.userService.findUsers('', undefined, currentUser.squad._id).subscribe(users => {
|
this.awardingService.getUnprocessedSquadAwards(currentUser.squad._id).subscribe(awards => {
|
||||||
users.forEach(user => {
|
this.awards = awards;
|
||||||
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.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
|
* get awards array with populated decorations
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue