Compare commits
No commits in common. "8c27f1b45483e276c98da242514fb30df021d464" and "1bf7d176154afa1c15b343fdfc307964f53ff0d8" have entirely different histories.
8c27f1b454
...
1bf7d17615
|
@ -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)
|
+ 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,8 +3,6 @@
|
||||||
// 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');
|
||||||
|
|
||||||
|
@ -12,11 +10,9 @@ 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 = {
|
||||||
|
@ -81,26 +77,8 @@ awarding.route('/')
|
||||||
|
|
||||||
.all(routerHandling.httpMethodNotAllowed);
|
.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')
|
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,6 +19,9 @@
|
||||||
<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>
|
||||||
|
@ -84,9 +87,6 @@
|
||||||
<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,7 +5,6 @@ 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" style="position: absolute;width: 400px;left: 40%;">
|
<div class="row">
|
||||||
<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,5 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.trash {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.table {
|
.table {
|
||||||
overflow-wrap: break-word;
|
overflow-wrap: break-word;
|
||||||
table-layout: fixed;
|
table-layout: fixed;
|
||||||
|
@ -19,6 +23,11 @@
|
||||||
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 @@
|
||||||
<div class="overview">
|
<form #form="ngForm" class="overview">
|
||||||
<h3>SQL Dashboard</h3>
|
<h3>SQL Dashboard</h3>
|
||||||
|
|
||||||
<div class="table-container">
|
<div class="table-container">
|
||||||
|
@ -75,4 +75,6 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
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 {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';
|
||||||
|
@ -13,15 +15,18 @@ 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: Award[];
|
awards = [];
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -34,8 +39,13 @@ export class SqlDashboardComponent implements OnInit {
|
||||||
this.promotions = promotions.filter(promotion => promotion.confirmed === 0);
|
this.promotions = promotions.filter(promotion => promotion.confirmed === 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.awardingService.getUnprocessedSquadAwards(currentUser.squad._id).subscribe(awards => {
|
this.userService.findUsers('', undefined, currentUser.squad._id).subscribe(users => {
|
||||||
this.awards = awards;
|
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.rankService.findRanks('', currentUser.squad.fraction).subscribe(ranks => {
|
||||||
|
|
|
@ -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
|
* get awards array with populated decorations
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue