Add Settings, Account, Bug Reports, and Leaderboard

Server:
- New SOR.Support project: SubmitBugReport, GetLeaderboard, GetAccountProfile handlers
- New SOR.Database support schema: BugReport + BugReportResponse entities + SupportDbContext
- EF migration: Migrations/Support/AddSupport
- Admin panel: Bug Reports list + detail pages with reply-to-submitter flow
- Admin NavMenu: Support section with Bug Reports link
- Reply creates chat.Notification (type "admin_response") for in-game mailbox

Client:
- Settings autoload (Settings.gd): music/sfx volume+mute, persisted to user://settings.cfg
- SettingsScreen: sliders + mute CheckButtons wired to Settings autoload
- AccountScreen: profile (display name, OP, rank score) + mailbox (admin_response notifications)
- LeaderboardScreen: paginated ranked player list, caller highlighted in blue
- BugReportDialog: category/title/description/steps form, submits via support.submit_bug_report
- MainScreen: new Leaderboard, Account, Settings, Report a Bug navigation buttons

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-06 20:14:12 -05:00
co-authored by Claude Happy
parent c4ef720570
commit a482cc5319
33 changed files with 2107 additions and 14 deletions
@@ -0,0 +1,193 @@
@page "/support/bug-reports/{Id:guid}"
@using Microsoft.AspNetCore.Identity
@using Microsoft.EntityFrameworkCore
@using SOR.Database.Contexts
@using SOR.Database.Entities.Chat
@using SOR.Database.Entities.Identity
@using SOR.Database.Entities.Support
@inject SupportDbContext SupportDb
@inject ChatDbContext ChatDb
@inject UserManager<Account> UserManager
@inject AuthenticationStateProvider AuthState
@inject NavigationManager Nav
<PageTitle>Bug Report — SOR Admin</PageTitle>
@if (_report is null)
{
<p class="text-muted">Loading…</p>
}
else
{
<div class="d-flex align-items-center gap-3 mb-4">
<a href="/support/bug-reports" class="btn btn-sm btn-outline-secondary">← Back</a>
<h4 class="mb-0">@_report.Title</h4>
<span class="badge @StatusBadge(_report.Status)">@_report.Status</span>
</div>
<div class="row g-4">
<!-- Left: report details -->
<div class="col-lg-8">
<div class="card mb-3">
<div class="card-body">
<dl class="row mb-0">
<dt class="col-sm-3">Submitter</dt>
<dd class="col-sm-9">@_report.SubmitterDisplayName <span class="text-muted small">(@_report.SubmitterAccountId)</span></dd>
<dt class="col-sm-3">Category</dt>
<dd class="col-sm-9">@_report.Category</dd>
<dt class="col-sm-3">Submitted</dt>
<dd class="col-sm-9">@_report.CreatedAt.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss")</dd>
</dl>
</div>
</div>
<div class="card mb-3">
<div class="card-header fw-semibold">Description</div>
<div class="card-body" style="white-space:pre-wrap">@_report.Description</div>
</div>
@if (!string.IsNullOrWhiteSpace(_report.StepsToReproduce))
{
<div class="card mb-3">
<div class="card-header fw-semibold">Steps to Reproduce</div>
<div class="card-body" style="white-space:pre-wrap">@_report.StepsToReproduce</div>
</div>
}
<!-- Responses thread -->
<h5 class="mt-4">Responses (@_report.Responses.Count)</h5>
@foreach (var resp in _report.Responses.OrderBy(r => r.CreatedAt))
{
<div class="card mb-2 border-primary">
<div class="card-body">
<div class="d-flex justify-content-between mb-1">
<strong>@resp.AdminDisplayName</strong>
<span class="text-muted small">@resp.CreatedAt.LocalDateTime.ToString("yyyy-MM-dd HH:mm")</span>
</div>
<div style="white-space:pre-wrap">@resp.Content</div>
</div>
</div>
}
<!-- Reply form -->
<div class="card mt-3">
<div class="card-header fw-semibold">Reply to submitter</div>
<div class="card-body">
<textarea class="form-control mb-2" rows="4" placeholder="Your response…"
@bind="_replyText"></textarea>
@if (!string.IsNullOrWhiteSpace(_replyError))
{
<p class="text-danger small">@_replyError</p>
}
<button class="btn btn-primary" @onclick="SubmitReplyAsync" disabled="@_replying">
@(_replying ? "Sending…" : "Send Reply")
</button>
<span class="text-muted small ms-2">The player will receive a notification in-game.</span>
</div>
</div>
</div>
<!-- Right: status management -->
<div class="col-lg-4">
<div class="card">
<div class="card-header fw-semibold">Status</div>
<div class="card-body d-flex flex-column gap-2">
@foreach (var s in new[] { "Open", "InProgress", "Resolved", "Closed" })
{
<button class="btn btn-sm @(s == _report.Status ? StatusBadge(s) + " text-white" : "btn-outline-secondary")"
@onclick="() => SetStatusAsync(s)">
@s
</button>
}
</div>
</div>
</div>
</div>
}
@code {
[Parameter] public Guid Id { get; set; }
private BugReport? _report;
private string _replyText = "";
private string _replyError = "";
private bool _replying = false;
protected override async Task OnInitializedAsync()
{
_report = await SupportDb.BugReports
.Include(r => r.Responses)
.FirstOrDefaultAsync(r => r.Id == Id);
}
private async Task SubmitReplyAsync()
{
if (_report is null) return;
if (string.IsNullOrWhiteSpace(_replyText))
{
_replyError = "Response cannot be empty.";
return;
}
_replying = true;
_replyError = "";
var authState = await AuthState.GetAuthenticationStateAsync();
var adminUser = await UserManager.GetUserAsync(authState.User);
var response = new BugReportResponse
{
BugReportId = _report.Id,
AdminAccountId = adminUser?.Id ?? Guid.Empty,
AdminDisplayName = adminUser?.DisplayName ?? adminUser?.UserName ?? "Admin",
Content = _replyText.Trim(),
CreatedAt = DateTimeOffset.UtcNow,
};
SupportDb.BugReportResponses.Add(response);
// Update report status to InProgress if it was Open
if (_report.Status == "Open")
_report.Status = "InProgress";
_report.UpdatedAt = DateTimeOffset.UtcNow;
await SupportDb.SaveChangesAsync();
// Notify the submitter via the Chat notification system
ChatDb.Notifications.Add(new Notification
{
RecipientAccountId = _report.SubmitterAccountId,
NotificationType = "admin_response",
Title = "Response to your bug report",
Body = $"An admin has responded to your bug report: \"{_report.Title}\"",
PayloadJson = System.Text.Json.JsonSerializer.Serialize(new
{
bugReportId = _report.Id,
preview = _replyText.Trim()[..Math.Min(_replyText.Trim().Length, 200)],
}),
CreatedAt = DateTimeOffset.UtcNow,
});
await ChatDb.SaveChangesAsync();
_replyText = "";
_replying = false;
_report.Responses.Add(response);
}
private async Task SetStatusAsync(string status)
{
if (_report is null || _report.Status == status) return;
_report.Status = status;
_report.UpdatedAt = DateTimeOffset.UtcNow;
await SupportDb.SaveChangesAsync();
}
private static string StatusBadge(string status) => status switch
{
"Open" => "bg-danger",
"InProgress" => "bg-warning text-dark",
"Resolved" => "bg-success",
"Closed" => "bg-secondary",
_ => "bg-secondary",
};
}
@@ -0,0 +1,119 @@
@page "/support/bug-reports"
@using Microsoft.EntityFrameworkCore
@using SOR.Database.Contexts
@using SOR.Database.Entities.Support
@inject SupportDbContext SupportDb
<PageTitle>Bug Reports — SOR Admin</PageTitle>
<div class="d-flex align-items-center gap-3 mb-4">
<h3 class="mb-0">Bug Reports</h3>
<span class="badge bg-secondary">@_total</span>
</div>
<div class="d-flex gap-2 mb-3">
@foreach (var status in _statuses)
{
<button class="btn btn-sm @(status == _filter ? "btn-primary" : "btn-outline-secondary")"
@onclick="() => SetFilter(status)">
@status
</button>
}
</div>
@if (_loading)
{
<p class="text-muted">Loading…</p>
}
else if (_reports.Count == 0)
{
<p class="text-muted">No bug reports found.</p>
}
else
{
<table class="table table-sm table-hover align-middle">
<thead>
<tr>
<th>Status</th>
<th>Category</th>
<th>Title</th>
<th>Submitter</th>
<th>Submitted</th>
<th>Responses</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var r in _reports)
{
<tr>
<td><span class="badge @StatusBadge(r.Status)">@r.Status</span></td>
<td><span class="text-muted small">@r.Category</span></td>
<td>@r.Title</td>
<td class="text-muted small">@r.SubmitterDisplayName</td>
<td class="text-muted small">@r.CreatedAt.LocalDateTime.ToString("yyyy-MM-dd HH:mm")</td>
<td class="text-center">@r.Responses.Count</td>
<td>
<a class="btn btn-sm btn-outline-primary" href="/support/bug-reports/@r.Id">View</a>
</td>
</tr>
}
</tbody>
</table>
<div class="d-flex gap-2 align-items-center mt-3">
<button class="btn btn-sm btn-outline-secondary" @onclick="PrevPage" disabled="@(_page == 0)">← Prev</button>
<span class="text-muted small">Page @(_page + 1) of @_pageCount</span>
<button class="btn btn-sm btn-outline-secondary" @onclick="NextPage" disabled="@(_page >= _pageCount - 1)">Next →</button>
</div>
}
@code {
private static readonly string[] _statuses = ["All", "Open", "InProgress", "Resolved", "Closed"];
private const int PageSize = 25;
private List<BugReport> _reports = [];
private int _total = 0;
private int _page = 0;
private int _pageCount = 1;
private bool _loading = true;
private string _filter = "All";
protected override async Task OnInitializedAsync() => await LoadAsync();
private async Task LoadAsync()
{
_loading = true;
var query = SupportDb.BugReports
.Include(r => r.Responses)
.AsQueryable();
if (_filter != "All")
query = query.Where(r => r.Status == _filter);
_total = await query.CountAsync();
_pageCount = Math.Max(1, (int)Math.Ceiling(_total / (double)PageSize));
_page = Math.Clamp(_page, 0, _pageCount - 1);
_reports = await query
.OrderByDescending(r => r.CreatedAt)
.Skip(_page * PageSize)
.Take(PageSize)
.ToListAsync();
_loading = false;
}
private async Task SetFilter(string s) { _filter = s; _page = 0; await LoadAsync(); }
private async Task PrevPage() { _page--; await LoadAsync(); }
private async Task NextPage() { _page++; await LoadAsync(); }
private static string StatusBadge(string status) => status switch
{
"Open" => "bg-danger",
"InProgress" => "bg-warning text-dark",
"Resolved" => "bg-success",
"Closed" => "bg-secondary",
_ => "bg-secondary",
};
}