From 026a3611a66387e837b3b41285f58cc73ba5c776 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Sun, 17 Jun 2018 10:47:02 +0200 Subject: [PATCH 01/14] Fix CSV export headline (CC-32) --- package.json | 2 +- static/src/app/statistic/war/scoreboard/scoreboard.component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9a46c82..23e7421 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opt-cc", - "version": "1.7.6", + "version": "1.7.7", "author": "Florian Hartwich ", "private": true, "scripts": { diff --git a/static/src/app/statistic/war/scoreboard/scoreboard.component.ts b/static/src/app/statistic/war/scoreboard/scoreboard.component.ts index ac2b5b3..aa05ffd 100644 --- a/static/src/app/statistic/war/scoreboard/scoreboard.component.ts +++ b/static/src/app/statistic/war/scoreboard/scoreboard.component.ts @@ -71,7 +71,7 @@ export class ScoreboardComponent implements OnChanges { exportCSV() { let csvOut = ''; for (let i = 0; i < this.tableHead.length; i++) { - csvOut += this.tableHead[i]; + csvOut += this.tableHead[i].head; if (i !== this.tableHead.length - 1) { csvOut += ','; } From 07a6822920418a92c34e4bfb1cd8d45cff1ce260 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Sun, 17 Jun 2018 11:52:43 +0200 Subject: [PATCH 02/14] Save vehicles and magazine on kill log (CC-36) --- api/apib/data_structures/_log.apib | 5 ++ api/models/logs/kill.js | 9 +++ api/models/logs/vehicle.js | 6 ++ api/tools/log-parse-tool.js | 89 ++++++++++++++++++------------ 4 files changed, 74 insertions(+), 35 deletions(-) diff --git a/api/apib/data_structures/_log.apib b/api/apib/data_structures/_log.apib index 7b44d5d..535e4e4 100644 --- a/api/apib/data_structures/_log.apib +++ b/api/apib/data_structures/_log.apib @@ -43,6 +43,9 @@ + `BLUFOR` + `OPFOR` + `NONE` ++ shooterVehicle: `FV-720 Mora` (string, optional) - vehicle in whiock the shooting player sat ++ targetVehicle: `Ifrit-GMG` (string, optional) - vehicle in which the target player sat ++ magazine: `30 mm APFSDS` (string, optional) - magazine name used to execute the kill #LogRespawn (Log) ## Properties @@ -84,3 +87,5 @@ + `HEAVY` + `AIR` + `UNKNOWN` ++ shooterVehicle: `FV-720 Mora` (string, optional) - vehicle in whiock the shooting player sat ++ magazine: `30 mm APFSDS` (string, optional) - magazine name used to execute the kill diff --git a/api/models/logs/kill.js b/api/models/logs/kill.js index 29e76a3..e695b24 100644 --- a/api/models/logs/kill.js +++ b/api/models/logs/kill.js @@ -24,6 +24,15 @@ const LogKillSchema = new Schema({ type: Boolean, required: true, }, + magazine: { + type: String, + }, + shooterVehicle: { + type: String, + }, + targetVehicle: { + type: String, + }, fraction: { type: String, enum: ['BLUFOR', 'OPFOR', 'NONE'], diff --git a/api/models/logs/vehicle.js b/api/models/logs/vehicle.js index e360e00..e2e5307 100644 --- a/api/models/logs/vehicle.js +++ b/api/models/logs/vehicle.js @@ -33,6 +33,12 @@ const LogVehicleKillSchema = new Schema({ enum: ['LIGHT', 'HEAVY', 'AIR', 'UNKNOWN'], required: true, }, + magazine: { + type: String, + }, + shooterVehicle: { + type: String, + }, }, { collection: 'logVehicle', }); diff --git a/api/tools/log-parse-tool.js b/api/tools/log-parse-tool.js index 3d9f73b..44de371 100644 --- a/api/tools/log-parse-tool.js +++ b/api/tools/log-parse-tool.js @@ -17,9 +17,9 @@ const vehicleNameEndRegex = /\s\(\w+:/; const sideRegex = /(side:\s(.*?)\))/; -// const magazineRegex = /(magazine:\s(.*?)\))/; +const magazineRegex = /(magazine:\s(.*?)\))/; -// const vehicleRegex = /(vehicle:\s(.*?)\))/; +const vehicleRegex = /(vehicle:\s(.*?)\))/; const categoryRegex = /(category:\s(.*?)\))/; @@ -51,7 +51,7 @@ const parseWarLog = (lineArray, war) => { ]; const addPlayerIfNotExists = (inputPlayer, steamUUID) => { - const player = getPlayerAndFractionFromString(inputPlayer); + const player = getPlayerInfoFromString(inputPlayer); if (player && player.name && player.fraction && !playerArrayContains(stats.players, player)) { player['warId'] = war._id; player['steamUUID'] = steamUUID; @@ -74,7 +74,7 @@ const parseWarLog = (lineArray, war) => { stats.clean.push(line); const shooterString = line.substring(line.lastIndexOf(' von: ') + 6, line.search(/$/) - 1); - const shooter = getPlayerAndFractionFromString(shooterString); + const shooter = getPlayerInfoFromString(shooterString); if (line.includes('Fahrzeug:')) { const targetString = line.substring(line.lastIndexOf(' --- Fahrzeug: ') + 15, line.lastIndexOf(' von:')); @@ -93,19 +93,36 @@ const parseWarLog = (lineArray, war) => { } else { vehicleKill.shooter = shooter ? shooter.name : null; } + if (shooter.magazine) { + vehicleKill.magazine = shooter.magazine; + } + if (shooter.vehicle) { + vehicleKill.shooterVehicle = shooter.vehicle; + } + stats.vehicles.push(vehicleKill); } } else { const targetString = line.substring(line.lastIndexOf(' --- Einheit: ') + 14, line.lastIndexOf(' von:')); - const target = getPlayerAndFractionFromString(targetString); - stats.kills.push({ + const target = getPlayerInfoFromString(targetString); + const kill = { war: war._id, time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]), shooter: shooter ? shooter.name : null, target: target ? target.name : null, friendlyFire: shooter ? target.fraction === shooter.fraction : false, fraction: shooter ? shooter.fraction : 'NONE', - }); + }; + if (shooter.magazine) { + kill.magazine = shooter.magazine; + } + if (shooter.vehicle) { + kill.shooterVehicle = shooter.vehicle; + } + if (target.vehicle) { + kill.targetVehicle = target.vehicle; + } + stats.kills.push(kill); } } else if (line.includes('(Budget)')) { /** @@ -173,9 +190,9 @@ const parseWarLog = (lineArray, war) => { const stabilized = !!line.includes('stabilisiert."'); const medicName = line.substring(line.lastIndexOf('wurde von ') + 10, line.lastIndexOf(stabilized ? ' stabilisiert' : ' wiederbelebt')); - const medic = getPlayerAndFractionFromString(medicName); + const medic = getPlayerInfoFromString(medicName); const patientName = line.substring(line.lastIndexOf('--- ') + 4, line.lastIndexOf(' wurde von')); - const patient = getPlayerAndFractionFromString(patientName); + const patient = getPlayerInfoFromString(patientName); stats.revive.push({ war: war._id, @@ -191,9 +208,9 @@ const parseWarLog = (lineArray, war) => { */ stats.clean.push(line); const driverString = line.substring(line.lastIndexOf('wurde von ') + 10, line.lastIndexOf(' eingeflogen')); - const driver = getPlayerAndFractionFromString(driverString); + const driver = getPlayerInfoFromString(driverString); const passengerString = line.substring(line.lastIndexOf('--- ') + 3, line.lastIndexOf(' wurde von')); - const passenger = getPlayerAndFractionFromString(passengerString); + const passenger = getPlayerInfoFromString(passengerString); const distance = parseInt(line.substring(line.lastIndexOf('eingeflogen (') + 13, line.lastIndexOf('m)') - 1)); stats.transport.push({ @@ -285,15 +302,20 @@ const getBudgetEntry = (budg, warId, warDate) => { }; }; -const getPlayerAndFractionFromString = (inputString) => { +const getPlayerInfoFromString = (inputString) => { + const resPlayer = {}; const playerNameRegexMatch = playerNameRegex.exec(inputString); const sideMatch = sideRegex.exec(inputString); // SINGLE PLAYER NAME let name; if (playerNameRegexMatch && playerNameRegexMatch.length >= 2) { - // NAME name = playerNameRegexMatch[2].trim(); + // do not return player for 'Error: No unit' + if (!name && name === 'Error: No unit') { + return; + } + resPlayer.name = name; } // ADDITIONAL PLAYER NAMES let additionalPlayerMatch; @@ -317,34 +339,31 @@ const getPlayerAndFractionFromString = (inputString) => { } } - // const magazineMatch = magazineRegex.exec(inputString); - // const vehicleMatch = vehicleRegex.exec(inputString); + if (side && side !== 'ENEMY') { + resPlayer.fraction = side === 'WEST' ? 'BLUFOR' : 'OPFOR'; + } - // if (magazineMatch && magazineMatch.length >= 3) { // MAGAZINE - // console.log(magazineMatch[2]) - // } + const magazineMatch = magazineRegex.exec(inputString); + if (magazineMatch && magazineMatch.length >= 3) { + let magazine = magazineMatch[2]; + if (new RegExp('\\(.*$').test(magazine)) { + magazine = magazine.concat(')'); + } + resPlayer.magazine = magazine; + } - // if (vehicleMatch && vehicleMatch.length >= 3 && vehicleMatch[2]) { - // let vehicle = vehicleMatch[2]; - // if (new RegExp("\\(.*$").test(vehicle)) { - // vehicle = vehicle.concat(")"); - // } // VEHICLE - // console.log(vehicle) - // } - - let fraction; - if (side) { - fraction = side !== 'ENEMY' ? side === 'WEST' ? - 'BLUFOR' : 'OPFOR' : - undefined; + const vehicleMatch = vehicleRegex.exec(inputString); + if (vehicleMatch && vehicleMatch.length >= 3 && vehicleMatch[2]) { + let vehicle = vehicleMatch[2]; + if (new RegExp('\\(.*$').test(vehicle)) { + vehicle = vehicle.concat(')'); + } + resPlayer.vehicle = vehicle; } - // do not return player for 'Error: No unit' - if (name && name !== 'Error: No unit') { - return {name: name, fraction: fraction}; - } + return resPlayer; }; const getVehicleAndFractionFromString = (nameClassFractionString) => { From a29a39d8e0e05dc87a9940f4c3652d246144524e Mon Sep 17 00:00:00 2001 From: HardiReady Date: Sun, 17 Jun 2018 12:46:58 +0200 Subject: [PATCH 03/14] add possibility to delete multiple player awardings at once (CC-23) --- .../award-user/award-user.component.html | 13 +++++++-- .../users/award-user/award-user.component.ts | 29 ++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/static/src/app/users/award-user/award-user.component.html b/static/src/app/users/award-user/award-user.component.html index 9ff5fdc..12633ab 100644 --- a/static/src/app/users/award-user/award-user.component.html +++ b/static/src/app/users/award-user/award-user.component.html @@ -73,7 +73,9 @@ Begründung Datum Status - + + Löschen + @@ -94,10 +96,15 @@ {{award.date | date: 'dd.MM.yyyy'}} - {{award.confirmed === 0? 'In Bearbeitung' : (award.confirmed === 1? 'Genehmigt' : 'Abgelehnt')}} + {{award.confirmed === 0 ? 'In Bearbeitung' : (award.confirmed === 1 ? 'Genehmigt' : 'Abgelehnt')}} - + diff --git a/static/src/app/users/award-user/award-user.component.ts b/static/src/app/users/award-user/award-user.component.ts index e826195..14f230d 100644 --- a/static/src/app/users/award-user/award-user.component.ts +++ b/static/src/app/users/award-user/award-user.component.ts @@ -93,17 +93,24 @@ export class AwardUserComponent implements OnInit { } } - deleteAwarding(awardingId) { - this.awardingService.deleteAwarding(awardingId).subscribe((res) => { - this.awardingService.getUserAwardings(this.userId) - .subscribe((awards) => { - this.awards = awards; - this.showSuccessLabel = true; - setTimeout(() => { - this.showSuccessLabel = false; - }, 2000); - }); - }); + deleteAwarding() { + const checkedAwardings = this.awards.filter(award => award['checked'] == true); + + if (checkedAwardings.length > 0) { + checkedAwardings.forEach(awarding => { + this.awardingService.deleteAwarding(awarding._id).subscribe((res) => { + this.awardingService.getUserAwardings(this.userId) + .subscribe((awards) => { + this.awards = awards; + }); + }); + }); + + this.showSuccessLabel = true; + setTimeout(() => { + this.showSuccessLabel = false; + }, 4000); + } } cancel() { From 162453c894ef86d793662b31b077048f417f925c Mon Sep 17 00:00:00 2001 From: HardiReady Date: Sun, 17 Jun 2018 12:48:08 +0200 Subject: [PATCH 04/14] Fix lint --- static/src/app/users/award-user/award-user.component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/static/src/app/users/award-user/award-user.component.ts b/static/src/app/users/award-user/award-user.component.ts index 14f230d..37fe524 100644 --- a/static/src/app/users/award-user/award-user.component.ts +++ b/static/src/app/users/award-user/award-user.component.ts @@ -94,7 +94,7 @@ export class AwardUserComponent implements OnInit { } deleteAwarding() { - const checkedAwardings = this.awards.filter(award => award['checked'] == true); + const checkedAwardings = this.awards.filter(award => award['checked'] === true); if (checkedAwardings.length > 0) { checkedAwardings.forEach(awarding => { @@ -117,5 +117,4 @@ export class AwardUserComponent implements OnInit { this.router.navigate(['../..'], {relativeTo: this.route}); return false; } - } From d1f53f78c93c261a7daf107254936dc4bc9e815d Mon Sep 17 00:00:00 2001 From: HardiReady Date: Sun, 17 Jun 2018 16:03:25 +0200 Subject: [PATCH 05/14] clean up code --- .../users/award-user/award-user.component.ts | 9 ++++--- .../users/edit-user/edit-user.component.ts | 24 +++++++++++-------- .../users/user-list/user-item.component.ts | 1 - .../users/user-list/user-list.component.ts | 2 -- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/static/src/app/users/award-user/award-user.component.ts b/static/src/app/users/award-user/award-user.component.ts index 37fe524..2429a42 100644 --- a/static/src/app/users/award-user/award-user.component.ts +++ b/static/src/app/users/award-user/award-user.component.ts @@ -51,7 +51,6 @@ export class AwardUserComponent implements OnInit { .subscribe(id => this.userId = id); } - toggleDecoPreview(descriptionField, decorationId, image) { if (decorationId !== '0') { this.decoPreviewDisplay = 'flex'; // visible & keep same height for all children @@ -72,10 +71,10 @@ export class AwardUserComponent implements OnInit { const reason = reasonField.value; if (decorationId && reason.length > 0) { const award = { - 'userId': this.userId, - 'decorationId': decorationId, - 'reason': reason, - 'date': Date.now() + userId: this.userId, + decorationId: decorationId, + reason: reason, + date: Date.now() }; this.awardingService.addAwarding(award).subscribe(() => { this.awardingService.getUserAwardings(this.userId) diff --git a/static/src/app/users/edit-user/edit-user.component.ts b/static/src/app/users/edit-user/edit-user.component.ts index 733c5b9..1cad7ae 100644 --- a/static/src/app/users/edit-user/edit-user.component.ts +++ b/static/src/app/users/edit-user/edit-user.component.ts @@ -53,10 +53,12 @@ export class EditUserComponent implements OnInit { user.squadId = '0'; this.ranksDisplay = 'none'; } else { - this.rankService.findRanks('', user.squadId.fraction).subscribe(ranks => { - this.ranks = ranks; - this.ranksDisplay = 'block'; - }); + this.rankService + .findRanks('', user.squadId.fraction) + .subscribe(ranks => { + this.ranks = ranks; + this.ranksDisplay = 'block'; + }); } this.user = user; }); @@ -68,12 +70,14 @@ export class EditUserComponent implements OnInit { toggleRanks() { if (this.user.squadId !== '0') { - this.rankService.findRanks('', this.user.squadId.fraction).subscribe( - ranks => { - this.ranks = ranks; - this.ranksDisplay = 'block'; - } - ); + this.rankService + .findRanks('', this.user.squadId.fraction) + .subscribe( + ranks => { + this.ranks = ranks; + this.ranksDisplay = 'block'; + } + ); } else { this.ranksDisplay = 'none'; } diff --git a/static/src/app/users/user-list/user-item.component.ts b/static/src/app/users/user-list/user-item.component.ts index 122afa7..9da5bb6 100644 --- a/static/src/app/users/user-list/user-item.component.ts +++ b/static/src/app/users/user-list/user-item.component.ts @@ -34,6 +34,5 @@ export class UserItemComponent { delete() { this.userDelete.emit(this.user); } - } diff --git a/static/src/app/users/user-list/user-list.component.ts b/static/src/app/users/user-list/user-list.component.ts index 3f4aec7..a4be69f 100644 --- a/static/src/app/users/user-list/user-list.component.ts +++ b/static/src/app/users/user-list/user-list.component.ts @@ -41,7 +41,6 @@ export class UserListComponent implements OnInit { } ngOnInit() { - this.users$ = this.userService.users$; const paramsStream = this.route.queryParams @@ -106,5 +105,4 @@ export class UserListComponent implements OnInit { this.location.replaceState(absoluteUrl, queryPart); } - } From 2a698092e161559ccb1fef7597ce38c7c610e3bd Mon Sep 17 00:00:00 2001 From: HardiReady Date: Sun, 17 Jun 2018 16:44:31 +0200 Subject: [PATCH 06/14] Add SQL Dashboard (lazy implementation) (CC-24) --- static/src/app/app.component.html | 3 + static/src/app/app.config.ts | 4 +- static/src/app/models/model-interfaces.ts | 1 + static/src/app/request/request.module.ts | 3 +- static/src/app/request/request.routing.ts | 8 +- .../sql-dashboard/sql-dashboard.component.css | 33 ++++++++ .../sql-dashboard.component.html | 80 +++++++++++++++++++ .../sql-dashboard/sql-dashboard.component.ts | 60 ++++++++++++++ 8 files changed, 188 insertions(+), 4 deletions(-) create mode 100644 static/src/app/request/sql-dashboard/sql-dashboard.component.css create mode 100644 static/src/app/request/sql-dashboard/sql-dashboard.component.html create mode 100644 static/src/app/request/sql-dashboard/sql-dashboard.component.ts diff --git a/static/src/app/app.component.html b/static/src/app/app.component.html index 5a5f99c..732a112 100644 --- a/static/src/app/app.component.html +++ b/static/src/app/app.component.html @@ -48,6 +48,9 @@ diff --git a/static/src/app/login/login.component.html b/static/src/app/login/login.component.html index b66611c..92de22e 100644 --- a/static/src/app/login/login.component.html +++ b/static/src/app/login/login.component.html @@ -1,6 +1,6 @@