Skip to content

Commit 1e550ac

Browse files
feat: Add filtering options for Ban File Monitors dashboard and update UI messages
1 parent df93d51 commit 1e550ac

3 files changed

Lines changed: 58 additions & 12 deletions

File tree

src/XtremeIdiots.Portal.Web/Controllers/BanFileMonitorsController.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ public class BanFileMonitorsController(
4040
/// each server is protected and in sync with the central ban file.
4141
/// </summary>
4242
[HttpGet]
43-
public async Task<IActionResult> Index(CancellationToken cancellationToken = default)
43+
public async Task<IActionResult> Index(
44+
[FromQuery] bool showAll = false,
45+
CancellationToken cancellationToken = default)
4446
{
4547
return await ExecuteWithErrorHandlingAsync(async () =>
4648
{
@@ -64,7 +66,23 @@ public async Task<IActionResult> Index(CancellationToken cancellationToken = def
6466
return RedirectToAction("Display", "Errors", new { id = 500 });
6567
}
6668

67-
var monitors = monitorsResponse.Result.Data.Items.ToList();
69+
var allMonitors = monitorsResponse.Result.Data.Items.ToList();
70+
71+
// Active monitors are the ones the agent will actually run a check loop for.
72+
// Anything else (sync disabled or agent disabled) clutters the dashboard with
73+
// stale data and is hidden by default; admins can opt in via ?showAll=true to
74+
// diagnose misconfigurations.
75+
static bool IsActive(XtremeIdiots.Portal.Repository.Abstractions.Models.V1.BanFileMonitors.BanFileMonitorDto m)
76+
{
77+
return m.GameServer is not null
78+
&& m.GameServer.BanFileSyncEnabled
79+
&& m.GameServer.AgentEnabled;
80+
}
81+
82+
var hiddenCount = showAll ? 0 : allMonitors.Count(m => !IsActive(m));
83+
var monitors = showAll
84+
? (IReadOnlyList<XtremeIdiots.Portal.Repository.Abstractions.Models.V1.BanFileMonitors.BanFileMonitorDto>)allMonitors
85+
: allMonitors.Where(IsActive).ToList();
6886

6987
var liveStatusResponse = await liveStatusTask.ConfigureAwait(false);
7088
var liveStatusLookup = liveStatusResponse.IsSuccess && liveStatusResponse.Result?.Data?.Items is not null
@@ -81,7 +99,9 @@ public async Task<IActionResult> Index(CancellationToken cancellationToken = def
8199
? activeBanCountsResponse.Result.Data.Items.ToDictionary(c => c.GameType)
82100
: [];
83101

84-
// Build per-game-type roll-up cards for game types the user can see.
102+
// Per-game-type cards reflect the full ban-counts view (DB has the same active
103+
// bans regardless of which servers happen to be enabled), but the visible
104+
// game-type set follows the currently-displayed monitors.
85105
var visibleGameTypes = monitors
86106
.Where(m => m.GameServer is not null)
87107
.Select(m => m.GameServer.GameType)
@@ -105,7 +125,9 @@ public async Task<IActionResult> Index(CancellationToken cancellationToken = def
105125
Monitors = monitors,
106126
LiveStatusLookup = liveStatusLookup,
107127
ServerConfigs = serverConfigs,
108-
GameTypeCards = gameTypeCards
128+
GameTypeCards = gameTypeCards,
129+
ShowingAll = showAll,
130+
HiddenInactiveCount = hiddenCount
109131
};
110132

111133
return View(viewModel);

src/XtremeIdiots.Portal.Web/ViewModels/BanFileMonitorsDashboardViewModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public sealed class BanFileMonitorsDashboardViewModel
2424
public required IReadOnlyDictionary<Guid, Dictionary<string, System.Text.Json.JsonElement>> ServerConfigs { get; init; }
2525

2626
public required IReadOnlyList<BanFileMonitorGameTypeCard> GameTypeCards { get; init; }
27+
28+
/// <summary>True when the dashboard is showing every monitor, false when filtered to active.</summary>
29+
public required bool ShowingAll { get; init; }
30+
31+
/// <summary>Count of monitors hidden by the active-only filter (zero when ShowingAll is true).</summary>
32+
public required int HiddenInactiveCount { get; init; }
2733
}
2834

2935
/// <summary>

src/XtremeIdiots.Portal.Web/Views/BanFileMonitors/Index.cshtml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,32 @@
103103

104104
<div class="wrapper wrapper-content animated fadeInRight">
105105

106-
<div class="alert alert-primary" role="alert">
107-
<i class="fa-solid fa-fw fa-circle-info" aria-hidden="true"></i>
108-
Ban file monitors are now <strong>read-only status snapshots</strong> written by the server agent.
109-
To enable / disable monitoring for a server, toggle <strong>Agent Enabled</strong> + <strong>Ban File Sync</strong> on
110-
<a asp-controller="GameServers" asp-action="Index">the game server's edit page</a>.
111-
Ban file sync is a sub-feature of the agent and requires Agent Enabled. The FTP path is resolved
112-
automatically from the server's <strong>Ban File Root Path</strong> plus per-game-type rules and
113-
the currently-running mod.
106+
<div class="alert alert-primary d-flex align-items-start" role="alert">
107+
<i class="fa-solid fa-fw fa-circle-info me-2 mt-1" aria-hidden="true"></i>
108+
<div class="flex-grow-1">
109+
Ban file monitors are <strong>read-only status snapshots</strong> written by the server agent.
110+
To enable / disable monitoring for a server, toggle <strong>Agent Enabled</strong> + <strong>Ban File Sync</strong>
111+
on <a asp-controller="GameServers" asp-action="Index">the game server's edit page</a>.
112+
Ban file sync is a sub-feature of the agent and requires Agent Enabled. The FTP path is resolved
113+
automatically from the server's <strong>Ban File Root Path</strong> plus per-game-type rules and
114+
the currently-running mod.
115+
116+
@if (Model.ShowingAll)
117+
{
118+
<div class="mt-2">
119+
<i class="fa-solid fa-fw fa-eye" aria-hidden="true"></i> Showing <strong>all monitors</strong>, including disabled and misconfigured.
120+
<a asp-action="Index">Show active only</a>
121+
</div>
122+
}
123+
else if (Model.HiddenInactiveCount > 0)
124+
{
125+
<div class="mt-2">
126+
<i class="fa-solid fa-fw fa-eye-slash" aria-hidden="true"></i>
127+
@Model.HiddenInactiveCount monitor(s) hidden because Ban File Sync or Agent is disabled.
128+
<a asp-action="Index" asp-route-showAll="true">Show all</a>
129+
</div>
130+
}
131+
</div>
114132
</div>
115133

116134
@if (Model.GameTypeCards.Count > 0)

0 commit comments

Comments
 (0)