28
README.md
|
@ -6,6 +6,32 @@ _MEAN Application_
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
## Development
|
### Setup mongoDB
|
||||||
|
|
||||||
|
https://docs.mongodb.com/manual/administration/install-community/
|
||||||
|
|
||||||
|
### Setup node and npm
|
||||||
|
|
||||||
|
sudo apt-get install npm nodejs-legacy
|
||||||
|
|
||||||
|
update to latest npm version
|
||||||
|
|
||||||
|
sudo npm install -g npm@latest
|
||||||
|
|
||||||
|
update node to latest version
|
||||||
|
|
||||||
|
sudo npm install -g n@latest
|
||||||
|
n latest
|
||||||
|
|
||||||
|
check versions
|
||||||
|
|
||||||
|
npm -v
|
||||||
|
node -v
|
||||||
|
|
||||||
|
## Development and Execution
|
||||||
|
|
||||||
|
### First run in dev mode
|
||||||
|
|
||||||
|
### Run in Production
|
||||||
|
|
||||||
## License Information
|
## License Information
|
||||||
|
|
|
@ -8,6 +8,7 @@ module.exports = {
|
||||||
cmdCreateSig: rootRoute + '/cmd/createSignature',
|
cmdCreateSig: rootRoute + '/cmd/createSignature',
|
||||||
command: rootRoute + '/cmd',
|
command: rootRoute + '/cmd',
|
||||||
decorations: rootRoute + '/decorations',
|
decorations: rootRoute + '/decorations',
|
||||||
|
logs: rootRoute + '/logs',
|
||||||
overview: rootRoute + '/overview',
|
overview: rootRoute + '/overview',
|
||||||
players: rootRoute + '/players',
|
players: rootRoute + '/players',
|
||||||
ranks: rootRoute + '/ranks',
|
ranks: rootRoute + '/ranks',
|
||||||
|
|
|
@ -4,7 +4,7 @@ const cron = require('cron');
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const {exec} = require('child_process');
|
const {exec} = require('child_process');
|
||||||
const UserModel = require('../models/user');
|
const UserModel = require('../models/user');
|
||||||
const signatureTool = require('../signature-tool/signature-tool');
|
const signatureTool = require('../tools/signature-tool');
|
||||||
|
|
||||||
const createAllSignatures = () => {
|
const createAllSignatures = () => {
|
||||||
console.log('\x1b[35m%s\x1b[0m', new Date().toLocaleString()
|
console.log('\x1b[35m%s\x1b[0m', new Date().toLocaleString()
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const sortCollectionBy = (collection, key) => {
|
|
||||||
collection.sort((a, b) => {
|
|
||||||
a = a[key].toLowerCase();
|
|
||||||
b = b[key].toLowerCase();
|
|
||||||
if (a < b) return -1;
|
|
||||||
if (a > b) return 1;
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
return collection;
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.sortCollection = sortCollectionBy;
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const mongoose = require('mongoose');
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
const LogBudgetSchema = new Schema({
|
||||||
|
war: {
|
||||||
|
type: mongoose.Schema.Types.ObjectId,
|
||||||
|
ref: 'War',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
time: {
|
||||||
|
type: Date,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
fraction: {
|
||||||
|
type: String,
|
||||||
|
enum: ['BLUFOR', 'OPFOR'],
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
oldBudget: {
|
||||||
|
type: Number,
|
||||||
|
get: v => Math.round(v),
|
||||||
|
set: v => Math.round(v),
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
newBudget: {
|
||||||
|
type: Number,
|
||||||
|
get: v => Math.round(v),
|
||||||
|
set: v => Math.round(v),
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
collection: 'logBudget'
|
||||||
|
});
|
||||||
|
// optional more indices
|
||||||
|
LogBudgetSchema.index({war: 1});
|
||||||
|
|
||||||
|
module.exports = mongoose.model('LogBudget', LogBudgetSchema);
|
|
@ -0,0 +1,35 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const mongoose = require('mongoose');
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
const LogFlagSchema = new Schema({
|
||||||
|
war: {
|
||||||
|
type: mongoose.Schema.Types.ObjectId,
|
||||||
|
ref: 'War',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
time: {
|
||||||
|
type: Date,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
player: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
flagFraction: {
|
||||||
|
type: String,
|
||||||
|
enum: ['BLUFOR', 'OPFOR'],
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
capture: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
collection: 'logFlag'
|
||||||
|
});
|
||||||
|
// optional more indices
|
||||||
|
LogFlagSchema.index({war: 1, player: 1});
|
||||||
|
|
||||||
|
module.exports = mongoose.model('LogFlag', LogFlagSchema);
|
|
@ -0,0 +1,38 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const mongoose = require('mongoose');
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
const LogKillSchema = new Schema({
|
||||||
|
war: {
|
||||||
|
type: mongoose.Schema.Types.ObjectId,
|
||||||
|
ref: 'War',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
time: {
|
||||||
|
type: Date,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
shooter: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
target: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
friendlyFire: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
fraction: {
|
||||||
|
type: String,
|
||||||
|
enum: ['BLUFOR', 'OPFOR', 'NONE'],
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
collection: 'logKill'
|
||||||
|
});
|
||||||
|
// optional more indices
|
||||||
|
LogKillSchema.index({war: 1, shooter: 1, target: 1});
|
||||||
|
|
||||||
|
module.exports = mongoose.model('LogKill', LogKillSchema);
|
|
@ -0,0 +1,39 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const mongoose = require('mongoose');
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
const LogKillSchema = new Schema({
|
||||||
|
war: {
|
||||||
|
type: mongoose.Schema.Types.ObjectId,
|
||||||
|
ref: 'War',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
time: {
|
||||||
|
type: Date,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
ptBlufor: {
|
||||||
|
type: Number,
|
||||||
|
get: v => Math.round(v),
|
||||||
|
set: v => Math.round(v),
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
ptOpfor: {
|
||||||
|
type: Number,
|
||||||
|
get: v => Math.round(v),
|
||||||
|
set: v => Math.round(v),
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
fraction: {
|
||||||
|
type: String,
|
||||||
|
enum: ['BLUFOR', 'OPFOR', 'NONE'],
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
collection: 'logPoints'
|
||||||
|
});
|
||||||
|
// optional more indices
|
||||||
|
LogKillSchema.index({war: 1, shooter: 1, target: 1});
|
||||||
|
|
||||||
|
module.exports = mongoose.model('LogPoints', LogKillSchema);
|
|
@ -0,0 +1,26 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const mongoose = require('mongoose');
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
const LogRespawnSchema = new Schema({
|
||||||
|
war: {
|
||||||
|
type: mongoose.Schema.Types.ObjectId,
|
||||||
|
ref: 'War',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
time: {
|
||||||
|
type: Date,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
player: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
collection: 'logRespawn'
|
||||||
|
});
|
||||||
|
// optional more indices
|
||||||
|
LogRespawnSchema.index({war: 1, player: 1});
|
||||||
|
|
||||||
|
module.exports = mongoose.model('LogRespawn', LogRespawnSchema);
|
|
@ -0,0 +1,39 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const mongoose = require('mongoose');
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
const LogReviveSchema = new Schema({
|
||||||
|
war: {
|
||||||
|
type: mongoose.Schema.Types.ObjectId,
|
||||||
|
ref: 'War',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
time: {
|
||||||
|
type: Date,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
medic: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
patient: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
stabilized: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
fraction: {
|
||||||
|
type: String,
|
||||||
|
enum: ['BLUFOR', 'OPFOR'],
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
collection: 'logRevive'
|
||||||
|
});
|
||||||
|
// optional more indices
|
||||||
|
LogReviveSchema.index({war: 1, medic: 1});
|
||||||
|
|
||||||
|
module.exports = mongoose.model('LogRevive', LogReviveSchema);
|
|
@ -0,0 +1,41 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const mongoose = require('mongoose');
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
const LogTransportSchema = new Schema({
|
||||||
|
war: {
|
||||||
|
type: mongoose.Schema.Types.ObjectId,
|
||||||
|
ref: 'War',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
time: {
|
||||||
|
type: Date,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
driver: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
passenger: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
distance: {
|
||||||
|
type: Number,
|
||||||
|
get: v => Math.round(v),
|
||||||
|
set: v => Math.round(v),
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
fraction: {
|
||||||
|
type: String,
|
||||||
|
enum: ['BLUFOR', 'OPFOR'],
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
collection: 'logTransport'
|
||||||
|
});
|
||||||
|
// optional more indices
|
||||||
|
LogTransportSchema.index({war: 1});
|
||||||
|
|
||||||
|
module.exports = mongoose.model('LogTransport', LogTransportSchema);
|
|
@ -53,6 +53,11 @@ const PlayerSchema = new Schema({
|
||||||
get: v => Math.round(v),
|
get: v => Math.round(v),
|
||||||
set: v => Math.round(v),
|
set: v => Math.round(v),
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
sort: {
|
||||||
|
type: Number,
|
||||||
|
get: v => Math.round(v),
|
||||||
|
set: v => Math.round(v)
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
collection: 'player',
|
collection: 'player',
|
||||||
|
|
|
@ -10,19 +10,20 @@ const WarSchema = new Schema({
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
type: Date,
|
type: Date,
|
||||||
|
},
|
||||||
|
endDate : {
|
||||||
|
type: Date,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
ptBlufor: {
|
ptBlufor: {
|
||||||
type: Number,
|
type: Number,
|
||||||
get: v => Math.round(v),
|
get: v => Math.round(v),
|
||||||
set: v => Math.round(v),
|
set: v => Math.round(v),
|
||||||
required: true
|
|
||||||
},
|
},
|
||||||
ptOpfor: {
|
ptOpfor: {
|
||||||
type: Number,
|
type: Number,
|
||||||
get: v => Math.round(v),
|
get: v => Math.round(v),
|
||||||
set: v => Math.round(v),
|
set: v => Math.round(v),
|
||||||
required: true
|
|
||||||
},
|
},
|
||||||
playersBlufor: {
|
playersBlufor: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
@ -38,7 +39,32 @@ const WarSchema = new Schema({
|
||||||
},
|
},
|
||||||
campaign: {
|
campaign: {
|
||||||
type: mongoose.Schema.Types.ObjectId,
|
type: mongoose.Schema.Types.ObjectId,
|
||||||
ref: 'Campaign'
|
ref: 'Campaign',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
budgetBlufor: {
|
||||||
|
type: Number,
|
||||||
|
get: v => Math.round(v),
|
||||||
|
set: v => Math.round(v),
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
budgetOpfor: {
|
||||||
|
type: Number,
|
||||||
|
get: v => Math.round(v),
|
||||||
|
set: v => Math.round(v),
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
endBudgetBlufor: {
|
||||||
|
type: Number,
|
||||||
|
get: v => Math.round(v),
|
||||||
|
set: v => Math.round(v),
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
|
endBudgetOpfor: {
|
||||||
|
type: Number,
|
||||||
|
get: v => Math.round(v),
|
||||||
|
set: v => Math.round(v),
|
||||||
|
default: 0
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
collection: 'war',
|
collection: 'war',
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
"licence": "CC BY-SA 4.0",
|
"licence": "CC BY-SA 4.0",
|
||||||
"description": "RESTful API for Operation Pandora Trigger Command Center, includes signature generator",
|
"description": "RESTful API for Operation Pandora Trigger Command Center, includes signature generator",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
|
"author": "Florian Hartwich <hardi@noarch.de>",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "NODE_ENV=production node server.js",
|
"start": "NODE_ENV=production node server.js",
|
||||||
|
|
|
@ -9,7 +9,7 @@ const codes = require('./http-codes');
|
||||||
|
|
||||||
const routerHandling = require('../middleware/router-handling');
|
const routerHandling = require('../middleware/router-handling');
|
||||||
const createAllSignatures = require('../cron-job/cron').createAllSignatures;
|
const createAllSignatures = require('../cron-job/cron').createAllSignatures;
|
||||||
const createSignature = require('../signature-tool/signature-tool');
|
const createSignature = require('../tools/signature-tool');
|
||||||
|
|
||||||
const command = express.Router();
|
const command = express.Router();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,156 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// modules
|
||||||
|
const express = require('express');
|
||||||
|
const async = require('async');
|
||||||
|
const logger = require('debug')('cc:logs');
|
||||||
|
|
||||||
|
const routerHandling = require('../middleware/router-handling');
|
||||||
|
const decimalToTimeString = require('../tools/util').decimalToTimeString;
|
||||||
|
|
||||||
|
// Mongoose Model using mongoDB
|
||||||
|
const LogBudgetModel = require('../models/logs/budget');
|
||||||
|
const LogRespawnModel = require('../models/logs/respawn');
|
||||||
|
const LogReviveModel = require('../models/logs/revive');
|
||||||
|
const LogKillModel = require('../models/logs/kill');
|
||||||
|
const LogTransportModel = require('../models/logs/transport');
|
||||||
|
const LogFlagModel = require('../models/logs/flag');
|
||||||
|
const LogPointsModel = require('../models/logs/points');
|
||||||
|
|
||||||
|
const logsRouter = express.Router();
|
||||||
|
|
||||||
|
function processLogRequest(model, filter, res, next) {
|
||||||
|
model.find(filter, {}, {sort: {time: 1}}, (err, log) => {
|
||||||
|
if (err) return next(err);
|
||||||
|
if (!log || log.length === 0) {
|
||||||
|
const err = new Error('No logs found');
|
||||||
|
err.status = require('./http-codes').notfound;
|
||||||
|
return next(err)
|
||||||
|
}
|
||||||
|
res.locals.items = log;
|
||||||
|
next();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// routes **********************
|
||||||
|
logsRouter.route('/:warId')
|
||||||
|
.get((req, res, next) => {
|
||||||
|
const filter = {war: req.params.warId};
|
||||||
|
const sort = {sort: {time: 1}};
|
||||||
|
|
||||||
|
const pointsObjects = LogPointsModel.find(filter, {}, sort);
|
||||||
|
const budgetObjects = LogBudgetModel.find(filter, {}, sort);
|
||||||
|
const respawnObjects = LogRespawnModel.find(filter, {}, sort);
|
||||||
|
const reviveObjects = LogReviveModel.find(filter, {}, sort);
|
||||||
|
const killObjects = LogKillModel.find(filter, {}, sort);
|
||||||
|
const transportObjects = LogTransportModel.find(filter, {}, sort);
|
||||||
|
const flagObjects = LogFlagModel.find(filter, {}, sort);
|
||||||
|
const resources = {
|
||||||
|
points: pointsObjects.exec.bind(pointsObjects),
|
||||||
|
budget: budgetObjects.exec.bind(budgetObjects),
|
||||||
|
respawn: respawnObjects.exec.bind(respawnObjects),
|
||||||
|
revive: reviveObjects.exec.bind(reviveObjects),
|
||||||
|
kill: killObjects.exec.bind(killObjects),
|
||||||
|
transport: transportObjects.exec.bind(transportObjects),
|
||||||
|
flag: flagObjects.exec.bind(flagObjects)
|
||||||
|
};
|
||||||
|
|
||||||
|
async.parallel(resources, function (error, results){
|
||||||
|
if (error) {
|
||||||
|
res.status(500).send(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
res.locals.items = results;
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.all(
|
||||||
|
routerHandling.httpMethodNotAllowed
|
||||||
|
);
|
||||||
|
|
||||||
|
logsRouter.route('/:warId/budget')
|
||||||
|
.get((req, res, next) => {
|
||||||
|
const filter = {war: req.params.warId};
|
||||||
|
if (req.query.fraction) filter['fraction'] = req.query.fraction;
|
||||||
|
processLogRequest(LogBudgetModel, filter, res, next);
|
||||||
|
})
|
||||||
|
.all(
|
||||||
|
routerHandling.httpMethodNotAllowed
|
||||||
|
);
|
||||||
|
|
||||||
|
logsRouter.route('/:warId/respawn')
|
||||||
|
.get((req, res, next) => {
|
||||||
|
const filter = {war: req.params.warId};
|
||||||
|
if (req.query.player) filter['player'] = req.query.player;
|
||||||
|
processLogRequest(LogRespawnModel, filter, res, next);
|
||||||
|
})
|
||||||
|
.all(
|
||||||
|
routerHandling.httpMethodNotAllowed
|
||||||
|
);
|
||||||
|
|
||||||
|
logsRouter.route('/:warId/revive')
|
||||||
|
.get((req, res, next) => {
|
||||||
|
const filter = {war: req.params.warId};
|
||||||
|
if (req.query.medic) filter['medic'] = req.query.medic;
|
||||||
|
if (req.query.patient) filter['patient'] = req.query.patient;
|
||||||
|
if (req.query.stabilized) filter['stabilized'] = true;
|
||||||
|
if (req.query.revive) filter['stabilized'] = false;
|
||||||
|
if (req.query.fraction) filter['fraction'] = req.query.fraction;
|
||||||
|
processLogRequest(LogReviveModel, filter, res, next);
|
||||||
|
})
|
||||||
|
.all(
|
||||||
|
routerHandling.httpMethodNotAllowed
|
||||||
|
);
|
||||||
|
|
||||||
|
logsRouter.route('/:warId/kills')
|
||||||
|
.get((req, res, next) => {
|
||||||
|
const filter = {war: req.params.warId};
|
||||||
|
if (req.query.shooter) filter['shooter'] = req.query.shooter;
|
||||||
|
if (req.query.target) filter['target'] = req.query.target;
|
||||||
|
if (req.query.friendlyFire) filter['friendlyFire'] = true;
|
||||||
|
if (req.query.noFriendlyFire) filter['friendlyFire'] = false;
|
||||||
|
if (req.query.fraction) filter['fraction'] = req.query.fraction;
|
||||||
|
processLogRequest(LogKillModel, filter, res, next);
|
||||||
|
})
|
||||||
|
.all(
|
||||||
|
routerHandling.httpMethodNotAllowed
|
||||||
|
);
|
||||||
|
|
||||||
|
logsRouter.route('/:warId/transport')
|
||||||
|
.get((req, res, next) => {
|
||||||
|
const filter = {war: req.params.warId};
|
||||||
|
if (req.query.driver) filter['driver'] = req.query.driver;
|
||||||
|
if (req.query.passenger) filter['passenger'] = req.query.passenger;
|
||||||
|
if (req.query.fraction) filter['fraction'] = req.query.fraction;
|
||||||
|
processLogRequest(LogTransportModel, filter, res, next);
|
||||||
|
})
|
||||||
|
.all(
|
||||||
|
routerHandling.httpMethodNotAllowed
|
||||||
|
);
|
||||||
|
|
||||||
|
logsRouter.route('/:warId/flag')
|
||||||
|
.get((req, res, next) => {
|
||||||
|
const filter = {war: req.params.warId};
|
||||||
|
if (req.query.player) filter['player'] = req.query.player;
|
||||||
|
if (req.query.capture) filter['capture'] = true;
|
||||||
|
if (req.query.defend) filter['capture'] = false;
|
||||||
|
if (req.query.fraction) filter['fraction'] = req.query.fraction;
|
||||||
|
processLogRequest(LogFlagModel, filter, res, next);
|
||||||
|
})
|
||||||
|
.all(
|
||||||
|
routerHandling.httpMethodNotAllowed
|
||||||
|
);
|
||||||
|
|
||||||
|
logsRouter.route('/:warId/points')
|
||||||
|
.get((req, res, next) => {
|
||||||
|
const filter = {war: req.params.warId};
|
||||||
|
if (req.query.fraction) filter['fraction'] = req.query.fraction;
|
||||||
|
processLogRequest(LogPointsModel, filter, res, next);
|
||||||
|
})
|
||||||
|
.all(
|
||||||
|
routerHandling.httpMethodNotAllowed
|
||||||
|
);
|
||||||
|
|
||||||
|
logsRouter.use(routerHandling.emptyResponse);
|
||||||
|
|
||||||
|
module.exports = logsRouter;
|
|
@ -3,7 +3,6 @@
|
||||||
// modules
|
// modules
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const mkdirp = require("mkdirp");
|
const mkdirp = require("mkdirp");
|
||||||
const {exec} = require('child_process');
|
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const multer = require('multer');
|
const multer = require('multer');
|
||||||
const storage = multer.memoryStorage();
|
const storage = multer.memoryStorage();
|
||||||
|
@ -17,10 +16,19 @@ 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 parseWarLog = require('../tools/log-parse-tool');
|
||||||
|
|
||||||
// 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');
|
||||||
const PlayerModel = require('../models/player');
|
const PlayerModel = require('../models/player');
|
||||||
|
const LogKillModel = require('../models/logs/kill');
|
||||||
|
const LogRespawnModel = require('../models/logs/respawn');
|
||||||
|
const LogReviveModel = require('../models/logs/revive');
|
||||||
|
const LogTransportModel = require('../models/logs/transport');
|
||||||
|
const LogFlagModel = require('../models/logs/flag');
|
||||||
|
const LogBudgetModel = require('../models/logs/budget');
|
||||||
|
const LogPointsModel = require('../models/logs/points');
|
||||||
|
|
||||||
const wars = express.Router();
|
const wars = express.Router();
|
||||||
|
|
||||||
|
@ -61,70 +69,63 @@ wars.route('/')
|
||||||
})
|
})
|
||||||
|
|
||||||
.post(apiAuthenticationMiddleware, checkMT, upload.single('log'), (req, res, next) => {
|
.post(apiAuthenticationMiddleware, checkMT, upload.single('log'), (req, res, next) => {
|
||||||
let body = req.body;
|
const body = req.body;
|
||||||
let parts = body.date.split("-");
|
const warBody = new WarModel(body);
|
||||||
body.date = new Date(parseInt(parts[0], 10),
|
|
||||||
parseInt(parts[1], 10) - 1,
|
|
||||||
parseInt(parts[2], 10));
|
|
||||||
const war = new WarModel(body);
|
|
||||||
|
|
||||||
if (req.file) {
|
if (req.file) {
|
||||||
war.save((err, war) => {
|
fs.readFile(req.file.buffer, (file, err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
const lineArray = file.toString().split("\n");
|
||||||
|
const statsResult = parseWarLog(lineArray, warBody);
|
||||||
|
statsResult.war.save((err, war) => {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
PlayerModel.create(statsResult.players, function (err) {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
LogKillModel.create(statsResult.kills, function () {
|
||||||
|
LogRespawnModel.create(statsResult.respawn, function () {
|
||||||
|
LogReviveModel.create(statsResult.revive, function () {
|
||||||
|
LogFlagModel.create(statsResult.flag, function () {
|
||||||
|
LogBudgetModel.create(statsResult.budget, function () {
|
||||||
|
LogTransportModel.create(statsResult.transport, function () {
|
||||||
|
LogPointsModel.create(statsResult.points, function () {
|
||||||
const folderName = __dirname + '/../resource/logs/' + war._id;
|
const folderName = __dirname + '/../resource/logs/' + war._id;
|
||||||
mkdirp(folderName, function (err) {
|
mkdirp(folderName, function (err) {
|
||||||
if (err) {
|
if (err) return next(err);
|
||||||
return next(err);
|
|
||||||
}
|
// save clean log file
|
||||||
fs.appendFile(folderName + '/war.log', new Buffer(req.file.buffer), (err) => {
|
const cleanFile = fs.createWriteStream(folderName + '/clean.log');
|
||||||
if (err) {
|
statsResult.clean.forEach(cleanLine => {
|
||||||
return next(err);
|
cleanFile.write(cleanLine + '\n\n')
|
||||||
}
|
});
|
||||||
exec(__dirname + '/../war-parser/run.sh ' + folderName + ' ' + war._id, (error, stdout) => {
|
cleanFile.end();
|
||||||
if (error) {
|
|
||||||
return next(error);
|
// save raw log file
|
||||||
}
|
const rawFile = fs.createWriteStream(folderName + '/war.log');
|
||||||
exec(__dirname + '/../war-parser/clean.sh /../' + folderName + ' | tee ' + folderName + '/clean.log', (error) => {
|
lineArray.forEach(rawLine => {
|
||||||
if (error) {
|
rawFile.write(rawLine + '\n')
|
||||||
return next(error);
|
});
|
||||||
}
|
rawFile.end();
|
||||||
let obj = JSON.parse(`${stdout}`);
|
|
||||||
for (let i = 0; i < obj.length; i++) {
|
|
||||||
if (!obj[i].fraction) {
|
|
||||||
obj.splice(i, 1);
|
|
||||||
} else if (obj[i].fraction === 'BLUFOR') {
|
|
||||||
war.playersBlufor++;
|
|
||||||
} else {
|
|
||||||
war.playersOpfor++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WarModel.findByIdAndUpdate(war._id, war, {new: true}, (err, item) => {
|
|
||||||
if (err) {
|
|
||||||
err.status = codes.wrongrequest;
|
|
||||||
}
|
|
||||||
else if (!item) {
|
|
||||||
err = new Error("item not found");
|
|
||||||
err.status = codes.notfound;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
PlayerModel.create(obj, function (err) {
|
|
||||||
if (err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
res.status(codes.created);
|
res.status(codes.created);
|
||||||
res.locals.items = war;
|
res.locals.items = war;
|
||||||
return next();
|
next();
|
||||||
});
|
})
|
||||||
}
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const err = new Error('no Logfile provided');
|
const err = new Error('no Logfile provided');
|
||||||
|
|
|
@ -35,6 +35,7 @@ const signatureRouter = require('./routes/signatures');
|
||||||
const commandRouter = require('./routes/command');
|
const commandRouter = require('./routes/command');
|
||||||
const campaignRouter = require('./routes/campaigns');
|
const campaignRouter = require('./routes/campaigns');
|
||||||
const warRouter = require('./routes/wars');
|
const warRouter = require('./routes/wars');
|
||||||
|
const logRouter = require('./routes/logs');
|
||||||
|
|
||||||
// Configuration ***********************************
|
// Configuration ***********************************
|
||||||
// mongoose promise setup
|
// mongoose promise setup
|
||||||
|
@ -83,6 +84,7 @@ 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.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);
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
@ -0,0 +1,244 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const playerArrayContains = require('./util').playerArrayContains;
|
||||||
|
|
||||||
|
const parseWarLog = (lineArray, war) => {
|
||||||
|
const nameToLongError = 'Error: ENAMETOOLONG: name too long, open \'';
|
||||||
|
const stats = {
|
||||||
|
war: war,
|
||||||
|
clean: [],
|
||||||
|
budget: [],
|
||||||
|
points: [],
|
||||||
|
kills: [],
|
||||||
|
respawn: [],
|
||||||
|
revive: [],
|
||||||
|
flag: [],
|
||||||
|
transport: [],
|
||||||
|
players: []
|
||||||
|
};
|
||||||
|
|
||||||
|
const addPlayersIfNotExists = (inputPlayers) => {
|
||||||
|
inputPlayers.forEach(player => {
|
||||||
|
if (player && player.name && player.fraction && !playerArrayContains(stats.players, player)) {
|
||||||
|
player['warId'] = war._id;
|
||||||
|
stats.players.push(player);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
lineArray.some(line => {
|
||||||
|
/**
|
||||||
|
* sanitize nameToLongError coming up in first line
|
||||||
|
*/
|
||||||
|
if (line.includes(nameToLongError)) {
|
||||||
|
line = line.substring(line.indexOf(nameToLongError) + nameToLongError.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* KILLS
|
||||||
|
*/
|
||||||
|
if (line.includes('Abschuss') && !line.includes('Fahrzeug')) {
|
||||||
|
stats.clean.push(line);
|
||||||
|
const shooterString = line.substring(line.lastIndexOf(' von: ') + 6, line.lastIndexOf('. :OPT LOG END'));
|
||||||
|
const shooter = getPlayerAndFractionFromString(shooterString);
|
||||||
|
const targetString = line.substring(line.lastIndexOf(' || ') + 4, line.lastIndexOf(' von:'));
|
||||||
|
const target = getPlayerAndFractionFromString(targetString);
|
||||||
|
|
||||||
|
stats.kills.push({
|
||||||
|
war: war._id,
|
||||||
|
time: getFullTimeDate(war.date, line.split(' ')[5]),
|
||||||
|
shooter: shooter ? shooter.name : null,
|
||||||
|
target: target.name,
|
||||||
|
friendlyFire: shooter ? target.fraction === shooter.fraction : false,
|
||||||
|
fraction: shooter ? shooter.fraction : 'NONE'
|
||||||
|
});
|
||||||
|
|
||||||
|
addPlayersIfNotExists([shooter, target]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BUDGET
|
||||||
|
*/
|
||||||
|
if (line.includes('Budget')) {
|
||||||
|
stats.clean.push(line);
|
||||||
|
const budg = line.split(' ');
|
||||||
|
if (line.includes('Endbudget')) {
|
||||||
|
stats.war['endBudgetBlufor'] = transformMoneyString(budg[11]);
|
||||||
|
stats.war['endBudgetOpfor'] = transformMoneyString(budg[14]);
|
||||||
|
console.log(budg)
|
||||||
|
console.log(budg[0].substr(0, budg[0].length - 1).split('/').join('-') + 'T' + budg[5] +'.000+02:00')
|
||||||
|
war.endDate = new Date(budg[0].substr(0, budg[0].length - 1).split('/').join('-') + 'T0' + budg[5] +'.000+02:00');
|
||||||
|
} else if (line.includes('Startbudget')) {
|
||||||
|
stats.war.date = new Date(budg[0].substr(0, budg[0].length - 1).split('/').join('-') + 'T22:00:00.000+02:00');
|
||||||
|
stats.war['budgetBlufor'] = transformMoneyString(budg[11]);
|
||||||
|
stats.war['budgetOpfor'] = transformMoneyString(budg[14]);
|
||||||
|
} else {
|
||||||
|
stats.budget.push(getBudgetEntry(budg, war._id, war.date));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FLAG
|
||||||
|
*/
|
||||||
|
if (line.includes('Fahne')) {
|
||||||
|
stats.clean.push(line);
|
||||||
|
const playerName = line.substring(line.lastIndexOf('t von ') + 6, line.lastIndexOf(' :OPT LOG END'));
|
||||||
|
const flagFraction = line.includes('NATO Flagge') ? 'BLUFOR' : 'OPFOR';
|
||||||
|
const capture = !!line.includes('Flagge erobert');
|
||||||
|
|
||||||
|
stats.flag.push({
|
||||||
|
war: war._id,
|
||||||
|
time: getFullTimeDate(war.date, line.split(' ')[5]),
|
||||||
|
player: playerName,
|
||||||
|
flagFraction: flagFraction,
|
||||||
|
capture: capture
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POINTS
|
||||||
|
*/
|
||||||
|
if (line.includes('Punkte')) {
|
||||||
|
stats.clean.push(line);
|
||||||
|
const pt = line.split(' ');
|
||||||
|
|
||||||
|
if (line.includes('Endpunktestand')) {
|
||||||
|
stats.war['ptBlufor'] = parseInt(pt[11]);
|
||||||
|
stats.war['ptOpfor'] = parseInt(pt[14].slice(0, -1));
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
stats.points.push(getPointsEntry(pt, line, war._id, war.date))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RESPAWN
|
||||||
|
*/
|
||||||
|
if (line.includes('Respawn')) {
|
||||||
|
stats.clean.push(line);
|
||||||
|
const resp = line.split(' ');
|
||||||
|
const playerName = line.substring(line.lastIndexOf('Spieler:') + 9, line.lastIndexOf('-') - 1);
|
||||||
|
stats.respawn.push(getRespawnEntry(resp, playerName, war._id, war.date));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* REVIVE
|
||||||
|
*/
|
||||||
|
if (line.includes('Revive')) {
|
||||||
|
stats.clean.push(line);
|
||||||
|
const stabilized = !!line.includes('stabilisiert');
|
||||||
|
const medicName = line.substring(line.lastIndexOf('wurde von ') + 10,
|
||||||
|
line.lastIndexOf(stabilized ? ' stabilisiert' : ' wiederbelebt'));
|
||||||
|
const medic = getPlayerAndFractionFromString(medicName);
|
||||||
|
const patientName = line.substring(line.lastIndexOf('|| ') + 3, line.lastIndexOf(' wurde von'));
|
||||||
|
const patient = getPlayerAndFractionFromString(patientName);
|
||||||
|
|
||||||
|
stats.revive.push({
|
||||||
|
war: war._id,
|
||||||
|
time: getFullTimeDate(war.date, line.split(' ')[5]),
|
||||||
|
stabilized: stabilized,
|
||||||
|
medic: medic.name,
|
||||||
|
patient: patient.name,
|
||||||
|
fraction: medic.fraction
|
||||||
|
});
|
||||||
|
|
||||||
|
addPlayersIfNotExists([medic, patient]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TRANSPORT
|
||||||
|
*/
|
||||||
|
if (line.includes('Transport ||')) {
|
||||||
|
stats.clean.push(line);
|
||||||
|
const driverString = line.substring(line.lastIndexOf('wurde von ') + 10, line.lastIndexOf(' eingeflogen'));
|
||||||
|
const driver = getPlayerAndFractionFromString(driverString);
|
||||||
|
const passengerString = line.substring(line.lastIndexOf('|| ') + 3, line.lastIndexOf(' wurde von'));
|
||||||
|
const passenger = getPlayerAndFractionFromString(passengerString);
|
||||||
|
const distance = parseInt(line.substring(line.lastIndexOf('eingeflogen (') + 13, line.lastIndexOf('m)') - 1));
|
||||||
|
|
||||||
|
stats.transport.push({
|
||||||
|
war: war._id,
|
||||||
|
time: getFullTimeDate(war.date, line.split(' ')[5]),
|
||||||
|
driver: driver.name,
|
||||||
|
passenger: passenger ? passenger.name : null,
|
||||||
|
fraction: driver.fraction,
|
||||||
|
distance: distance
|
||||||
|
});
|
||||||
|
|
||||||
|
addPlayersIfNotExists([driver, passenger]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (let i = 0; i < stats.players.length; i++) {
|
||||||
|
const playerName = stats.players[i].name;
|
||||||
|
stats.players[i]['respawn'] = stats.respawn.filter(res => res.player === playerName).length;
|
||||||
|
stats.players[i]['kill'] = stats.kills.filter(kill => kill.shooter === playerName && !kill.friendlyFire).length;
|
||||||
|
stats.players[i]['friendlyFire'] = stats.kills.filter(kill => kill.shooter === playerName && kill.friendlyFire).length;
|
||||||
|
stats.players[i]['death'] = stats.kills.filter(kill => kill.target === playerName).length;
|
||||||
|
stats.players[i]['revive'] = stats.revive.filter(rev => rev.medic === playerName && !rev.stabilized).length;
|
||||||
|
stats.players[i]['flagTouch'] = stats.flag.filter(flag => flag.player === playerName).length;
|
||||||
|
stats.players[i]['sort'] = stats.players[i]['kill'] + stats.players[i]['revive'] + stats.players[i]['flagTouch']
|
||||||
|
- stats.players[i]['friendlyFire'] - stats.players[i]['death'] - stats.players[i]['respawn']
|
||||||
|
}
|
||||||
|
|
||||||
|
stats.war.playersBlufor = stats.players.filter(player => player.fraction === 'BLUFOR').length;
|
||||||
|
stats.war.playersOpfor = stats.players.filter(player => player.fraction === 'OPFOR').length;
|
||||||
|
|
||||||
|
return stats;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getRespawnEntry = (respawn, playerName, warId, warDate) => {
|
||||||
|
return {
|
||||||
|
war: warId,
|
||||||
|
time: getFullTimeDate(warDate, respawn[5]),
|
||||||
|
player: playerName
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getPointsEntry = (pt, line, warId, warDate) => {
|
||||||
|
return {
|
||||||
|
war: warId,
|
||||||
|
time: getFullTimeDate(warDate, pt[5]),
|
||||||
|
ptBlufor: parseInt(pt[12]),
|
||||||
|
ptOpfor: parseInt(pt[15].slice(0, -1)),
|
||||||
|
fraction: line.includes('no Domination') ? 'NONE' : line.includes('NATO +1') ? 'BLUFOR' : 'OPFOR'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getBudgetEntry = (budg, warId, warDate) => {
|
||||||
|
return {
|
||||||
|
war: warId,
|
||||||
|
time: getFullTimeDate(warDate, budg[5]),
|
||||||
|
fraction: budg[9] === 'NATO' ? 'BLUFOR' : 'OPFOR',
|
||||||
|
oldBudget: transformMoneyString(budg[11]),
|
||||||
|
newBudget: transformMoneyString(budg[14])
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getPlayerAndFractionFromString = (nameAndFractionString) => {
|
||||||
|
const nameArray = nameAndFractionString.split(' ');
|
||||||
|
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);
|
||||||
|
// do not return player for 'Selbstverschulden' or 'Error: No unit'
|
||||||
|
if (name && name !== 'Error: No unit') {
|
||||||
|
return {name: name, fraction: fraction};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformMoneyString = (budgetString) => {
|
||||||
|
if (!budgetString.includes('e+')) {
|
||||||
|
return parseInt(budgetString);
|
||||||
|
}
|
||||||
|
const budget = budgetString.split('e+');
|
||||||
|
return Math.round(parseFloat(budget[0]) * Math.pow(10, parseInt(budget[1])));
|
||||||
|
};
|
||||||
|
|
||||||
|
const getFullTimeDate = (date, timeString) => {
|
||||||
|
const returnDate = new Date(date);
|
||||||
|
const time = timeString.split(':');
|
||||||
|
returnDate.setHours(time[0]);
|
||||||
|
returnDate.setMinutes(time[1]);
|
||||||
|
return returnDate;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = parseWarLog;
|
|
@ -0,0 +1,50 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const sortCollectionBy = (collection, key) => {
|
||||||
|
collection.sort((a, b) => {
|
||||||
|
a = a[key].toLowerCase();
|
||||||
|
b = b[key].toLowerCase();
|
||||||
|
if (a < b) return -1;
|
||||||
|
if (a > b) return 1;
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
return collection;
|
||||||
|
};
|
||||||
|
|
||||||
|
const playerArrayContains = (arr, item) => {
|
||||||
|
let i = 0, count = arr.length, matchFound = false;
|
||||||
|
|
||||||
|
for (; i < count; i++) {
|
||||||
|
if (arr[i].name === item.name && arr[i].fraction === item.fraction) {
|
||||||
|
matchFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return matchFound;
|
||||||
|
};
|
||||||
|
|
||||||
|
const timeStringToDecimal = (timeString) => {
|
||||||
|
const timeArray = timeString.split(':');
|
||||||
|
const hour = parseInt(timeArray[0]);
|
||||||
|
const sek = parseInt(timeArray[1]) * 60 + parseInt(timeArray[2]);
|
||||||
|
|
||||||
|
return hour + (sek / 3600);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const decimalToTimeString = (decimal) => {
|
||||||
|
const hours = parseInt(decimal.toString().split(".")[0]);
|
||||||
|
const minutesFloat = ((decimal % 1) * 3600) / 60;
|
||||||
|
const minutes = parseInt(minutesFloat.toString().split(".")[0]);
|
||||||
|
const seconds = Math.round((minutesFloat - parseInt(minutes)) * 60);
|
||||||
|
|
||||||
|
return (hours < 10 ? '0' + hours : hours) + ':' +
|
||||||
|
(minutes < 10 ? '0' + minutes : minutes) + ':' +
|
||||||
|
(seconds < 10 ? '0' + seconds : seconds);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.sortCollection = sortCollectionBy;
|
||||||
|
exports.playerArrayContains = playerArrayContains;
|
||||||
|
exports.timeStringToDecimal = timeStringToDecimal;
|
||||||
|
exports.decimalToTimeString = decimalToTimeString;
|
|
@ -1,20 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
FILE="$1/war.log"
|
|
||||||
|
|
||||||
while IFS='' read -r line || [[ -n "$line" ]]; do
|
|
||||||
case "$line" in
|
|
||||||
*"Budget"* | *"Mission"* | *"Abschuss"* | *"Respawn"* | *"Punkte"* | *"Flagge"* | *"Revive"* | *"Transport"*)
|
|
||||||
echo $line;
|
|
||||||
echo ""
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done < ${FILE}
|
|
||||||
|
|
||||||
# Add OPT Scoreboard
|
|
||||||
while IFS= read -r line; do
|
|
||||||
if [[ $line =~ [^[:space:]] ]]; then
|
|
||||||
echo "$line"
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
done < <(grep -A 100 Scoreboard ${FILE} )
|
|
|
@ -1,97 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
createScoreboard() {
|
|
||||||
NAME="$1"
|
|
||||||
FILE="$2"
|
|
||||||
WAR_ID="$3"
|
|
||||||
|
|
||||||
KILL=0
|
|
||||||
FF=0
|
|
||||||
REVIVE=0
|
|
||||||
DEATH=0
|
|
||||||
RESPAWN=0
|
|
||||||
FLAG=0
|
|
||||||
FRACTION=
|
|
||||||
|
|
||||||
#escape '[' -> somehow escapes all special chars, hah?
|
|
||||||
ESC_NAME=$(echo "$NAME" | sed -r 's/[\[]+/\\[/g')
|
|
||||||
|
|
||||||
while IFS= read -r line; do
|
|
||||||
case "$line" in
|
|
||||||
*\(WEST\)[" "]von:[" "]${ESC_NAME}[" "]\(EAST\)* | *\(EAST\)[" "]von:[" "]${ESC_NAME}[" "]\(WEST\)*)
|
|
||||||
((KILL++))
|
|
||||||
;;
|
|
||||||
*\(EAST\)[" "]von:[" "]${ESC_NAME}[" "]\(EAST\)* | *\(WEST\)[" "]von:[" "]${ESC_NAME}[" "]\(WEST\)*)
|
|
||||||
((FF++))
|
|
||||||
;;
|
|
||||||
*\(EAST\)[" "]wurde[" "]von[" "]${ESC_NAME}[" "]\(EAST\)[" "]wiederbelebt* | *\(WEST\)[" "]wurde[" "]von[" "]${ESC_NAME}[" "]\(WEST\)[" "]wiederbelebt*)
|
|
||||||
((REVIVE++))
|
|
||||||
;;
|
|
||||||
*${ESC_NAME}[" "]*von:*)
|
|
||||||
((DEATH++))
|
|
||||||
;;
|
|
||||||
*Flagge[" "]erobert[" "]von[" "]${ESC_NAME}* | *Flagge[" "]gesichert[" "]von[" "]${ESC_NAME}*)
|
|
||||||
((FLAG++))
|
|
||||||
;;
|
|
||||||
*Spieler:*${ESC_NAME}*)
|
|
||||||
((RESPAWN++))
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [[ -z ${FRACTION} && ( "$line" == *${ESC_NAME}[" "]\(WEST\)* || "$line" == *${ESC_NAME}[" "]\(NATO\)* ) ]]; then
|
|
||||||
FRACTION="BLUFOR"
|
|
||||||
fi
|
|
||||||
if [[ -z ${FRACTION} && ( "$line" == *${ESC_NAME}[" "]\(EAST\)* || "$line" == *${ESC_NAME}[" "]\(CSAT\)* ) ]]; then
|
|
||||||
FRACTION="OPFOR"
|
|
||||||
fi
|
|
||||||
done < <(grep -- "${ESC_NAME}" ${FILE})
|
|
||||||
|
|
||||||
printf "\t{\"name\":\"$NAME\", \"fraction\":\"$FRACTION\", \"kill\":${KILL}, \"friendlyFire\":${FF}, \"revive\":${REVIVE}, \"death\":${DEATH}, \"respawn\":${RESPAWN}, \"flagTouch\":${FLAG}, \"warId\":\"${WAR_ID}\"} "
|
|
||||||
if [[ -z ${4} ]]; then
|
|
||||||
printf ",\n"
|
|
||||||
else
|
|
||||||
printf "\n"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FILE="$1/war.log"
|
|
||||||
WAR_ID="$2"
|
|
||||||
PLAYERS=()
|
|
||||||
|
|
||||||
while IFS='' read -r line || [[ -n "$line" ]]; do
|
|
||||||
if [[ -n $line ]]; then
|
|
||||||
case "$line" in
|
|
||||||
*"TFAR_RadioRequestEvent"*)
|
|
||||||
RES=$(echo "$(grep -oP ':[0-9]+\s\(\K.*?(?=\)\sREMOTE)' <<< "$line")")
|
|
||||||
;;
|
|
||||||
*"Respawn"*)
|
|
||||||
RES=$(echo "$(grep -oP '\|\|\sSpieler:\s\K.*?(?=\s-\sKosten:)' <<< "$line")")
|
|
||||||
;;
|
|
||||||
*"Abschuss"*)
|
|
||||||
RES=$(echo "$(grep -oP '\|\|\s\K.*?(?=\s\((EAST|WEST|CIV))' <<< "$line")")
|
|
||||||
RES1=$(echo "$(grep -oP 'von:\s\K.*?(?=\s\((EAST|WEST|CIV))' <<< "$line")")
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [[ $RES != *"Error: No unit"* && $RES1 != *"Error: No unit"* ]]; then
|
|
||||||
if [[ -n $RES && " ${PLAYERS[*]} " != *" $RES "* ]]; then
|
|
||||||
PLAYERS+=("$RES")
|
|
||||||
fi
|
|
||||||
if [[ -n $RES1 && " ${PLAYERS[*]} " != *" $RES1 "* ]]; then
|
|
||||||
PLAYERS+=("$RES1")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done < ${FILE}
|
|
||||||
|
|
||||||
echo "["
|
|
||||||
|
|
||||||
for ((i=0; i<${#PLAYERS[*]}; i++));
|
|
||||||
do
|
|
||||||
if [[ "$((i+1))" -eq "${#PLAYERS[*]}" ]]; then
|
|
||||||
last="true"
|
|
||||||
fi
|
|
||||||
createScoreboard "${PLAYERS[i]}" ${FILE} ${WAR_ID} ${last}
|
|
||||||
done
|
|
||||||
echo "]"
|
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"name": "opt-cc",
|
"name": "opt-cc",
|
||||||
"version": "1.5.4",
|
"version": "1.6.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"author": "Florian Hartwich <hardi@noarch.de>",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run deploy-static-prod && npm start --prefix ./api",
|
"start": "npm run deploy-static-prod && npm start --prefix ./api",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "opt-cc-static",
|
"name": "opt-cc-static",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"author": "Florian Hartwich <hardi@noarch.de>",
|
||||||
"private": true,
|
"private": true,
|
||||||
"angular-cli": {},
|
"angular-cli": {},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -22,7 +23,7 @@
|
||||||
"@angular/platform-browser": "^4.4.4",
|
"@angular/platform-browser": "^4.4.4",
|
||||||
"@angular/platform-browser-dynamic": "^4.4.4",
|
"@angular/platform-browser-dynamic": "^4.4.4",
|
||||||
"@angular/router": "^4.4.4",
|
"@angular/router": "^4.4.4",
|
||||||
"@swimlane/ngx-charts": "^6.0.2",
|
"@swimlane/ngx-charts": "^6.1.0",
|
||||||
"@swimlane/ngx-datatable": "^10.2.3",
|
"@swimlane/ngx-datatable": "^10.2.3",
|
||||||
"bootstrap": "^3.3.7",
|
"bootstrap": "^3.3.7",
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.4.1",
|
||||||
|
@ -30,7 +31,7 @@
|
||||||
"jquery": "^3.1.0",
|
"jquery": "^3.1.0",
|
||||||
"jquery-ui": "^1.12.0",
|
"jquery-ui": "^1.12.0",
|
||||||
"jquery-ui-bundle": "^1.11.4",
|
"jquery-ui-bundle": "^1.11.4",
|
||||||
"ngx-bootstrap": "^2.0.0-beta.6",
|
"ngx-bootstrap": "^1.9.3",
|
||||||
"ngx-clipboard": "^8.1.0",
|
"ngx-clipboard": "^8.1.0",
|
||||||
"ngx-cookie-service": "^1.0.9",
|
"ngx-cookie-service": "^1.0.9",
|
||||||
"ngx-infinite-scroll": "^0.5.2",
|
"ngx-infinite-scroll": "^0.5.2",
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {Component} from "@angular/core";
|
||||||
import {AppUser, Squad} from "../models/model-interfaces";
|
import {AppUser, Squad} from "../models/model-interfaces";
|
||||||
import {Observable} from "rxjs/Observable";
|
import {Observable} from "rxjs/Observable";
|
||||||
import {AppUserService} from "../services/app-user-service/app-user.service";
|
import {AppUserService} from "../services/app-user-service/app-user.service";
|
||||||
import {SquadService} from "../services/squad-service/squad.service";
|
import {SquadService} from "../services/army-management/squad.service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import {Component, HostListener} from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
import {NavigationEnd, NavigationStart, Router} from '@angular/router';
|
import {NavigationEnd, NavigationStart, Router} from '@angular/router';
|
||||||
import {LoginService} from './services/login-service/login-service';
|
import {LoginService} from './services/app-user-service/login-service';
|
||||||
import {PromotionService} from "./services/promotion-service/promotion.service";
|
import {PromotionService} from "./services/army-management/promotion.service";
|
||||||
import {AwardingService} from "./services/awarding-service/awarding.service";
|
import {AwardingService} from "./services/army-management/awarding.service";
|
||||||
import {RouteConfig} from "./app.config";
|
import {RouteConfig} from "./app.config";
|
||||||
|
|
||||||
declare function require(url: string);
|
declare function require(url: string);
|
||||||
|
@ -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('stats') || router.url.includes('overview')) {
|
if (router.url.includes('overview')) {
|
||||||
window.scrollTo({left: 0, top: 0, behavior: 'smooth'});
|
window.scrollTo({left: 0, top: 0, behavior: 'smooth'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,19 +3,20 @@ export class AppConfig {
|
||||||
public readonly apiUrl = '/api';
|
public readonly apiUrl = '/api';
|
||||||
|
|
||||||
public readonly apiAppUserPath = this.apiUrl + '/account/';
|
public readonly apiAppUserPath = this.apiUrl + '/account/';
|
||||||
public readonly apiAwardPath = this.apiUrl + '/awardings';
|
|
||||||
public readonly apiDecorationPath = this.apiUrl + '/decorations/';
|
|
||||||
public readonly apiAuthenticationPath = this.apiUrl + '/authenticate';
|
public readonly apiAuthenticationPath = this.apiUrl + '/authenticate';
|
||||||
public readonly apiSignupPath = this.apiUrl + '/authenticate/signup';
|
public readonly apiAwardPath = this.apiUrl + '/awardings';
|
||||||
public readonly apiRankPath = this.apiUrl + '/ranks/';
|
public readonly apiCampaignPath = this.apiUrl + '/campaigns';
|
||||||
public readonly apiSquadPath = this.apiUrl + '/squads/';
|
public readonly apiDecorationPath = this.apiUrl + '/decorations/';
|
||||||
public readonly apiUserPath = this.apiUrl + '/users/';
|
public readonly apiLogsPath = this.apiUrl + '/logs';
|
||||||
public readonly apiOverviewPath = this.apiUrl + '/overview';
|
public readonly apiOverviewPath = this.apiUrl + '/overview';
|
||||||
public readonly apiPlayersPath = this.apiUrl + '/players';
|
public readonly apiPlayersPath = this.apiUrl + '/players';
|
||||||
public readonly apiRequestAwardPath = this.apiUrl + '/request/award';
|
|
||||||
public readonly apiPromotionPath = this.apiUrl + '/request/promotion';
|
public readonly apiPromotionPath = this.apiUrl + '/request/promotion';
|
||||||
|
public readonly apiRankPath = this.apiUrl + '/ranks/';
|
||||||
|
public readonly apiRequestAwardPath = this.apiUrl + '/request/award';
|
||||||
|
public readonly apiSignupPath = this.apiUrl + '/authenticate/signup';
|
||||||
|
public readonly apiSquadPath = this.apiUrl + '/squads/';
|
||||||
|
public readonly apiUserPath = this.apiUrl + '/users/';
|
||||||
public readonly apiWarPath = this.apiUrl + '/wars';
|
public readonly apiWarPath = this.apiUrl + '/wars';
|
||||||
public readonly apiCampaignPath = this.apiUrl + '/campaigns';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,24 +2,24 @@ import {NgModule} from '@angular/core';
|
||||||
import {BrowserModule} from "@angular/platform-browser";
|
import {BrowserModule} from "@angular/platform-browser";
|
||||||
import {HttpModule} from '@angular/http';
|
import {HttpModule} from '@angular/http';
|
||||||
import {AppComponent} from './app.component';
|
import {AppComponent} from './app.component';
|
||||||
import {LoginService} from "./services/login-service/login-service";
|
import {LoginService} from "./services/app-user-service/login-service";
|
||||||
import {appRouting, routingComponents, routingProviders} from './app.routing';
|
import {appRouting, routingComponents, routingProviders} from './app.routing';
|
||||||
import {SquadService} from "./services/squad-service/squad.service";
|
import {SquadService} from "./services/army-management/squad.service";
|
||||||
import {SquadStore} from "./services/stores/squad.store";
|
import {SquadStore} from "./services/stores/squad.store";
|
||||||
import {DecorationStore} from "./services/stores/decoration.store";
|
import {DecorationStore} from "./services/stores/decoration.store";
|
||||||
import {DecorationService} from "./services/decoration-service/decoration.service";
|
import {DecorationService} from "./services/army-management/decoration.service";
|
||||||
import {RankStore} from "./services/stores/rank.store";
|
import {RankStore} from "./services/stores/rank.store";
|
||||||
import {RankService} from "./services/rank-service/rank.service";
|
import {RankService} from "./services/army-management/rank.service";
|
||||||
import {AppConfig} from "./app.config";
|
import {AppConfig} from "./app.config";
|
||||||
import {LoginGuardAdmin, LoginGuardHL, LoginGuardSQL} from "./login/login.guard";
|
import {LoginGuardAdmin, LoginGuardHL, LoginGuardSQL} from "./login/login.guard";
|
||||||
import {AwardingService} from "./services/awarding-service/awarding.service";
|
import {AwardingService} from "./services/army-management/awarding.service";
|
||||||
import {HttpClient} from "./services/http-client";
|
import {HttpClient} from "./services/http-client";
|
||||||
import {ArmyService} from "./services/army-service/army.service";
|
import {ArmyService} from "./services/army-service/army.service";
|
||||||
import {ClipboardModule} from 'ngx-clipboard';
|
import {ClipboardModule} from 'ngx-clipboard';
|
||||||
import {PromotionService} from "./services/promotion-service/promotion.service";
|
import {PromotionService} from "./services/army-management/promotion.service";
|
||||||
import {SharedModule} from "./shared.module";
|
import {SharedModule} from "./shared.module";
|
||||||
import {BrowserAnimationsModule} from "@angular/platform-browser/animations";
|
import {BrowserAnimationsModule} from "@angular/platform-browser/animations";
|
||||||
import {UserService} from "./services/user-service/user.service";
|
import {UserService} from "./services/army-management/user.service";
|
||||||
import {UserStore} from "./services/stores/user.store";
|
import {UserStore} from "./services/stores/user.store";
|
||||||
import {CookieService} from "ngx-cookie-service";
|
import {CookieService} from "ngx-cookie-service";
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import {Component} from "@angular/core";
|
import {Component} 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/user-service/user.service";
|
import {UserService} from "../services/army-management/user.service";
|
||||||
import {Subscription} from "rxjs/Subscription";
|
import {Subscription} from "rxjs/Subscription";
|
||||||
import {RouteConfig} from "../app.config";
|
import {RouteConfig} from "../app.config";
|
||||||
import {AwardingService} from "../services/awarding-service/awarding.service";
|
import {AwardingService} from "../services/army-management/awarding.service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {FormControl} from "@angular/forms";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Observable} from "rxjs/Observable";
|
import {Observable} from "rxjs/Observable";
|
||||||
import {Decoration} from "../../models/model-interfaces";
|
import {Decoration} from "../../models/model-interfaces";
|
||||||
import {DecorationService} from "../../services/decoration-service/decoration.service";
|
import {DecorationService} from "../../services/army-management/decoration.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'decoration-list',
|
selector: 'decoration-list',
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {decorationRoutesModule, decorationsRoutingComponents} from "./decoration
|
||||||
import {SharedModule} from "../shared.module";
|
import {SharedModule} from "../shared.module";
|
||||||
import {CommonModule} from "@angular/common";
|
import {CommonModule} from "@angular/common";
|
||||||
import {DecorationStore} from "../services/stores/decoration.store";
|
import {DecorationStore} from "../services/stores/decoration.store";
|
||||||
import {DecorationService} from "../services/decoration-service/decoration.service";
|
import {DecorationService} from "../services/army-management/decoration.service";
|
||||||
import {NgModule} from "@angular/core";
|
import {NgModule} from "@angular/core";
|
||||||
import {ButtonsModule} from "ngx-bootstrap";
|
import {ButtonsModule} from "ngx-bootstrap";
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {Component, ViewChild} from "@angular/core";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {NgForm} from "@angular/forms";
|
import {NgForm} from "@angular/forms";
|
||||||
import {Decoration} from "../../models/model-interfaces";
|
import {Decoration} from "../../models/model-interfaces";
|
||||||
import {DecorationService} from "../../services/decoration-service/decoration.service";
|
import {DecorationService} from "../../services/army-management/decoration.service";
|
||||||
import {Subscription} from "rxjs/Subscription";
|
import {Subscription} from "rxjs/Subscription";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {Component, OnInit} from "@angular/core";
|
import {Component, OnInit} from "@angular/core";
|
||||||
import {Router} from "@angular/router";
|
import {Router} from "@angular/router";
|
||||||
import {LoginService} from "../services/login-service/login-service";
|
import {LoginService} from "../services/app-user-service/login-service";
|
||||||
import {RouteConfig} from "../app.config";
|
import {RouteConfig} from "../app.config";
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
|
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
|
||||||
import {LoginService} from "../services/login-service/login-service";
|
import {LoginService} from "../services/app-user-service/login-service";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class LoginGuardSQL implements CanActivate {
|
export class LoginGuardSQL implements CanActivate {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {Component, OnInit} from "@angular/core";
|
import {Component, OnInit} from "@angular/core";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {LoginService} from "../services/login-service/login-service";
|
import {LoginService} from "../services/app-user-service/login-service";
|
||||||
import {RouteConfig} from "../app.config";
|
import {RouteConfig} from "../app.config";
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,15 @@ export interface War {
|
||||||
_id?: string;
|
_id?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
date?: string;
|
date?: string;
|
||||||
|
endDate?: string;
|
||||||
ptBlufor?: number;
|
ptBlufor?: number;
|
||||||
ptOpfor?: number;
|
ptOpfor?: number;
|
||||||
playersBlufor?: number;
|
playersBlufor?: number;
|
||||||
playersOpfor?: number;
|
playersOpfor?: number;
|
||||||
|
budgetBlufor?: number;
|
||||||
|
budgetOpfor?: number;
|
||||||
|
endBudgetBlufor?: number;
|
||||||
|
endBudgetOpfor?: number;
|
||||||
players?: Player[];
|
players?: Player[];
|
||||||
campaign?: string;
|
campaign?: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {Component, ViewChild} from "@angular/core";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {NgForm} from "@angular/forms";
|
import {NgForm} from "@angular/forms";
|
||||||
import {Rank} from "../../models/model-interfaces";
|
import {Rank} from "../../models/model-interfaces";
|
||||||
import {RankService} from "../../services/rank-service/rank.service";
|
import {RankService} from "../../services/army-management/rank.service";
|
||||||
import {Subscription} from "rxjs/Subscription";
|
import {Subscription} from "rxjs/Subscription";
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {FormControl} from "@angular/forms";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Observable} from "rxjs/Observable";
|
import {Observable} from "rxjs/Observable";
|
||||||
import {Rank} from "../../models/model-interfaces";
|
import {Rank} from "../../models/model-interfaces";
|
||||||
import {RankService} from "../../services/rank-service/rank.service";
|
import {RankService} from "../../services/army-management/rank.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'rank-list',
|
selector: 'rank-list',
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {NgModule} from "@angular/core";
|
||||||
import {rankRouterModule, ranksRoutingComponents} from "./ranks.routing";
|
import {rankRouterModule, ranksRoutingComponents} from "./ranks.routing";
|
||||||
import {SharedModule} from "../shared.module";
|
import {SharedModule} from "../shared.module";
|
||||||
import {CommonModule} from "@angular/common";
|
import {CommonModule} from "@angular/common";
|
||||||
import {RankService} from "../services/rank-service/rank.service";
|
import {RankService} from "../services/army-management/rank.service";
|
||||||
import {RankStore} from "../services/stores/rank.store";
|
import {RankStore} from "../services/stores/rank.store";
|
||||||
import {ButtonsModule} from "ngx-bootstrap";
|
import {ButtonsModule} from "ngx-bootstrap";
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,10 @@ import {Component, ViewChild} from "@angular/core";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Award, Decoration, User} from "../../models/model-interfaces";
|
import {Award, Decoration, User} from "../../models/model-interfaces";
|
||||||
import {NgForm} from "@angular/forms";
|
import {NgForm} from "@angular/forms";
|
||||||
import {AwardingService} from "../../services/awarding-service/awarding.service";
|
import {AwardingService} from "../../services/army-management/awarding.service";
|
||||||
import {DecorationService} from "../../services/decoration-service/decoration.service";
|
import {DecorationService} from "../../services/army-management/decoration.service";
|
||||||
import {UserService} from "../../services/user-service/user.service";
|
import {UserService} from "../../services/army-management/user.service";
|
||||||
import {LoginService} from "../../services/login-service/login-service";
|
import {LoginService} from "../../services/app-user-service/login-service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {Component} from "@angular/core";
|
import {Component} from "@angular/core";
|
||||||
import {Award} from "../../models/model-interfaces";
|
import {Award} from "../../models/model-interfaces";
|
||||||
import {AwardingService} from "../../services/awarding-service/awarding.service";
|
import {AwardingService} from "../../services/army-management/awarding.service";
|
||||||
import {LoginService} from "../../services/login-service/login-service";
|
import {LoginService} from "../../services/app-user-service/login-service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import {Component} from "@angular/core";
|
import {Component} from "@angular/core";
|
||||||
import {Promotion, Rank} from "../../models/model-interfaces";
|
import {Promotion, Rank} from "../../models/model-interfaces";
|
||||||
import {RankService} from "../../services/rank-service/rank.service";
|
import {RankService} from "../../services/army-management/rank.service";
|
||||||
import {PromotionService} from "../../services/promotion-service/promotion.service";
|
import {PromotionService} from "../../services/army-management/promotion.service";
|
||||||
import {LoginService} from "../../services/login-service/login-service";
|
import {LoginService} from "../../services/app-user-service/login-service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -2,10 +2,10 @@ import {Component, ViewChild} from "@angular/core";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Rank, User} from "../../models/model-interfaces";
|
import {Rank, User} from "../../models/model-interfaces";
|
||||||
import {NgForm} from "@angular/forms";
|
import {NgForm} from "@angular/forms";
|
||||||
import {UserService} from "../../services/user-service/user.service";
|
import {UserService} from "../../services/army-management/user.service";
|
||||||
import {RankService} from "../../services/rank-service/rank.service";
|
import {RankService} from "../../services/army-management/rank.service";
|
||||||
import {PromotionService} from "../../services/promotion-service/promotion.service";
|
import {PromotionService} from "../../services/army-management/promotion.service";
|
||||||
import {LoginService} from "../../services/login-service/login-service";
|
import {LoginService} from "../../services/app-user-service/login-service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -3,8 +3,8 @@ import {Http, Response} from "@angular/http";
|
||||||
import "rxjs/add/operator/map";
|
import "rxjs/add/operator/map";
|
||||||
|
|
||||||
import {AppConfig} from "../../app.config";
|
import {AppConfig} from "../../app.config";
|
||||||
import {AwardingService} from "../awarding-service/awarding.service";
|
import {AwardingService} from "../army-management/awarding.service";
|
||||||
import {PromotionService} from "../promotion-service/promotion.service";
|
import {PromotionService} from "../army-management/promotion.service";
|
||||||
import {CookieService} from "ngx-cookie-service";
|
import {CookieService} from "ngx-cookie-service";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
|
@ -0,0 +1,80 @@
|
||||||
|
import {Injectable} from "@angular/core";
|
||||||
|
import {AppConfig} from "../../app.config";
|
||||||
|
import {HttpClient} from "../http-client";
|
||||||
|
import {URLSearchParams} from "@angular/http";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class LogsService {
|
||||||
|
|
||||||
|
constructor(private http: HttpClient,
|
||||||
|
private config: AppConfig) {
|
||||||
|
}
|
||||||
|
|
||||||
|
getFullLog(warId: string) {
|
||||||
|
return this.http.get(this.config.apiLogsPath + '/' + warId)
|
||||||
|
.map(res => res.json())
|
||||||
|
}
|
||||||
|
|
||||||
|
getBudgetLogs(warId: string, fraction = '') {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
params.append('fraction', fraction);
|
||||||
|
return this.http.get(this.config.apiLogsPath + '/' + warId + '/budget', params)
|
||||||
|
.map(res => res.json())
|
||||||
|
}
|
||||||
|
|
||||||
|
getRespawnLogs(warId: string, playerName = '') {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
params.append('player', playerName);
|
||||||
|
return this.http.get(this.config.apiLogsPath + '/' + warId + '/respawn', params)
|
||||||
|
.map(res => res.json())
|
||||||
|
}
|
||||||
|
|
||||||
|
getPointsLogs(warId: string, fraction = '') {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
params.append('fraction', fraction);
|
||||||
|
return this.http.get(this.config.apiLogsPath + '/' + warId + '/points', params)
|
||||||
|
.map(res => res.json())
|
||||||
|
}
|
||||||
|
|
||||||
|
getReviveLogs(warId: string, medicName = '', patientName = '', fraction = '', stabilizedOnly = false, reviveOnly = false) {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
params.append('medic', medicName);
|
||||||
|
params.append('patient', patientName);
|
||||||
|
params.append('fraction', fraction);
|
||||||
|
params.append('stabilized', stabilizedOnly ? 'true' : '');
|
||||||
|
params.append('revive', reviveOnly ? 'true' : '');
|
||||||
|
return this.http.get(this.config.apiLogsPath + '/' + warId + '/revive', params)
|
||||||
|
.map(res => res.json())
|
||||||
|
}
|
||||||
|
|
||||||
|
getKillLogs(warId: string, shooterName = '', targetName = '', fraction = '', friendlyFireOnly = false, notFriendlyFireOnly = false) {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
params.append('shooter', shooterName);
|
||||||
|
params.append('target', targetName);
|
||||||
|
params.append('fraction', fraction);
|
||||||
|
params.append('friendlyFire', friendlyFireOnly ? 'true' : '');
|
||||||
|
params.append('noFriendlyFire', notFriendlyFireOnly ? 'true' : '');
|
||||||
|
return this.http.get(this.config.apiLogsPath + '/' + warId + '/kills', params)
|
||||||
|
.map(res => res.json())
|
||||||
|
}
|
||||||
|
|
||||||
|
getTransportLogs(warId: string, driverName = '', passengerName = '', fraction = '') {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
params.append('driver', driverName);
|
||||||
|
params.append('passenger', passengerName);
|
||||||
|
params.append('fraction', fraction);
|
||||||
|
return this.http.get(this.config.apiLogsPath + '/' + warId + '/transport', params)
|
||||||
|
.map(res => res.json())
|
||||||
|
}
|
||||||
|
|
||||||
|
getFlagLogs(warId: string, playerName = '', fraction = '', captureOnly = false, defendOnly = false) {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
params.append('player', playerName);
|
||||||
|
params.append('fraction', fraction);
|
||||||
|
params.append('capture', captureOnly ? 'true' : '');
|
||||||
|
params.append('defend', defendOnly ? 'true' : '');
|
||||||
|
return this.http.get(this.config.apiLogsPath + '/' + warId + '/flag', params)
|
||||||
|
.map(res => res.json())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ import {Component, ViewChild} from "@angular/core";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {NgForm} from "@angular/forms";
|
import {NgForm} from "@angular/forms";
|
||||||
import {Squad} from "../../models/model-interfaces";
|
import {Squad} from "../../models/model-interfaces";
|
||||||
import {SquadService} from "../../services/squad-service/squad.service";
|
import {SquadService} from "../../services/army-management/squad.service";
|
||||||
import {Subscription} from "rxjs/Subscription";
|
import {Subscription} from "rxjs/Subscription";
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {FormControl} from "@angular/forms";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Observable} from "rxjs/Observable";
|
import {Observable} from "rxjs/Observable";
|
||||||
import {Squad} from "../../models/model-interfaces";
|
import {Squad} from "../../models/model-interfaces";
|
||||||
import {SquadService} from "../../services/squad-service/squad.service";
|
import {SquadService} from "../../services/army-management/squad.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'squad-list',
|
selector: 'squad-list',
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {CommonModule} from "@angular/common";
|
||||||
import {SharedModule} from "../shared.module";
|
import {SharedModule} from "../shared.module";
|
||||||
import {squadRouterModule, squadsRoutingComponents} from "./squads.routing";
|
import {squadRouterModule, squadsRoutingComponents} from "./squads.routing";
|
||||||
import {SquadStore} from "../services/stores/squad.store";
|
import {SquadStore} from "../services/stores/squad.store";
|
||||||
import {SquadService} from "../services/squad-service/squad.service";
|
import {SquadService} from "../services/army-management/squad.service";
|
||||||
import {ButtonsModule} from "ngx-bootstrap";
|
import {ButtonsModule} from "ngx-bootstrap";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {Component} from "@angular/core";
|
import {Component} from "@angular/core";
|
||||||
import {ActivatedRoute} from "@angular/router";
|
import {ActivatedRoute} from "@angular/router";
|
||||||
import {CampaignPlayer} from "../../models/model-interfaces";
|
import {CampaignPlayer} from "../../models/model-interfaces";
|
||||||
import {PlayerService} from "../../services/player-service/player.service";
|
import {PlayerService} from "../../services/logs/player.service";
|
||||||
import {ChartUtils} from "../../utils/chart-utils";
|
import {ChartUtils} from "../../utils/chart-utils";
|
||||||
import {Location} from '@angular/common';
|
import {Location} from '@angular/common';
|
||||||
|
|
||||||
|
@ -91,6 +91,10 @@ export class CampaignPlayerDetailComponent {
|
||||||
this.reviveData = this.assignData(this.yAxisRevive, "revive");
|
this.reviveData = this.assignData(this.yAxisRevive, "revive");
|
||||||
this.captureData = this.assignData(this.yAxisCapture, "flagTouch");
|
this.captureData = this.assignData(this.yAxisCapture, "flagTouch");
|
||||||
|
|
||||||
|
if (this.totalDeath === 0) {
|
||||||
|
// avoid infinite or NaN with no death
|
||||||
|
this.totalDeath = 1;
|
||||||
|
}
|
||||||
this.kdRatio = parseFloat((this.totalKills / this.totalDeath).toFixed(2));
|
this.kdRatio = parseFloat((this.totalKills / this.totalDeath).toFixed(2));
|
||||||
if (this.kdRatio > 1) this.maxKd = this.kdRatio * 1.7;
|
if (this.kdRatio > 1) this.maxKd = this.kdRatio * 1.7;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {Component, ViewChild} from "@angular/core";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {NgForm} from "@angular/forms";
|
import {NgForm} from "@angular/forms";
|
||||||
import {Campaign} from "../../models/model-interfaces";
|
import {Campaign} from "../../models/model-interfaces";
|
||||||
import {CampaignService} from "../../services/campaign-service/campaign.service";
|
import {CampaignService} from "../../services/logs/campaign.service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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 {CarouselConfig} from "ngx-bootstrap";
|
||||||
import {CampaignService} from "../../services/campaign-service/campaign.service";
|
import {CampaignService} from "../../services/logs/campaign.service";
|
||||||
import {ChartUtils} from "../../utils/chart-utils";
|
import {ChartUtils} from "../../utils/chart-utils";
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,18 +2,19 @@ import {NgModule} from '@angular/core';
|
||||||
import {CommonModule} from "@angular/common";
|
import {CommonModule} from "@angular/common";
|
||||||
import {SharedModule} from "../shared.module";
|
import {SharedModule} from "../shared.module";
|
||||||
import {statsRouterModule, statsRoutingComponents} from "./stats.routing";
|
import {statsRouterModule, statsRoutingComponents} from "./stats.routing";
|
||||||
import {WarService} from "../services/war-service/war.service";
|
import {WarService} from "../services/logs/war.service";
|
||||||
import {NgxChartsModule} from "@swimlane/ngx-charts";
|
import {NgxChartsModule} from "@swimlane/ngx-charts";
|
||||||
import {AccordionModule, CarouselModule} from "ngx-bootstrap";
|
import {AccordionModule, TabsModule} from "ngx-bootstrap";
|
||||||
import {CampaignService} from "../services/campaign-service/campaign.service";
|
import {CampaignService} from "../services/logs/campaign.service";
|
||||||
import {NgxDatatableModule} from "@swimlane/ngx-datatable";
|
import {NgxDatatableModule} from "@swimlane/ngx-datatable";
|
||||||
import {PlayerService} from "../services/player-service/player.service";
|
import {PlayerService} from "../services/logs/player.service";
|
||||||
|
import {LogsService} from "../services/logs/logs.service";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: statsRoutingComponents,
|
declarations: statsRoutingComponents,
|
||||||
imports: [CommonModule, SharedModule, statsRouterModule, NgxChartsModule,
|
imports: [CommonModule, SharedModule, statsRouterModule, NgxChartsModule,
|
||||||
AccordionModule.forRoot(), CarouselModule.forRoot(), NgxDatatableModule],
|
AccordionModule.forRoot(), TabsModule.forRoot(), NgxDatatableModule],
|
||||||
providers: [WarService, CampaignService, PlayerService]
|
providers: [WarService, CampaignService, PlayerService, LogsService]
|
||||||
})
|
})
|
||||||
export class StatsModule {
|
export class StatsModule {
|
||||||
static routes = statsRouterModule;
|
static routes = statsRouterModule;
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
.vertical-spacer {
|
.vertical-spacer {
|
||||||
height: 100vh;
|
height: 205px;
|
||||||
float: left;
|
float: left;
|
||||||
width: 4%;
|
width: 4%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.head-field {
|
||||||
|
font-size: 24px;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 1500px) {
|
@media screen and (min-width: 1500px) {
|
||||||
.vertical-spacer {
|
.vertical-spacer {
|
||||||
width: 15%;
|
width: 15%;
|
||||||
|
@ -36,6 +42,36 @@
|
||||||
color: blue;
|
color: blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chart-container {
|
||||||
|
width: 90%;
|
||||||
|
margin: 2%;
|
||||||
|
min-width: 900px;
|
||||||
|
height: 400px;
|
||||||
|
padding: 15px;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ########### TABS ########### */
|
||||||
|
|
||||||
|
:host /deep/ .nav-tabs {
|
||||||
|
padding-left: 35%!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host /deep/ .nav-link {
|
||||||
|
background: #4b4b4b;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host /deep/ .nav-link:hover {
|
||||||
|
background: #286090;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host /deep/ .nav-tabs>li.active>a{
|
||||||
|
background: #222222;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
/* ########### DATATABLE ########### */
|
/* ########### DATATABLE ########### */
|
||||||
|
|
||||||
:host /deep/ .datatable-header {
|
:host /deep/ .datatable-header {
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
<div #overview class="overview fade-in" xmlns="http://www.w3.org/1999/html">
|
<div #overview class="overview fade-in" xmlns="http://www.w3.org/1999/html">
|
||||||
<div class=vertical-spacer>
|
<div class=vertical-spacer></div>
|
||||||
</div>
|
|
||||||
<div style="overflow:hidden">
|
<div style="overflow:hidden">
|
||||||
<div style="width: 920px;min-height: 263px;">
|
<div style="width: 920px;min-height: 205px;">
|
||||||
<h2>{{war.title}} - vom {{war.date | date: 'dd.MM.yyyy'}}</h2>
|
<h2>{{war.title}} - vom {{war.date | date: 'dd.MM.yyyy'}}</h2>
|
||||||
<h3 class="pull-left" style="width: 250px">
|
<div class="pull-left head-field" style="width: 250px">
|
||||||
<h4>Endpunktestand:</h4>
|
<h4>Endpunktestand:</h4>
|
||||||
<span class="text-blufor" style="font-weight: bold; margin-right: 10px">NATO {{war.ptBlufor}}</span>
|
<span class="text-blufor" style="font-weight: bold; margin-right: 10px">NATO {{war.ptBlufor}}</span>
|
||||||
<span style="font-size: x-large">|</span>
|
<span style="font-size: x-large">|</span>
|
||||||
<span class="text-opfor" style="font-weight: bold; margin-left: 10px;">{{war.ptOpfor}} CSAT</span>
|
<span class="text-opfor" style="font-weight: bold; margin-left: 10px;">{{war.ptOpfor}} CSAT</span>
|
||||||
</h3>
|
</div>
|
||||||
|
|
||||||
<h3 class="pull-left" style="padding-left: 150px;">
|
<div class="pull-left head-field " style="padding-left: 140px;">
|
||||||
<h4>Teilnehmer:</h4>
|
<h4 style="margin-bottom: 0;">Teilnehmer:</h4>
|
||||||
<ngx-charts-pie-chart
|
<ngx-charts-pie-chart
|
||||||
[view]="[150, 150]"
|
[view]="[120, 120]"
|
||||||
[scheme]="{domain: ['#B22222', '#0000FF']}"
|
[scheme]="colorScheme"
|
||||||
[results]="playerChart"
|
[results]="playerChart"
|
||||||
[legend]="false"
|
[legend]="false"
|
||||||
[explodeSlices]="false"
|
[explodeSlices]="false"
|
||||||
|
@ -23,9 +22,9 @@
|
||||||
[doughnut]="false"
|
[doughnut]="false"
|
||||||
[gradient]="false">
|
[gradient]="false">
|
||||||
</ngx-charts-pie-chart>
|
</ngx-charts-pie-chart>
|
||||||
</h3>
|
</div>
|
||||||
|
|
||||||
<div class="pull-left" style="padding-left: 150px; padding-top:15px">
|
<div class="pull-left " style="padding-left: 150px; padding-top:15px">
|
||||||
<a class="btn btn-default" style="margin: 20px" target="_blank" href="resource/logs/{{war._id}}/clean.log">Logfile
|
<a class="btn btn-default" style="margin: 20px" target="_blank" href="resource/logs/{{war._id}}/clean.log">Logfile
|
||||||
anzeigen</a>
|
anzeigen</a>
|
||||||
<form class="form-group">
|
<form class="form-group">
|
||||||
|
@ -51,11 +50,18 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<tabset #staticTabs>
|
||||||
|
<tab>
|
||||||
|
<ng-template tabHeading>
|
||||||
|
<img src="../../../assets/scoreboard-btn.png"> Scoreboard
|
||||||
|
</ng-template>
|
||||||
|
<div class=vertical-spacer></div>
|
||||||
<ngx-datatable
|
<ngx-datatable
|
||||||
[rows]="rows"
|
[rows]="rows"
|
||||||
[reorderable]="reorderable"
|
|
||||||
[sorts]="[{prop: 'kill', dir: 'desc'}]"
|
[sorts]="[{prop: 'kill', dir: 'desc'}]"
|
||||||
|
[reorderable]="reorderable"
|
||||||
[messages]="{emptyMessage: 'Loading...'}"
|
[messages]="{emptyMessage: 'Loading...'}"
|
||||||
[headerHeight]="cellHeight"
|
[headerHeight]="cellHeight"
|
||||||
[rowHeight]="cellHeight"
|
[rowHeight]="cellHeight"
|
||||||
|
@ -82,6 +88,156 @@
|
||||||
<ngx-datatable-column [width]="100" name="Tod" prop="death"></ngx-datatable-column>
|
<ngx-datatable-column [width]="100" name="Tod" prop="death"></ngx-datatable-column>
|
||||||
<ngx-datatable-column [width]="100" name="Respawn" prop="respawn"></ngx-datatable-column>
|
<ngx-datatable-column [width]="100" name="Respawn" prop="respawn"></ngx-datatable-column>
|
||||||
</ngx-datatable>
|
</ngx-datatable>
|
||||||
|
</tab>
|
||||||
|
|
||||||
|
<tab (select)="loadFractionData()">
|
||||||
|
<ng-template tabHeading>
|
||||||
|
<img src="../../../assets/fraction-btn.png"> Fraktionen
|
||||||
|
</ng-template>
|
||||||
|
<div class="fade-in chart-container">
|
||||||
|
<ngx-charts-line-chart
|
||||||
|
[scheme]="colorScheme"
|
||||||
|
[results]="pointData"
|
||||||
|
[gradient]="gradient"
|
||||||
|
[xAxis]="xAxis"
|
||||||
|
[yAxis]="yAxis"
|
||||||
|
[curve]="monotoneYCurve"
|
||||||
|
[legend]="legend"
|
||||||
|
[legendTitle]="legendTitle"
|
||||||
|
[showXAxisLabel]="showXAxisLabel"
|
||||||
|
[showYAxisLabel]="showYAxisLabel"
|
||||||
|
[yAxisLabel]="yAxisLabelPoints"
|
||||||
|
[autoScale]="autoscale"
|
||||||
|
[timeline]="timeline"
|
||||||
|
[roundDomains]="roundDomains">
|
||||||
|
</ngx-charts-line-chart>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="fade-in chart-container">
|
||||||
|
<ngx-charts-line-chart
|
||||||
|
[scheme]="colorScheme"
|
||||||
|
[results]="budgetData"
|
||||||
|
[gradient]="gradient"
|
||||||
|
[xAxis]="xAxis"
|
||||||
|
[yAxis]="yAxis"
|
||||||
|
[curve]="monotoneYCurve"
|
||||||
|
[legend]="legend"
|
||||||
|
[legendTitle]="legendTitle"
|
||||||
|
[showXAxisLabel]="showXAxisLabel"
|
||||||
|
[showYAxisLabel]="showYAxisLabel"
|
||||||
|
[yAxisLabel]="yAxisLabelBudget"
|
||||||
|
[autoScale]="autoscale"
|
||||||
|
[timeline]="timeline"
|
||||||
|
[roundDomains]="roundDomains">
|
||||||
|
</ngx-charts-line-chart>
|
||||||
|
</div>
|
||||||
|
<div class="fade-in chart-container">
|
||||||
|
<ngx-charts-line-chart
|
||||||
|
[scheme]="colorScheme"
|
||||||
|
[results]="killData"
|
||||||
|
[gradient]="gradient"
|
||||||
|
[xAxis]="xAxis"
|
||||||
|
[yAxis]="yAxis"
|
||||||
|
[curve]="monotoneYCurve"
|
||||||
|
[legend]="legend"
|
||||||
|
[legendTitle]="legendTitle"
|
||||||
|
[showXAxisLabel]="showXAxisLabel"
|
||||||
|
[showYAxisLabel]="showYAxisLabel"
|
||||||
|
[yAxisLabel]="yAxisLabelKill"
|
||||||
|
[autoScale]="autoscale"
|
||||||
|
[timeline]="timeline"
|
||||||
|
[roundDomains]="roundDomains">
|
||||||
|
</ngx-charts-line-chart>
|
||||||
|
</div>
|
||||||
|
<div class="fade-in chart-container">
|
||||||
|
<ngx-charts-line-chart
|
||||||
|
[scheme]="colorScheme"
|
||||||
|
[results]="friendlyFireData"
|
||||||
|
[gradient]="gradient"
|
||||||
|
[xAxis]="xAxis"
|
||||||
|
[yAxis]="yAxis"
|
||||||
|
[curve]="monotoneYCurve"
|
||||||
|
[legend]="legend"
|
||||||
|
[legendTitle]="legendTitle"
|
||||||
|
[showXAxisLabel]="showXAxisLabel"
|
||||||
|
[showYAxisLabel]="showYAxisLabel"
|
||||||
|
[yAxisLabel]="yAxisLabelFriendlyFire"
|
||||||
|
[autoScale]="autoscale"
|
||||||
|
[timeline]="timeline"
|
||||||
|
[roundDomains]="roundDomains">
|
||||||
|
</ngx-charts-line-chart>
|
||||||
|
</div>
|
||||||
|
<div class="fade-in chart-container">
|
||||||
|
<ngx-charts-line-chart
|
||||||
|
[scheme]="colorScheme"
|
||||||
|
[results]="transportData"
|
||||||
|
[gradient]="gradient"
|
||||||
|
[xAxis]="xAxis"
|
||||||
|
[yAxis]="yAxis"
|
||||||
|
[curve]="monotoneYCurve"
|
||||||
|
[legend]="legend"
|
||||||
|
[legendTitle]="legendTitle"
|
||||||
|
[showXAxisLabel]="showXAxisLabel"
|
||||||
|
[showYAxisLabel]="showYAxisLabel"
|
||||||
|
[yAxisLabel]="yAxisLabelTransport"
|
||||||
|
[autoScale]="autoscale"
|
||||||
|
[timeline]="timeline"
|
||||||
|
[roundDomains]="roundDomains">
|
||||||
|
</ngx-charts-line-chart>
|
||||||
|
</div>
|
||||||
|
<div class="fade-in chart-container">
|
||||||
|
<ngx-charts-line-chart
|
||||||
|
[scheme]="colorScheme"
|
||||||
|
[results]="reviveData"
|
||||||
|
[gradient]="gradient"
|
||||||
|
[xAxis]="xAxis"
|
||||||
|
[yAxis]="yAxis"
|
||||||
|
[curve]="monotoneYCurve"
|
||||||
|
[legend]="legend"
|
||||||
|
[legendTitle]="legendTitle"
|
||||||
|
[showXAxisLabel]="showXAxisLabel"
|
||||||
|
[showYAxisLabel]="showYAxisLabel"
|
||||||
|
[yAxisLabel]="yAxisLabelRevive"
|
||||||
|
[autoScale]="autoscale"
|
||||||
|
[timeline]="timeline"
|
||||||
|
[roundDomains]="roundDomains">
|
||||||
|
</ngx-charts-line-chart>
|
||||||
|
</div>
|
||||||
|
<div class="fade-in chart-container">
|
||||||
|
<ngx-charts-line-chart
|
||||||
|
[scheme]="colorScheme"
|
||||||
|
[results]="stabilizedData"
|
||||||
|
[gradient]="gradient"
|
||||||
|
[xAxis]="xAxis"
|
||||||
|
[yAxis]="yAxis"
|
||||||
|
[curve]="monotoneYCurve"
|
||||||
|
[legend]="legend"
|
||||||
|
[legendTitle]="legendTitle"
|
||||||
|
[showXAxisLabel]="showXAxisLabel"
|
||||||
|
[showYAxisLabel]="showYAxisLabel"
|
||||||
|
[yAxisLabel]="yAxisLabelStabilize"
|
||||||
|
[autoScale]="autoscale"
|
||||||
|
[timeline]="timeline"
|
||||||
|
[roundDomains]="roundDomains">
|
||||||
|
</ngx-charts-line-chart>
|
||||||
|
</div>
|
||||||
|
<div class="fade-in chart-container">
|
||||||
|
<ngx-charts-area-chart
|
||||||
|
[scheme]="colorScheme"
|
||||||
|
[results]="flagData"
|
||||||
|
[xAxis]="xAxis"
|
||||||
|
[yAxis]="yAxis"
|
||||||
|
[curve]="stepCurve"
|
||||||
|
[legend]="legend"
|
||||||
|
[legendTitle]="legendTitle"
|
||||||
|
[showXAxisLabel]="showXAxisLabel"
|
||||||
|
[showYAxisLabel]="showYAxisLabel"
|
||||||
|
[yAxisLabel]="yAxisLabelFlag"
|
||||||
|
[autoScale]="autoscale"
|
||||||
|
[timeline]="timeline"
|
||||||
|
[roundDomains]="roundDomains">
|
||||||
|
</ngx-charts-area-chart>
|
||||||
|
</div>
|
||||||
|
</tab>
|
||||||
|
</tabset>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import {Component, ElementRef, ViewChild} from "@angular/core";
|
import {Component, ElementRef, ViewChild} from "@angular/core";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {WarService} from "../../services/war-service/war.service";
|
import {WarService} from "../../services/logs/war.service";
|
||||||
import {War} from "../../models/model-interfaces";
|
import {War} from "../../models/model-interfaces";
|
||||||
|
import {LogsService} from "../../services/logs/logs.service";
|
||||||
|
import {TabsetComponent} from "ngx-bootstrap";
|
||||||
|
import * as d3 from "d3";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -11,14 +14,16 @@ import {War} from "../../models/model-interfaces";
|
||||||
})
|
})
|
||||||
export class WarDetailComponent {
|
export class WarDetailComponent {
|
||||||
|
|
||||||
|
@ViewChild('overview') private overviewContainer: ElementRef;
|
||||||
|
|
||||||
|
@ViewChild('staticTabs') staticTabs: TabsetComponent;
|
||||||
|
|
||||||
war: War = {players: []};
|
war: War = {players: []};
|
||||||
|
|
||||||
fractionRadioSelect: string;
|
fractionRadioSelect: string;
|
||||||
|
|
||||||
playerChart: any[] = [];
|
playerChart: any[] = [];
|
||||||
|
|
||||||
@ViewChild('overview') private overviewContainer: ElementRef;
|
|
||||||
|
|
||||||
cellHeight = 40;
|
cellHeight = 40;
|
||||||
|
|
||||||
rows = [];
|
rows = [];
|
||||||
|
@ -30,10 +35,55 @@ export class WarDetailComponent {
|
||||||
sortDescending: 'glyphicon glyphicon-triangle-bottom',
|
sortDescending: 'glyphicon glyphicon-triangle-bottom',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pointData: any[] = [];
|
||||||
|
budgetData: any[] = [];
|
||||||
|
killData: any[] = [];
|
||||||
|
friendlyFireData: any[] = [];
|
||||||
|
transportData: any[] = [];
|
||||||
|
reviveData: any[] = [];
|
||||||
|
stabilizedData: any[] = [];
|
||||||
|
flagData: any[] = [];
|
||||||
|
|
||||||
|
tmpPointData;
|
||||||
|
tmpBudgetData;
|
||||||
|
tmpKillData;
|
||||||
|
tmpFrienlyFireData;
|
||||||
|
tmpTransportData;
|
||||||
|
tmpReviveData;
|
||||||
|
tmpStabilizeData;
|
||||||
|
tmpFlagCaptureData;
|
||||||
|
|
||||||
|
colorScheme = {
|
||||||
|
domain: ['#0000FF', '#B22222']
|
||||||
|
};
|
||||||
|
|
||||||
|
yAxisLabelPoints = 'Punkte';
|
||||||
|
yAxisLabelBudget = 'Budget';
|
||||||
|
yAxisLabelKill = 'Kills';
|
||||||
|
yAxisLabelFriendlyFire = 'FriendlyFire';
|
||||||
|
yAxisLabelTransport = 'Lufttransport';
|
||||||
|
yAxisLabelRevive = 'Revive';
|
||||||
|
yAxisLabelStabilize = 'Stabilisiert';
|
||||||
|
yAxisLabelFlag = 'Flaggenbesitz';
|
||||||
|
|
||||||
|
monotoneYCurve = d3.curveMonotoneY;
|
||||||
|
stepCurve = d3.curveStepAfter;
|
||||||
|
gradient = false;
|
||||||
|
yAxis = true;
|
||||||
|
xAxis = true;
|
||||||
|
legend = false;
|
||||||
|
legendTitle = false;
|
||||||
|
showXAxisLabel = false;
|
||||||
|
showYAxisLabel = true;
|
||||||
|
autoscale = true;
|
||||||
|
timeline = false;
|
||||||
|
roundDomains = true;
|
||||||
|
fractionChartsInitialized: boolean = false;
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private warService: WarService) {
|
private warService: WarService,
|
||||||
Object.assign(this, this.playerChart)
|
private logsService: LogsService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -54,6 +104,29 @@ export class WarDetailComponent {
|
||||||
"value": war.playersBlufor
|
"value": war.playersBlufor
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
this.tmpPointData = [
|
||||||
|
{
|
||||||
|
"name": "NATO",
|
||||||
|
"series": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "CSAT",
|
||||||
|
"series": []
|
||||||
|
}
|
||||||
|
];
|
||||||
|
this.tmpBudgetData = JSON.parse(JSON.stringify(this.tmpPointData));
|
||||||
|
this.tmpKillData = JSON.parse(JSON.stringify(this.tmpPointData));
|
||||||
|
this.tmpFrienlyFireData = JSON.parse(JSON.stringify(this.tmpPointData));
|
||||||
|
this.tmpTransportData = JSON.parse(JSON.stringify(this.tmpPointData));
|
||||||
|
this.tmpReviveData = JSON.parse(JSON.stringify(this.tmpPointData));
|
||||||
|
this.tmpStabilizeData = JSON.parse(JSON.stringify(this.tmpPointData));
|
||||||
|
this.tmpFlagCaptureData = JSON.parse(JSON.stringify(this.tmpPointData));
|
||||||
|
|
||||||
|
Object.assign(this, [this.playerChart, this.pointData, this.budgetData, this.killData,
|
||||||
|
this.friendlyFireData, this.transportData, this.reviveData, this.stabilizedData, this.flagData]);
|
||||||
|
|
||||||
|
this.fractionChartsInitialized = false;
|
||||||
|
this.staticTabs.tabs[0].active = true;
|
||||||
this.scrollOverviewTop();
|
this.scrollOverviewTop();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -82,4 +155,212 @@ export class WarDetailComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadFractionData() {
|
||||||
|
if (!this.fractionChartsInitialized) {
|
||||||
|
const startDateObj = new Date(this.war.date);
|
||||||
|
startDateObj.setHours(0);
|
||||||
|
startDateObj.setMinutes(1);
|
||||||
|
|
||||||
|
this.logsService.getFullLog(this.war._id).subscribe((data) => {
|
||||||
|
// POINTS
|
||||||
|
data.points.forEach(pointEntry => {
|
||||||
|
const dateObj = new Date(this.war.date);
|
||||||
|
const time = pointEntry.time.split(':');
|
||||||
|
dateObj.setHours(time[0]);
|
||||||
|
dateObj.setMinutes(time[1]);
|
||||||
|
this.tmpPointData[0].series.push({
|
||||||
|
"name": new Date(pointEntry.time),
|
||||||
|
"value": pointEntry.ptBlufor
|
||||||
|
});
|
||||||
|
this.tmpPointData[1].series.push({
|
||||||
|
"name": new Date(pointEntry.time),
|
||||||
|
"value": pointEntry.ptOpfor
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// BUDGET
|
||||||
|
this.tmpBudgetData[0].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": this.war.budgetBlufor
|
||||||
|
});
|
||||||
|
this.tmpBudgetData[1].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": this.war.budgetOpfor
|
||||||
|
});
|
||||||
|
data.budget.forEach(budgetEntry => {
|
||||||
|
this.tmpBudgetData[budgetEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
|
||||||
|
"name": new Date(budgetEntry.time),
|
||||||
|
"value": budgetEntry.newBudget
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// KILLS
|
||||||
|
let killCountBlufor = 0;
|
||||||
|
let killCountOpfor = 0;
|
||||||
|
let ffKillCountBlufor = 0;
|
||||||
|
let ffKillCountOpfor = 0;
|
||||||
|
this.tmpKillData[0].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": killCountBlufor
|
||||||
|
});
|
||||||
|
this.tmpKillData[1].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": killCountOpfor
|
||||||
|
});
|
||||||
|
this.tmpFrienlyFireData[0].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": ffKillCountBlufor
|
||||||
|
});
|
||||||
|
this.tmpFrienlyFireData[1].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": ffKillCountOpfor
|
||||||
|
});
|
||||||
|
|
||||||
|
data.kill.forEach(killEntry => {
|
||||||
|
if (killEntry.fraction === 'BLUFOR') {
|
||||||
|
if (killEntry.friendlyFire === false) {
|
||||||
|
killCountBlufor++;
|
||||||
|
} else {
|
||||||
|
ffKillCountBlufor++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (killEntry.friendlyFire === false) {
|
||||||
|
killCountOpfor++;
|
||||||
|
} else {
|
||||||
|
ffKillCountOpfor++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.tmpKillData[killEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
|
||||||
|
"name": new Date(killEntry.time),
|
||||||
|
"value": killEntry.fraction === 'BLUFOR' ? killCountBlufor : killCountOpfor
|
||||||
|
});
|
||||||
|
this.tmpFrienlyFireData[killEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
|
||||||
|
"name": new Date(killEntry.time),
|
||||||
|
"value": killEntry.fraction === 'BLUFOR' ? ffKillCountBlufor : ffKillCountOpfor
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// TRANSPORT
|
||||||
|
let transportCountBlufor = 0;
|
||||||
|
let transportCountOpfor = 0;
|
||||||
|
this.tmpTransportData[0].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": transportCountBlufor
|
||||||
|
});
|
||||||
|
this.tmpTransportData[1].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": transportCountOpfor
|
||||||
|
});
|
||||||
|
|
||||||
|
data.transport.forEach(transportEntry => {
|
||||||
|
if (transportEntry.fraction === 'BLUFOR') {
|
||||||
|
transportCountBlufor++;
|
||||||
|
} else {
|
||||||
|
transportCountOpfor++;
|
||||||
|
}
|
||||||
|
this.tmpTransportData[transportEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
|
||||||
|
"name": new Date(transportEntry.time),
|
||||||
|
"value": transportEntry.fraction === 'BLUFOR' ? transportCountBlufor : transportCountOpfor
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// REVIVE & STABILIZE
|
||||||
|
let reviveCountBlufor = 0;
|
||||||
|
let reviveCountOpfor = 0;
|
||||||
|
let stabilizeCountBlufor = 0;
|
||||||
|
let stabilizeCountOpfor = 0;
|
||||||
|
this.tmpReviveData[0].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": reviveCountBlufor
|
||||||
|
});
|
||||||
|
this.tmpReviveData[1].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": reviveCountOpfor
|
||||||
|
});
|
||||||
|
this.tmpStabilizeData[0].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": stabilizeCountBlufor
|
||||||
|
});
|
||||||
|
this.tmpStabilizeData[1].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": stabilizeCountOpfor
|
||||||
|
});
|
||||||
|
data.revive.forEach(reviveEntry => {
|
||||||
|
if (reviveEntry.fraction === 'BLUFOR') {
|
||||||
|
if (reviveEntry.stabilized === false) {
|
||||||
|
reviveCountBlufor++;
|
||||||
|
} else {
|
||||||
|
reviveCountOpfor++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (reviveEntry.stabilized === false) {
|
||||||
|
stabilizeCountBlufor++;
|
||||||
|
} else {
|
||||||
|
stabilizeCountOpfor++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.tmpReviveData[reviveEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
|
||||||
|
"name": new Date(reviveEntry.time),
|
||||||
|
"value": reviveEntry.fraction === 'BLUFOR' ? reviveCountBlufor : reviveCountOpfor
|
||||||
|
});
|
||||||
|
this.tmpStabilizeData[reviveEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
|
||||||
|
"name": new Date(reviveEntry.time),
|
||||||
|
"value": reviveEntry.fraction === 'BLUFOR' ? stabilizeCountBlufor : stabilizeCountOpfor
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// FLAG
|
||||||
|
let flagStatusBlufor = true;
|
||||||
|
let flagStatusOpfor = true;
|
||||||
|
this.tmpFlagCaptureData[0].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": flagStatusBlufor
|
||||||
|
});
|
||||||
|
this.tmpFlagCaptureData[1].series.push({
|
||||||
|
"name": startDateObj,
|
||||||
|
"value": flagStatusOpfor
|
||||||
|
});
|
||||||
|
|
||||||
|
data.flag.forEach(flagEntry => {
|
||||||
|
if (flagEntry.flagFraction === 'BLUFOR') {
|
||||||
|
flagStatusBlufor = !flagEntry.capture
|
||||||
|
} else {
|
||||||
|
flagStatusOpfor = !flagEntry.capture;
|
||||||
|
}
|
||||||
|
this.tmpFlagCaptureData[flagEntry.flagFraction === 'BLUFOR' ? 0 : 1].series.push({
|
||||||
|
"name": new Date(flagEntry.time),
|
||||||
|
"value": flagEntry.flagFraction === 'BLUFOR' ? flagStatusBlufor : flagStatusOpfor
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
this.addFinalTimeDataEntriesAndPopulate(new Date(this.war.endDate));
|
||||||
|
|
||||||
|
this.fractionChartsInitialized = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addFinalTimeDataEntriesAndPopulate(endDate) {
|
||||||
|
[this.tmpPointData, this.tmpBudgetData, this.tmpTransportData, this.tmpReviveData, this.tmpStabilizeData,
|
||||||
|
this.tmpKillData, this.tmpFrienlyFireData, this.tmpFlagCaptureData].forEach(tmp => {
|
||||||
|
for (let j in [0, 1]) {
|
||||||
|
if (tmp[j].series[tmp[j].series.length - 1].name < endDate) {
|
||||||
|
tmp[j].series.push({
|
||||||
|
'name': endDate,
|
||||||
|
'value': tmp[j].series[tmp[j].series.length - 1].value
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.pointData = this.tmpPointData;
|
||||||
|
this.budgetData = this.tmpBudgetData;
|
||||||
|
this.transportData = this.tmpTransportData;
|
||||||
|
this.reviveData = this.tmpReviveData;
|
||||||
|
this.stabilizedData = this.tmpStabilizeData;
|
||||||
|
this.killData = this.tmpKillData;
|
||||||
|
this.friendlyFireData = this.tmpFrienlyFireData;
|
||||||
|
this.flagData = this.tmpFlagCaptureData;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {ChangeDetectionStrategy, Component, EventEmitter} from "@angular/core";
|
import {ChangeDetectionStrategy, Component, EventEmitter} from "@angular/core";
|
||||||
import {War} from "../../models/model-interfaces";
|
import {War} from "../../models/model-interfaces";
|
||||||
import {LoginService} from "../../services/login-service/login-service";
|
import {LoginService} from "../../services/app-user-service/login-service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'pjm-war-item',
|
selector: 'pjm-war-item',
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import {Component, OnInit} from "@angular/core";
|
import {Component, OnInit} from "@angular/core";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Campaign, War} from "../../models/model-interfaces";
|
import {Campaign, War} from "../../models/model-interfaces";
|
||||||
import {WarService} from "../../services/war-service/war.service";
|
import {WarService} from "../../services/logs/war.service";
|
||||||
import {LoginService} from "../../services/login-service/login-service";
|
import {LoginService} from "../../services/app-user-service/login-service";
|
||||||
import {CampaignService} from "../../services/campaign-service/campaign.service";
|
import {CampaignService} from "../../services/logs/campaign.service";
|
||||||
import {RouteConfig} from "../../app.config";
|
import {RouteConfig} from "../../app.config";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -12,36 +12,6 @@
|
||||||
<show-error text="Name" path="title"></show-error>
|
<show-error text="Name" path="title"></show-error>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="date">Datum</label>
|
|
||||||
<input type="date" class="form-control"
|
|
||||||
[(ngModel)]="war.date"
|
|
||||||
name="date"
|
|
||||||
id="date"
|
|
||||||
required/>
|
|
||||||
<show-error text="Datum" path="date"></show-error>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="ptblu">Punkte NATO</label>
|
|
||||||
<input type="number" class="form-control" step="1"
|
|
||||||
[(ngModel)]="war.ptBlufor"
|
|
||||||
name="ptblu"
|
|
||||||
id="ptblu"
|
|
||||||
required/>
|
|
||||||
<show-error text="Punkte NATO" path="ptblu"></show-error>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="ptopf">Punkte CSAT</label>
|
|
||||||
<input type="number" class="form-control" step="1"
|
|
||||||
[(ngModel)]="war.ptOpfor"
|
|
||||||
name="ptopf"
|
|
||||||
id="ptopf"
|
|
||||||
required/>
|
|
||||||
<show-error text="Punkte CSAT" path="ptopf"></show-error>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="campaign">Kampagne</label>
|
<label for="campaign">Kampagne</label>
|
||||||
<select class="form-control"
|
<select class="form-control"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import {Component, ViewChild} from "@angular/core";
|
import {Component, ViewChild} from "@angular/core";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {NgForm} from "@angular/forms";
|
import {NgForm} from "@angular/forms";
|
||||||
import {WarService} from "../../services/war-service/war.service";
|
import {WarService} from "../../services/logs/war.service";
|
||||||
import {War} from "../../models/model-interfaces";
|
import {War} from "../../models/model-interfaces";
|
||||||
import {CampaignService} from "../../services/campaign-service/campaign.service";
|
import {CampaignService} from "../../services/logs/campaign.service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -14,7 +14,7 @@ import {CampaignService} from "../../services/campaign-service/campaign.service"
|
||||||
})
|
})
|
||||||
export class WarSubmitComponent {
|
export class WarSubmitComponent {
|
||||||
|
|
||||||
war: War = {date: new Date().toISOString().slice(0, 10), players: []};
|
war: War = {players: []};
|
||||||
|
|
||||||
fileList: FileList;
|
fileList: FileList;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ div.user-list-entry, a.user-list-entry {
|
||||||
background: lightgrey;
|
background: lightgrey;
|
||||||
}
|
}
|
||||||
|
|
||||||
span {
|
span > a, span.glyphicon, span.icon-award{
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ import {Component, ViewChild} from "@angular/core";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Award, Decoration} from "../../models/model-interfaces";
|
import {Award, Decoration} from "../../models/model-interfaces";
|
||||||
import {NgForm} from "@angular/forms";
|
import {NgForm} from "@angular/forms";
|
||||||
import {AwardingService} from "../../services/awarding-service/awarding.service";
|
import {AwardingService} from "../../services/army-management/awarding.service";
|
||||||
import {DecorationService} from "../../services/decoration-service/decoration.service";
|
import {DecorationService} from "../../services/army-management/decoration.service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import {Component, ViewChild} from "@angular/core";
|
import {Component, ViewChild} from "@angular/core";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Rank, Squad, User} from "../../models/model-interfaces";
|
import {Rank, Squad, User} from "../../models/model-interfaces";
|
||||||
import {UserService} from "../../services/user-service/user.service";
|
import {UserService} from "../../services/army-management/user.service";
|
||||||
import {SquadService} from "../../services/squad-service/squad.service";
|
import {SquadService} from "../../services/army-management/squad.service";
|
||||||
import {RankService} from "../../services/rank-service/rank.service";
|
import {RankService} from "../../services/army-management/rank.service";
|
||||||
import {Subscription} from "rxjs";
|
import {Subscription} from "rxjs";
|
||||||
import {NgForm} from "@angular/forms";
|
import {NgForm} from "@angular/forms";
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {Location} from "@angular/common";
|
||||||
import {FormControl} from "@angular/forms";
|
import {FormControl} from "@angular/forms";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Observable} from "rxjs/Observable";
|
import {Observable} from "rxjs/Observable";
|
||||||
import {UserService} from "../../services/user-service/user.service";
|
import {UserService} from "../../services/army-management/user.service";
|
||||||
import {User} from "../../models/model-interfaces";
|
import {User} from "../../models/model-interfaces";
|
||||||
import {ADD, LOAD} from "../../services/stores/user.store";
|
import {ADD, LOAD} from "../../services/stores/user.store";
|
||||||
|
|
||||||
|
|
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 797 B |