Compare commits

..

No commits in common. "5d3c9cbe913170786e0d482742f707f654da2270" and "7867c1d48098eb044672d7e5ef19ffc8096dbaf3" have entirely different histories.

7 changed files with 14 additions and 46 deletions

View File

@ -14,9 +14,6 @@ const CampaignModel = require('../models/campaign');
const PlayerModel = require('../models/player'); const PlayerModel = require('../models/player');
const WarModel = require('../models/war'); const WarModel = require('../models/war');
// Util
const isSteamUUID = require('../tools/util').isSteamUUID;
const campaignPlayer = express.Router(); const campaignPlayer = express.Router();
// routes ********************** // routes **********************
@ -89,7 +86,7 @@ campaignPlayer.route('/ranking/:campaignId')
routerHandling.httpMethodNotAllowed routerHandling.httpMethodNotAllowed
); );
campaignPlayer.route('/single/:campaignId/:playerId') campaignPlayer.route('/single/:campaignId/:playerName')
.get((req, res, next) => { .get((req, res, next) => {
CampaignModel.findById(req.params.campaignId, (err, campaign) => { CampaignModel.findById(req.params.campaignId, (err, campaign) => {
if (err) return next(err); if (err) return next(err);
@ -98,24 +95,17 @@ campaignPlayer.route('/single/:campaignId/:playerId')
const warIds = wars.map((obj) => { const warIds = wars.map((obj) => {
return obj._id; return obj._id;
}); });
PlayerModel.find({name: req.params.playerName, warId: {"$in": warIds}})
// find by player name until v1.6.12, afterwards by SteamUUID
const playerId = req.params.playerId;
const filter = {};
filter[isSteamUUID(playerId) ? 'steamUUID' : 'name'] = playerId;
filter['warId'] = {"$in": warIds};
PlayerModel.find(filter)
.populate('warId') .populate('warId')
.exec((err, items) => { .exec((err, items) => {
if (err) return next(err); if (err) return next(err);
if (!items || items.length === 0) { if (!items || items.length === 0) {
const err = new Error('Unknown player id'); const err = new Error('Unknown player name');
err.status = codes.notfound; err.status = codes.notfound;
return next(err) return next(err)
} }
res.locals.items = { res.locals.items = {
name: items[items.length - 1].name, name: req.params.playerName,
campaign: campaign, campaign: campaign,
players: items players: items
}; };

View File

@ -1,11 +1,5 @@
"use strict"; "use strict";
const isSteamUUID = (input) => {
const steamUIDPattern = new RegExp("[0-9]{17}");
return steamUIDPattern.test(input)
};
const sortCollectionBy = (collection, key) => { const sortCollectionBy = (collection, key) => {
collection.sort((a, b) => { collection.sort((a, b) => {
a = a[key].toLowerCase(); a = a[key].toLowerCase();
@ -54,4 +48,3 @@ exports.sortCollection = sortCollectionBy;
exports.playerArrayContains = playerArrayContains; exports.playerArrayContains = playerArrayContains;
exports.timeStringToDecimal = timeStringToDecimal; exports.timeStringToDecimal = timeStringToDecimal;
exports.decimalToTimeString = decimalToTimeString; exports.decimalToTimeString = decimalToTimeString;
exports.isSteamUUID = isSteamUUID;

View File

@ -1,6 +1,6 @@
{ {
"name": "opt-cc", "name": "opt-cc",
"version": "1.7.0", "version": "1.6.13",
"author": "Florian Hartwich <hardi@noarch.de>", "author": "Florian Hartwich <hardi@noarch.de>",
"private": true, "private": true,
"scripts": { "scripts": {

View File

@ -72,4 +72,5 @@ ngx-datatable {
background: #4b4b4b; background: #4b4b4b;
-webkit-box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.5); -webkit-box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.5);
} }
/* Table Scrollbar END */ /* Table Scrollbar END */

View File

@ -31,16 +31,13 @@
<ngx-datatable-column [width]="70" name="Tod" prop="death"></ngx-datatable-column> <ngx-datatable-column [width]="70" name="Tod" prop="death"></ngx-datatable-column>
<ngx-datatable-column [width]="90" name="Respawn" prop="respawn"></ngx-datatable-column> <ngx-datatable-column [width]="90" name="Respawn" prop="respawn"></ngx-datatable-column>
<!--<ngx-datatable-column [width]="80" name="" prop="name">--> <!--<ngx-datatable-column [width]="80" name="" prop="name">-->
<!--<ng-template ngx-datatable-cell-template let-value="value">--> <!--<ng-template ngx-datatable-cell-template let-value="value">-->
<!--<span class="btn btn-sm btn-default in-table-btn disabled">Detail</span>--> <!--<span class="btn btn-sm btn-default in-table-btn disabled">Detail</span>-->
<!--</ng-template>--> <!--</ng-template>-->
<!--</ngx-datatable-column>--> <!--</ngx-datatable-column>-->
<ngx-datatable-column [width]="80"> <ngx-datatable-column [width]="80" name="" prop="name">
<ng-template ngx-datatable-cell-template let-row="row"> <ng-template ngx-datatable-cell-template let-value="value">
<span class="btn btn-sm btn-default in-table-btn" <span class="btn btn-sm btn-default in-table-btn" (click)="selectPlayerDetail(1, value)">Gesamt</span>
(click)="selectPlayerDetail(1, isSteamUUID(row['steamUUID']) ? row['steamUUID'] : row['name'])">
Gesamt
</span>
</ng-template> </ng-template>
</ngx-datatable-column> </ngx-datatable-column>
</ngx-datatable> </ngx-datatable>

View File

@ -1,7 +1,6 @@
import {Component, ElementRef, EventEmitter, SimpleChanges} from "@angular/core"; import {Component, ElementRef, EventEmitter, SimpleChanges} from "@angular/core";
import {War} from "../../../models/model-interfaces"; import {War} from "../../../models/model-interfaces";
import {Fraction} from "../../../utils/fraction.enum"; import {Fraction} from "../../../utils/fraction.enum";
import {PlayerUtils} from "../../../utils/player-utils";
@Component({ @Component({
selector: 'scoreboard', selector: 'scoreboard',
@ -18,8 +17,6 @@ export class ScoreboardComponent {
war: War; war: War;
isSteamUUID = PlayerUtils.isSteamUUID;
fractionFilterSelected: string; fractionFilterSelected: string;
cellHeight = 40; cellHeight = 40;
@ -36,11 +33,8 @@ export class ScoreboardComponent {
constructor(private elRef: ElementRef) { constructor(private elRef: ElementRef) {
} }
selectPlayerDetail(view: number, player) { selectPlayerDetail(view: number, playerName: string) {
this.playerTabSwitch.emit({ this.playerTabSwitch.emit({view: view, player: playerName})
view: view,
player: player
})
} }
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {

View File

@ -1,7 +0,0 @@
export class PlayerUtils {
public static isSteamUUID(input: string): boolean {
const steamUIDPattern = new RegExp("[0-9]{17}");
return steamUIDPattern.test(input)
}
}