Compare commits

..

No commits in common. "8c27f1b45483e276c98da242514fb30df021d464" and "1bf7d176154afa1c15b343fdfc307964f53ff0d8" have entirely different histories.

9 changed files with 36 additions and 53 deletions

View File

@ -58,15 +58,3 @@ 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)

View File

@ -3,8 +3,6 @@
// modules
const express = require('express');
const mongoose = require('mongoose');
// HTTP status codes by name
const codes = require('./http-codes');
@ -12,11 +10,9 @@ 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 = {
@ -81,26 +77,8 @@ awarding.route('/')
.all(routerHandling.httpMethodNotAllowed);
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

View File

@ -19,6 +19,9 @@
<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>
@ -84,9 +87,6 @@
<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>

View File

@ -5,7 +5,6 @@ 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

@ -1,6 +1,6 @@
<form class="form-signin" (ngSubmit)="login(userName.value, password.value)">
<div class="row" style="position: absolute;width: 400px;left: 40%;">
<div class="row">
<h2 style="text-align: center;" class="form-signin-heading">Anmelden</h2>
<label for="inputEmail" class="sr-only">Benutzername</label>
@ -23,5 +23,7 @@
</div>
</form>

View File

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

View File

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

View File

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

View File

@ -25,11 +25,6 @@ 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
*/