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

View File

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

View File

@ -2,13 +2,13 @@
<div class="army-member-view-container">
<div class="return-button">
<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}}
</h3>
</div>
<div class="text-center">
<img src="resource/signature/{{user._id}}.png">
<img src="{{signatureUrl}}">
</div>
<div class="input-group" style="width: 662px; margin: auto;">
<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>
</tr>
</thead>
<tbody *ngFor="let award of user.awards">
<tbody *ngFor="let award of awards">
<tr *ngIf="award.confirmed === 1" class="cell-outline">
<td class="text-center" *ngIf="award.decorationId.isMedal">
<img height="90px" src="resource/decoration/{{award.decorationId._id}}.png">

View File

@ -1,9 +1,10 @@
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 {UserService} from "../services/user-service/user.service";
import {Subscription} from "rxjs/Subscription";
import {RouteConfig} from "../app.config";
import {AwardingService} from "../services/awarding-service/awarding.service";
@Component({
@ -17,13 +18,16 @@ export class ArmyMemberComponent {
user: User = {};
awards: Award[] = [];
signatureUrl;
isCopied = false;
constructor(private router: Router,
private route: ActivatedRoute,
private userService: UserService) {
private userService: UserService,
private awardingService: AwardingService) {
}
ngOnInit() {
@ -34,6 +38,9 @@ export class ArmyMemberComponent {
.subscribe(user => {
this.user = user;
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 {
margin-top: 40px;
overflow-x: auto;
width: 50%;
width: 90%;
min-width: 800px;
}
.form-group {
width: 25%;
width: 30%;
min-width: 400px;
}
h3 {