Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit a251df8

Browse files
committed
Finishing first pass on hostile reporting system.
1 parent de38011 commit a251df8

12 files changed

Lines changed: 84 additions & 30 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.DS_Store
12
node_modules
23
*.sublime*
34
config/private.js

‎config/settings.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,11 @@ module.exports = function () {
4141

4242
scanMaxShips: 100,
4343
scanMinShips: 1,
44+
45+
whitelist: {
46+
alliances: [ 1354830081 ],
47+
corporations: []
48+
}
49+
4450
};
4551
};

‎lib/actions/postStatusAction.js‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function (hostileService, eventService, memberService, async, eveapi, headerParser, errorResponse, successResponse, _) {
1+
module.exports = function (hostileService, eventService, memberService, async, eveapi, headerParser, settings, errorResponse, successResponse, _) {
22

33
var pub = {};
44

@@ -8,6 +8,7 @@ module.exports = function (hostileService, eventService, memberService, async, e
88
|| !status.systemName
99
|| !status.reporterId
1010
|| !status.reporterName
11+
|| !status.text
1112
|| !status.pilots
1213
|| !typeof(status.pilots) === 'object') {
1314
return false;
@@ -19,6 +20,7 @@ module.exports = function (hostileService, eventService, memberService, async, e
1920
pub.run = function (req, res) {
2021
var scanData = req.body.scanData;
2122

23+
if (scanData.pilots === undefined) scanData.pilots = [];
2224
if (!checkStatusDataIntegrity(scanData)) {
2325
return errorResponse.respond(res, 'status', 'Invalid status data.');
2426
}
@@ -36,18 +38,22 @@ module.exports = function (hostileService, eventService, memberService, async, e
3638
var hostiles = [];
3739
_.forEach(results.characters, function(character) {
3840

39-
// do a quick check here to see if corporationId or allianceId is in the whitelist
41+
if (_.contains(settings.whitelist.alliances, parseInt(character.allianceID))) return;
42+
if (_.contains(settings.whitelist.corporations, parseInt(character.corporationID))) return;
43+
4044
hostiles.push({ id: character.characterID
4145
, name: character.characterName
42-
, corporationId: character.corporationID
46+
, corporationID: character.corporationID
4347
, corporationName: character.corporationName
44-
, allianceId: character.allianceID
48+
, allianceID: character.allianceID
4549
, allianceName: character.allianceName
4650
, shipTypeId: null
47-
, shipType: 'Non-visual'
51+
, shipType: null
4852
, shipName: null
4953
});
54+
5055
});
56+
console.log(hostiles)
5157
callback(null, hostiles);
5258
}
5359
], function (error, hostiles) {

‎lib/services/hostileService.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ module.exports = function (keyGenerator, storageManager) {
1616
id: hostile.id,
1717
name: hostile.name,
1818

19+
corporationID: hostile.corporationID,
20+
corporationName: hostile.corporationName,
21+
22+
allianceID: hostile.allianceID,
23+
allianceName: hostile.allianceName,
24+
1925
shipType: hostile.shipType,
2026
shipTypeId: hostile.shipTypeId,
2127
shipName: hostile.shipName,
@@ -34,6 +40,8 @@ module.exports = function (keyGenerator, storageManager) {
3440
//TODO: this should be an upsert for a given pilot
3541
for (id in scanData.pilots) {
3642
var hostile = createHostile(headerData, scanData.pilots[id], armadaKey);
43+
console.log('hostile:')
44+
console.log(hostile)
3745
storageManager.addItem('hostile', hostile, function (error) {
3846
if (error) return callback(error);
3947
});

‎public/css/main.css‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ a:hover { color: #fff0be }
9292
}
9393

9494
#status-buttons {
95-
background-color: #000;
96-
border: solid 1px #222;
97-
border-radius: 5px;
95+
background-color: #222;
96+
border: solid 1px #444;
97+
border-radius: 2px;
9898
bottom: 0;
9999
margin-bottom: 3rem;
100100
margin-left: 5px;
@@ -417,6 +417,13 @@ rect.status-hostile { stroke: #d9534f; fill: #74312f; }
417417
padding-bottom: 2.4rem;
418418
}
419419

420+
.panel .text.system {
421+
color: #ffcc2a;
422+
font-family: 'Droid Sans', sans-serif;
423+
font-size: 16px;
424+
padding-bottom: 0;
425+
}
426+
420427
.panel .close {
421428
width: 1rem;
422429
height: 1rem;
@@ -456,19 +463,21 @@ rect.status-hostile { stroke: #d9534f; fill: #74312f; }
456463
background-color: #111;
457464
width: 14.1rem;
458465
color: #ccc;
459-
min-width: 25rem;
460-
min-height: 10rem;
461466
padding: 0.8rem 0.4rem;
462467
font-weight: normal;
463468
text-align: left;
464469
border: 0.16rem solid #111
465470
}
466471

472+
.panel .textinput.status-data {
473+
min-width: 25rem;
474+
min-height: 10rem;
475+
}
476+
467477
.panel .legend {
468478
display: block;
469479
color: #666;
470480
padding: 0.2rem;
471-
width: 14rem;
472481
margin: 0 auto;
473482
}
474483

‎public/images/icon-reportClear.png‎

720 Bytes
Loading
690 Bytes
Loading

‎public/index.html‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ <h2 id="current-system"></h2>
7474
{{/if}}
7575
<div class="content">
7676
{{#if text}}
77-
<div class="text">{{{text}}}</div>
77+
<div class="text {{#if textclass}}{{textclass}}{{/if}}">{{{text}}}</div>
7878
{{/if}}
7979
{{#if textinputs}}
8080
{{#each textinputs}}
@@ -165,8 +165,34 @@ <h2 id="current-system"></h2>
165165
<tr>
166166
<td class="ship-icon">{{{shipIcon}}}</td>
167167
<td class="name"><a href="javascript:CCPEVE.showInfo(1377, {{id}});">{{name}}</a></td>
168-
<td class="ship-type"><a href="javascript:CCPEVE.showInfo({{shipTypeId}});">{{shipType}}</a></td>
169-
<td class="ship-name">{{shipName}}</td>
168+
<td class="corp">
169+
{{#if corporationName}}
170+
<a href="javascript:CCPEVE.showInfo(2, {{corporationID}});">[ {{corporationName}} ]</a>
171+
{{else}}
172+
Corporation details unavailable
173+
{{/if}}
174+
</td>
175+
<td class="alliance">
176+
{{#if allianceName}}
177+
<a href="javascript:CCPEVE.showInfo(16159, {{allianceID}});">&lt; {{allianceName}} &gt;</a>
178+
{{else}}
179+
No Alliance
180+
{{/if}}
181+
</td>
182+
<td class="ship-type">
183+
{{#if shipTypeId}}
184+
<a href="javascript:CCPEVE.showInfo({{shipTypeId}});">{{shipType}}</a>
185+
{{else}}
186+
Non-visual
187+
{{/if}}
188+
</td>
189+
<td class="ship-name">
190+
{{#if shipName}}
191+
{{shipName}}
192+
{{else}}
193+
Ship name unavailable
194+
{{/if}}
195+
</td>
170196
<td class="system {{#if isDocked}}docked{{/if}}"><a href="javascript:CCPEVE.showInfo(5,{{systemId}});">{{systemName}}</a></td>
171197
<td class="reporter"><a href="javascript:CCPEVE.showInfo(1377, {{reporterId}});">{{reporterName}}</a></td>
172198
<td class="actions" onClick="UIPanels.showHostileOptionsPanel('{{id}}');"><img src="/images/icon-options.png" alt="Options"/></td>

‎public/js/Main.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ function submitScan(scanData) {
131131

132132
function submitStatusButtonClick(button) {
133133
var scanData = $(button).siblings('.status-data').val();
134-
submitStatus(scanData);
134+
submitStatus("validate", scanData);
135135
}
136136

137-
function submitStatus(localPilots) {
137+
function submitStatus(reported_status, pilots) {
138138
UIPanels.showLoadingPanel('Uploading status...', function () {
139-
var status = ScanList.addStatus(localPilots);
139+
var status = ScanList.addStatus(reported_status, pilots);
140140

141141
Server.postStatus(status, function(error, data) {
142142
UIPanels.hidePanel(function () {

‎public/js/ScanList.js‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@ var ScanList = {
66
Data.ui.scans.empty();
77
},
88

9-
addStatus: function(pilotList) {
9+
addStatus: function(reported_status, pilots) {
1010
var status = {systemId: Data.ui.currentSystem.data('systemId')
1111
, systemName: Data.ui.currentSystem.text(), pilots: []
1212
, reporterId: Data.state.self.id
1313
, reporterName: Data.state.self.name
14-
, pilots: ScanList.parseLocal(pilotList)};
15-
16-
if (status.pilots.length > 0) {
17-
status.text = 'hostile';
18-
} else {
19-
status.text = 'clear';
20-
}
14+
, pilots: ScanList.parseLocal(pilots)};
2115

16+
if (reported_status) status.text = reported_status;
2217
return status;
2318
},
2419

@@ -80,12 +75,14 @@ var ScanList = {
8075
return parsedScanData;
8176
},
8277

83-
parseLocal: function (localPilots) {
78+
parseLocal: function (local) {
8479
var parsedLocal = [];
8580

86-
localPilots.split("\n").forEach(function (pilot) {
87-
if (pilot.length > 0) parsedLocal.push(pilot);
88-
});
81+
if (local) {
82+
local.split("\n").forEach(function (pilot) {
83+
if (pilot.length > 0) parsedLocal.push(pilot);
84+
});
85+
}
8986

9087
return parsedLocal;
9188
},

0 commit comments

Comments
 (0)