Compare commits

..

No commits in common. "24f46b0f3cb7412eba2c83d072e0fdf65edce759" and "3ccdbe4da307fa348ac4277dc00144c9f771bdcb" have entirely different histories.

17 changed files with 51 additions and 241 deletions

View File

@ -3,7 +3,6 @@
"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",

View File

@ -5,7 +5,6 @@ const express = require('express');
const logger = require('debug')('cc:logs'); const logger = require('debug')('cc:logs');
const routerHandling = require('../middleware/router-handling'); const routerHandling = require('../middleware/router-handling');
const decimalToTimeString = require('../tools/util').decimalToTimeString;
// Mongoose Model using mongoDB // Mongoose Model using mongoDB
const LogBudgetModel = require('../models/logs/budget'); const LogBudgetModel = require('../models/logs/budget');
@ -26,13 +25,7 @@ function processLogRequest(model, filter, res, next) {
err.status = require('./http-codes').notfound; err.status = require('./http-codes').notfound;
return next(err) return next(err)
} }
const updatedTimeItems = []; res.locals.items = log;
for (let i =0; i <log.length; i++) {
let item = log[i].toObject();
item.time = decimalToTimeString(item.time);
updatedTimeItems.push(item);
}
res.locals.items = updatedTimeItems;
next(); next();
}) })
} }

View File

@ -150,7 +150,7 @@ wars.route('/:id')
err.status = codes.notfound; err.status = codes.notfound;
return next(err); return next(err);
} }
PlayerModel.find({warId: item._id}, {}, {sort: {kill: 'desc'}}, (err, items) => { PlayerModel.find({warId: item._id}, {}, {sort: {sort: 'desc'}}, (err, items) => {
if (err) { if (err) {
return next(err); return next(err);
} }

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const timeStringToDecimal = require('../tools/util').timeStringToDecimal; const timeStringToDecimal = require('../tools/util').timeStringToDecimal;
const playerArrayContains = require('./util').playerArrayContains; const arrayContains = require('./util').arrayContains;
const parseWarLog = (lineArray, war) => { const parseWarLog = (lineArray, war) => {
const nameToLongError = 'Error: ENAMETOOLONG: name too long, open \''; const nameToLongError = 'Error: ENAMETOOLONG: name too long, open \'';
@ -20,7 +20,7 @@ const parseWarLog = (lineArray, war) => {
const addPlayersIfNotExists = (inputPlayers) => { const addPlayersIfNotExists = (inputPlayers) => {
inputPlayers.forEach(player => { inputPlayers.forEach(player => {
if (player && player.name && player.fraction && !playerArrayContains(stats.players, player)) { if (player && player.name && player.fraction && !arrayContains(stats.players, player)) {
player['warId'] = war._id; player['warId'] = war._id;
stats.players.push(player); stats.players.push(player);
} }

View File

@ -29,7 +29,7 @@ const timeStringToDecimal = (timeString) => {
const hour = parseInt(timeArray[0]); const hour = parseInt(timeArray[0]);
const sek = parseInt(timeArray[1]) * 60 + parseInt(timeArray[2]); const sek = parseInt(timeArray[1]) * 60 + parseInt(timeArray[2]);
return hour + (sek / 3600); return hour + sek * (1 / 3600);
}; };
@ -45,6 +45,6 @@ const decimalToTimeString = (decimal) => {
}; };
exports.sortCollection = sortCollectionBy; exports.sortCollection = sortCollectionBy;
exports.playerArrayContains = playerArrayContains; exports.arrayContains = playerArrayContains;
exports.timeStringToDecimal = timeStringToDecimal; exports.timeStringToDecimal = timeStringToDecimal;
exports.decimalToTimeString = decimalToTimeString; exports.decimalToTimeString = decimalToTimeString;

View File

@ -2,7 +2,6 @@
"name": "opt-cc", "name": "opt-cc",
"version": "1.6.0", "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",

View File

@ -1,7 +1,6 @@
{ {
"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": {
@ -31,6 +30,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-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",

View File

@ -50,10 +50,6 @@ export interface War {
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;
} }

View File

@ -11,6 +11,7 @@ export class LogsService {
} }
getBudgetLogs(warId: string, fraction = '') { getBudgetLogs(warId: string, fraction = '') {
console.log("CALL")
const params = new URLSearchParams(); const params = new URLSearchParams();
params.append('fraction', fraction); params.append('fraction', fraction);
return this.http.get(this.config.apiLogsPath + '/' + warId + '/budget', params) return this.http.get(this.config.apiLogsPath + '/' + warId + '/budget', params)

View File

@ -91,10 +91,6 @@ 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;

View File

@ -4,7 +4,7 @@ import {SharedModule} from "../shared.module";
import {statsRouterModule, statsRoutingComponents} from "./stats.routing"; import {statsRouterModule, statsRoutingComponents} from "./stats.routing";
import {WarService} from "../services/logs/war.service"; import {WarService} from "../services/logs/war.service";
import {NgxChartsModule} from "@swimlane/ngx-charts"; import {NgxChartsModule} from "@swimlane/ngx-charts";
import {AccordionModule, TabsModule} from "ngx-bootstrap"; import {AccordionModule, CarouselModule} from "ngx-bootstrap";
import {CampaignService} from "../services/logs/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/logs/player.service"; import {PlayerService} from "../services/logs/player.service";
@ -13,7 +13,7 @@ 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(), TabsModule.forRoot(), NgxDatatableModule], AccordionModule.forRoot(), CarouselModule.forRoot(), NgxDatatableModule],
providers: [WarService, CampaignService, PlayerService, LogsService] providers: [WarService, CampaignService, PlayerService, LogsService]
}) })
export class StatsModule { export class StatsModule {

View File

@ -1,15 +1,9 @@
.vertical-spacer { .vertical-spacer {
height: 205px; height: 100vh;
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%;
@ -42,36 +36,6 @@
color: blue; color: blue;
} }
.chart-container {
width: 80%;
min-width: 500px;
height: 400px;
padding: 15px;
margin: 2%;
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 {

View File

@ -1,19 +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> <div class=vertical-spacer>
</div>
<div style="overflow:hidden"> <div style="overflow:hidden">
<div style="width: 920px;min-height: 205px;"> <div style="width: 920px;min-height: 263px;">
<h2>{{war.title}} - vom {{war.date | date: 'dd.MM.yyyy'}}</h2> <h2>{{war.title}} - vom {{war.date | date: 'dd.MM.yyyy'}}</h2>
<div class="pull-left head-field" style="width: 250px"> <h3 class="pull-left" 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>
</div> </h3>
<div class="pull-left head-field " style="padding-left: 150px;"> <h3 class="pull-left" style="padding-left: 150px;">
<h4 style="margin-bottom: 0;">Teilnehmer:</h4> <h4>Teilnehmer:</h4>
<ngx-charts-pie-chart <ngx-charts-pie-chart
[view]="[120, 120]" [view]="[150, 150]"
[scheme]="{domain: ['#B22222', '#0000FF']}" [scheme]="{domain: ['#B22222', '#0000FF']}"
[results]="playerChart" [results]="playerChart"
[legend]="false" [legend]="false"
@ -22,9 +23,9 @@
[doughnut]="false" [doughnut]="false"
[gradient]="false"> [gradient]="false">
</ngx-charts-pie-chart> </ngx-charts-pie-chart>
</div> </h3>
<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">
@ -50,85 +51,38 @@
</form> </form>
</div> </div>
</div> </div>
</div>
<tabset> <!--may be added in future: [sorts]="[{prop: 'sort', dir: 'desc'}]"-->
<tab> <ngx-datatable
<ng-template tabHeading> [rows]="rows"
<img src="../../../assets/scoreboard-btn.png"> Scoreboard [reorderable]="reorderable"
</ng-template> [messages]="{emptyMessage: 'Loading...'}"
<div class=vertical-spacer></div> [headerHeight]="cellHeight"
<ngx-datatable [rowHeight]="cellHeight"
[rows]="rows" [cssClasses]='customClasses'
[sorts]="[{prop: 'kill', dir: 'desc'}]" [selectionType]="'single'"
[reorderable]="reorderable" (select)="selectPlayerDetail($event)">
[messages]="{emptyMessage: 'Loading...'}" <ngx-datatable-column name="Spieler" prop="name" [width]="210" style="padding-left:10px">
[headerHeight]="cellHeight" <ng-template ngx-datatable-cell-template let-row="row" let-value="value">
[rowHeight]="cellHeight"
[cssClasses]='customClasses'
[selectionType]="'single'"
(select)="selectPlayerDetail($event)">
<ngx-datatable-column name="Spieler" prop="name" [width]="210" style="padding-left:10px">
<ng-template ngx-datatable-cell-template let-row="row" let-value="value">
<span class="player-name" <span class="player-name"
[ngClass]="row['fraction'] === 'BLUFOR' ? 'text-blufor' : 'text-opfor'"> [ngClass]="row['fraction'] === 'BLUFOR' ? 'text-blufor' : 'text-opfor'">
{{value}} {{value}}
</span> </span>
</ng-template> </ng-template>
</ngx-datatable-column> </ngx-datatable-column>
<ngx-datatable-column name="Fraktion" prop="fraction" [width]="100"> <ngx-datatable-column name="Fraktion" prop="fraction" [width]="100">
<ng-template ngx-datatable-cell-template let-value="value"> <ng-template ngx-datatable-cell-template let-value="value">
{{value === 'BLUFOR' ? 'NATO' : 'CSAT'}} {{value === 'BLUFOR' ? 'NATO' : 'CSAT'}}
</ng-template> </ng-template>
</ngx-datatable-column> </ngx-datatable-column>
<ngx-datatable-column [width]="90" name="Kills" prop="kill"></ngx-datatable-column> <ngx-datatable-column [width]="90" name="Kills" prop="kill"></ngx-datatable-column>
<ngx-datatable-column [width]="110" name="FriendlyFire" prop="friendlyFire"></ngx-datatable-column> <ngx-datatable-column [width]="110" name="FriendlyFire" prop="friendlyFire"></ngx-datatable-column>
<ngx-datatable-column [width]="100" name="Revive" prop="revive"></ngx-datatable-column> <ngx-datatable-column [width]="100" name="Revive" prop="revive"></ngx-datatable-column>
<ngx-datatable-column [width]="100" name="Eroberung" prop="flagTouch"></ngx-datatable-column> <ngx-datatable-column [width]="100" name="Eroberung" prop="flagTouch"></ngx-datatable-column>
<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> </div>
<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"
[legend]="legend"
[legendTitle]="legendTitle"
[showXAxisLabel]="showXAxisLabel"
[showYAxisLabel]="showYAxisLabel"
[yAxisLabel]="yAxisLabelPoints"
[autoScale]="autoscale"
[timeline]="timeline"
[roundDomains]="roundDomains">
</ngx-charts-line-chart>
</div>
<div class="fade-in chart-container">
<ngx-charts-line-chart
[scheme]="colorScheme"
[results]="budgetData"
[gradient]="gradient"
[xAxis]="xAxis"
[yAxis]="yAxis"
[legend]="legend"
[legendTitle]="legendTitle"
[showXAxisLabel]="showXAxisLabel"
[showYAxisLabel]="showYAxisLabel"
[yAxisLabel]="yAxisLabelBudget"
[autoScale]="autoscale"
[timeline]="timeline"
[roundDomains]="roundDomains">
</ngx-charts-line-chart>
</div>
</tab>
</tabset>
</div> </div>

View File

@ -31,32 +31,10 @@ export class WarDetailComponent {
sortDescending: 'glyphicon glyphicon-triangle-bottom', sortDescending: 'glyphicon glyphicon-triangle-bottom',
}; };
pointData: any[] = [];
budgetData: any[] = [];
colorScheme = {
domain: ['#0000FF', '#B22222']
};
yAxisLabelPoints = 'Punkte';
yAxisLabelBudget = 'Budget';
gradient = false;
yAxis = true;
xAxis = true;
legend = false;
legendTitle = false;
showXAxisLabel = false;
showYAxisLabel = true;
autoscale = true;
timeline = false;
roundDomains = true;
fractionInitialized: boolean = false;
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router, private router: Router,
private warService: WarService, private warService: WarService) {
private logsService: LogsService) { Object.assign(this, this.playerChart)
} }
ngOnInit() { ngOnInit() {
@ -77,7 +55,6 @@ export class WarDetailComponent {
"value": war.playersBlufor "value": war.playersBlufor
} }
]; ];
Object.assign(this, [this.playerChart, this.pointData, this.budgetData]);
this.scrollOverviewTop(); this.scrollOverviewTop();
}); });
} }
@ -106,73 +83,4 @@ export class WarDetailComponent {
} }
} }
loadFractionData() {
if (!this.fractionInitialized) {
const tmpPointData = [
{
"name": "NATO",
"series": []
},
{
"name": "CSAT",
"series": []
}
];
const tmpBudgetData = JSON.parse(JSON.stringify(tmpPointData));
const tmpKillData = JSON.parse(JSON.stringify(tmpPointData));
const tmpFrienlyFireData = JSON.parse(JSON.stringify(tmpPointData));
const tmpTransportData = JSON.parse(JSON.stringify(tmpPointData));
const tmpReviveData = JSON.parse(JSON.stringify(tmpPointData));
const tmpStabilizeData = JSON.parse(JSON.stringify(tmpPointData));
const tmpFlagCaptureData = JSON.parse(JSON.stringify(tmpPointData));
// POINTS
this.logsService.getPointsLogs(this.war._id).subscribe((data) => {
data.forEach(pointEntry => {
const dateObj = new Date(this.war.date);
const time = pointEntry.time.split(':');
dateObj.setHours(time[0]);
dateObj.setMinutes(time[1]);
tmpPointData[0].series.push({
"name": dateObj,
"value": pointEntry.ptBlufor
});
tmpPointData[1].series.push({
"name": dateObj,
"value": pointEntry.ptOpfor
});
});
this.pointData = tmpPointData;
});
// BUDGET
this.logsService.getBudgetLogs(this.war._id).subscribe((data) => {
const dateObj = new Date(this.war.date);
dateObj.setHours(0);
dateObj.setMinutes(0);
tmpBudgetData[0].series.push({
"name": dateObj,
"value": this.war.budgetBlufor
});
tmpBudgetData[1].series.push({
"name": dateObj,
"value": this.war.budgetOpfor
});
data.forEach(budgetEntry => {
const time = budgetEntry.time.split(':');
const dateObj = new Date(this.war.date);
dateObj.setHours(time[0]);
dateObj.setMinutes(time[1]);
tmpBudgetData[budgetEntry.fraction === 'BLUFOR' ? 0 : 1].series.push({
"name": dateObj,
"value": budgetEntry.newBudget
});
});
this.budgetData = tmpBudgetData;
});
this.fractionInitialized = true;
}
}
} }

View File

@ -26,7 +26,7 @@ div.user-list-entry, a.user-list-entry {
background: lightgrey; background: lightgrey;
} }
span > a, span.glyphicon, span.icon-award{ span {
cursor: pointer; cursor: pointer;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 797 B