Fix army member detail & user list sort

pull/14/head
Florian Hartwich 2017-10-14 19:58:34 +02:00
parent 732d8a15f0
commit 1aa6ed10e0
5 changed files with 21 additions and 13 deletions

View File

@ -10,7 +10,6 @@ const codes = require('./http-codes');
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 sortCollectionBy = require('../middleware/util').sortCollection;
const offsetlimitMiddleware = require('../middleware/limitoffset-middleware-mongo'); const offsetlimitMiddleware = require('../middleware/limitoffset-middleware-mongo');
const filterHandlerCreator = require('../middleware/filter-handler-mongo'); const filterHandlerCreator = require('../middleware/filter-handler-mongo');
const routerHandling = require('../middleware/router-handling'); const routerHandling = require('../middleware/router-handling');
@ -31,14 +30,14 @@ users.route('/')
const userQuery = () => { const userQuery = () => {
UserModel.find(dbFilter, res.locals.filter, res.locals.limitskip) UserModel.find(dbFilter, res.locals.filter, res.locals.limitskip)
.populate('squadId') .populate('squadId')
.exec((err, users) => { .collation({locale: "en", strength: 2}) // case insensitive order
.sort('username').exec((err, users) => {
if (err) return next(err); if (err) return next(err);
if (users.length === 0) { if (users.length === 0) {
res.locals.items = users; res.locals.items = users;
res.locals.processed = true; res.locals.processed = true;
return next(); return next();
} }
//users = sortCollectionBy(users, 'username');
UserModel.count(dbFilter, (err, totalCount) => { UserModel.count(dbFilter, (err, totalCount) => {
res.set('x-total-count', totalCount); res.set('x-total-count', totalCount);
res.locals.items = users; res.locals.items = users;
@ -48,10 +47,10 @@ users.route('/')
}) })
}; };
if (!req.query.q) req.query.q = '' if (!req.query.q) req.query.q = '';
const dbFilter = {username: {"$regex": req.query.q, "$options": "i"}}; const dbFilter = {username: {"$regex": req.query.q, "$options": "i"}};
if (req.query.squadId) dbFilter["squadId"] = {"$eq": req.query.squadId}; if (req.query.squadId) dbFilter["squadId"] = {"$eq": req.query.squadId};
// squad / fracion filter setup // squad / fraction filter setup
if (req.query.fractFilter && req.query.fractFilter !== 'UNASSIGNED' && !req.query.squadId) { if (req.query.fractFilter && req.query.fractFilter !== 'UNASSIGNED' && !req.query.squadId) {
SquadModel.find({'fraction': req.query.fractFilter}, {_id: 1}, (err, squads) => { SquadModel.find({'fraction': req.query.fractFilter}, {_id: 1}, (err, squads) => {
dbFilter['squadId'] = {$in: squads.map(squad => squad.id)}; dbFilter['squadId'] = {$in: squads.map(squad => squad.id)};

View File

@ -1,6 +1,6 @@
{ {
"name": "opt-cc", "name": "opt-cc",
"version": "1.5.3", "version": "1.5.4",
"license": "MIT", "license": "MIT",
"private": true, "private": true,
"scripts": { "scripts": {

View File

@ -2,13 +2,13 @@
<div class="army-member-view-container"> <div class="army-member-view-container">
<div class="return-button"> <div class="return-button">
<span class="btn btn-default" style="position:absolute;" (click)="backToOverview()">< zurück zur Übersicht</span> <span class="btn btn-default" style="position:absolute;" (click)="backToOverview()">< zurück zur Übersicht</span>
<h3 class="text-center" [ngClass]="user.squad?.fraction === 'BLUFOR' ? 'blufor' : 'opfor'"> <h3 class="text-center" [ngClass]="user.squadId?.fraction === 'BLUFOR' ? 'blufor' : 'opfor'">
Auszeichnungen von {{user.rank?.name}} {{user.username}} Auszeichnungen von {{user.rank?.name}} {{user.username}}
</h3> </h3>
</div> </div>
<div class="text-center"> <div class="text-center">
<img src="resource/signature/{{user._id}}.png"> <img src="{{signatureUrl}}">
</div> </div>
<div class="input-group" style="width: 662px; margin: auto;"> <div class="input-group" style="width: 662px; margin: auto;">
<input type="text" style="background: white;" class="form-control" [(ngModel)]="signatureUrl" readonly> <input type="text" style="background: white;" class="form-control" [(ngModel)]="signatureUrl" readonly>
@ -29,7 +29,7 @@
<th class="col-sm-1 text-right" style="border-radius: 0 10px 0 0;">Verliehen am</th> <th class="col-sm-1 text-right" style="border-radius: 0 10px 0 0;">Verliehen am</th>
</tr> </tr>
</thead> </thead>
<tbody *ngFor="let award of user.awards"> <tbody *ngFor="let award of awards">
<tr *ngIf="award.confirmed === 1" class="cell-outline"> <tr *ngIf="award.confirmed === 1" class="cell-outline">
<td class="text-center" *ngIf="award.decorationId.isMedal"> <td class="text-center" *ngIf="award.decorationId.isMedal">
<img height="90px" src="resource/decoration/{{award.decorationId._id}}.png"> <img height="90px" src="resource/decoration/{{award.decorationId._id}}.png">

View File

@ -1,9 +1,10 @@
import {Component} from "@angular/core"; import {Component} from "@angular/core";
import {User} from "../models/model-interfaces"; import {Award, User} from "../models/model-interfaces";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {UserService} from "../services/user-service/user.service"; import {UserService} from "../services/user-service/user.service";
import {Subscription} from "rxjs/Subscription"; import {Subscription} from "rxjs/Subscription";
import {RouteConfig} from "../app.config"; import {RouteConfig} from "../app.config";
import {AwardingService} from "../services/awarding-service/awarding.service";
@Component({ @Component({
@ -17,13 +18,16 @@ export class ArmyMemberComponent {
user: User = {}; user: User = {};
awards: Award[] = [];
signatureUrl; signatureUrl;
isCopied = false; isCopied = false;
constructor(private router: Router, constructor(private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private userService: UserService) { private userService: UserService,
private awardingService: AwardingService) {
} }
ngOnInit() { ngOnInit() {
@ -34,6 +38,9 @@ export class ArmyMemberComponent {
.subscribe(user => { .subscribe(user => {
this.user = user; this.user = user;
this.signatureUrl = window.location.origin + '/resource/signature/' + user._id + '.png'; this.signatureUrl = window.location.origin + '/resource/signature/' + user._id + '.png';
this.awardingService.getUserAwardings(user._id).subscribe((awards => {
this.awards = awards;
}));
}); });
}; };

View File

@ -15,11 +15,13 @@
.table-container { .table-container {
margin-top: 40px; margin-top: 40px;
overflow-x: auto; overflow-x: auto;
width: 50%; width: 90%;
min-width: 800px;
} }
.form-group { .form-group {
width: 25%; width: 30%;
min-width: 400px;
} }
h3 { h3 {