From 98412ca0ab5fdeebe9077165b058b54b5023ab59 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Fri, 22 Dec 2017 07:56:26 +0100 Subject: [PATCH 01/11] finish basic ranking endpoint --- api/routes/players.js | 58 ++++++++++++++++++- package.json | 2 +- static/src/app/app.config.ts | 2 +- .../src/app/services/logs/player.service.ts | 2 +- 4 files changed, 58 insertions(+), 6 deletions(-) diff --git a/api/routes/players.js b/api/routes/players.js index c296f8d..243f4fc 100644 --- a/api/routes/players.js +++ b/api/routes/players.js @@ -2,7 +2,7 @@ // modules const express = require('express'); -const logger = require('debug')('cc:wars'); +const logger = require('debug')('cc:players'); // HTTP status codes by name const codes = require('./http-codes'); @@ -17,7 +17,59 @@ const WarModel = require('../models/war'); const campaignPlayer = express.Router(); // routes ********************** -campaignPlayer.route('/:campaignId/:playerName') +campaignPlayer.route('/ranking/:campaignId') + .get((req, res, next) => { + WarModel.find({campaign: req.params.campaignId}, '_id', (err, wars) => { + if (err) return next(err); + const warIds = wars.map((obj) => { + return obj._id; + }); + PlayerModel.find({warId: {"$in": warIds}}, (err, items) => { + if (err) return next(err); + if (!items || items.length === 0) { + const err = new Error('No players for given campaignId'); + err.status = codes.notfound; + return next(err) + } + + const rankingItems = []; + new Set(items.map(x => x.name)).forEach(playerName => { + const playerInstances = items.filter(p => p.name === playerName) + const resItem = {name: playerName, kill: 0, death: 0, friendlyFire: 0, revive: 0, respawn: 0, flagTouch: 0}; + for (let i = 0; i < playerInstances.length; i++) { + resItem.kill += playerInstances[i].kill; + resItem.death += playerInstances[i].death; + resItem.friendlyFire += playerInstances[i].friendlyFire; + resItem.revive += playerInstances[i].revive; + resItem.respawn += playerInstances[i].respawn; + resItem.flagTouch += playerInstances[i].flagTouch; + } + resItem.fraction = playerInstances[playerInstances.length - 1].fraction; + rankingItems.push(resItem); + }); + + function getTopFive(fieldName) { + return rankingItems.sort((a, b) => b[fieldName] - a[fieldName]).slice(0, 5) + } + + res.locals.items = { + kills: getTopFive('kill'), + death: getTopFive('death'), + friendlyFire: getTopFive('friendlyFire'), + revive: getTopFive('revive'), + respawn: getTopFive('respawn'), + flagTouch: getTopFive('flagTouch') + }; + next(); + }) + }) + }) + + .all( + routerHandling.httpMethodNotAllowed + ); + +campaignPlayer.route('/single/:campaignId/:playerName') .get((req, res, next) => { CampaignModel.findById(req.params.campaignId, (err, campaign) => { if (err) return next(err); @@ -31,7 +83,7 @@ campaignPlayer.route('/:campaignId/:playerName') .exec((err, items) => { if (err) return next(err); if (!items || items.length === 0) { - const err = new Error('unknown player name'); + const err = new Error('Unknown player name'); err.status = codes.notfound; return next(err) } diff --git a/package.json b/package.json index 45f5e44..2ee1189 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opt-cc", - "version": "1.6.6", + "version": "1.6.7", "license": "MIT", "author": "Florian Hartwich ", "private": true, diff --git a/static/src/app/app.config.ts b/static/src/app/app.config.ts index 7187683..69ed7f8 100644 --- a/static/src/app/app.config.ts +++ b/static/src/app/app.config.ts @@ -35,4 +35,4 @@ export const RouteConfig = { requestPromotionPath: 'promotion', confirmAwardPath: 'confirm-award', confirmPromotionPath: 'confirm-promotion' -} +}; diff --git a/static/src/app/services/logs/player.service.ts b/static/src/app/services/logs/player.service.ts index ae231cc..fce391d 100644 --- a/static/src/app/services/logs/player.service.ts +++ b/static/src/app/services/logs/player.service.ts @@ -10,7 +10,7 @@ export class PlayerService { } getCampaignPlayer(campaignId: string, playerName: string) { - return this.http.get(this.config.apiPlayersPath + '/' + campaignId + '/' + playerName) + return this.http.get(this.config.apiPlayersPath + '/single/' + campaignId + '/' + playerName) .map(res => res.json()) } From f72054f60672c0405d71c2e53fb8296704a960f5 Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Sat, 23 Dec 2017 10:41:36 +0100 Subject: [PATCH 02/11] add new list entry for highscore --- package-lock.json | 2 +- package.json | 2 +- static/package-lock.json | 790 ++++++++++++++++++ .../statistic/war-list/war-list.component.css | 7 + .../war-list/war-list.component.html | 39 +- .../statistic/war-list/war-list.component.ts | 17 +- 6 files changed, 838 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index d3988d0..1c3c8fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "opt-cc", - "version": "1.6.3", + "version": "1.6.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2ee1189..008f884 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "start": "npm run deploy-static-prod && npm start --prefix ./api", "dev": "npm run deploy-static && npm run dev --prefix ./api", "deploy-static": "cd ./static && $(npm bin)/ng build && ln -s ../api/resource/ ../public/resource", - "deploy-static-prod": "cd ./static && $(npm bin)/ng build --prod --aot && ln -s ../api/resource/ ../public/resource", + "deploy-static:prod": "cd ./static && $(npm bin)/ng build --prod --aot && ln -s ../api/resource/ ../public/resource", "postinstall": "npm install --prefix ./static && npm install --prefix ./api", "mongodb": "mkdir -p mongodb-data && mongod --dbpath ./mongodb-data", "test": "npm test --prefix ./api", diff --git a/static/package-lock.json b/static/package-lock.json index c956c85..eaadae8 100644 --- a/static/package-lock.json +++ b/static/package-lock.json @@ -1160,6 +1160,7 @@ "requires": { "anymatch": "1.3.2", "async-each": "1.0.1", + "fsevents": "1.1.3", "glob-parent": "2.0.0", "inherits": "2.0.3", "is-binary-path": "1.0.1", @@ -3164,6 +3165,795 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, + "fsevents": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz", + "integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==", + "optional": true, + "requires": { + "nan": "2.7.0", + "node-pre-gyp": "0.6.39" + }, + "dependencies": { + "abbrev": { + "version": "1.1.0", + "bundled": true, + "optional": true + }, + "ajv": { + "version": "4.11.8", + "bundled": true, + "optional": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true + }, + "aproba": { + "version": "1.1.1", + "bundled": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.4", + "bundled": true, + "optional": true, + "requires": { + "delegates": "1.0.0", + "readable-stream": "2.2.9" + } + }, + "asn1": { + "version": "0.2.3", + "bundled": true, + "optional": true + }, + "assert-plus": { + "version": "0.2.0", + "bundled": true, + "optional": true + }, + "asynckit": { + "version": "0.4.0", + "bundled": true, + "optional": true + }, + "aws-sign2": { + "version": "0.6.0", + "bundled": true, + "optional": true + }, + "aws4": { + "version": "1.6.0", + "bundled": true, + "optional": true + }, + "balanced-match": { + "version": "0.4.2", + "bundled": true + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "bundled": true, + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "block-stream": { + "version": "0.0.9", + "bundled": true, + "requires": { + "inherits": "2.0.3" + } + }, + "boom": { + "version": "2.10.1", + "bundled": true, + "requires": { + "hoek": "2.16.3" + } + }, + "brace-expansion": { + "version": "1.1.7", + "bundled": true, + "requires": { + "balanced-match": "0.4.2", + "concat-map": "0.0.1" + } + }, + "buffer-shims": { + "version": "1.0.0", + "bundled": true + }, + "caseless": { + "version": "0.12.0", + "bundled": true, + "optional": true + }, + "co": { + "version": "4.6.0", + "bundled": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true + }, + "combined-stream": { + "version": "1.0.5", + "bundled": true, + "requires": { + "delayed-stream": "1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "bundled": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true + }, + "cryptiles": { + "version": "2.0.5", + "bundled": true, + "requires": { + "boom": "2.10.1" + } + }, + "dashdash": { + "version": "1.14.1", + "bundled": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "optional": true + } + } + }, + "debug": { + "version": "2.6.8", + "bundled": true, + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.4.2", + "bundled": true, + "optional": true + }, + "delayed-stream": { + "version": "1.0.0", + "bundled": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.2", + "bundled": true, + "optional": true + }, + "ecc-jsbn": { + "version": "0.1.1", + "bundled": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "extend": { + "version": "3.0.1", + "bundled": true, + "optional": true + }, + "extsprintf": { + "version": "1.0.2", + "bundled": true + }, + "forever-agent": { + "version": "0.6.1", + "bundled": true, + "optional": true + }, + "form-data": { + "version": "2.1.4", + "bundled": true, + "optional": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.15" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true + }, + "fstream": { + "version": "1.0.11", + "bundled": true, + "requires": { + "graceful-fs": "4.1.11", + "inherits": "2.0.3", + "mkdirp": "0.5.1", + "rimraf": "2.6.1" + } + }, + "fstream-ignore": { + "version": "1.0.5", + "bundled": true, + "optional": true, + "requires": { + "fstream": "1.0.11", + "inherits": "2.0.3", + "minimatch": "3.0.4" + } + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "optional": true, + "requires": { + "aproba": "1.1.1", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" + } + }, + "getpass": { + "version": "0.1.7", + "bundled": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "optional": true + } + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "bundled": true + }, + "har-schema": { + "version": "1.0.5", + "bundled": true, + "optional": true + }, + "har-validator": { + "version": "4.2.1", + "bundled": true, + "optional": true, + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "optional": true + }, + "hawk": { + "version": "3.1.3", + "bundled": true, + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "hoek": { + "version": "2.16.3", + "bundled": true + }, + "http-signature": { + "version": "1.1.1", + "bundled": true, + "optional": true, + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.0", + "sshpk": "1.13.0" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true + }, + "ini": { + "version": "1.3.4", + "bundled": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "bundled": true, + "optional": true + }, + "isarray": { + "version": "1.0.0", + "bundled": true + }, + "isstream": { + "version": "0.1.2", + "bundled": true, + "optional": true + }, + "jodid25519": { + "version": "1.0.2", + "bundled": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "jsbn": { + "version": "0.1.1", + "bundled": true, + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "bundled": true, + "optional": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "bundled": true, + "optional": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "bundled": true, + "optional": true + }, + "jsonify": { + "version": "0.0.0", + "bundled": true, + "optional": true + }, + "jsprim": { + "version": "1.4.0", + "bundled": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.0.2", + "json-schema": "0.2.3", + "verror": "1.3.6" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "optional": true + } + } + }, + "mime-db": { + "version": "1.27.0", + "bundled": true + }, + "mime-types": { + "version": "2.1.15", + "bundled": true, + "requires": { + "mime-db": "1.27.0" + } + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "requires": { + "brace-expansion": "1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true, + "optional": true + }, + "node-pre-gyp": { + "version": "0.6.39", + "bundled": true, + "optional": true, + "requires": { + "detect-libc": "1.0.2", + "hawk": "3.1.3", + "mkdirp": "0.5.1", + "nopt": "4.0.1", + "npmlog": "4.1.0", + "rc": "1.2.1", + "request": "2.81.0", + "rimraf": "2.6.1", + "semver": "5.3.0", + "tar": "2.2.1", + "tar-pack": "3.4.0" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "optional": true, + "requires": { + "abbrev": "1.1.0", + "osenv": "0.1.4" + } + }, + "npmlog": { + "version": "4.1.0", + "bundled": true, + "optional": true, + "requires": { + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true + }, + "oauth-sign": { + "version": "0.8.2", + "bundled": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "optional": true + }, + "osenv": { + "version": "0.1.4", + "bundled": true, + "optional": true, + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true + }, + "performance-now": { + "version": "0.2.0", + "bundled": true, + "optional": true + }, + "process-nextick-args": { + "version": "1.0.7", + "bundled": true + }, + "punycode": { + "version": "1.4.1", + "bundled": true, + "optional": true + }, + "qs": { + "version": "6.4.0", + "bundled": true, + "optional": true + }, + "rc": { + "version": "1.2.1", + "bundled": true, + "optional": true, + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.4", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.2.9", + "bundled": true, + "requires": { + "buffer-shims": "1.0.0", + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "1.0.1", + "util-deprecate": "1.0.2" + } + }, + "request": { + "version": "2.81.0", + "bundled": true, + "optional": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.15", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.0.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.2", + "tunnel-agent": "0.6.0", + "uuid": "3.0.1" + } + }, + "rimraf": { + "version": "2.6.1", + "bundled": true, + "requires": { + "glob": "7.1.2" + } + }, + "safe-buffer": { + "version": "5.0.1", + "bundled": true + }, + "semver": { + "version": "5.3.0", + "bundled": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "optional": true + }, + "sntp": { + "version": "1.0.9", + "bundled": true, + "requires": { + "hoek": "2.16.3" + } + }, + "sshpk": { + "version": "1.13.0", + "bundled": true, + "optional": true, + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jodid25519": "1.0.2", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "optional": true + } + } + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "1.0.1", + "bundled": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "stringstream": { + "version": "0.0.5", + "bundled": true, + "optional": true + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "optional": true + }, + "tar": { + "version": "2.2.1", + "bundled": true, + "requires": { + "block-stream": "0.0.9", + "fstream": "1.0.11", + "inherits": "2.0.3" + } + }, + "tar-pack": { + "version": "3.4.0", + "bundled": true, + "optional": true, + "requires": { + "debug": "2.6.8", + "fstream": "1.0.11", + "fstream-ignore": "1.0.5", + "once": "1.4.0", + "readable-stream": "2.2.9", + "rimraf": "2.6.1", + "tar": "2.2.1", + "uid-number": "0.0.6" + } + }, + "tough-cookie": { + "version": "2.3.2", + "bundled": true, + "optional": true, + "requires": { + "punycode": "1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "bundled": true, + "optional": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "bundled": true, + "optional": true + }, + "uid-number": { + "version": "0.0.6", + "bundled": true, + "optional": true + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true + }, + "uuid": { + "version": "3.0.1", + "bundled": true, + "optional": true + }, + "verror": { + "version": "1.3.6", + "bundled": true, + "optional": true, + "requires": { + "extsprintf": "1.0.2" + } + }, + "wide-align": { + "version": "1.1.2", + "bundled": true, + "optional": true, + "requires": { + "string-width": "1.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true + } + } + }, "fstream": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", diff --git a/static/src/app/statistic/war-list/war-list.component.css b/static/src/app/statistic/war-list/war-list.component.css index a4a0c63..56fdf99 100644 --- a/static/src/app/statistic/war-list/war-list.component.css +++ b/static/src/app/statistic/war-list/war-list.component.css @@ -5,3 +5,10 @@ color: white; font-weight: 600; } + +.top-list-entry { + margin-top: -16px; + margin-bottom: 10px; + width: 50%; + float: left; +} diff --git a/static/src/app/statistic/war-list/war-list.component.html b/static/src/app/statistic/war-list/war-list.component.html index eee2b9f..c37affa 100644 --- a/static/src/app/statistic/war-list/war-list.component.html +++ b/static/src/app/statistic/war-list/war-list.component.html @@ -20,24 +20,37 @@ -
-
- -
- - +
+
+
+ + Highscore + +
+
+
+ +
+
+ + +
diff --git a/static/src/app/statistic/war-list/war-list.component.ts b/static/src/app/statistic/war-list/war-list.component.ts index 4f6eb9a..85338e4 100644 --- a/static/src/app/statistic/war-list/war-list.component.ts +++ b/static/src/app/statistic/war-list/war-list.component.ts @@ -17,6 +17,8 @@ export class WarListComponent implements OnInit { campaigns: Campaign[] = []; + public readonly highscore = 'HIGHSCORE'; + constructor(private warService: WarService, private campaignService: CampaignService, public loginService: LoginService, @@ -59,10 +61,17 @@ export class WarListComponent implements OnInit { } } - selectOverview(overviewId) { - if (this.selectedWarId != overviewId) { - this.selectedWarId = overviewId; - this.router.navigate([{outlets: {'right': ['overview', overviewId]}}], {relativeTo: this.route}); + selectOverview(campaignId) { + if (this.selectedWarId != campaignId) { + this.selectedWarId = campaignId; + this.router.navigate([{outlets: {'right': ['overview', campaignId]}}], {relativeTo: this.route}); + } + } + + selectHighscore(campaignId) { + if (this.selectedWarId != campaignId + this.highscore) { + this.selectedWarId = campaignId + this.highscore; + //this.router.navigate([{outlets: {'right': ['highscore', campaignId]}}], {relativeTo: this.route}); } } From d0bf863fb20f4aff56492103e8e5c48a37e2cffb Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Sat, 23 Dec 2017 10:59:27 +0100 Subject: [PATCH 03/11] add empty Highscore page and routing --- .../highscore/highscore.component.css | 31 ++++ .../highscore/highscore.component.html | 5 + .../highscore/highscore.component.ts | 157 ++++++++++++++++++ static/src/app/statistic/stats.routing.ts | 12 +- .../statistic/war-list/war-list.component.ts | 2 +- 5 files changed, 203 insertions(+), 4 deletions(-) create mode 100644 static/src/app/statistic/highscore/highscore.component.css create mode 100644 static/src/app/statistic/highscore/highscore.component.html create mode 100644 static/src/app/statistic/highscore/highscore.component.ts diff --git a/static/src/app/statistic/highscore/highscore.component.css b/static/src/app/statistic/highscore/highscore.component.css new file mode 100644 index 0000000..2666e75 --- /dev/null +++ b/static/src/app/statistic/highscore/highscore.component.css @@ -0,0 +1,31 @@ +.slide-chart-container { + width: 90%; + min-width: 880px; + height: 650px; + margin: auto; + padding-left: 5%; +} + +:host /deep/ .carousel-indicators { + display: none; +} + +:host /deep/ .carousel-control { + width: 5%; + cursor: pointer; +} + +:host /deep/ .chart-legend { + position: absolute; + margin-top: -60px; + margin-left: -220px; +} + +:host /deep/ .chart-legend .legend-labels { + width: 200px; +} + +:host /deep/ .chart-legend .legend-label { + float: left; + padding-left: 14px; +} diff --git a/static/src/app/statistic/highscore/highscore.component.html b/static/src/app/statistic/highscore/highscore.component.html new file mode 100644 index 0000000..6bdb3fc --- /dev/null +++ b/static/src/app/statistic/highscore/highscore.component.html @@ -0,0 +1,5 @@ +
+

{{title}}

+ +
+ diff --git a/static/src/app/statistic/highscore/highscore.component.ts b/static/src/app/statistic/highscore/highscore.component.ts new file mode 100644 index 0000000..7e2756c --- /dev/null +++ b/static/src/app/statistic/highscore/highscore.component.ts @@ -0,0 +1,157 @@ +import {Component} from "@angular/core"; +import {ActivatedRoute} from "@angular/router"; +import {CarouselConfig} from "ngx-bootstrap"; +import {CampaignService} from "../../services/logs/campaign.service"; +import {ChartUtils} from "../../utils/chart-utils"; +import {Fraction} from "../../utils/fraction.enum"; + + +@Component({ + selector: 'stats-highscore', + templateUrl: './highscore.component.html', + styleUrls: ['./highscore.component.css', '../../style/list-entry.css', '../../style/overview.css'], + inputs: ['campaigns'], + providers: [{provide: CarouselConfig, useValue: {interval: false}}] +}) +export class StatisticHighScoreComponent { + + id = ""; + title = ""; + + pointData: any[] = []; + pointSumData: any[] = []; + playerData: any[] = []; + currentData: any[] = []; + activeSlideIndex; + + colorScheme = { + domain: [Fraction.COLOR_BLUFOR, Fraction.COLOR_OPFOR] + }; + gradient = false; + xAxis = true; + yAxis = true; + roundDomains = true; + legend = true; + legendTitle = ''; + showXAxisLabel = true; + showYAxisLabel = true; + yAxisLabel = ""; + autoscale = true; + timeline = false; + + constructor(private route: ActivatedRoute, + private campaignService: CampaignService) { + } + + ngOnInit() { + this.route.params + .map(params => params['id']) + .subscribe((id) => { + this.id = id; + if (this.campaignService.campaigns) { + this.initWars(this.campaignService.campaigns); + } else { + this.campaignService.getAllCampaigns().subscribe(campaigns => { + this.initWars(campaigns); + }) + } + }); + } + + initWars(campaigns) { + let wars = []; + let itemsProcessed = 0; + campaigns = campaigns.filter(campaign => this.id === 'all' || campaign._id === this.id); + campaigns.forEach(campaign => { + wars = wars.concat(campaign.wars); + itemsProcessed++; + if (itemsProcessed === campaigns.length) { + if (this.id === 'all') { + this.title = "Gesamtübersicht"; + wars.sort((a, b) => { + // sort by dates, because older campaign can contain newer war + if (a['date'] > (b['date'])) return -1; + if (a['date'] < (b['date'])) return 1; + return 0; + }) + } else { + this.title = campaign.title; + } + this.initChart(wars); + } + }) + } + + goToSlide(index: number) { + switch (index) { + case 0: + this.currentData = this.pointSumData; + this.yAxisLabel = "Gesamtpunkte"; + break; + case 1: + this.currentData = this.pointData; + this.yAxisLabel = "Punkte"; + break; + case 2: + this.currentData = this.playerData; + this.yAxisLabel = "Anzahl Spieler"; + break; + } + this.activeSlideIndex = index; + } + + initChart(wars: any[]) { + const pointsObj = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR); + const pointsSumObj = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR); + const playersObj = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR); + + for (let i = wars.length - 1; i >= 0; i--) { + const j = wars.length - i - 1; + const warDateString = ChartUtils.getShortDateString(wars[i].date); + + pointsObj[0].series.push({ + name: warDateString, + value: wars[i].ptBlufor + }); + pointsObj[1].series.push({ + name: warDateString, + value: wars[i].ptOpfor + }); + pointsSumObj[0].series.push({ + name: warDateString, + value: pointsSumObj[0].series[j - 1] ? + pointsSumObj[0].series[j - 1].value + wars[i].ptBlufor : + wars[i].ptBlufor + }); + pointsSumObj[1].series.push({ + name: warDateString, + value: pointsSumObj[1].series[j - 1] + ? pointsSumObj[1].series[j - 1].value + wars[i].ptOpfor : + wars[i].ptOpfor + }); + playersObj[0].series.push({ + name: warDateString, + value: wars[i].playersBlufor + }); + playersObj[1].series.push({ + name: warDateString, + value: wars[i].playersOpfor + }); + } + + this.pointData = pointsObj; + this.pointSumData = pointsSumObj; + this.playerData = playersObj; + if (this.id != 'all') { + this.goToSlide(0); + } else { + this.goToSlide(1); + } + Object.assign(this, this.currentData); + } + + isActiveSlide(index) { + return this.activeSlideIndex === index ? '#d9edf7' : 'white' + } + +} diff --git a/static/src/app/statistic/stats.routing.ts b/static/src/app/statistic/stats.routing.ts index db263b9..dba063b 100644 --- a/static/src/app/statistic/stats.routing.ts +++ b/static/src/app/statistic/stats.routing.ts @@ -10,6 +10,7 @@ import {WarDetailComponent} from "./war-detail/war-detail.component"; import {ScoreboardComponent} from "./war-detail/scoreboard/scoreboard.component"; import {WarSubmitComponent} from "./war-submit/war-submit.component"; import {FractionStatsComponent} from "./war-detail/fraction-stats/fraction-stats.component"; +import {StatisticHighScoreComponent} from "./highscore/highscore.component"; export const statsRoutes: Routes = [{ @@ -26,6 +27,11 @@ export const statsRoutes: Routes = [{ component: StatisticOverviewComponent, outlet: 'right' }, + { + path: 'highscore/:id', + component: StatisticHighScoreComponent, + outlet: 'right' + }, { path: 'new-campaign', component: CampaignSubmitComponent, @@ -49,7 +55,7 @@ export const statsRoutes: Routes = [{ export const statsRouterModule: ModuleWithProviders = RouterModule.forChild(statsRoutes); -export const statsRoutingComponents = [StatisticComponent, StatisticOverviewComponent, CampaignSubmitComponent, - WarListComponent, WarSubmitComponent, WarDetailComponent, ScoreboardComponent, FractionStatsComponent, - CampaignPlayerDetailComponent, WarItemComponent]; +export const statsRoutingComponents = [StatisticComponent, StatisticOverviewComponent, StatisticHighScoreComponent, + CampaignSubmitComponent, WarListComponent, WarSubmitComponent, WarDetailComponent, ScoreboardComponent, + FractionStatsComponent, CampaignPlayerDetailComponent, WarItemComponent]; diff --git a/static/src/app/statistic/war-list/war-list.component.ts b/static/src/app/statistic/war-list/war-list.component.ts index 85338e4..d4af553 100644 --- a/static/src/app/statistic/war-list/war-list.component.ts +++ b/static/src/app/statistic/war-list/war-list.component.ts @@ -71,7 +71,7 @@ export class WarListComponent implements OnInit { selectHighscore(campaignId) { if (this.selectedWarId != campaignId + this.highscore) { this.selectedWarId = campaignId + this.highscore; - //this.router.navigate([{outlets: {'right': ['highscore', campaignId]}}], {relativeTo: this.route}); + this.router.navigate([{outlets: {'right': ['highscore', campaignId]}}], {relativeTo: this.route}); } } From 651401787e55101d10c0e7df49080a87a32b7e66 Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Sat, 23 Dec 2017 11:19:08 +0100 Subject: [PATCH 04/11] init data on highscore --- .../src/app/services/logs/player.service.ts | 5 + .../highscore/highscore.component.ts | 132 ++---------------- .../overview/stats-overview.component.ts | 4 +- 3 files changed, 17 insertions(+), 124 deletions(-) diff --git a/static/src/app/services/logs/player.service.ts b/static/src/app/services/logs/player.service.ts index fce391d..8fa3b53 100644 --- a/static/src/app/services/logs/player.service.ts +++ b/static/src/app/services/logs/player.service.ts @@ -14,5 +14,10 @@ export class PlayerService { .map(res => res.json()) } + getCampaignHighscore(campaignId: string) { + return this.http.get(this.config.apiPlayersPath + '/ranking/' + campaignId) + .map(res => res.json()) + } + } diff --git a/static/src/app/statistic/highscore/highscore.component.ts b/static/src/app/statistic/highscore/highscore.component.ts index 7e2756c..043a598 100644 --- a/static/src/app/statistic/highscore/highscore.component.ts +++ b/static/src/app/statistic/highscore/highscore.component.ts @@ -1,45 +1,22 @@ import {Component} from "@angular/core"; import {ActivatedRoute} from "@angular/router"; -import {CarouselConfig} from "ngx-bootstrap"; +import {PlayerService} from "../../services/logs/player.service"; import {CampaignService} from "../../services/logs/campaign.service"; -import {ChartUtils} from "../../utils/chart-utils"; -import {Fraction} from "../../utils/fraction.enum"; @Component({ selector: 'stats-highscore', templateUrl: './highscore.component.html', styleUrls: ['./highscore.component.css', '../../style/list-entry.css', '../../style/overview.css'], - inputs: ['campaigns'], - providers: [{provide: CarouselConfig, useValue: {interval: false}}] + inputs: ['campaigns'] }) export class StatisticHighScoreComponent { id = ""; title = ""; - pointData: any[] = []; - pointSumData: any[] = []; - playerData: any[] = []; - currentData: any[] = []; - activeSlideIndex; - - colorScheme = { - domain: [Fraction.COLOR_BLUFOR, Fraction.COLOR_OPFOR] - }; - gradient = false; - xAxis = true; - yAxis = true; - roundDomains = true; - legend = true; - legendTitle = ''; - showXAxisLabel = true; - showYAxisLabel = true; - yAxisLabel = ""; - autoscale = true; - timeline = false; - constructor(private route: ActivatedRoute, + private playerService: PlayerService, private campaignService: CampaignService) { } @@ -49,109 +26,22 @@ export class StatisticHighScoreComponent { .subscribe((id) => { this.id = id; if (this.campaignService.campaigns) { - this.initWars(this.campaignService.campaigns); + this.initData(); } else { this.campaignService.getAllCampaigns().subscribe(campaigns => { - this.initWars(campaigns); + this.initData() }) } }); } - initWars(campaigns) { - let wars = []; - let itemsProcessed = 0; - campaigns = campaigns.filter(campaign => this.id === 'all' || campaign._id === this.id); - campaigns.forEach(campaign => { - wars = wars.concat(campaign.wars); - itemsProcessed++; - if (itemsProcessed === campaigns.length) { - if (this.id === 'all') { - this.title = "Gesamtübersicht"; - wars.sort((a, b) => { - // sort by dates, because older campaign can contain newer war - if (a['date'] > (b['date'])) return -1; - if (a['date'] < (b['date'])) return 1; - return 0; - }) - } else { - this.title = campaign.title; - } - this.initChart(wars); - } + initData() { + this.title = this.campaignService.campaigns + .filter(camp => camp._id === this.id).pop().title; + + this.playerService.getCampaignHighscore(this.id).subscribe(players => { + console.log(players); }) } - goToSlide(index: number) { - switch (index) { - case 0: - this.currentData = this.pointSumData; - this.yAxisLabel = "Gesamtpunkte"; - break; - case 1: - this.currentData = this.pointData; - this.yAxisLabel = "Punkte"; - break; - case 2: - this.currentData = this.playerData; - this.yAxisLabel = "Anzahl Spieler"; - break; - } - this.activeSlideIndex = index; - } - - initChart(wars: any[]) { - const pointsObj = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR); - const pointsSumObj = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR); - const playersObj = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR); - - for (let i = wars.length - 1; i >= 0; i--) { - const j = wars.length - i - 1; - const warDateString = ChartUtils.getShortDateString(wars[i].date); - - pointsObj[0].series.push({ - name: warDateString, - value: wars[i].ptBlufor - }); - pointsObj[1].series.push({ - name: warDateString, - value: wars[i].ptOpfor - }); - pointsSumObj[0].series.push({ - name: warDateString, - value: pointsSumObj[0].series[j - 1] ? - pointsSumObj[0].series[j - 1].value + wars[i].ptBlufor : - wars[i].ptBlufor - }); - pointsSumObj[1].series.push({ - name: warDateString, - value: pointsSumObj[1].series[j - 1] - ? pointsSumObj[1].series[j - 1].value + wars[i].ptOpfor : - wars[i].ptOpfor - }); - playersObj[0].series.push({ - name: warDateString, - value: wars[i].playersBlufor - }); - playersObj[1].series.push({ - name: warDateString, - value: wars[i].playersOpfor - }); - } - - this.pointData = pointsObj; - this.pointSumData = pointsSumObj; - this.playerData = playersObj; - if (this.id != 'all') { - this.goToSlide(0); - } else { - this.goToSlide(1); - } - Object.assign(this, this.currentData); - } - - isActiveSlide(index) { - return this.activeSlideIndex === index ? '#d9edf7' : 'white' - } - } diff --git a/static/src/app/statistic/overview/stats-overview.component.ts b/static/src/app/statistic/overview/stats-overview.component.ts index 12d6b8d..a7eb8a4 100644 --- a/static/src/app/statistic/overview/stats-overview.component.ts +++ b/static/src/app/statistic/overview/stats-overview.component.ts @@ -1,6 +1,5 @@ import {Component} from "@angular/core"; import {ActivatedRoute} from "@angular/router"; -import {CarouselConfig} from "ngx-bootstrap"; import {CampaignService} from "../../services/logs/campaign.service"; import {ChartUtils} from "../../utils/chart-utils"; import {Fraction} from "../../utils/fraction.enum"; @@ -10,8 +9,7 @@ import {Fraction} from "../../utils/fraction.enum"; selector: 'stats-overview', templateUrl: './stats-overview.component.html', styleUrls: ['./stats-overview.component.css', '../../style/list-entry.css', '../../style/overview.css'], - inputs: ['campaigns'], - providers: [{provide: CarouselConfig, useValue: {interval: false}}] + inputs: ['campaigns'] }) export class StatisticOverviewComponent { From 23f1a610929023d71c9bff031cb9dcba1198029d Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Sat, 23 Dec 2017 11:44:38 +0100 Subject: [PATCH 05/11] add first top5 table --- api/routes/players.js | 2 +- .../highscore/highscore.component.css | 32 ++----------------- .../highscore/highscore.component.html | 23 ++++++++++++- .../highscore/highscore.component.ts | 15 ++++++++- 4 files changed, 40 insertions(+), 32 deletions(-) diff --git a/api/routes/players.js b/api/routes/players.js index 243f4fc..f0943b3 100644 --- a/api/routes/players.js +++ b/api/routes/players.js @@ -53,7 +53,7 @@ campaignPlayer.route('/ranking/:campaignId') } res.locals.items = { - kills: getTopFive('kill'), + kill: getTopFive('kill'), death: getTopFive('death'), friendlyFire: getTopFive('friendlyFire'), revive: getTopFive('revive'), diff --git a/static/src/app/statistic/highscore/highscore.component.css b/static/src/app/statistic/highscore/highscore.component.css index 2666e75..f5eba27 100644 --- a/static/src/app/statistic/highscore/highscore.component.css +++ b/static/src/app/statistic/highscore/highscore.component.css @@ -1,31 +1,5 @@ -.slide-chart-container { - width: 90%; - min-width: 880px; - height: 650px; +ngx-datatable { + width: 320px; margin: auto; - padding-left: 5%; -} - -:host /deep/ .carousel-indicators { - display: none; -} - -:host /deep/ .carousel-control { - width: 5%; - cursor: pointer; -} - -:host /deep/ .chart-legend { - position: absolute; - margin-top: -60px; - margin-left: -220px; -} - -:host /deep/ .chart-legend .legend-labels { - width: 200px; -} - -:host /deep/ .chart-legend .legend-label { - float: left; - padding-left: 14px; + height: 240px; } diff --git a/static/src/app/statistic/highscore/highscore.component.html b/static/src/app/statistic/highscore/highscore.component.html index 6bdb3fc..396ae44 100644 --- a/static/src/app/statistic/highscore/highscore.component.html +++ b/static/src/app/statistic/highscore/highscore.component.html @@ -1,5 +1,26 @@ -
+

{{title}}

+ + + + + {{value}} + + + + +
diff --git a/static/src/app/statistic/highscore/highscore.component.ts b/static/src/app/statistic/highscore/highscore.component.ts index 043a598..fd97cf5 100644 --- a/static/src/app/statistic/highscore/highscore.component.ts +++ b/static/src/app/statistic/highscore/highscore.component.ts @@ -2,6 +2,7 @@ import {Component} from "@angular/core"; import {ActivatedRoute} from "@angular/router"; import {PlayerService} from "../../services/logs/player.service"; import {CampaignService} from "../../services/logs/campaign.service"; +import {Fraction} from "../../utils/fraction.enum"; @Component({ @@ -13,8 +14,20 @@ import {CampaignService} from "../../services/logs/campaign.service"; export class StatisticHighScoreComponent { id = ""; + title = ""; + players = {}; + + cellHeight = 40; + + customClasses = { + sortAscending: 'glyphicon glyphicon-triangle-top', + sortDescending: 'glyphicon glyphicon-triangle-bottom', + }; + + readonly fraction = Fraction; + constructor(private route: ActivatedRoute, private playerService: PlayerService, private campaignService: CampaignService) { @@ -40,7 +53,7 @@ export class StatisticHighScoreComponent { .filter(camp => camp._id === this.id).pop().title; this.playerService.getCampaignHighscore(this.id).subscribe(players => { - console.log(players); + this.players = players; }) } From 7239995ce300dffa1fd5c2d909b3230dfe107344 Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Tue, 26 Dec 2017 17:09:49 +0100 Subject: [PATCH 06/11] add plazer highscore tables with filter --- api/routes/players.js | 24 ++-- .../highscore/highscore.component.css | 74 +++++++++- .../highscore/highscore.component.html | 136 +++++++++++++++++- .../highscore/highscore.component.ts | 40 +++++- .../scoreboard/scoreboard.component.css | 20 +++ .../war-detail/war-detail.component.css | 15 -- 6 files changed, 273 insertions(+), 36 deletions(-) diff --git a/api/routes/players.js b/api/routes/players.js index f0943b3..d9b917f 100644 --- a/api/routes/players.js +++ b/api/routes/players.js @@ -34,7 +34,7 @@ campaignPlayer.route('/ranking/:campaignId') const rankingItems = []; new Set(items.map(x => x.name)).forEach(playerName => { - const playerInstances = items.filter(p => p.name === playerName) + const playerInstances = items.filter(p => p.name === playerName); const resItem = {name: playerName, kill: 0, death: 0, friendlyFire: 0, revive: 0, respawn: 0, flagTouch: 0}; for (let i = 0; i < playerInstances.length; i++) { resItem.kill += playerInstances[i].kill; @@ -48,17 +48,23 @@ campaignPlayer.route('/ranking/:campaignId') rankingItems.push(resItem); }); - function getTopFive(fieldName) { - return rankingItems.sort((a, b) => b[fieldName] - a[fieldName]).slice(0, 5) + function getSortedField(fieldName) { + let num = 1; + rankingItems.sort((a, b) => b[fieldName] - a[fieldName]) + const res = JSON.parse(JSON.stringify(rankingItems)); + for (const entity of res) { + entity.num = num++; + } + return res; } res.locals.items = { - kill: getTopFive('kill'), - death: getTopFive('death'), - friendlyFire: getTopFive('friendlyFire'), - revive: getTopFive('revive'), - respawn: getTopFive('respawn'), - flagTouch: getTopFive('flagTouch') + kill: getSortedField('kill'), + death: getSortedField('death'), + friendlyFire: getSortedField('friendlyFire'), + revive: getSortedField('revive'), + respawn: getSortedField('respawn'), + flagTouch: getSortedField('flagTouch') }; next(); }) diff --git a/static/src/app/statistic/highscore/highscore.component.css b/static/src/app/statistic/highscore/highscore.component.css index f5eba27..7392fa2 100644 --- a/static/src/app/statistic/highscore/highscore.component.css +++ b/static/src/app/statistic/highscore/highscore.component.css @@ -1,5 +1,71 @@ -ngx-datatable { - width: 320px; - margin: auto; - height: 240px; +h2 { + margin-left: 10%; } + +.player-name { + font-weight: bold; +} + +.search-field { + width: 30%; + margin: 20px 0 0 10%; +} + +ngx-datatable { + width: 345px; + margin: 3% 5% 0 5%; + height: 310px; + float: left; + border: solid #dfdfdf 1px; + border-radius: 10px 10px 2px 2px; +} + +:host /deep/ .datatable-header { + background: #222222; + font-weight: 700; + border-radius: 10px 10px 0 0; + color: white; +} + +:host /deep/ span.datatable-header-cell-label, :host /deep/ div.datatable-body-cell-label { + padding-left: 8px; +} + +:host /deep/ .ngx-datatable .datatable-header { + /*vertical center alignment*/ + display: table-cell; + vertical-align: middle; +} + +:host /deep/ .ngx-datatable .datatable-body .datatable-body-row > div { + /*vertical alignment*/ + position: relative; + top: 10px; +} + +:host /deep/ .datatable-body-row { + color: #222222; + border-bottom: 1px solid grey; +} + +:host /deep/ .datatable-body-row:hover { + background-color: #f7f7f7; +} + +/* Table Scrollbar BEGIN */ +:host /deep/ .ngx-datatable.scroll-vertical .datatable-body::-webkit-scrollbar { + width: 12px; +} + +:host /deep/ .ngx-datatable.scroll-vertical .datatable-body::-webkit-scrollbar-track { + -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); + border-radius: 10px; +} + +:host /deep/ .ngx-datatable.scroll-vertical .datatable-body::-webkit-scrollbar-thumb { + border-radius: 10px; + background: #4b4b4b; + -webkit-box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.5); +} + +/* Table Scrollbar END */ diff --git a/static/src/app/statistic/highscore/highscore.component.html b/static/src/app/statistic/highscore/highscore.component.html index 396ae44..775fe7b 100644 --- a/static/src/app/statistic/highscore/highscore.component.html +++ b/static/src/app/statistic/highscore/highscore.component.html @@ -1,18 +1,32 @@
-

{{title}}

+

{{title}} ⟶ Highscore

+ +
+ + + + +
- + + @@ -20,7 +34,117 @@ - + + + + + + + + {{value}} + + + + + + + + + + + {{value}} + + + + + + + + + + + + {{value}} + + + + + + + + + + + + {{value}} + + + + + + + + + + + + {{value}} + + + + + +
diff --git a/static/src/app/statistic/highscore/highscore.component.ts b/static/src/app/statistic/highscore/highscore.component.ts index fd97cf5..348be6c 100644 --- a/static/src/app/statistic/highscore/highscore.component.ts +++ b/static/src/app/statistic/highscore/highscore.component.ts @@ -3,6 +3,7 @@ import {ActivatedRoute} from "@angular/router"; import {PlayerService} from "../../services/logs/player.service"; import {CampaignService} from "../../services/logs/campaign.service"; import {Fraction} from "../../utils/fraction.enum"; +import {FormControl} from "@angular/forms"; @Component({ @@ -13,14 +14,28 @@ import {Fraction} from "../../utils/fraction.enum"; }) export class StatisticHighScoreComponent { - id = ""; + id = ''; - title = ""; + title = ''; + + searchTerm = new FormControl(); players = {}; + playersStored = {}; + cellHeight = 40; + numberColWidth = 60; + + nameColWidth = 210; + + valueColWidth = 110; + + emptyMessage = {emptyMessage: 'Keine Einträge'}; + + reorderable = false; + customClasses = { sortAscending: 'glyphicon glyphicon-triangle-top', sortDescending: 'glyphicon glyphicon-triangle-bottom', @@ -54,7 +69,28 @@ export class StatisticHighScoreComponent { this.playerService.getCampaignHighscore(this.id).subscribe(players => { this.players = players; + this.playersStored = players; }) } + filterPlayers() { + if (!this.searchTerm.value || this.searchTerm.value === '') { + this.players = this.playersStored; + } else { + this.players = { + kill: this.filterPlayerAttribute('kill'), + friendlyFire: this.filterPlayerAttribute('friendlyFire'), + death: this.filterPlayerAttribute('death'), + respawn: this.filterPlayerAttribute('respawn'), + revive: this.filterPlayerAttribute('revive'), + flagTouch: this.filterPlayerAttribute('flagTouch') + } + } + } + + private filterPlayerAttribute(attribute) { + const query = this.searchTerm.value.toLowerCase(); + return this.playersStored[attribute].filter(p => p.name.toLowerCase().includes(query)) + } + } diff --git a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.css b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.css index 4fa0a59..9d6dfd4 100644 --- a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.css +++ b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.css @@ -42,6 +42,26 @@ ngx-datatable { background-color: #f7f7f7; } +/* Table Scrollbar BEGIN */ +:host /deep/ .ngx-datatable.scroll-vertical .datatable-body::-webkit-scrollbar { + width: 12px; +} + +:host /deep/ .ngx-datatable.scroll-vertical .datatable-body::-webkit-scrollbar-track { + -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); + border-radius: 10px; +} + +:host /deep/ .ngx-datatable.scroll-vertical .datatable-body::-webkit-scrollbar-thumb { + border-radius: 10px; + background: #4b4b4b; + -webkit-box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.5); +} +/* Table Scrollbar END */ + + + + .in-table-btn { position: absolute; margin-top: -5px; diff --git a/static/src/app/statistic/war-detail/war-detail.component.css b/static/src/app/statistic/war-detail/war-detail.component.css index be9f74a..d104953 100644 --- a/static/src/app/statistic/war-detail/war-detail.component.css +++ b/static/src/app/statistic/war-detail/war-detail.component.css @@ -39,18 +39,3 @@ .nav-tabs > li.deactivated > a.nav-link { cursor: not-allowed !important; } - -:host /deep/ .ngx-datatable.scroll-vertical .datatable-body::-webkit-scrollbar { - width: 12px; -} - -:host /deep/ .ngx-datatable.scroll-vertical .datatable-body::-webkit-scrollbar-track { - -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); - border-radius: 10px; -} - -:host /deep/ .ngx-datatable.scroll-vertical .datatable-body::-webkit-scrollbar-thumb { - border-radius: 10px; - background: #4b4b4b; - -webkit-box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.5); -} From 2daefe0e6c384ccf918d08c78cfd780b1037bfab Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Wed, 27 Dec 2017 12:21:41 +0100 Subject: [PATCH 07/11] add observable for filter --- .../src/app/statistic/highscore/highscore.component.html | 3 ++- static/src/app/statistic/highscore/highscore.component.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/static/src/app/statistic/highscore/highscore.component.html b/static/src/app/statistic/highscore/highscore.component.html index 775fe7b..040e549 100644 --- a/static/src/app/statistic/highscore/highscore.component.html +++ b/static/src/app/statistic/highscore/highscore.component.html @@ -3,7 +3,7 @@
@@ -58,6 +58,7 @@ + this.filterPlayers()) + .subscribe(); } initData() { From a18bedbc4880d847d6d8d425bf493d91dcaa3165 Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Wed, 27 Dec 2017 12:50:22 +0100 Subject: [PATCH 08/11] add AND filter functionality --- .../app/statistic/highscore/highscore.component.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/static/src/app/statistic/highscore/highscore.component.ts b/static/src/app/statistic/highscore/highscore.component.ts index 880c9f2..2f6a1a1 100644 --- a/static/src/app/statistic/highscore/highscore.component.ts +++ b/static/src/app/statistic/highscore/highscore.component.ts @@ -96,8 +96,16 @@ export class StatisticHighScoreComponent { } private filterPlayerAttribute(attribute) { - const query = this.searchTerm.value.toLowerCase(); - return this.playersStored[attribute].filter(p => p.name.toLowerCase().includes(query)) + const query = this.searchTerm.value.toLowerCase().split('&'); + + return this.playersStored[attribute].filter(player => { + for (let i = 0; i < query.length; i++) { + if (player.name.toLowerCase().includes(query[i].trim())) { + return true; + } + } + return false; + }) } } From 1e83e0c8a884f9455f170ff9c3159fbb2ab6773c Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Wed, 27 Dec 2017 12:50:49 +0100 Subject: [PATCH 09/11] reformat code --- .../war-detail/scoreboard/scoreboard.component.css | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.css b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.css index 9d6dfd4..dc703e8 100644 --- a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.css +++ b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.css @@ -48,7 +48,7 @@ ngx-datatable { } :host /deep/ .ngx-datatable.scroll-vertical .datatable-body::-webkit-scrollbar-track { - -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); + -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); border-radius: 10px; } @@ -57,11 +57,9 @@ ngx-datatable { background: #4b4b4b; -webkit-box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.5); } + /* Table Scrollbar END */ - - - .in-table-btn { position: absolute; margin-top: -5px; From 9b9e2b9fa07daf0b6bfd4bfcde1c06b9c8d385e9 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Wed, 27 Dec 2017 20:12:24 +0100 Subject: [PATCH 10/11] revert package-json to master --- static/package-lock.json | 790 --------------------------------------- 1 file changed, 790 deletions(-) diff --git a/static/package-lock.json b/static/package-lock.json index eaadae8..c956c85 100644 --- a/static/package-lock.json +++ b/static/package-lock.json @@ -1160,7 +1160,6 @@ "requires": { "anymatch": "1.3.2", "async-each": "1.0.1", - "fsevents": "1.1.3", "glob-parent": "2.0.0", "inherits": "2.0.3", "is-binary-path": "1.0.1", @@ -3165,795 +3164,6 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, - "fsevents": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz", - "integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==", - "optional": true, - "requires": { - "nan": "2.7.0", - "node-pre-gyp": "0.6.39" - }, - "dependencies": { - "abbrev": { - "version": "1.1.0", - "bundled": true, - "optional": true - }, - "ajv": { - "version": "4.11.8", - "bundled": true, - "optional": true, - "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" - } - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true - }, - "aproba": { - "version": "1.1.1", - "bundled": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.4", - "bundled": true, - "optional": true, - "requires": { - "delegates": "1.0.0", - "readable-stream": "2.2.9" - } - }, - "asn1": { - "version": "0.2.3", - "bundled": true, - "optional": true - }, - "assert-plus": { - "version": "0.2.0", - "bundled": true, - "optional": true - }, - "asynckit": { - "version": "0.4.0", - "bundled": true, - "optional": true - }, - "aws-sign2": { - "version": "0.6.0", - "bundled": true, - "optional": true - }, - "aws4": { - "version": "1.6.0", - "bundled": true, - "optional": true - }, - "balanced-match": { - "version": "0.4.2", - "bundled": true - }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "bundled": true, - "optional": true, - "requires": { - "tweetnacl": "0.14.5" - } - }, - "block-stream": { - "version": "0.0.9", - "bundled": true, - "requires": { - "inherits": "2.0.3" - } - }, - "boom": { - "version": "2.10.1", - "bundled": true, - "requires": { - "hoek": "2.16.3" - } - }, - "brace-expansion": { - "version": "1.1.7", - "bundled": true, - "requires": { - "balanced-match": "0.4.2", - "concat-map": "0.0.1" - } - }, - "buffer-shims": { - "version": "1.0.0", - "bundled": true - }, - "caseless": { - "version": "0.12.0", - "bundled": true, - "optional": true - }, - "co": { - "version": "4.6.0", - "bundled": true, - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true - }, - "combined-stream": { - "version": "1.0.5", - "bundled": true, - "requires": { - "delayed-stream": "1.0.0" - } - }, - "concat-map": { - "version": "0.0.1", - "bundled": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true - }, - "cryptiles": { - "version": "2.0.5", - "bundled": true, - "requires": { - "boom": "2.10.1" - } - }, - "dashdash": { - "version": "1.14.1", - "bundled": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "optional": true - } - } - }, - "debug": { - "version": "2.6.8", - "bundled": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-extend": { - "version": "0.4.2", - "bundled": true, - "optional": true - }, - "delayed-stream": { - "version": "1.0.0", - "bundled": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true, - "optional": true - }, - "detect-libc": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "ecc-jsbn": { - "version": "0.1.1", - "bundled": true, - "optional": true, - "requires": { - "jsbn": "0.1.1" - } - }, - "extend": { - "version": "3.0.1", - "bundled": true, - "optional": true - }, - "extsprintf": { - "version": "1.0.2", - "bundled": true - }, - "forever-agent": { - "version": "0.6.1", - "bundled": true, - "optional": true - }, - "form-data": { - "version": "2.1.4", - "bundled": true, - "optional": true, - "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.15" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true - }, - "fstream": { - "version": "1.0.11", - "bundled": true, - "requires": { - "graceful-fs": "4.1.11", - "inherits": "2.0.3", - "mkdirp": "0.5.1", - "rimraf": "2.6.1" - } - }, - "fstream-ignore": { - "version": "1.0.5", - "bundled": true, - "optional": true, - "requires": { - "fstream": "1.0.11", - "inherits": "2.0.3", - "minimatch": "3.0.4" - } - }, - "gauge": { - "version": "2.7.4", - "bundled": true, - "optional": true, - "requires": { - "aproba": "1.1.1", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" - } - }, - "getpass": { - "version": "0.1.7", - "bundled": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "optional": true - } - } - }, - "glob": { - "version": "7.1.2", - "bundled": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "graceful-fs": { - "version": "4.1.11", - "bundled": true - }, - "har-schema": { - "version": "1.0.5", - "bundled": true, - "optional": true - }, - "har-validator": { - "version": "4.2.1", - "bundled": true, - "optional": true, - "requires": { - "ajv": "4.11.8", - "har-schema": "1.0.5" - } - }, - "has-unicode": { - "version": "2.0.1", - "bundled": true, - "optional": true - }, - "hawk": { - "version": "3.1.3", - "bundled": true, - "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" - } - }, - "hoek": { - "version": "2.16.3", - "bundled": true - }, - "http-signature": { - "version": "1.1.1", - "bundled": true, - "optional": true, - "requires": { - "assert-plus": "0.2.0", - "jsprim": "1.4.0", - "sshpk": "1.13.0" - } - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true - }, - "ini": { - "version": "1.3.4", - "bundled": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "is-typedarray": { - "version": "1.0.0", - "bundled": true, - "optional": true - }, - "isarray": { - "version": "1.0.0", - "bundled": true - }, - "isstream": { - "version": "0.1.2", - "bundled": true, - "optional": true - }, - "jodid25519": { - "version": "1.0.2", - "bundled": true, - "optional": true, - "requires": { - "jsbn": "0.1.1" - } - }, - "jsbn": { - "version": "0.1.1", - "bundled": true, - "optional": true - }, - "json-schema": { - "version": "0.2.3", - "bundled": true, - "optional": true - }, - "json-stable-stringify": { - "version": "1.0.1", - "bundled": true, - "optional": true, - "requires": { - "jsonify": "0.0.0" - } - }, - "json-stringify-safe": { - "version": "5.0.1", - "bundled": true, - "optional": true - }, - "jsonify": { - "version": "0.0.0", - "bundled": true, - "optional": true - }, - "jsprim": { - "version": "1.4.0", - "bundled": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.0.2", - "json-schema": "0.2.3", - "verror": "1.3.6" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "optional": true - } - } - }, - "mime-db": { - "version": "1.27.0", - "bundled": true - }, - "mime-types": { - "version": "2.1.15", - "bundled": true, - "requires": { - "mime-db": "1.27.0" - } - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "requires": { - "brace-expansion": "1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.0.0", - "bundled": true, - "optional": true - }, - "node-pre-gyp": { - "version": "0.6.39", - "bundled": true, - "optional": true, - "requires": { - "detect-libc": "1.0.2", - "hawk": "3.1.3", - "mkdirp": "0.5.1", - "nopt": "4.0.1", - "npmlog": "4.1.0", - "rc": "1.2.1", - "request": "2.81.0", - "rimraf": "2.6.1", - "semver": "5.3.0", - "tar": "2.2.1", - "tar-pack": "3.4.0" - } - }, - "nopt": { - "version": "4.0.1", - "bundled": true, - "optional": true, - "requires": { - "abbrev": "1.1.0", - "osenv": "0.1.4" - } - }, - "npmlog": { - "version": "4.1.0", - "bundled": true, - "optional": true, - "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true - }, - "oauth-sign": { - "version": "0.8.2", - "bundled": true, - "optional": true - }, - "object-assign": { - "version": "4.1.1", - "bundled": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true, - "optional": true - }, - "osenv": { - "version": "0.1.4", - "bundled": true, - "optional": true, - "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true - }, - "performance-now": { - "version": "0.2.0", - "bundled": true, - "optional": true - }, - "process-nextick-args": { - "version": "1.0.7", - "bundled": true - }, - "punycode": { - "version": "1.4.1", - "bundled": true, - "optional": true - }, - "qs": { - "version": "6.4.0", - "bundled": true, - "optional": true - }, - "rc": { - "version": "1.2.1", - "bundled": true, - "optional": true, - "requires": { - "deep-extend": "0.4.2", - "ini": "1.3.4", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true, - "optional": true - } - } - }, - "readable-stream": { - "version": "2.2.9", - "bundled": true, - "requires": { - "buffer-shims": "1.0.0", - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "1.0.1", - "util-deprecate": "1.0.2" - } - }, - "request": { - "version": "2.81.0", - "bundled": true, - "optional": true, - "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.1.4", - "har-validator": "4.2.1", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.15", - "oauth-sign": "0.8.2", - "performance-now": "0.2.0", - "qs": "6.4.0", - "safe-buffer": "5.0.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.2", - "tunnel-agent": "0.6.0", - "uuid": "3.0.1" - } - }, - "rimraf": { - "version": "2.6.1", - "bundled": true, - "requires": { - "glob": "7.1.2" - } - }, - "safe-buffer": { - "version": "5.0.1", - "bundled": true - }, - "semver": { - "version": "5.3.0", - "bundled": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true, - "optional": true - }, - "sntp": { - "version": "1.0.9", - "bundled": true, - "requires": { - "hoek": "2.16.3" - } - }, - "sshpk": { - "version": "1.13.0", - "bundled": true, - "optional": true, - "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jodid25519": "1.0.2", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "optional": true - } - } - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" - } - }, - "string_decoder": { - "version": "1.0.1", - "bundled": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, - "stringstream": { - "version": "0.0.5", - "bundled": true, - "optional": true - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true, - "optional": true - }, - "tar": { - "version": "2.2.1", - "bundled": true, - "requires": { - "block-stream": "0.0.9", - "fstream": "1.0.11", - "inherits": "2.0.3" - } - }, - "tar-pack": { - "version": "3.4.0", - "bundled": true, - "optional": true, - "requires": { - "debug": "2.6.8", - "fstream": "1.0.11", - "fstream-ignore": "1.0.5", - "once": "1.4.0", - "readable-stream": "2.2.9", - "rimraf": "2.6.1", - "tar": "2.2.1", - "uid-number": "0.0.6" - } - }, - "tough-cookie": { - "version": "2.3.2", - "bundled": true, - "optional": true, - "requires": { - "punycode": "1.4.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "bundled": true, - "optional": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "bundled": true, - "optional": true - }, - "uid-number": { - "version": "0.0.6", - "bundled": true, - "optional": true - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true - }, - "uuid": { - "version": "3.0.1", - "bundled": true, - "optional": true - }, - "verror": { - "version": "1.3.6", - "bundled": true, - "optional": true, - "requires": { - "extsprintf": "1.0.2" - } - }, - "wide-align": { - "version": "1.1.2", - "bundled": true, - "optional": true, - "requires": { - "string-width": "1.0.2" - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true - } - } - }, "fstream": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", From c2f2d72901ec18a01368e0d3accf89b88138386a Mon Sep 17 00:00:00 2001 From: HardiReady Date: Wed, 27 Dec 2017 20:34:16 +0100 Subject: [PATCH 11/11] optimize highscore filter --- static/src/app/statistic/highscore/highscore.component.html | 6 ------ static/src/app/statistic/highscore/highscore.component.ts | 2 +- static/src/app/statistic/war-list/war-list.component.html | 4 ---- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/static/src/app/statistic/highscore/highscore.component.html b/static/src/app/statistic/highscore/highscore.component.html index 040e549..1e4297d 100644 --- a/static/src/app/statistic/highscore/highscore.component.html +++ b/static/src/app/statistic/highscore/highscore.component.html @@ -17,7 +17,6 @@ { for (let i = 0; i < query.length; i++) { - if (player.name.toLowerCase().includes(query[i].trim())) { + if (query[i].trim() != '' && player.name.toLowerCase().includes(query[i].trim())) { return true; } } diff --git a/static/src/app/statistic/war-list/war-list.component.html b/static/src/app/statistic/war-list/war-list.component.html index c37affa..721ef16 100644 --- a/static/src/app/statistic/war-list/war-list.component.html +++ b/static/src/app/statistic/war-list/war-list.component.html @@ -23,22 +23,18 @@
-