Skip to content

Commit

Permalink
fix(admin): make admin friendlier by adding reload button
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMcAssey committed Jan 24, 2025
1 parent bf46b70 commit 965c7a6
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 18 deletions.
4 changes: 4 additions & 0 deletions GLOKON.Baiters.Client/src/pages/ActorsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ onMounted(() => {
<p class="text-sm mr-auto">
Here you will find all actors currently spawned
</p>
<Button icon="fas fa-rotate-right"
severity="primary"
:loading="isLoading"
@click="fetchData()" />
<SplitButton label="Spawn Actor"
severity="info"
icon="fas fa-wrench"
Expand Down
4 changes: 4 additions & 0 deletions GLOKON.Baiters.Client/src/pages/BansPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ onMounted(() => {
<p class="text-sm mr-auto">
Here you will find all actors currently spawned
</p>
<Button icon="fas fa-rotate-right"
severity="primary"
:loading="isLoading"
@click="fetchData()" />
<Button icon="fas fa-plus"
label="Ban SteamID"
severity="info"
Expand Down
4 changes: 4 additions & 0 deletions GLOKON.Baiters.Client/src/pages/ChalkCanvasesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ onMounted(() => {
<p class="text-sm mr-auto">
Here you will find all chalk canvases currently in-game
</p>
<Button icon="fas fa-rotate-right"
severity="primary"
:loading="isLoading"
@click="fetchData()" />
</div>
<DataTable :value="results" data-key="id" paginator :row-hover="true" :loading="isLoading"
:rows="50" :rowsPerPageOptions="[25, 50, 100]" stripedRows responsiveLayout="scroll">
Expand Down
6 changes: 6 additions & 0 deletions GLOKON.Baiters.Client/src/pages/PluginsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {useToast} from "primevue/usetoast";
import DataTable from 'primevue/datatable';
import Column from 'primevue/column';
import type { AxiosInstance } from 'axios';
import Button from 'primevue/button';
const toast = useToast();
const isLoading = ref(false);
Expand Down Expand Up @@ -49,6 +50,11 @@ onMounted(() => {
<p class="text-sm mr-auto">
Here you will find all plugins enabled on the server
</p>

<Button icon="fas fa-rotate-right"
severity="primary"
:loading="isLoading"
@click="fetchData()" />
</div>
<DataTable :value="results" data-key="id" paginator :row-hover="true" :loading="isLoading"
:rows="50" :rowsPerPageOptions="[25, 50, 100]" stripedRows responsiveLayout="scroll">
Expand Down
17 changes: 6 additions & 11 deletions GLOKON.Baiters.Client/src/pages/UsersPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,7 @@ function fetchData(): void {
$http.get(`/api/users/`)
.then((response) => {
if (response.data) {
const responseData = response.data;
const items = [];
for (const id of Object.keys(responseData)) {
items.push({
id: id,
...responseData[id],
});
}
results.value = items;
results.value = response.data;
} else {
results.value = [];
}
Expand Down Expand Up @@ -234,6 +224,11 @@ onMounted(() => {
<p class="text-sm mr-auto">
Here you will find all users currently on the server
</p>
<Button icon="fas fa-rotate-right"
severity="primary"
:loading="isLoading"
@click="fetchData()" />

<Button icon="fas fa-envelope"
label="Send Letter to Everyone"
severity="info"
Expand Down
2 changes: 1 addition & 1 deletion GLOKON.Baiters.Server/Controllers/ServerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public IActionResult Index()
{
return Ok(new ServerInfoResponse
{
ServerSteamId = gm.Server.ServerId,
ServerSteamId = gm.Server.ServerId.ToString(),
LobbyCode = gm.Server.LobbyCode,
PlayerCount = gm.Server.PlayerCount,
MaxPlayers = gm.Server.MaxPlayerCount,
Expand Down
3 changes: 2 additions & 1 deletion GLOKON.Baiters.Server/Controllers/UsersController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using GLOKON.Baiters.Core;
using GLOKON.Baiters.Core.Models.Game;
using GLOKON.Baiters.Server.Requests;
using GLOKON.Baiters.Server.Responses;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

Expand All @@ -14,7 +15,7 @@ public class UsersController(GameManager gm) : Controller
[HttpGet]
public IActionResult Index()
{
return Ok(gm.Server.Players);
return Ok(gm.Server.Players.Select((player) => new PlayerResponse(player.Key, player.Value)).ToList().OrderByDescending(player => player.FisherName));
}

[HttpPost("kick/{steamId}")]
Expand Down
4 changes: 2 additions & 2 deletions GLOKON.Baiters.Server/Responses/ActorResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ internal struct ActorResponse(long id, Actor actor)
{
public DateTimeOffset SpawnedAt { get; set; } = actor.SpawnedAt;

public long Id { get; set; } = id;
public string Id { get; set; } = id.ToString();

public string Type { get; set; } = actor.Type;

public ulong OwnerId { get; set; } = actor.OwnerId;
public string OwnerId { get; set; } = actor.OwnerId.ToString();

public Vector3 Position { get; set; } = actor.Position;

Expand Down
2 changes: 1 addition & 1 deletion GLOKON.Baiters.Server/Responses/BanResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal struct BanResponse(ulong steamId, PlayerBan playerBan)
{
public DateTime CreatedAt { get; set; } = playerBan.CreatedAt;

public ulong SteamId { get; set; } = steamId;
public string SteamId { get; set; } = steamId.ToString();

public string PlayerName { get; set; } = playerBan.PlayerName;

Expand Down
2 changes: 1 addition & 1 deletion GLOKON.Baiters.Server/Responses/ChalkCanvasResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace GLOKON.Baiters.Server.Responses
{
internal struct ChalkCanvasResponse(long id, ChalkCanvas chalkCanvas)
{
public long Id { get; set; } = id;
public string Id { get; set; } = id.ToString();

public ChalkCanvasPoint[] Points { get; set; } = chalkCanvas.Cells.Values.ToArray();

Expand Down
37 changes: 37 additions & 0 deletions GLOKON.Baiters.Server/Responses/PlayerResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using GLOKON.Baiters.Core.Models.Actor;
using GLOKON.Baiters.Core.Models.Game;
using System.Numerics;

namespace GLOKON.Baiters.Server.Responses
{
internal struct PlayerResponse(ulong id, Player player)
{
public DateTimeOffset SpawnedAt { get; set; } = player.SpawnedAt;

public string Id { get; set; } = id.ToString();

public string Type { get; set; } = player.Type;

public string OwnerId { get; set; } = player.OwnerId.ToString();

public Vector3 Position { get; set; } = player.Position;

public Vector3 Rotation { get; set; } = player.Rotation;

public string Zone { get; set; } = player.Zone;

public uint? DespawnTime { get; set; } = player.DespawnTime;

public string FisherName { get; set; } = player.FisherName;

public bool IsAdmin { get; set; } = player.IsAdmin;

public string? ActorId { get; set; } = player.ActorId?.ToString() ?? null;

public string? LastEmote { get; set; } = player.LastEmote;

public Cosmetics? Cosmetics { get; set; } = player.Cosmetics;

public HeldItem? HeldItem { get; set; } = player.HeldItem;
}
}
2 changes: 1 addition & 1 deletion GLOKON.Baiters.Server/Responses/ServerInfoResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
internal struct ServerInfoResponse
{
public required ulong ServerSteamId { get; set; }
public required string ServerSteamId { get; set; }

public required string LobbyCode { get; set; }

Expand Down

0 comments on commit 965c7a6

Please sign in to comment.