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

Commit 564eca4

Browse files
committed
- Add active staff members to home page
- Add better coordinate copying - AFK people color gradient
1 parent 73ea436 commit 564eca4

File tree

6 files changed

+51
-9
lines changed

6 files changed

+51
-9
lines changed

app/Http/Controllers/HomeController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
use App\Ban;
66
use App\Helpers\GeneralHelper;
77
use App\Http\Resources\BanResource;
8+
use App\Http\Resources\PlayerIndexResource;
89
use App\Server;
910
use App\Player;
1011
use Illuminate\Http\Request;
12+
use Illuminate\Support\Facades\DB;
1113
use Inertia\Inertia;
1214
use Inertia\Response;
1315

@@ -38,10 +40,18 @@ public function render(Request $request): Response
3840
->orderByDesc('timestamp')
3941
->limit(8)->get())->toArray($request);
4042

43+
$playerList = Player::getAllOnlinePlayers(true);
44+
$players = array_keys($playerList);
45+
usort($players, function ($a, $b) use ($playerList) {
46+
return $playerList[$a]['id'] <=> $playerList[$b]['id'];
47+
});
48+
$staff = Player::query()->where('is_staff', '=', true)->whereIn('steam_identifier', $players)->get();
49+
4150
return Inertia::render('Home', [
4251
'quote' => $quote,
4352
'bans' => $bans,
4453
'playerMap' => Player::fetchSteamPlayerNameMap($bans, 'identifier'),
54+
'staff' => PlayerIndexResource::collection($staff),
4555
]);
4656
}
4757

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"leaflet": "^1.7.1",
4343
"leaflet-gesture-handling": "^1.2.1",
4444
"leaflet-rotatedmarker": "^0.2.0",
45+
"rainbowvis.js": "^1.0.1",
4546
"vue-clipboard2": "^0.3.1",
4647
"vue-linkify": "^1.0.1",
4748
"vue2-circle-progress": "^1.2.3"

resources/js/Pages/Home.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@
7474
</table>
7575
</div>
7676

77+
<div class="mt-5">
78+
<h3 class="dark:text-white">
79+
{{ t('home.staff') }}
80+
</h3>
81+
<div class="flex flex-wrap -mx-3">
82+
<inertia-link class="block px-4 py-2 font-semibold text-center text-white bg-green-600 rounded m-3" v-for="player in staff" :key="player.id" :href="'/players/' + player.identifier">
83+
{{ player.playerName }}
84+
</inertia-link>
85+
</div>
86+
</div>
87+
7788
</div>
7889
</template>
7990

@@ -147,6 +158,10 @@ export default {
147158
type: Array,
148159
required: true,
149160
},
161+
staff: {
162+
type: Array,
163+
required: true,
164+
},
150165
playerMap: {
151166
type: Object,
152167
required: true,

resources/js/Pages/Map/Index.vue

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<div class="-mt-12" id="map-wrapper">
3333
<div class="relative">
3434
<div id="map" class="w-map max-w-full relative h-max"></div>
35-
<pre class="bg-opacity-70 bg-white coordinate-attr absolute bottom-0 left-0 cursor-pointer z-1k" @click="copyText($event, clickedCoords)" v-if="clickedCoords">{{ clickedCoords }}</pre>
35+
<pre class="bg-opacity-70 bg-white coordinate-attr absolute bottom-0 left-0 cursor-pointer z-1k" v-if="clickedCoords"><span @click="copyText($event, clickedCoords)">{{ clickedCoords }}</span> / <span @click="copyText($event, coordsCommand)">{{ t('map.command') }}</span></pre>
3636
</div>
3737
<div v-if="afkPeople" class="w-map-right pt-4">
3838
<h3 class="mb-2">{{ t('map.afk_title') }}</h3>
@@ -51,6 +51,7 @@ import L from "leaflet";
5151
import {GestureHandling} from "leaflet-gesture-handling";
5252
import "leaflet-rotatedmarker";
5353
import custom_icons from "../../data/vehicles.json";
54+
const Rainbow = require('rainbowvis.js');
5455
5556
(function(global){
5657
let MarkerMixin = {
@@ -99,6 +100,7 @@ export default {
99100
trackedPlayer: window.location.hash.substr(1),
100101
firstRefresh: true,
101102
clickedCoords: '',
103+
coordsCommand: '',
102104
afkPeople: '',
103105
openPopup: null
104106
};
@@ -194,7 +196,7 @@ export default {
194196
};
195197
196198
$.each(custom_icons, function(type, cfg) {
197-
if (cfg.models.includes(vehicle.model)) {
199+
if (cfg.models.includes(vehicle.model+"")) {
198200
ret.type = type;
199201
ret.size = cfg.size;
200202
}
@@ -370,16 +372,22 @@ export default {
370372
const lastExtra = attributes.pop();
371373
extra += '<br><i>Is ' + (attributes.length > 0 ? attributes.join(', ') + ' and ' : '') + lastExtra + '</i>';
372374
373-
if (player.afk > 300) {
375+
if (player.afk > 15 * 60) {
374376
extra += '<br><i>Hasn\'t moved in ' + _this.formatSeconds(player.afk) + '</i>';
375377
}
376-
if (player.afk > 15 * 60) {
377-
const linkColor = isStaff ? 'text-green-600 dark:text-green-400' : 'text-indigo-600 dark:text-indigo-400';
378+
if (player.afk > 30 * 60) {
379+
const linkColor = isStaff ? 'rgb(16, 185, 129)' : (() => {
380+
let rainbow = new Rainbow();
381+
rainbow.setNumberRange(30 * 60, 3 * 60 * 60);
382+
rainbow.setSpectrum('#d9ff00', '#ffbf00', '#ff6600', '#ff0000');
383+
384+
return '#' + rainbow.colourAt(player.afk);
385+
})();
378386
379387
afkList.push(`<tr title="` + (isStaff ? 'Is a staff member' : '') + `">
380-
<td class="pr-2"><a class="` + linkColor + `" target="_blank" href="/players/` + player.steamIdentifier + `">` + player.character.fullName + `</a></td>
388+
<td class="pr-2"><a style="color: ` + linkColor + `" target="_blank" href="/players/` + player.steamIdentifier + `">` + player.character.fullName + `</a></td>
381389
<td class="pr-2">hasn't moved in ` + _this.formatSeconds(player.afk) + `</td>
382-
<td><a class="` + linkColor + ` track-cid" href="#" data-trackid="` + id + `" data-popup="true">[Track]</a></td>
390+
<td><a class="track-cid" style="color: ` + linkColor + `" href="#" data-trackid="` + id + `" data-popup="true">[Track]</a></td>
383391
</tr>`.replace(/\r?\n(\s{4})?/gm, ''));
384392
}
385393
@@ -507,6 +515,7 @@ export default {
507515
};
508516
509517
_this.clickedCoords = "[X=" + Math.round(game.x) + ",Y=" + Math.round(game.y) + "] / [X=" + map.x + ",Y=" + map.y + "]";
518+
_this.coordsCommand = "/tp_coords " + Math.round(game.x) + " " + Math.round(game.y);
510519
511520
console.info('Clicked coordinates', map);
512521
});

resources/js/locales/en-us.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"length": "Length",
5050
"time": "Created at"
5151
},
52-
"no_bans": "No recent bans by you"
52+
"no_bans": "No recent bans by you",
53+
"staff": "Active Staff members"
5354
},
5455
"map": {
5556
"title": "Live-Map",
@@ -61,7 +62,8 @@
6162
"pause": "Pause update",
6263
"track": "Track character",
6364
"stop_track": "Stop tracking character",
64-
"afk_title": "AFK Players"
65+
"afk_title": "AFK Players",
66+
"command": "tp"
6567
},
6668
"nav": {
6769
"dark": "Dark",

0 commit comments

Comments
 (0)