Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.

Commit 0c980ef

Browse files
authored
Merge pull request #166 from ExpDev07/dev
Some more features
2 parents 562d198 + e22dc77 commit 0c980ef

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

app/Http/Controllers/MapController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Http\Controllers;
44

5+
use App\Player;
56
use App\Server;
67
use Illuminate\Http\Request;
78
use Inertia\Inertia;
@@ -26,8 +27,13 @@ public function index(Request $request): Response
2627
];
2728
}
2829

30+
$staff = Player::query()->where('is_staff', '=', true)->select(['steam_identifier'])->get()->toArray();
31+
2932
return Inertia::render('Map/Index', [
3033
'servers' => $serverIps,
34+
'staff' => $staff ? array_map(function($player) {
35+
return $player['steam_identifier'];
36+
}, $staff) : []
3137
]);
3238
}
3339

resources/js/Pages/Map/Index.vue

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ export default {
8383
servers: {
8484
type: Array,
8585
required: true
86+
},
87+
staff: {
88+
type: Array,
89+
required: true
8690
}
8791
},
8892
data() {
@@ -95,7 +99,8 @@ export default {
9599
trackedPlayer: window.location.hash.substr(1),
96100
firstRefresh: true,
97101
clickedCoords: '',
98-
afkPeople: ''
102+
afkPeople: '',
103+
openPopup: null
99104
};
100105
},
101106
methods: {
@@ -299,7 +304,8 @@ export default {
299304
isDead = player.character && 'dead' in player.character && player.character.dead,
300305
speed = 'vehicle' in player && player.vehicle && 'speed' in player.vehicle ? player.vehicle.speed : null,
301306
icon = _this.getIcon(player, isDriving, isPassenger, isInvisible, isDead),
302-
vehicle = _this.getVehicleType(player.vehicle);
307+
vehicle = _this.getVehicleType(player.vehicle),
308+
isStaff = _this.staff.includes(player.steamIdentifier);
303309
304310
if (printPlayerInfo && printPlayerInfo === player.character.id) {
305311
printPlayerInfo = null;
@@ -348,6 +354,9 @@ export default {
348354
attributes.push('dead');
349355
markers[id].options.forceZIndex = 101;
350356
}
357+
if (isStaff) {
358+
attributes.push('a staff member');
359+
}
351360
if (isDriving) {
352361
attributes.push('driving (' + (vehicle.type === 'car' ? 'car/bike' : vehicle.type) + ')');
353362
markers[id].options.forceZIndex = 100;
@@ -364,10 +373,12 @@ export default {
364373
extra += '<br><i>Hasn\'t moved in ' + _this.formatSeconds(player.afk) + '</i>';
365374
}
366375
if (player.afk > 15 * 60) {
367-
afkList.push(`<tr>
368-
<td class="pr-2"><a class="text-indigo-600 dark:text-indigo-400" target="_blank" href="/players/` + player.steamIdentifier + `">` + player.character.fullName + `</a></td>
376+
const linkColor = isStaff ? 'text-green-600 dark:text-green-400' : 'text-indigo-600 dark:text-indigo-400';
377+
378+
afkList.push(`<tr title="` + (isStaff ? 'Is a staff member' : '') + `">
379+
<td class="pr-2"><a class="` + linkColor + `" target="_blank" href="/players/` + player.steamIdentifier + `">` + player.character.fullName + `</a></td>
369380
<td class="pr-2">hasn't moved in ` + _this.formatSeconds(player.afk) + `</td>
370-
<td><a class="text-indigo-600 dark:text-indigo-400 track-cid" href="#" data-trackid="` + id + `">[Track]</a></td>
381+
<td><a class="` + linkColor + ` track-cid" href="#" data-trackid="` + id + `" data-popup="true">[Track]</a></td>
371382
</tr>`.replace(/\r?\n(\s{4})?/gm, ''));
372383
}
373384
@@ -377,11 +388,20 @@ export default {
377388
_this.map.setView(coords, _this.firstRefresh ? 6 : _this.map.getZoom(), {
378389
duration: 0.1
379390
});
391+
392+
if (_this.firstRefresh) {
393+
_this.openPopup = id;
394+
}
380395
} else {
381396
extra += '<br><br><a href="#" class="track-cid" data-trackid="' + id + '">' + _this.t('map.track') + '</a>';
382397
}
383398
384399
markers[id]._popup.setContent(player.character.fullName + '<sup>' + player.source + '</sup> (<a href="/players/' + player.steamIdentifier + '" target="_blank">#' + player.character.id + '</a>)' + extra);
400+
401+
if (_this.openPopup === id) {
402+
markers[id].openPopup();
403+
_this.openPopup = null;
404+
}
385405
});
386406
387407
this.afkPeople = afkList.length > 0 ? '<table>' + afkList.join("\n") + '</table>' : '';
@@ -504,6 +524,10 @@ export default {
504524
window.location.hash = track;
505525
506526
_this.map.closePopup();
527+
528+
if ($(this).data('popup')) {
529+
_this.openPopup = track;
530+
}
507531
}
508532
});
509533

0 commit comments

Comments
 (0)