Compare commits

..

51 Commits

Author SHA1 Message Date
HardiReady e848ee1b66 update from master v1.6.11 2018-02-18 12:54:22 +01:00
hardi a4f39dca16 Merge branch 'release/v1.6.11' of hardi/opt-cc into master 2018-02-16 16:49:03 +01:00
Florian Hartwich 82fdec3d62 update visible version # 2018-02-16 16:44:17 +01:00
Florian Hartwich ad3dd61c32 update ngx-chart for firefox cursor-pos fix; remove highscore box horizontal scrollbar as firefox fix 2018-02-16 16:43:39 +01:00
Florian Hartwich b49a17eecb Add test run todo for readme.md 2018-02-16 16:26:40 +01:00
Florian Hartwich d3f091253a revert hyperlink html change 2018-02-16 16:13:33 +01:00
Florian Hartwich 31c41f3bab replace markdown links with html for new window direct 2018-02-16 16:11:26 +01:00
Florian Hartwich 6ffc4de42a complete readme 2018-02-16 15:58:49 +01:00
Florian Hartwich bcfe6cf49a Add pm2 setup to 3rd party init 2018-02-16 15:34:31 +01:00
HardiReady 553dc492a6 Add automation 3rd party software install script 2018-02-11 12:26:53 +01:00
HardiReady eb3514c075 remove console log 2018-02-04 16:57:34 +01:00
hardi ea2c3e34ba Merge branch 'release/v1.6.10' of hardi/opt-cc into master 2018-02-04 16:38:57 +01:00
HardiReady e46896ed9b Update version 2018-02-04 16:37:15 +01:00
HardiReady b4729788ab Add ID validator; fix authentication secret usage 2018-02-04 16:36:42 +01:00
HardiReady ef65552c7b Update modules and apply logger use 2018-02-04 15:58:28 +01:00
HardiReady ebfaa7afb1 retrieve jws token from env config 2018-02-03 21:41:38 +01:00
hardi fdb81bdeda Remove old token from api config 2018-02-03 21:20:39 +01:00
hardi be824d3a24 update db schema doc 2018-02-03 17:18:47 +01:00
hardi 003cf39a9c Update 'README.md' 2018-02-03 12:55:38 +01:00
hardi 0907cb0902 Merge branch 'task/license-update' of hardi/opt-cc into master 2018-02-03 12:54:20 +01:00
hardi 38ce62f91a Update 'package.json' 2018-02-03 12:53:29 +01:00
hardi 3c60d0c9d4 Add static license file 2018-02-03 12:52:32 +01:00
hardi 13281f7f39 Add license file for API 2018-02-03 12:51:06 +01:00
hardi cd6f644fa5 Update 'README.md' 2018-02-03 12:45:55 +01:00
hardi 9fb865f4dc Merge branch 'release/v1.6.9' of hardi/opt-cc into master 2018-02-03 12:23:53 +01:00
HardiReady fcae4d57cd remove empty squads from army view; replace window.scroll with window.scrollTo() 2018-02-03 12:13:11 +01:00
HardiReady e2d522ac7c reactivate respawn parse 2018-02-03 11:34:46 +01:00
Florian Hartwich 5d1ac86b02 Fix war date and driver nptr; deactivate respawn log 2018-02-02 10:48:43 +01:00
HardiReady c4f1cc7713 remove console trace 2018-02-01 07:07:53 +01:00
HardiReady c6b9858420 Add new transport parsing to stats upload 2018-02-01 07:06:26 +01:00
HardiReady 8ae4999593 Add respawn to logparser processing 2018-01-28 17:45:54 +01:00
HardiReady 359fb4787c Fix bg change destroy condition 2018-01-21 11:50:22 +01:00
hardi 3b2325483d Merge branch 'release/v1.6.8' of hardi/opt-cc into master 2018-01-21 11:44:19 +01:00
HardiReady 5943a40576 suppress bg reloading on page change 2018-01-21 11:38:54 +01:00
HardiReady cdb63ba41b update version # 2018-01-16 19:47:07 +01:00
HardiReady 9dbef87dac Fix log parser (partially) & optimize design army overview 2018-01-16 19:46:28 +01:00
HardiReady cf7260a06d Add background for army overview 2018-01-13 15:03:12 +01:00
HardiReady 9c92c7713e Merge branch 'release/1.6.7' 2017-12-27 20:42:47 +01:00
HardiReady 4c20821fc8 fix field error for highscore player 2017-12-27 20:42:30 +01:00
hardi 3e78921372 Merge branch 'release/1.6.7' of hardi/opt-cc into master 2017-12-27 20:37:45 +01:00
HardiReady c2f2d72901 optimize highscore filter 2017-12-27 20:34:16 +01:00
HardiReady 9b9e2b9fa0 revert package-json to master 2017-12-27 20:12:24 +01:00
Florian Hartwich 1e83e0c8a8 reformat code 2017-12-27 12:50:49 +01:00
Florian Hartwich a18bedbc48 add AND filter functionality 2017-12-27 12:50:22 +01:00
Florian Hartwich 2daefe0e6c add observable for filter 2017-12-27 12:21:41 +01:00
Florian Hartwich 7239995ce3 add plazer highscore tables with filter 2017-12-26 17:09:49 +01:00
Florian Hartwich 23f1a61092 add first top5 table 2017-12-23 11:44:38 +01:00
Florian Hartwich 651401787e init data on highscore 2017-12-23 11:19:08 +01:00
Florian Hartwich d0bf863fb2 add empty Highscore page and routing 2017-12-23 10:59:27 +01:00
Florian Hartwich f72054f606 add new list entry for highscore 2017-12-23 10:41:36 +01:00
HardiReady 98412ca0ab finish basic ranking endpoint 2017-12-22 07:56:26 +01:00
51 changed files with 3595 additions and 462 deletions

View File

@ -1,37 +1,74 @@
# Operation Pandora Trigger Commandcenter # Operation Pandora Trigger Commandcenter
_MEAN Application_ A [MEAN Application](http://mean.io/) created for [operation-pandora.com](https://www.operation-pandora.com) Arma3 Community
## Installation ## Installation
### Setup mongoDB All steps described here are working with a Debian based Linux system
https://docs.mongodb.com/manual/administration/install-community/ ### Setup required 3rd Party Software
### Setup node and npm #### Setup for Development
sudo apt-get install npm nodejs-legacy Run the installation script located in the docs folder:
update to latest npm version ./docs/opt-cc-environment/3rd-party-install
sudo npm install -g npm@latest It installs NPM, Node and MongoDB on latest versions.
In addition, it sets up the mongo deamon to start up automatically with the system.
update node to latest version #### Setup for Production
sudo npm install -g n@latest **NOTE:** It his highly recommended not to run the following steps as _root_ user!
n latest
check versions Before triggering the environment execution run
npm -v npm install
node -v
## Development and Execution inside the main folder, to process all needed npm package installations for the program execution.
### First run in dev mode For production setup run the script, described in _Setup for development_, adding the parameter `prod`
### Run in Production ./docs/opt-cc-environment/3rd-party-install prod
This adds the [`pm2` process manager](http://pm2.keymetrics.io/) to be installed and start the _opt-cc_ server as `pm2` process.
Run the `sudo` command printed as last output to configure the `pm2` process for automatic start on the system, as the current user.
## Development
### Run and Modify Application
**NOTE:** Do not use the execution described here in any production environment! It will make the running application highly vulnerable.
Before triggering the environment execution run
npm install
inside the main folder, to process all needed npm package installations for the program execution.
To compile the Angular code and afterwards start the Express server with `nodemon` for development purpose run
npm run dev
Any changes on `api` code will trigger an automatic restart of the Express server.
Changes on `static` code can be submitted with
npm run deploy-static
The page must be reloaded after this build step is finished, in order to make changes visible.
## Run Tests
_TODO_
## License Information ## License Information
### Express API (`/api`)
published under [CC BY-SA 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/legalcode.txt) \
Main concept for API Server, pagination and MongoDB usage by [Prof. Dr.-Ing. Johannes Konert](https://prof.beuth-hochschule.de/konert/) \
All endpoints, signature image builder and Arma3 RPT-Log parsing by [Florian Hartwich](https://de.linkedin.com/in/florian-hartwich-b67b02125)
### Angular 5 Frontend (`/static`)
published under [MIT License](https://opensource.org/licenses/MIT)

431
api/LICENSE.txt Normal file
View File

@ -0,0 +1,431 @@
Attribution-ShareAlike 4.0 International
applies to:
- Express server setup (modified), pagination and mongoDB connection setup, Copyright (c) Johannes Konert
- Express endpoints, signature image builder and Arma3 RPT log parser (c) 2018 "HardiReady" Florian Hartwich
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal services or legal advice. Distribution of
Creative Commons public licenses does not create a lawyer-client or
other relationship. Creative Commons makes its licenses and related
information available on an "as-is" basis. Creative Commons gives no
warranties regarding its licenses, any material licensed under their
terms and conditions, or any related information. Creative Commons
disclaims all liability for damages resulting from their use to the
fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and
conditions that creators and other rights holders may use to share
original works of authorship and other material subject to copyright
and certain other rights specified in the public license below. The
following considerations are for informational purposes only, are not
exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are
intended for use by those authorized to give the public
permission to use material in ways otherwise restricted by
copyright and certain other rights. Our licenses are
irrevocable. Licensors should read and understand the terms
and conditions of the license they choose before applying it.
Licensors should also secure all rights necessary before
applying our licenses so that the public can reuse the
material as expected. Licensors should clearly mark any
material not subject to the license. This includes other CC-
licensed material, or material used under an exception or
limitation to copyright. More considerations for licensors:
wiki.creativecommons.org/Considerations_for_licensors
Considerations for the public: By using one of our public
licenses, a licensor grants the public permission to use the
licensed material under specified terms and conditions. If
the licensor's permission is not necessary for any reason--for
example, because of any applicable exception or limitation to
copyright--then that use is not regulated by the license. Our
licenses grant only permissions under copyright and certain
other rights that a licensor has authority to grant. Use of
the licensed material may still be restricted for other
reasons, including because others have copyright or other
rights in the material. A licensor may make special requests,
such as asking that all changes be marked or described.
Although not required by our licenses, you are encouraged to
respect those requests where reasonable. More_considerations
for the public:
wiki.creativecommons.org/Considerations_for_licensees
=======================================================================
Creative Commons Attribution-ShareAlike 4.0 International Public
License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution-ShareAlike 4.0 International Public License ("Public
License"). To the extent this Public License may be interpreted as a
contract, You are granted the Licensed Rights in consideration of Your
acceptance of these terms and conditions, and the Licensor grants You
such rights in consideration of benefits the Licensor receives from
making the Licensed Material available under these terms and
conditions.
Section 1 -- Definitions.
a. Adapted Material means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material
and in which the Licensed Material is translated, altered,
arranged, transformed, or otherwise modified in a manner requiring
permission under the Copyright and Similar Rights held by the
Licensor. For purposes of this Public License, where the Licensed
Material is a musical work, performance, or sound recording,
Adapted Material is always produced where the Licensed Material is
synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
c. BY-SA Compatible License means a license listed at
creativecommons.org/compatiblelicenses, approved by Creative
Commons as essentially the equivalent of this Public License.
d. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or
categorized. For purposes of this Public License, the rights
specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights.
e. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international
agreements.
f. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material.
g. License Elements means the license attributes listed in the name
of a Creative Commons Public License. The License Elements of this
Public License are Attribution and ShareAlike.
h. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
License.
i. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license.
j. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
k. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.
l. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
m. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
Section 2 -- Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License,
the Licensor hereby grants You a worldwide, royalty-free,
non-sublicensable, non-exclusive, irrevocable license to
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
in part; and
b. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
License does not apply, and You do not need to comply with
its terms and conditions.
3. Term. The term of this Public License is specified in Section
6(a).
4. Media and formats; technical modifications allowed. The
Licensor authorizes You to exercise the Licensed Rights in
all media and formats whether now known or hereafter created,
and to make technical modifications necessary to do so. The
Licensor waives and/or agrees not to assert any right or
authority to forbid You from making technical modifications
necessary to exercise the Licensed Rights, including
technical modifications necessary to circumvent Effective
Technological Measures. For purposes of this Public License,
simply making modifications authorized by this Section 2(a)
(4) never produces Adapted Material.
5. Downstream recipients.
a. Offer from the Licensor -- Licensed Material. Every
recipient of the Licensed Material automatically
receives an offer from the Licensor to exercise the
Licensed Rights under the terms and conditions of this
Public License.
b. Additional offer from the Licensor -- Adapted Material.
Every recipient of Adapted Material from You
automatically receives an offer from the Licensor to
exercise the Licensed Rights in the Adapted Material
under the conditions of the Adapter's License You apply.
c. No downstream restrictions. You may not offer or impose
any additional or different terms or conditions on, or
apply any Effective Technological Measures to, the
Licensed Material if doing so restricts exercise of the
Licensed Rights by any recipient of the Licensed
Material.
6. No endorsement. Nothing in this Public License constitutes or
may be construed as permission to assert or imply that You
are, or that Your use of the Licensed Material is, connected
with, or sponsored, endorsed, or granted official status by,
the Licensor or others designated to receive attribution as
provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not
licensed under this Public License, nor are publicity,
privacy, and/or other similar personality rights; however, to
the extent possible, the Licensor waives and/or agrees not to
assert any such rights held by the Licensor to the limited
extent necessary to allow You to exercise the Licensed
Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this
Public License.
3. To the extent possible, the Licensor waives any right to
collect royalties from You for the exercise of the Licensed
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties.
Section 3 -- License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the
following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified
form), You must:
a. retain the following if it is supplied by the Licensor
with the Licensed Material:
i. identification of the creator(s) of the Licensed
Material and any others designated to receive
attribution, in any reasonable manner requested by
the Licensor (including by pseudonym if
designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of
warranties;
v. a URI or hyperlink to the Licensed Material to the
extent reasonably practicable;
b. indicate if You modified the Licensed Material and
retain an indication of any previous modifications; and
c. indicate the Licensed Material is licensed under this
Public License, and include the text of, or the URI or
hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any
reasonable manner based on the medium, means, and context in
which You Share the Licensed Material. For example, it may be
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
b. ShareAlike.
In addition to the conditions in Section 3(a), if You Share
Adapted Material You produce, the following conditions also apply.
1. The Adapter's License You apply must be a Creative Commons
license with the same License Elements, this version or
later, or a BY-SA Compatible License.
2. You must include the text of, or the URI or hyperlink to, the
Adapter's License You apply. You may satisfy this condition
in any reasonable manner based on the medium, means, and
context in which You Share Adapted Material.
3. You may not offer or impose any additional or different terms
or conditions on, or apply any Effective Technological
Measures to, Adapted Material that restrict exercise of the
rights granted under the Adapter's License You apply.
Section 4 -- Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that
apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material,
including for purposes of Section 3(b); and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not
replace Your obligations under this Public License where the Licensed
Rights include other Copyright and Similar Rights.
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
c. The disclaimer of warranties and limitation of liability provided
above shall be interpreted in a manner that, to the extent
possible, most closely approximates an absolute disclaimer and
waiver of all liability.
Section 6 -- Term and Termination.
a. This Public License applies for the term of the Copyright and
Similar Rights licensed here. However, if You fail to comply with
this Public License, then Your rights under this Public License
terminate automatically.
b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided
it is cured within 30 days of Your discovery of the
violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any
right the Licensor may have to seek remedies for Your violations
of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the
Licensed Material under separate terms or conditions or stop
distributing the Licensed Material at any time; however, doing so
will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
License.
Section 7 -- Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different
terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the
Licensed Material not stated herein are separate from and
independent of the terms and conditions of this Public License.
Section 8 -- Interpretation.
a. For the avoidance of doubt, this Public License does not, and
shall not be interpreted to, reduce, limit, restrict, or impose
conditions on any use of the Licensed Material that could lawfully
be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is
deemed unenforceable, it shall be automatically reformed to the
minimum extent necessary to make it enforceable. If the provision
cannot be reformed, it shall be severed from this Public License
without affecting the enforceability of the remaining terms and
conditions.
c. No term or condition of this Public License will be waived and no
failure to comply consented to unless expressly agreed to by the
Licensor.
d. Nothing in this Public License constitutes or may be interpreted
as a limitation upon, or waiver of, any privileges and immunities
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
=======================================================================
Creative Commons is not a party to its public
licenses. Notwithstanding, Creative Commons may elect to apply one of
its public licenses to material it publishes and in those instances
will be considered the “Licensor.” The text of the Creative Commons
public licenses is dedicated to the public domain under the CC0 Public
Domain Dedication. Except for the limited purpose of indicating that
material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo
of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the
public licenses.
Creative Commons may be contacted at creativecommons.org.

View File

@ -1,12 +1,15 @@
module.exports = { module.exports = {
port: 8091, port: 8091,
secret: "$8h94j+8z4trh%nj+18tj!h4gf8zu&#418zf4zjt(16",
database: { database: {
uri: 'mongodb://localhost:27017/', uri: 'mongodb://localhost:27017/',
db: 'cc', db: 'cc',
}, },
prod: {
env: 'production'
},
dev: { dev: {
env: 'dev' env: 'dev'
}, },

View File

@ -6,8 +6,14 @@ const {exec} = require('child_process');
const UserModel = require('../models/user'); const UserModel = require('../models/user');
const signatureTool = require('../tools/signature-tool'); const signatureTool = require('../tools/signature-tool');
const debug = require('debug');
const error = debug('cc:cronjob:err');
const logger = debug('cc:cronjob');
logger.log = console.log.bind(console);
const createAllSignatures = () => { const createAllSignatures = () => {
console.log('\x1b[35m%s\x1b[0m', new Date().toLocaleString() logger('\x1b[35m%s\x1b[0m', new Date().toLocaleString()
+ ': cron job started - UPDATE SIGNATURES'); + ': cron job started - UPDATE SIGNATURES');
// mock response // mock response
@ -25,31 +31,31 @@ const createAllSignatures = () => {
if (!err || (err && err.message.startsWith('Fraction not defined'))) { if (!err || (err && err.message.startsWith('Fraction not defined'))) {
callback() callback()
} else { } else {
console.error('\x1b[41m%s\x1b[0m', new Date().toLocaleString() error('\x1b[41m%s\x1b[0m', new Date().toLocaleString()
+ ': Error in execution - UPDATE SIGNATURES: ' + err) + ': Error in execution - UPDATE SIGNATURES: ' + err.message)
} }
}; };
signatureTool(user._id, res, next) signatureTool(user._id, res, next)
}, () => { }, () => {
if (err) { if (err) {
console.error('\x1b[41m%s\x1b[0m', new Date().toLocaleString() error('\x1b[41m%s\x1b[0m', new Date().toLocaleString()
+ ': Error in execution - UPDATE SIGNATURES: ' + err) + ': Error in execution - UPDATE SIGNATURES: ' + err.message)
} }
console.log('\x1b[35m%s\x1b[0m', new Date().toLocaleString() logger('\x1b[35m%s\x1b[0m', new Date().toLocaleString()
+ ': finished successful - UPDATE SIGNATURES'); + ': finished successful - UPDATE SIGNATURES');
}) })
}); });
}; };
const createBackup = () => { const createBackup = () => {
console.log('\x1b[35m%s\x1b[0m', new Date().toLocaleString() logger('\x1b[35m%s\x1b[0m', new Date().toLocaleString()
+ ': cron job started - CREATE BACKUP'); + ': cron job started - CREATE BACKUP');
exec(__dirname + '/../../backup/backup.sh', (error, stdout, stderr) => { exec(__dirname + '/../../backup/backup.sh', (err, stdout, stderr) => {
if (error) { if (err) {
console.log(error); error(err.message);
} }
console.log('\x1b[32m%s\x1b[0m',stderr); logger('\x1b[32m%s\x1b[0m',stderr);
console.log('\x1b[35m%s\x1b[0m', new Date().toLocaleString() logger('\x1b[35m%s\x1b[0m', new Date().toLocaleString()
+ ': cron job finished - CREATE BACKUP'); + ': cron job finished - CREATE BACKUP');
}) })
}; };

View File

@ -12,8 +12,10 @@ const apiAuthentication = (req, res, next) => {
// decode token // decode token
if (token) { if (token) {
const secret = process.env.NODE_ENV === config.prod.env ? process.env.JWS_SECRET : 'dev-secret';
// verifies secret and checks exp // verifies secret and checks exp
jwt.verify(token, config.secret, (err, decoded) => { jwt.verify(token, secret, (err, decoded) => {
if (err) { if (err) {
return res.status(403).json({success: false, message: 'Failed to authenticate token.'}); return res.status(403).json({success: false, message: 'Failed to authenticate token.'});
} else { } else {

View File

@ -0,0 +1,20 @@
"use strict";
// HTTP status codes by name
const codes = require('../routes/http-codes');
/**
* check if id has valid UUID format
*/
const idValidator = (req, res, next) => {
const reqId = req.params.id;
if (!reqId.match(/^[0-9a-fA-F]{24}$/)) {
const err = new Error("Invalid request id format");
err.status = codes.notfound;
return next(err);
}
next();
};
exports.idValidator = idValidator;

1824
api/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,8 +6,8 @@
"author": "Florian Hartwich <hardi@noarch.de>", "author": "Florian Hartwich <hardi@noarch.de>",
"private": true, "private": true,
"scripts": { "scripts": {
"start": "NODE_ENV=production node server.js", "start": "DEBUG='cc:*' NODE_ENV=production node server.js",
"dev": "NODE_ENV=dev nodemon server.js", "dev": "DEBUG='cc:*' NODE_ENV=dev nodemon server.js",
"test": "mocha --require ./test/config/spec_helper.js", "test": "mocha --require ./test/config/spec_helper.js",
"e2e": "NODE_ENV=test node server.js" "e2e": "NODE_ENV=test node server.js"
}, },
@ -17,25 +17,26 @@
"body-parser": "~1.13.2", "body-parser": "~1.13.2",
"cors": "^2.8.4", "cors": "^2.8.4",
"cron": "^1.3.0", "cron": "^1.3.0",
"debug": "~2.2.0", "debug": "^3.1.0",
"express": "^4.16.1", "express": "^4.16.2",
"imagemin": "^5.2.2", "imagemin": "^5.2.2",
"imagemin-pngquant": "^5.0.0", "imagemin-pngquant": "^5.0.0",
"jimp": "^0.2.27", "jimp": "^0.2.27",
"jsonwebtoken": "^7.4.3", "jsonwebtoken": "^7.4.3",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"mongoose": "^4.12.0", "mongoose": "^5.0.3",
"morgan": "~1.6.1", "morgan": "~1.6.1",
"multer": "^1.3.0", "multer": "^1.3.0",
"node-sha1": "^1.0.1", "node-sha1": "^1.0.1",
"q": "^1.5.0", "q": "^1.5.0",
"serve-favicon": "~2.3.0" "serve-favicon": "~2.3.0",
"supports-color": "^5.1.0"
}, },
"devDependencies": { "devDependencies": {
"chai": "^3.5.0", "chai": "^3.5.0",
"chai-http": "^3.0.0", "chai-http": "^3.0.0",
"mocha": "^3.5.3", "mocha": "^3.5.3",
"nodemon": "^1.12.1" "nodemon": "^1.14.12"
} }
} }

View File

@ -8,9 +8,6 @@ const Q = require('q');
const _ = require('lodash'); const _ = require('lodash');
const logger = require('debug')('cc:authenticate'); const logger = require('debug')('cc:authenticate');
const apiAuthenticationMiddleware = require('../middleware/auth-middleware');
const checkAdmin = require('../middleware/permission-check').checkAdmin;
// HTTP status codes by name // HTTP status codes by name
const codes = require('./http-codes'); const codes = require('./http-codes');
@ -57,12 +54,14 @@ let authCheck = (username, password, res) => {
} }
if (user && user.activated && bcrypt.compareSync(password, user.password)) { if (user && user.activated && bcrypt.compareSync(password, user.password)) {
// authentication successful // authentication successful
const secret = process.env.NODE_ENV === config.prod.env ? process.env.JWS_SECRET : 'dev-secret';
deferred.resolve({ deferred.resolve({
_id: user._id, _id: user._id,
username: user.username, username: user.username,
permission: user.permission, permission: user.permission,
squad: user.squad, squad: user.squad,
token: jwt.sign({sub: user._id}, config.secret, {expiresIn: diff * 60}), token: jwt.sign({sub: user._id}, secret, {expiresIn: diff * 60}),
tokenExpireDate: new Date(Date.now().valueOf() + diff * 60000 - 1000) tokenExpireDate: new Date(Date.now().valueOf() + diff * 60000 - 1000)
}); });
} else { } else {

View File

@ -7,10 +7,12 @@ const logger = require('debug')('cc:campaigns');
// HTTP status codes by name // HTTP status codes by name
const codes = require('./http-codes'); const codes = require('./http-codes');
const routerHandling = require('../middleware/router-handling');
const apiAuthenticationMiddleware = require('../middleware/auth-middleware'); const apiAuthenticationMiddleware = require('../middleware/auth-middleware');
const checkMT = require('../middleware/permission-check').checkMT; const checkMT = require('../middleware/permission-check').checkMT;
const routerHandling = require('../middleware/router-handling');
const idValidator = require('../middleware/validators').idValidator;
// Mongoose Model using mongoDB // Mongoose Model using mongoDB
const CampaignModel = require('../models/campaign'); const CampaignModel = require('../models/campaign');
const WarModel = require('../models/war'); const WarModel = require('../models/war');
@ -41,7 +43,7 @@ campaigns.route('/')
); );
campaigns.route('/:id') campaigns.route('/:id')
.get((req, res, next) => { .get(idValidator, (req, res, next) => {
CampaignModel.findById(req.params.id, (err, item) => { CampaignModel.findById(req.params.id, (err, item) => {
if (err) { if (err) {
err.status = codes.servererror; err.status = codes.servererror;

View File

@ -13,7 +13,9 @@ 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 routerHandling = require('../middleware/router-handling'); const routerHandling = require('../middleware/router-handling');
const idValidator = require('../middleware/validators').idValidator;
// Mongoose Model using mongoDB // Mongoose Model using mongoDB
const DecorationModel = require('../models/decoration'); const DecorationModel = require('../models/decoration');
@ -71,7 +73,7 @@ decoration.route('/')
); );
decoration.route('/:id') decoration.route('/:id')
.get((req, res, next) => { .get(idValidator, (req, res, next) => {
DecorationModel.findById(req.params.id, (err, item) => { DecorationModel.findById(req.params.id, (err, item) => {
if (err) { if (err) {
err.status = codes.servererror; err.status = codes.servererror;

View File

@ -67,19 +67,24 @@ overview.route('/')
if (err) { if (err) {
return next(err); return next(err);
} }
const s = squad.toObject();
s.members = squadMembers; // do not return empty squads
s.memberCount = squadMembers.length; if (squadMembers.length > 0) {
if (s.fraction === 'BLUFOR') { const s = squad.toObject();
delete s.fraction; s.members = squadMembers;
armyOverview.BLUFOR.squads.push(s); s.memberCount = squadMembers.length;
countBlufor += s.members.length; if (s.fraction === 'BLUFOR') {
} delete s.fraction;
if (s.fraction === 'OPFOR') { armyOverview.BLUFOR.squads.push(s);
delete s.fraction; countBlufor += s.members.length;
armyOverview.OPFOR.squads.push(s); }
countOpfor += s.members.length; if (s.fraction === 'OPFOR') {
delete s.fraction;
armyOverview.OPFOR.squads.push(s);
countOpfor += s.members.length;
}
} }
callback(); callback();
}); });
}); });

View File

@ -2,7 +2,7 @@
// modules // modules
const express = require('express'); const express = require('express');
const logger = require('debug')('cc:wars'); const logger = require('debug')('cc:players');
// HTTP status codes by name // HTTP status codes by name
const codes = require('./http-codes'); const codes = require('./http-codes');
@ -17,7 +17,65 @@ const WarModel = require('../models/war');
const campaignPlayer = express.Router(); const campaignPlayer = express.Router();
// routes ********************** // 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 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: getSortedField('kill'),
death: getSortedField('death'),
friendlyFire: getSortedField('friendlyFire'),
revive: getSortedField('revive'),
respawn: getSortedField('respawn'),
flagTouch: getSortedField('flagTouch')
};
next();
})
})
})
.all(
routerHandling.httpMethodNotAllowed
);
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);
@ -31,7 +89,7 @@ campaignPlayer.route('/:campaignId/:playerName')
.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 name'); const err = new Error('Unknown player name');
err.status = codes.notfound; err.status = codes.notfound;
return next(err) return next(err)
} }

View File

@ -13,16 +13,15 @@ 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 routerHandling = require('../middleware/router-handling'); const routerHandling = require('../middleware/router-handling');
const idValidator = require('../middleware/validators').idValidator;
// Mongoose Model using mongoDB // Mongoose Model using mongoDB
const RankModel = require('../models/rank'); const RankModel = require('../models/rank');
const ranks = express.Router(); const ranks = express.Router();
// add middleware for bonus tasks 4 and 5 to find filter and offset/limit params for GET / and GET /:id
// routes ********************** // routes **********************
ranks.route('/') ranks.route('/')
.get((req, res, next) => { .get((req, res, next) => {
@ -74,7 +73,7 @@ ranks.route('/')
ranks.route('/:id') ranks.route('/:id')
.get((req, res, next) => { .get(idValidator, (req, res, next) => {
RankModel.findById(req.params.id, (err, item) => { RankModel.findById(req.params.id, (err, item) => {
if (err) { if (err) {
err.status = codes.servererror; err.status = codes.servererror;

View File

@ -16,6 +16,7 @@ const signatures = express.Router();
// routes ********************** // routes **********************
signatures.route('/:id') signatures.route('/:id')
// does not use idValidator since it works by username
.get((req, res, next) => { .get((req, res, next) => {
// decode UTF8-escape sequences (special characters) // decode UTF8-escape sequences (special characters)
const uri = decodeURIComponent(req.params.id); const uri = decodeURIComponent(req.params.id);

View File

@ -13,7 +13,9 @@ 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 routerHandling = require('../middleware/router-handling'); const routerHandling = require('../middleware/router-handling');
const idValidator = require('../middleware/validators').idValidator;
// Mongoose Model using mongoDB // Mongoose Model using mongoDB
const SquadModel = require('../models/squad'); const SquadModel = require('../models/squad');
@ -74,7 +76,7 @@ squads.route('/')
); );
squads.route('/:id') squads.route('/:id')
.get((req, res, next) => { .get(idValidator, (req, res, next) => {
SquadModel.findById(req.params.id, (err, item) => { SquadModel.findById(req.params.id, (err, item) => {
if (err) { if (err) {
err.status = codes.servererror; err.status = codes.servererror;

View File

@ -10,9 +10,11 @@ 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 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');
const idValidator = require('../middleware/validators').idValidator;
// Mongoose Model using mongoDB // Mongoose Model using mongoDB
const UserModel = require('../models/user'); const UserModel = require('../models/user');
@ -86,7 +88,7 @@ users.route('/')
users.route('/:id') users.route('/:id')
.get((req, res, next) => { .get(idValidator, (req, res, next) => {
UserModel.findById(req.params.id).populate('squadId').exec((err, user) => { UserModel.findById(req.params.id).populate('squadId').exec((err, user) => {
if (err) { if (err) {
err.status = codes.servererror; err.status = codes.servererror;

View File

@ -12,10 +12,14 @@ const logger = require('debug')('cc:wars');
// HTTP status codes by name // HTTP status codes by name
const codes = require('./http-codes'); const codes = require('./http-codes');
// access check
const apiAuthenticationMiddleware = require('../middleware/auth-middleware'); const apiAuthenticationMiddleware = require('../middleware/auth-middleware');
const checkMT = require('../middleware/permission-check').checkMT; const checkMT = require('../middleware/permission-check').checkMT;
const routerHandling = require('../middleware/router-handling');
const routerHandling = require('../middleware/router-handling');
const idValidator = require('../middleware/validators').idValidator;
// log paser tool
const parseWarLog = require('../tools/log-parse-tool'); const parseWarLog = require('../tools/log-parse-tool');
// Mongoose Model using mongoDB // Mongoose Model using mongoDB
@ -139,7 +143,7 @@ wars.route('/')
); );
wars.route('/:id') wars.route('/:id')
.get((req, res, next) => { .get(idValidator, (req, res, next) => {
WarModel.findById(req.params.id, (err, item) => { WarModel.findById(req.params.id, (err, item) => {
if (err) { if (err) {
err.status = codes.servererror; err.status = codes.servererror;

View File

@ -5,7 +5,12 @@ const path = require('path');
const favicon = require('serve-favicon'); const favicon = require('serve-favicon');
const bodyParser = require('body-parser'); const bodyParser = require('body-parser');
const requestLogger = require('morgan'); const requestLogger = require('morgan');
const debug = require('debug')('cc:server');
const debug = require('debug');
const error = debug('cc:server:err');
const logger = debug('cc:server');
logger.log = console.log.bind(console);
const cors = require('cors') const cors = require('cors')
const mongoose = require('mongoose'); const mongoose = require('mongoose');
@ -83,8 +88,8 @@ app.use(urls.request, requestRouter);
app.use(urls.awards, awardingRouter); app.use(urls.awards, awardingRouter);
app.use(urls.wars, warRouter); app.use(urls.wars, warRouter);
app.use(urls.players, playerRouter); app.use(urls.players, playerRouter);
app.use(urls.campaigns,campaignRouter); app.use(urls.campaigns, campaignRouter);
app.use(urls.logs,logRouter); app.use(urls.logs, logRouter);
app.use(urls.command, apiAuthenticationMiddleware, checkAdmin, commandRouter); app.use(urls.command, apiAuthenticationMiddleware, checkAdmin, commandRouter);
app.use(urls.account, apiAuthenticationMiddleware, checkAdmin, accountRouter); app.use(urls.account, apiAuthenticationMiddleware, checkAdmin, accountRouter);
@ -93,44 +98,29 @@ app.use(function (req, res) {
res.sendFile("public/index.html", {root: __dirname + '/..'}); res.sendFile("public/index.html", {root: __dirname + '/..'});
}); });
// (from express-generator boilerplate standard code)
// Errorhandling and requests without proper URLs ************************
// catch 404 and forward to error handler
app.use((req, res, next) => {
debug('Catching unmatched request to answer with 404');
let err = new Error('Not Found');
err.status = 404;
next(err);
});
// register error handlers // register error handlers
errorResponseWare(app); errorResponseWare(app);
// Start the server // Start the server
if (process.env.NODE_ENV !== config.test.env) { if (process.env.NODE_ENV !== config.test.env) {
const mongoosePromise = mongoose.connect(config.database.uri + config.database.db, { const mongoosePromise = mongoose.connect(config.database.uri + config.database.db);
useMongoClient: true
});
mongoosePromise.then((db) => { mongoosePromise.then((db) => {
app.listen(config.port, (err) => { app.listen(config.port, (err) => {
if (err !== undefined) { if (err !== undefined) {
debug('Error on startup, ', err); error('Error on startup, ', err);
} }
else { else {
debug('Listening on port ' + config.port); logger('Listening on port ' + config.port);
signatureCronJob.start(); signatureCronJob.start();
backupCronJob.start(); backupCronJob.start();
} }
}); });
}) })
} else { } else {
const mongoosePromise = mongoose.connect(config.database.uri + config.test.db, { const mongoosePromise = mongoose.connect(config.database.uri + config.test.db);
useMongoClient: true
});
mongoosePromise.then((db) => { mongoosePromise.then((db) => {
app.listen(config.test.port); app.listen(config.test.port);
console.log('Listening on port ' + config.test.port); logger('Listening on port ' + config.test.port);
}) })
} }

View File

@ -2,8 +2,11 @@
const playerArrayContains = require('./util').playerArrayContains; const playerArrayContains = require('./util').playerArrayContains;
const WHITESPACE = ' ';
const parseWarLog = (lineArray, war) => { const parseWarLog = (lineArray, war) => {
const nameToLongError = 'Error: ENAMETOOLONG: name too long, open \''; const NAME_TOO_LONG_ERROR = 'Error: ENAMETOOLONG: name too long, open \'';
const stats = { const stats = {
war: war, war: war,
clean: [], clean: [],
@ -29,25 +32,25 @@ const parseWarLog = (lineArray, war) => {
/** /**
* sanitize nameTooLongError coming up in first line * sanitize nameTooLongError coming up in first line
*/ */
if (line.includes(nameToLongError)) { if (line.includes(NAME_TOO_LONG_ERROR)) {
line = line.substring(line.indexOf(nameToLongError) + nameToLongError.length); line = line.substring(line.indexOf(NAME_TOO_LONG_ERROR) + NAME_TOO_LONG_ERROR.length);
} }
/** /**
* KILLS * KILLS
*/ */
if (line.includes('Abschuss') && !line.includes('Fahrzeug')) { if (line.includes('(Abschuss)') && !line.includes('Fahrzeug')) {
stats.clean.push(line); stats.clean.push(line);
const shooterString = line.substring(line.lastIndexOf(' von: ') + 6, line.lastIndexOf('. :OPT LOG END')); const shooterString = line.substring(line.lastIndexOf(' von: ') + 6, line.lastIndexOf('."'));
const shooter = getPlayerAndFractionFromString(shooterString); const shooter = getPlayerAndFractionFromString(shooterString);
const targetString = line.substring(line.lastIndexOf(' || ') + 4, line.lastIndexOf(' von:')); const targetString = line.substring(line.lastIndexOf(' --- ') + 5, line.lastIndexOf(' von:'));
const target = getPlayerAndFractionFromString(targetString); const target = getPlayerAndFractionFromString(targetString);
stats.kills.push({ stats.kills.push({
war: war._id, war: war._id,
time: getFullTimeDate(war.date, line.split(' ')[5]), time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
shooter: shooter ? shooter.name : null, shooter: shooter ? shooter.name : null,
target: target.name, target: target ? target.name : null,
friendlyFire: shooter ? target.fraction === shooter.fraction : false, friendlyFire: shooter ? target.fraction === shooter.fraction : false,
fraction: shooter ? shooter.fraction : 'NONE' fraction: shooter ? shooter.fraction : 'NONE'
}); });
@ -56,17 +59,18 @@ const parseWarLog = (lineArray, war) => {
/** /**
* BUDGET * BUDGET
*/ */
else if (line.includes('Budget')) { else if (line.includes('(Budget)')) {
stats.clean.push(line); stats.clean.push(line);
const budg = line.split(' '); const budg = line.split(WHITESPACE);
if (line.includes('Startbudget')) { if (line.includes('Startbudget')) {
stats.war['budgetBlufor'] = transformMoneyString(budg[11]); stats.war['budgetBlufor'] = transformMoneyString(budg[9]);
stats.war['budgetOpfor'] = transformMoneyString(budg[14]); stats.war['budgetOpfor'] = transformMoneyString(budg[12].slice(0,-1));
// this date needs to be assigned in first place !important // this date needs to be assigned in first place !important
stats.war.date = new Date(budg[0].substr(0, budg[0].length - 1).split('/').join('-')); const dateString = budg[0].slice(0,-1).split('/');
stats.war.date = new Date(dateString[0], dateString[1], dateString[2])
} else if (line.includes('Endbudget')) { } else if (line.includes('Endbudget')) {
stats.war['endBudgetBlufor'] = transformMoneyString(budg[11]); stats.war['endBudgetBlufor'] = transformMoneyString(budg[9].substr(1));
stats.war['endBudgetOpfor'] = transformMoneyString(budg[14]); stats.war['endBudgetOpfor'] = transformMoneyString(budg[12].slice(0,-1));
stats.war.endDate = getFullTimeDate(war.date, budg[5]); stats.war.endDate = getFullTimeDate(war.date, budg[5]);
} else { } else {
stats.budget.push(getBudgetEntry(budg, war._id, war.date)); stats.budget.push(getBudgetEntry(budg, war._id, war.date));
@ -76,15 +80,15 @@ const parseWarLog = (lineArray, war) => {
/** /**
* FLAG * FLAG
*/ */
else if (line.includes('Fahne')) { else if (line.includes('(Fahne)') && !line.includes('Dominator')) {
stats.clean.push(line); stats.clean.push(line);
const playerName = line.substring(line.lastIndexOf('t von ') + 6, line.lastIndexOf(' :OPT LOG END')); const playerName = line.substring(line.lastIndexOf('rt von ') + 7).slice(0, -2);
const flagFraction = line.includes('NATO Flagge') ? 'BLUFOR' : 'OPFOR'; const flagFraction = line.includes('NATO Flagge') ? 'BLUFOR' : 'OPFOR';
const capture = !!line.includes('Flagge erobert'); const capture = !!line.includes('Flagge erobert');
stats.flag.push({ stats.flag.push({
war: war._id, war: war._id,
time: getFullTimeDate(war.date, line.split(' ')[5]), time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
player: playerName, player: playerName,
flagFraction: flagFraction, flagFraction: flagFraction,
capture: capture capture: capture
@ -94,13 +98,13 @@ const parseWarLog = (lineArray, war) => {
/** /**
* POINTS * POINTS
*/ */
else if (line.includes('Punkte')) { else if (line.includes('(Punkte)')) {
stats.clean.push(line); stats.clean.push(line);
const pt = line.split(' '); const pt = line.split(WHITESPACE);
if (line.includes('Endpunktestand')) { if (line.includes('Endpunktestand')) {
stats.war['ptBlufor'] = parseInt(pt[11]); stats.war['ptBlufor'] = parseInt(pt[9]);
stats.war['ptOpfor'] = parseInt(pt[14].slice(0, -1)); stats.war['ptOpfor'] = parseInt(pt[12].slice(0, -1));
// EXIT LOOP // EXIT LOOP
return true; return true;
} else { } else {
@ -111,28 +115,27 @@ const parseWarLog = (lineArray, war) => {
/** /**
* RESPAWN * RESPAWN
*/ */
else if (line.includes('Respawn')) { else if (line.includes('(Respawn)')) {
stats.clean.push(line); const resp = line.split(WHITESPACE);
const resp = line.split(' '); const playerName = line.substring(line.lastIndexOf('Spieler:') + 9, line.lastIndexOf('- Kosten') -1);
const playerName = line.substring(line.lastIndexOf('Spieler:') + 9, line.lastIndexOf('-') - 1);
stats.respawn.push(getRespawnEntry(resp, playerName, war._id, war.date)); stats.respawn.push(getRespawnEntry(resp, playerName, war._id, war.date));
} }
/** /**
* REVIVE * REVIVE
*/ */
else if (line.includes('Revive')) { else if (line.includes('(Revive)')) {
stats.clean.push(line); stats.clean.push(line);
const stabilized = !!line.includes('stabilisiert'); const stabilized = !!line.includes('stabilisiert."');
const medicName = line.substring(line.lastIndexOf('wurde von ') + 10, const medicName = line.substring(line.lastIndexOf('wurde von ') + 10,
line.lastIndexOf(stabilized ? ' stabilisiert' : ' wiederbelebt')); line.lastIndexOf(stabilized ? ' stabilisiert' : ' wiederbelebt'));
const medic = getPlayerAndFractionFromString(medicName); const medic = getPlayerAndFractionFromString(medicName);
const patientName = line.substring(line.lastIndexOf('|| ') + 3, line.lastIndexOf(' wurde von')); const patientName = line.substring(line.lastIndexOf('--- ') + 4, line.lastIndexOf(' wurde von'));
const patient = getPlayerAndFractionFromString(patientName); const patient = getPlayerAndFractionFromString(patientName);
stats.revive.push({ stats.revive.push({
war: war._id, war: war._id,
time: getFullTimeDate(war.date, line.split(' ')[5]), time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
stabilized: stabilized, stabilized: stabilized,
medic: medic.name, medic: medic.name,
patient: patient.name, patient: patient.name,
@ -143,20 +146,20 @@ const parseWarLog = (lineArray, war) => {
/** /**
* TRANSPORT * TRANSPORT
*/ */
else if (line.includes('Transport ||')) { else if (line.includes('(Transport)')) {
stats.clean.push(line); stats.clean.push(line);
const driverString = line.substring(line.lastIndexOf('wurde von ') + 10, line.lastIndexOf(' eingeflogen')); const driverString = line.substring(line.lastIndexOf('wurde von ') + 10, line.lastIndexOf(' eingeflogen'));
const driver = getPlayerAndFractionFromString(driverString); const driver = getPlayerAndFractionFromString(driverString);
const passengerString = line.substring(line.lastIndexOf('|| ') + 3, line.lastIndexOf(' wurde von')); const passengerString = line.substring(line.lastIndexOf('--- ') + 3, line.lastIndexOf(' wurde von'));
const passenger = getPlayerAndFractionFromString(passengerString); const passenger = getPlayerAndFractionFromString(passengerString);
const distance = parseInt(line.substring(line.lastIndexOf('eingeflogen (') + 13, line.lastIndexOf('m)') - 1)); const distance = parseInt(line.substring(line.lastIndexOf('eingeflogen (') + 13, line.lastIndexOf('m)') - 1));
stats.transport.push({ stats.transport.push({
war: war._id, war: war._id,
time: getFullTimeDate(war.date, line.split(' ')[5]), time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
driver: driver.name, driver: driver ? driver.name : null,
passenger: passenger ? passenger.name : null, passenger: passenger ? passenger.name : null,
fraction: driver.fraction, fraction: driver ? driver.fraction : 'NONE',
distance: distance distance: distance
}); });
} }
@ -164,8 +167,8 @@ const parseWarLog = (lineArray, war) => {
/** /**
* PLAYERS * PLAYERS
*/ */
else if (line.includes('Fraktionsübersicht ||')) { else if (line.includes('(Fraktionsuebersicht)')) {
const playerString = line.substring(line.lastIndexOf('Fraktionsübersicht || ') + 22, line.lastIndexOf(', PUID')); const playerString = line.substring(line.lastIndexOf('--- ') + 4, line.lastIndexOf(', PUID'));
addPlayerIfNotExists(playerString) addPlayerIfNotExists(playerString)
} }
}); });
@ -200,9 +203,9 @@ const getPointsEntry = (pt, line, warId, warDate) => {
return { return {
war: warId, war: warId,
time: getFullTimeDate(warDate, pt[5]), time: getFullTimeDate(warDate, pt[5]),
ptBlufor: parseInt(pt[12]), ptBlufor: parseInt(pt[10]),
ptOpfor: parseInt(pt[15].slice(0, -1)), ptOpfor: parseInt(pt[13].slice(0, -3)),
fraction: line.includes('no Domination') ? 'NONE' : line.includes('NATO +1') ? 'BLUFOR' : 'OPFOR' fraction: line.includes('Kein Dominator') ? 'NONE' : line.includes('NATO +1') ? 'BLUFOR' : 'OPFOR'
} }
}; };
@ -210,14 +213,14 @@ const getBudgetEntry = (budg, warId, warDate) => {
return { return {
war: warId, war: warId,
time: getFullTimeDate(warDate, budg[5]), time: getFullTimeDate(warDate, budg[5]),
fraction: budg[9] === 'NATO' ? 'BLUFOR' : 'OPFOR', fraction: budg[7] === 'NATO' ? 'BLUFOR' : 'OPFOR',
oldBudget: transformMoneyString(budg[11]), oldBudget: transformMoneyString(budg[9]),
newBudget: transformMoneyString(budg[14]) newBudget: transformMoneyString(budg[12])
} }
}; };
const getPlayerAndFractionFromString = (nameAndFractionString) => { const getPlayerAndFractionFromString = (nameAndFractionString) => {
const nameArray = nameAndFractionString.split(' '); const nameArray = nameAndFractionString.split(WHITESPACE);
const fraction = nameArray[nameArray.length - 1] !== '(ENEMY)' ? nameArray[nameArray.length - 1] === '(WEST)' ? 'BLUFOR' : 'OPFOR' : undefined; const fraction = nameArray[nameArray.length - 1] !== '(ENEMY)' ? nameArray[nameArray.length - 1] === '(WEST)' ? 'BLUFOR' : 'OPFOR' : undefined;
const name = nameAndFractionString.substring(0, nameAndFractionString.indexOf(nameArray[nameArray.length - 1]) - 1); const name = nameAndFractionString.substring(0, nameAndFractionString.indexOf(nameArray[nameArray.length - 1]) - 1);
// do not return player for 'Selbstverschulden' or 'Error: No unit' // do not return player for 'Selbstverschulden' or 'Error: No unit'

View File

@ -23,7 +23,7 @@ do
# provide date for restore process, if data import is needed # provide date for restore process, if data import is needed
if [ -z "$1" ] if [ -z "$1" ]
then then
echo "table ${i}" (>&2 echo -e "$(date "+%Y-%m-%dT%T.%3N%z")\tTable: ${i}")
mongoexport --db cc --collection $i --out ${DATE}/collections/${i}.json; mongoexport --db cc --collection $i --out ${DATE}/collections/${i}.json;
else else
mongoimport --db cc --collection $i --drop --file ${1}/collections/${i}.json mongoimport --db cc --collection $i --drop --file ${1}/collections/${i}.json

View File

@ -0,0 +1,38 @@
#!/bin/bash
cd $(dirname $0)
#####################################################
###### INSTALL ALL REQUIRED 3RD-PARTY SOFTWARE ######
#####################################################
# MONGO DB COMMUNITY
# NPM
# NODE
# mongodb key & repo
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | \
sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
# install from apt
sudo apt-get update
sudo apt-get install -y mongodb-org npm
# enable mongod for autostart
sudo systemctl enable mongod.service
# install latest node version
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
source ~/.nvm/nvm.sh
nvm install stable
sudo ln -s ~/.nvm/versions/node/$(node -v)/bin/node /usr/bin/node
# upgrade to latest npm version
sudo npm install -g npm@latest
if [ "${1}" == "prod" ]; then
sudo npm install -g pm2
pm2 start ./../../pm2-start.json
pm2 startup systemd
fi

View File

@ -1,4 +1,3 @@
server { server {
listen 80; listen 80;
server_name cc.noarch.de; server_name cc.noarch.de;
@ -9,6 +8,8 @@ server {
listen 443 ssl; listen 443 ssl;
server_name cc.noarch.de; server_name cc.noarch.de;
server_tokens off;
ssl on; ssl on;
ssl_certificate /etc/letsencrypt/live/noarch.de/fullchain.pem; ssl_certificate /etc/letsencrypt/live/noarch.de/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/noarch.de/privkey.pem; ssl_certificate_key /etc/letsencrypt/live/noarch.de/privkey.pem;

Binary file not shown.

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "opt-cc", "name": "opt-cc",
"version": "1.6.3", "version": "1.6.7",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -5,7 +5,10 @@
"script": "./api/server.js", "script": "./api/server.js",
"watch": false, "watch": false,
"env": { "env": {
"TZ": "Europe/Berlin" "NODE_ENV": "production",
"DEBUG": "cc:*",
"TZ": "Europe/Berlin",
"JWS_SECRET": "secret"
} }
} }
] ]

7
static/LICENSE.txt Normal file
View File

@ -0,0 +1,7 @@
Copyright 2018 "HardiReady" Florian Hartwich
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

819
static/package-lock.json generated
View File

@ -208,9 +208,32 @@
} }
}, },
"@swimlane/ngx-charts": { "@swimlane/ngx-charts": {
"version": "6.1.0", "version": "7.1.0",
"resolved": "https://registry.npmjs.org/@swimlane/ngx-charts/-/ngx-charts-6.1.0.tgz", "resolved": "https://registry.npmjs.org/@swimlane/ngx-charts/-/ngx-charts-7.1.0.tgz",
"integrity": "sha512-918ksaRl8RvGWGOjpUCywTS1MnLTqHki53XXibyhZkmHGSP5yLkcArBAFhFLvtQTTbuX8KSz2WFKxwaJ3JuJFw==" "integrity": "sha512-1WMIsqcAczveN4M2WJO51BvqsFfTJ8mmq/nmvkaNBYoG98n1USoqo52itxzKJKLRnImItZnYdl+pW9WueyRlsw==",
"requires": {
"d3-array": "1.2.1",
"d3-brush": "1.0.4",
"d3-color": "1.0.3",
"d3-force": "1.1.0",
"d3-format": "1.2.0",
"d3-hierarchy": "1.1.5",
"d3-interpolate": "1.1.5",
"d3-scale": "1.0.6",
"d3-selection": "1.1.0",
"d3-shape": "1.2.0",
"d3-time-format": "2.1.1"
},
"dependencies": {
"d3-time-format": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-2.1.1.tgz",
"integrity": "sha512-8kAkymq2WMfzW7e+s/IUNAtN/y3gZXGRrdGfo6R8NKPAA85UBTxZg5E61bR6nLwjPjj4d3zywSQe1CkYLPFyrw==",
"requires": {
"d3-time": "1.0.7"
}
}
}
}, },
"@swimlane/ngx-datatable": { "@swimlane/ngx-datatable": {
"version": "11.0.4", "version": "11.0.4",
@ -1160,6 +1183,7 @@
"requires": { "requires": {
"anymatch": "1.3.2", "anymatch": "1.3.2",
"async-each": "1.0.1", "async-each": "1.0.1",
"fsevents": "1.1.3",
"glob-parent": "2.0.0", "glob-parent": "2.0.0",
"inherits": "2.0.3", "inherits": "2.0.3",
"is-binary-path": "1.0.1", "is-binary-path": "1.0.1",
@ -3164,6 +3188,795 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" "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": { "fstream": {
"version": "1.0.11", "version": "1.0.11",
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz",

View File

@ -23,7 +23,7 @@
"@angular/platform-browser": "^5.0.0", "@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0", "@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0", "@angular/router": "^5.0.0",
"@swimlane/ngx-charts": "^6.1.0", "@swimlane/ngx-charts": "^7.1.0",
"@swimlane/ngx-datatable": "^11.0.4", "@swimlane/ngx-datatable": "^11.0.4",
"bootstrap": "^3.3.7", "bootstrap": "^3.3.7",
"d3": "^4.11.0", "d3": "^4.11.0",

View File

@ -30,7 +30,7 @@ export class AppComponent {
} }
if (event instanceof NavigationEnd) { if (event instanceof NavigationEnd) {
this.loading = false; this.loading = false;
if (router.url.includes('overview')) { if (router.url.includes(RouteConfig.overviewPath)) {
window.scrollTo({left: 0, top: 0, behavior: 'smooth'}); window.scrollTo({left: 0, top: 0, behavior: 'smooth'});
} }
} }

View File

@ -35,4 +35,4 @@ export const RouteConfig = {
requestPromotionPath: 'promotion', requestPromotionPath: 'promotion',
confirmAwardPath: 'confirm-award', confirmAwardPath: 'confirm-award',
confirmPromotionPath: 'confirm-promotion' confirmPromotionPath: 'confirm-promotion'
} };

View File

@ -32,6 +32,10 @@
color: white; color: white;
} }
tbody {
background: #ffffffe0;
}
.cell-outline { .cell-outline {
outline: 1px solid #D4D4D4; outline: 1px solid #D4D4D4;
} }

View File

@ -1,4 +1,4 @@
import {Component} from "@angular/core"; import {Component, Inject} from "@angular/core";
import {Award, 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/army-management/user.service"; import {UserService} from "../services/army-management/user.service";
@ -6,6 +6,8 @@ import {Subscription} from "rxjs/Subscription";
import {RouteConfig} from "../app.config"; import {RouteConfig} from "../app.config";
import {AwardingService} from "../services/army-management/awarding.service"; import {AwardingService} from "../services/army-management/awarding.service";
import {Fraction} from "../utils/fraction.enum"; import {Fraction} from "../utils/fraction.enum";
import {DOCUMENT} from "@angular/common";
import {CSSHelpers} from "../global.helpers";
@Component({ @Component({
@ -30,10 +32,14 @@ export class ArmyMemberComponent {
constructor(private router: Router, constructor(private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private userService: UserService, private userService: UserService,
private awardingService: AwardingService) { private awardingService: AwardingService,
@Inject(DOCUMENT) private document) {
} }
ngOnInit() { ngOnInit() {
// set background image css
this.document.getElementById('right').setAttribute('style', CSSHelpers.getBackgroundCSS('../assets/bg.jpg'));
this.subscription = this.route.params this.subscription = this.route.params
.map(params => params['id']) .map(params => params['id'])
.filter(id => id != undefined) .filter(id => id != undefined)
@ -48,6 +54,12 @@ export class ArmyMemberComponent {
}; };
ngOnDestroy() {
if (this.router.url !== '/' + RouteConfig.overviewPath) {
this.document.getElementById('right').setAttribute('style', '');
}
}
backToOverview() { backToOverview() {
this.router.navigate([RouteConfig.overviewPath]); this.router.navigate([RouteConfig.overviewPath]);
} }

View File

@ -27,7 +27,7 @@
.middle-row { .middle-row {
min-height: 120px; min-height: 120px;
border: rgb(34, 34, 34); border: rgb(34, 34, 34);
background-color: white; background-color: #ffffffe0;
border-left-style: solid; border-left-style: solid;
border-right-style: solid; border-right-style: solid;
} }
@ -63,3 +63,13 @@ img {
text-align: center text-align: center
} }
.member-count {
margin-top: 15px;
padding: 8px;
text-align: center;
font-weight: bold;
color: whitesmoke;
background: #222222;
border-radius: 12px;
}

View File

@ -27,7 +27,7 @@
</div> </div>
</div> </div>
</div> </div>
<div style="padding: 20px; text-align: center;">Armeemitglieder: {{army.BLUFOR.memberCount}}</div> <div class="member-count">Armeemitglieder: {{army.BLUFOR.memberCount}}</div>
</div> </div>
<div class="pull-right" style="width: 45%;"> <div class="pull-right" style="width: 45%;">
@ -56,7 +56,7 @@
</div> </div>
</div> </div>
</div> </div>
<div style="padding: 20px; text-align: center;">Armeemitglieder: {{army.OPFOR.memberCount}}</div> <div class="member-count">Armeemitglieder: {{army.OPFOR.memberCount}}</div>
</div> </div>
</div> </div>

View File

@ -1,8 +1,11 @@
import {Component} from "@angular/core"; import {Component, Inject} from "@angular/core";
import {Army} from "../models/model-interfaces"; import {Army} from "../models/model-interfaces";
import {ArmyService} from "../services/army-service/army.service"; import {ArmyService} from "../services/army-service/army.service";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {Fraction} from "../utils/fraction.enum"; import {Fraction} from "../utils/fraction.enum";
import {DOCUMENT} from "@angular/common";
import {RouteConfig} from "../app.config";
import {CSSHelpers} from "../global.helpers";
@Component({ @Component({
@ -18,16 +21,27 @@ export class ArmyComponent {
constructor(private router: Router, constructor(private router: Router,
private route: ActivatedRoute, private route: ActivatedRoute,
private armyService: ArmyService) { private armyService: ArmyService,
@Inject(DOCUMENT) private document) {
} }
ngOnInit() { ngOnInit() {
// set background image css
this.document.getElementById('right').setAttribute('style', CSSHelpers.getBackgroundCSS('../assets/bg.jpg'));
// init army data
this.armyService.getArmy() this.armyService.getArmy()
.subscribe(army => { .subscribe(army => {
this.army = army; this.army = army;
}); });
}; };
ngOnDestroy() {
if (!this.router.url.includes(RouteConfig.overviewPath)) {
this.document.getElementById('right').setAttribute('style', '');
}
}
select(memberId) { select(memberId) {
this.router.navigate([{outlets: {'right': ['member', memberId]}}], {relativeTo: this.route}); this.router.navigate([{outlets: {'right': ['member', memberId]}}], {relativeTo: this.route});
} }

View File

@ -0,0 +1,9 @@
export const CSSHelpers = {
getBackgroundCSS: (imageUrl) => {
return 'background-image: url(' + imageUrl + ');' +
'background-size: cover;' +
'background-attachment: fixed;' +
'background-position: center;' +
'background-repeat: no-repeat;';
}
};

View File

@ -19,6 +19,7 @@ export interface User {
export interface Player { export interface Player {
_id?: string; _id?: string;
num?: string; // ranking number for high score
fraction?: string; fraction?: string;
name?: string; name?: string;
warId?: War; warId?: War;

View File

@ -10,7 +10,12 @@ export class PlayerService {
} }
getCampaignPlayer(campaignId: string, playerName: string) { 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())
}
getCampaignHighscore(campaignId: string) {
return this.http.get(this.config.apiPlayersPath + '/ranking/' + campaignId)
.map(res => res.json()) .map(res => res.json())
} }

View File

@ -0,0 +1,75 @@
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 {
overflow-x: hidden;
}
: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 */

View File

@ -0,0 +1,145 @@
<div class="highscore-container fade-in">
<h2>{{title}} ⟶ Highscore</h2>
<div class="input-group search-field">
<input id="search-tasks"
placeholder="Spielername (mehrere mit '&' trennen)"
type="text" #query class="form-control"
(keyup.enter)="filterPlayers()"
[formControl]="searchTerm">
<span class="input-group-btn">
<button class="btn btn-default" type="button"
(click)="filterPlayers()">
Filter
</button>
</span>
</div>
<ngx-datatable
[rows]="players.kill"
[messages]="emptyMessage"
[headerHeight]="cellHeight"
[rowHeight]="cellHeight"
[cssClasses]='customClasses'
[columnMode]="'force'"
[scrollbarV]="true"
[selectionType]="'single'">
<ngx-datatable-column [width]="numberColWidth" name="#" prop="num"></ngx-datatable-column>
<ngx-datatable-column name="Spieler" prop="name" [width]="nameColWidth" style="padding-left:10px">
<ng-template ngx-datatable-cell-template let-row="row" let-value="value">
<span class="player-name"
[style.color]="row['fraction'] === 'BLUFOR' ? fraction.COLOR_BLUFOR : fraction.COLOR_OPFOR">
{{value}}
</span>
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column [width]="valueColWidth" name="Kills" prop="kill"></ngx-datatable-column>
</ngx-datatable>
<ngx-datatable
[rows]="players.death"
[messages]="emptyMessage"
[headerHeight]="cellHeight"
[rowHeight]="cellHeight"
[cssClasses]='customClasses'
[columnMode]="'force'"
[scrollbarV]="true"
[selectionType]="'single'">
<ngx-datatable-column [width]="numberColWidth" name="#" prop="num"></ngx-datatable-column>
<ngx-datatable-column name="Spieler" prop="name" [width]="nameColWidth" style="padding-left:10px">
<ng-template ngx-datatable-cell-template let-row="row" let-value="value">
<span class="player-name"
[style.color]="row['fraction'] === 'BLUFOR' ? fraction.COLOR_BLUFOR : fraction.COLOR_OPFOR">
{{value}}
</span>
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column [width]="valueColWidth" name="Tode" prop="death"></ngx-datatable-column>
</ngx-datatable>
<ngx-datatable
[rows]="players.respawn"
[messages]="emptyMessage"
[headerHeight]="cellHeight"
[rowHeight]="cellHeight"
[cssClasses]='customClasses'
[columnMode]="'force'"
[scrollbarV]="true"
[selectionType]="'single'">
<ngx-datatable-column [width]="numberColWidth" name="#" prop="num"></ngx-datatable-column>
<ngx-datatable-column name="Spieler" prop="name" [width]="nameColWidth" style="padding-left:10px">
<ng-template ngx-datatable-cell-template let-row="row" let-value="value">
<span class="player-name"
[style.color]="row['fraction'] === 'BLUFOR' ? fraction.COLOR_BLUFOR : fraction.COLOR_OPFOR">
{{value}}
</span>
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column [width]="valueColWidth" name="Respawn" prop="respawn"></ngx-datatable-column>
</ngx-datatable>
<ngx-datatable
[rows]="players.friendlyFire"
[messages]="emptyMessage"
[headerHeight]="cellHeight"
[rowHeight]="cellHeight"
[cssClasses]='customClasses'
[columnMode]="'force'"
[scrollbarV]="true"
[selectionType]="'single'">
<ngx-datatable-column [width]="numberColWidth" name="#" prop="num"></ngx-datatable-column>
<ngx-datatable-column name="Spieler" prop="name" [width]="nameColWidth" style="padding-left:10px">
<ng-template ngx-datatable-cell-template let-row="row" let-value="value">
<span class="player-name"
[style.color]="row['fraction'] === 'BLUFOR' ? fraction.COLOR_BLUFOR : fraction.COLOR_OPFOR">
{{value}}
</span>
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column [width]="valueColWidth" name="FriendlyFire" prop="friendlyFire"></ngx-datatable-column>
</ngx-datatable>
<ngx-datatable
[rows]="players.revive"
[messages]="emptyMessage"
[headerHeight]="cellHeight"
[rowHeight]="cellHeight"
[cssClasses]='customClasses'
[columnMode]="'force'"
[scrollbarV]="true"
[selectionType]="'single'">
<ngx-datatable-column [width]="numberColWidth" name="#" prop="num"></ngx-datatable-column>
<ngx-datatable-column name="Spieler" prop="name" [width]="nameColWidth" style="padding-left:10px">
<ng-template ngx-datatable-cell-template let-row="row" let-value="value">
<span class="player-name"
[style.color]="row['fraction'] === 'BLUFOR' ? fraction.COLOR_BLUFOR : fraction.COLOR_OPFOR">
{{value}}
</span>
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column [width]="valueColWidth" name="Revive" prop="revive"></ngx-datatable-column>
</ngx-datatable>
<ngx-datatable
[rows]="players.flagTouch"
[messages]="emptyMessage"
[headerHeight]="cellHeight"
[rowHeight]="cellHeight"
[cssClasses]='customClasses'
[columnMode]="'force'"
[scrollbarV]="true"
[selectionType]="'single'">
<ngx-datatable-column [width]="numberColWidth" name="#" prop="num"></ngx-datatable-column>
<ngx-datatable-column name="Spieler" prop="name" [width]="nameColWidth" style="padding-left:10px">
<ng-template ngx-datatable-cell-template let-row="row" let-value="value">
<span class="player-name"
[style.color]="row['fraction'] === 'BLUFOR' ? fraction.COLOR_BLUFOR : fraction.COLOR_OPFOR">
{{value}}
</span>
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column [width]="valueColWidth" name="Eroberung" prop="flagTouch"></ngx-datatable-column>
</ngx-datatable>
</div>

View File

@ -0,0 +1,110 @@
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";
import {FormControl} from "@angular/forms";
import {Observable} from "rxjs/Observable";
import {Player} from "../../models/model-interfaces";
@Component({
selector: 'stats-highscore',
templateUrl: './highscore.component.html',
styleUrls: ['./highscore.component.css', '../../style/list-entry.css', '../../style/overview.css'],
inputs: ['campaigns']
})
export class StatisticHighScoreComponent {
id = '';
title = '';
searchTerm = new FormControl();
players : Player = {};
playersStored = {};
cellHeight = 40;
numberColWidth = 60;
nameColWidth = 210;
valueColWidth = 110;
emptyMessage = {emptyMessage: 'Keine Einträge'};
customClasses = {
sortAscending: 'glyphicon glyphicon-triangle-top',
sortDescending: 'glyphicon glyphicon-triangle-bottom',
};
readonly fraction = Fraction;
constructor(private route: ActivatedRoute,
private playerService: PlayerService,
private campaignService: CampaignService) {
}
ngOnInit() {
this.route.params
.map(params => params['id'])
.subscribe((id) => {
this.id = id;
if (this.campaignService.campaigns) {
this.initData();
} else {
this.campaignService.getAllCampaigns().subscribe(campaigns => {
this.initData()
})
}
});
const searchTermStream = this.searchTerm.valueChanges.debounceTime(400);
Observable.merge(searchTermStream)
.distinctUntilChanged().map(query => this.filterPlayers())
.subscribe();
}
initData() {
this.title = this.campaignService.campaigns
.filter(camp => camp._id === this.id).pop().title;
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().split('&');
return this.playersStored[attribute].filter(player => {
for (let i = 0; i < query.length; i++) {
if (query[i].trim() != '' && player.name.toLowerCase().includes(query[i].trim())) {
return true;
}
}
return false;
})
}
}

View File

@ -1,6 +1,5 @@
import {Component} from "@angular/core"; import {Component} from "@angular/core";
import {ActivatedRoute} from "@angular/router"; import {ActivatedRoute} from "@angular/router";
import {CarouselConfig} from "ngx-bootstrap";
import {CampaignService} from "../../services/logs/campaign.service"; import {CampaignService} from "../../services/logs/campaign.service";
import {ChartUtils} from "../../utils/chart-utils"; import {ChartUtils} from "../../utils/chart-utils";
import {Fraction} from "../../utils/fraction.enum"; import {Fraction} from "../../utils/fraction.enum";
@ -10,8 +9,7 @@ import {Fraction} from "../../utils/fraction.enum";
selector: 'stats-overview', selector: 'stats-overview',
templateUrl: './stats-overview.component.html', templateUrl: './stats-overview.component.html',
styleUrls: ['./stats-overview.component.css', '../../style/list-entry.css', '../../style/overview.css'], styleUrls: ['./stats-overview.component.css', '../../style/list-entry.css', '../../style/overview.css'],
inputs: ['campaigns'], inputs: ['campaigns']
providers: [{provide: CarouselConfig, useValue: {interval: false}}]
}) })
export class StatisticOverviewComponent { export class StatisticOverviewComponent {

View File

@ -11,6 +11,7 @@ import {ScoreboardComponent} from "./war-detail/scoreboard/scoreboard.component"
import {WarSubmitComponent} from "./war-submit/war-submit.component"; import {WarSubmitComponent} from "./war-submit/war-submit.component";
import {FractionStatsComponent} from "./war-detail/fraction-stats/fraction-stats.component"; import {FractionStatsComponent} from "./war-detail/fraction-stats/fraction-stats.component";
import {WarPlayerDetailComponent} from "./war-player-detail/war-player-detail.component"; import {WarPlayerDetailComponent} from "./war-player-detail/war-player-detail.component";
import {StatisticHighScoreComponent} from "./highscore/highscore.component";
export const statsRoutes: Routes = [{ export const statsRoutes: Routes = [{
@ -27,6 +28,11 @@ export const statsRoutes: Routes = [{
component: StatisticOverviewComponent, component: StatisticOverviewComponent,
outlet: 'right' outlet: 'right'
}, },
{
path: 'highscore/:id',
component: StatisticHighScoreComponent,
outlet: 'right'
},
{ {
path: 'new-campaign', path: 'new-campaign',
component: CampaignSubmitComponent, component: CampaignSubmitComponent,
@ -50,7 +56,6 @@ export const statsRoutes: Routes = [{
export const statsRouterModule: ModuleWithProviders = RouterModule.forChild(statsRoutes); export const statsRouterModule: ModuleWithProviders = RouterModule.forChild(statsRoutes);
export const statsRoutingComponents = [StatisticComponent, StatisticOverviewComponent, CampaignSubmitComponent, export const statsRoutingComponents = [StatisticComponent, StatisticOverviewComponent, StatisticHighScoreComponent,
WarListComponent, WarSubmitComponent, WarDetailComponent, ScoreboardComponent, FractionStatsComponent, CampaignSubmitComponent, WarListComponent, WarSubmitComponent, WarDetailComponent, ScoreboardComponent,
CampaignPlayerDetailComponent, WarPlayerDetailComponent, WarItemComponent]; FractionStatsComponent, CampaignPlayerDetailComponent, WarPlayerDetailComponent, WarItemComponent];

View File

@ -42,6 +42,24 @@ ngx-datatable {
background-color: #f7f7f7; 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 { .in-table-btn {
position: absolute; position: absolute;
margin-top: -5px; margin-top: -5px;

View File

@ -39,18 +39,3 @@
.nav-tabs > li.deactivated > a.nav-link { .nav-tabs > li.deactivated > a.nav-link {
cursor: not-allowed !important; 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);
}

View File

@ -66,7 +66,7 @@ export class WarDetailComponent {
this.fractionStatsInitialized = true; this.fractionStatsInitialized = true;
}); });
} }
window.scroll({left: 0, top: 0, behavior: 'smooth'}); window.scrollTo({left: 0, top: 0, behavior: 'smooth'});
} }
/** /**

View File

@ -5,3 +5,10 @@
color: white; color: white;
font-weight: 600; font-weight: 600;
} }
.top-list-entry {
margin-top: -16px;
margin-bottom: 10px;
width: 50%;
float: left;
}

View File

@ -20,24 +20,33 @@
</span> </span>
</div> </div>
<div class="fade-in list-entry" style="margin-top: -16px; margin-bottom: 10px;" <div class="fade-in list-entry top-list-entry"
[ngClass]="{selected : selectedWarId == campaign._id}" (click)="selectOverview(campaign._id)"> [ngClass]="{selected : selectedWarId == campaign._id}" (click)="selectOverview(campaign._id)">
<div class="row"> <div style="margin: auto;">
<div class="col-xs-9"> <span style="margin:auto">
<span style="margin:auto"> <a style="font-size: 22px;">Übersicht</a>
<a style="font-size: 22px;">Kampagnenübersicht</a> </span>
</span>
</div>
</div> </div>
</div> </div>
<div *ngFor="let war of campaign.wars"> <div class="fade-in list-entry top-list-entry"
<pjm-war-item [ngClass]="{selected : selectedWarId == campaign._id + highscore}" (click)="selectHighscore(campaign._id)">
[war]="war" <div style="margin: auto">
(warDelete)="deleteWar(war)" <span style="margin:auto">
(warSelected)="selectWar($event)" <a style="font-size: 22px;">Highscore</a>
[selected]="war._id == selectedWarId"> </span>
</pjm-war-item> </div>
</div>
<div style="padding-top: 40px;">
<div *ngFor="let war of campaign.wars">
<pjm-war-item
[war]="war"
(warDelete)="deleteWar(war)"
(warSelected)="selectWar($event)"
[selected]="war._id == selectedWarId">
</pjm-war-item>
</div>
</div> </div>
</accordion-group> </accordion-group>
</accordion> </accordion>

View File

@ -17,6 +17,8 @@ export class WarListComponent implements OnInit {
campaigns: Campaign[] = []; campaigns: Campaign[] = [];
public readonly highscore = 'HIGHSCORE';
constructor(private warService: WarService, constructor(private warService: WarService,
private campaignService: CampaignService, private campaignService: CampaignService,
public loginService: LoginService, public loginService: LoginService,
@ -59,10 +61,17 @@ export class WarListComponent implements OnInit {
} }
} }
selectOverview(overviewId) { selectOverview(campaignId) {
if (this.selectedWarId != overviewId) { if (this.selectedWarId != campaignId) {
this.selectedWarId = overviewId; this.selectedWarId = campaignId;
this.router.navigate([{outlets: {'right': ['overview', overviewId]}}], {relativeTo: this.route}); 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});
} }
} }

BIN
static/src/assets/bg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 KiB