Add database layer (EF Core + Postgres) and Blazor Server admin site
- SOR.Database: 5 bounded-context DbContexts (identity, catalog, collection, bazaar, chat), all entities/enums, JSONB for card abilities, ServiceRegistration with per-context connection string fallback to "Default" - SOR.Admin: Blazor Server (.NET 8) — card editor, account management, bazaar overview, feature flags; Identity + cookie auth; FallbackPolicy requires Admin/SuperAdmin role; login via minimal API form POST endpoint - Directory.Packages.props: add Microsoft.AspNetCore.Identity.EntityFrameworkCore - SOR.slnx: add SOR.Admin + SOR.Database to solution (11 projects, 0 errors, 0 warnings) 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:
@@ -0,0 +1,165 @@
|
||||
@page "/accounts/{Id:guid}"
|
||||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||||
@inject SorIdentityDbContext Db
|
||||
@inject UserManager<Account> UserManager
|
||||
@inject NavigationManager Nav
|
||||
|
||||
<PageTitle>Account – SOR Admin</PageTitle>
|
||||
|
||||
@if (_account == null)
|
||||
{
|
||||
<p class="text-muted">Loading…</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="mb-4">
|
||||
<a href="/accounts" class="text-muted text-decoration-none small">
|
||||
<i class="bi bi-arrow-left me-1"></i>Accounts
|
||||
</a>
|
||||
<h1 class="mt-1 mb-0">@(_account.DisplayName ?? _account.Email)</h1>
|
||||
<div class="text-muted small">@_account.Id</div>
|
||||
</div>
|
||||
|
||||
@if (_message != null)
|
||||
{
|
||||
<div class="alert @(_isError ? "alert-danger" : "alert-success")">@_message</div>
|
||||
}
|
||||
|
||||
<div class="row g-4">
|
||||
<!-- Profile -->
|
||||
<div class="col-md-6">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header fw-medium">Profile</div>
|
||||
<div class="card-body">
|
||||
<dl class="row mb-0">
|
||||
<dt class="col-sm-4">Email</dt>
|
||||
<dd class="col-sm-8">@_account.Email</dd>
|
||||
<dt class="col-sm-4">Display Name</dt>
|
||||
<dd class="col-sm-8">@(_account.DisplayName ?? "–")</dd>
|
||||
<dt class="col-sm-4">Created</dt>
|
||||
<dd class="col-sm-8">@_account.CreatedAt.ToString("yyyy-MM-dd HH:mm UTC")</dd>
|
||||
<dt class="col-sm-4">Last Login</dt>
|
||||
<dd class="col-sm-8">@(_account.LastLoginAt?.ToString("yyyy-MM-dd HH:mm UTC") ?? "Never")</dd>
|
||||
<dt class="col-sm-4">Email Confirmed</dt>
|
||||
<dd class="col-sm-8">@(_account.EmailConfirmed ? "Yes" : "No")</dd>
|
||||
<dt class="col-sm-4">2FA</dt>
|
||||
<dd class="col-sm-8">@(_account.TwoFactorEnabled ? "Enabled" : "Disabled")</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Roles -->
|
||||
<div class="col-md-6">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header fw-medium">Roles</div>
|
||||
<div class="card-body">
|
||||
@if (_roles.Count == 0)
|
||||
{
|
||||
<p class="text-muted small">No roles assigned.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
@foreach (var role in _roles)
|
||||
{
|
||||
<span class="badge bg-primary me-1 mb-1">@role</span>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ban / Unban -->
|
||||
<div class="col-md-6">
|
||||
<div class="card shadow-sm @(_isBanned ? "border-danger" : "")">
|
||||
<div class="card-header fw-medium d-flex justify-content-between">
|
||||
<span>Account Status</span>
|
||||
@if (_isBanned)
|
||||
{
|
||||
<span class="badge bg-danger">Banned until @_account.LockoutEnd?.ToString("yyyy-MM-dd")</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-success">Active</span>
|
||||
}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if (_isBanned)
|
||||
{
|
||||
<button class="btn btn-sm btn-outline-success" @onclick="UnbanAsync">
|
||||
<i class="bi bi-unlock me-1"></i>Unban Account
|
||||
</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="d-flex gap-2 align-items-end">
|
||||
<div>
|
||||
<label class="form-label small">Ban duration (days)</label>
|
||||
<input @bind="_banDays" type="number" min="1" max="36500"
|
||||
class="form-control form-control-sm" style="width:120px" />
|
||||
</div>
|
||||
<button class="btn btn-sm btn-danger" @onclick="BanAsync">
|
||||
<i class="bi bi-ban me-1"></i>Ban Account
|
||||
</button>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<button class="btn btn-sm btn-outline-danger" @onclick="BanPermanentAsync">
|
||||
Permanent Ban
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public Guid Id { get; set; }
|
||||
|
||||
private Account? _account;
|
||||
private List<string> _roles = new();
|
||||
private bool _isBanned;
|
||||
private int _banDays = 30;
|
||||
private string? _message;
|
||||
private bool _isError;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_account = await UserManager.FindByIdAsync(Id.ToString());
|
||||
if (_account != null)
|
||||
{
|
||||
_roles = (await UserManager.GetRolesAsync(_account)).ToList();
|
||||
_isBanned = _account.LockoutEnd > DateTimeOffset.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task BanAsync()
|
||||
{
|
||||
if (_account == null) return;
|
||||
await UserManager.SetLockoutEndDateAsync(
|
||||
_account, DateTimeOffset.UtcNow.AddDays(_banDays));
|
||||
_isBanned = true;
|
||||
_message = $"Account banned for {_banDays} days.";
|
||||
_isError = false;
|
||||
}
|
||||
|
||||
private async Task BanPermanentAsync()
|
||||
{
|
||||
if (_account == null) return;
|
||||
await UserManager.SetLockoutEndDateAsync(
|
||||
_account, DateTimeOffset.MaxValue);
|
||||
_isBanned = true;
|
||||
_message = "Account permanently banned.";
|
||||
_isError = false;
|
||||
}
|
||||
|
||||
private async Task UnbanAsync()
|
||||
{
|
||||
if (_account == null) return;
|
||||
await UserManager.SetLockoutEndDateAsync(_account, null);
|
||||
_isBanned = false;
|
||||
_message = "Account unbanned.";
|
||||
_isError = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
@page "/accounts"
|
||||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||||
@inject SorIdentityDbContext Db
|
||||
@inject NavigationManager Nav
|
||||
|
||||
<PageTitle>Accounts – SOR Admin</PageTitle>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="mb-0">Accounts</h1>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm mb-3">
|
||||
<div class="card-body py-2">
|
||||
<input value="@_search"
|
||||
@oninput="e => { _search = e.Value?.ToString() ?? string.Empty; Filter(); }"
|
||||
class="form-control form-control-sm" style="max-width:320px"
|
||||
placeholder="Search by email or display name…" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body p-0">
|
||||
@if (_accounts == null)
|
||||
{
|
||||
<p class="p-3 text-muted">Loading…</p>
|
||||
}
|
||||
else if (_accounts.Count == 0)
|
||||
{
|
||||
<p class="p-3 text-muted">No accounts found.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Email</th>
|
||||
<th>Display Name</th>
|
||||
<th>Created</th>
|
||||
<th>Last Login</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var acc in _accounts)
|
||||
{
|
||||
<tr>
|
||||
<td>@acc.Email</td>
|
||||
<td>@(acc.DisplayName ?? "–")</td>
|
||||
<td class="text-muted small">@acc.CreatedAt.ToString("yyyy-MM-dd")</td>
|
||||
<td class="text-muted small">
|
||||
@(acc.LastLoginAt?.ToString("yyyy-MM-dd") ?? "Never")
|
||||
</td>
|
||||
<td>
|
||||
@if (acc.LockoutEnd > DateTimeOffset.UtcNow)
|
||||
{
|
||||
<span class="badge bg-danger">Banned</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-success">Active</span>
|
||||
}
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<a class="btn btn-sm btn-outline-primary" href="/accounts/@acc.Id">
|
||||
<i class="bi bi-eye"></i> View
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private List<Account>? _accounts;
|
||||
private List<Account> _all = new();
|
||||
private string _search = string.Empty;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_all = await Db.Users
|
||||
.OrderByDescending(a => a.CreatedAt)
|
||||
.ToListAsync();
|
||||
_accounts = _all;
|
||||
}
|
||||
|
||||
private void Filter()
|
||||
{
|
||||
_accounts = _all
|
||||
.Where(a =>
|
||||
string.IsNullOrEmpty(_search) ||
|
||||
(a.Email?.Contains(_search, StringComparison.OrdinalIgnoreCase) == true) ||
|
||||
(a.DisplayName?.Contains(_search, StringComparison.OrdinalIgnoreCase) == true))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
@page "/bazaar"
|
||||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||||
@inject BazaarDbContext Db
|
||||
|
||||
<PageTitle>Bazaar – SOR Admin</PageTitle>
|
||||
|
||||
<h1 class="mb-4">Bazaar</h1>
|
||||
|
||||
<div class="row g-4 mb-4">
|
||||
<div class="col-sm-4">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="text-muted small mb-1">Active Listings</div>
|
||||
<div class="fs-3 fw-bold text-success">@(_active ?? 0)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="text-muted small mb-1">Total Transactions</div>
|
||||
<div class="fs-3 fw-bold">@(_txCount ?? 0)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header fw-medium">Recent Transactions</div>
|
||||
<div class="card-body p-0">
|
||||
@if (_recentTx == null)
|
||||
{
|
||||
<p class="p-3 text-muted">Loading…</p>
|
||||
}
|
||||
else if (_recentTx.Count == 0)
|
||||
{
|
||||
<p class="p-3 text-muted">No transactions yet.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-sm table-hover mb-0">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Amount</th>
|
||||
<th>Currency</th>
|
||||
<th>Listing</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var tx in _recentTx)
|
||||
{
|
||||
<tr>
|
||||
<td>@tx.TransactedAt.ToString("yyyy-MM-dd HH:mm")</td>
|
||||
<td>@tx.Amount.ToString("N2")</td>
|
||||
<td><span class="badge bg-secondary">@tx.Currency</span></td>
|
||||
<td class="text-muted small">@tx.ListingId</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private int? _active;
|
||||
private int? _txCount;
|
||||
private List<BazaarTransaction>? _recentTx;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_active = await Db.Listings.CountAsync(l => l.Status == BazaarListingStatus.Active);
|
||||
_txCount = await Db.Transactions.CountAsync();
|
||||
_recentTx = await Db.Transactions
|
||||
.OrderByDescending(t => t.TransactedAt)
|
||||
.Take(50)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,463 @@
|
||||
@page "/cards/new"
|
||||
@page "/cards/{Id:guid}"
|
||||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||||
@inject CatalogDbContext Db
|
||||
@inject NavigationManager Nav
|
||||
|
||||
<PageTitle>@(_isNew ? "New Card" : _card?.Name ?? "Card") – SOR Admin</PageTitle>
|
||||
|
||||
@if (_card == null)
|
||||
{
|
||||
<p class="text-muted">Loading…</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<a href="/cards" class="text-muted text-decoration-none small">
|
||||
<i class="bi bi-arrow-left me-1"></i>Cards
|
||||
</a>
|
||||
<h1 class="mb-0 mt-1">@(_isNew ? "New Card" : _card.Name)</h1>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
@if (!_isNew)
|
||||
{
|
||||
<button class="btn btn-outline-danger btn-sm" @onclick="DeleteAsync">
|
||||
<i class="bi bi-trash"></i> Delete
|
||||
</button>
|
||||
}
|
||||
<button class="btn btn-primary" @onclick="SaveAsync" disabled="@_saving">
|
||||
@if (_saving) { <span class="spinner-border spinner-border-sm me-1"></span> }
|
||||
<i class="bi bi-floppy me-1"></i>Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (_saveError != null)
|
||||
{
|
||||
<div class="alert alert-danger">@_saveError</div>
|
||||
}
|
||||
@if (_saveSuccess)
|
||||
{
|
||||
<div class="alert alert-success">Saved successfully.</div>
|
||||
}
|
||||
|
||||
<!-- Tabs -->
|
||||
<ul class="nav nav-tabs mb-4">
|
||||
@foreach (var tab in _tabs)
|
||||
{
|
||||
<li class="nav-item">
|
||||
<button class="nav-link @(tab == _activeTab ? "active" : "")"
|
||||
@onclick="@(() => _activeTab = tab)">@tab</button>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
<!-- ── Basic Info ─────────────────────────────────────────────────────── -->
|
||||
@if (_activeTab == "Basic")
|
||||
{
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Name <span class="text-danger">*</span></label>
|
||||
<input @bind="_card.Name" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Card Type</label>
|
||||
<select @bind="_card.CardType" class="form-select">
|
||||
@foreach (var t in Enum.GetValues<CardType>())
|
||||
{
|
||||
<option value="@t">@t</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Affinity</label>
|
||||
<select @bind="_card.Affinity" class="form-select">
|
||||
@foreach (var a in Enum.GetValues<Affinity>())
|
||||
{
|
||||
<option value="@a">@a</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label">Description</label>
|
||||
<textarea @bind="_card.Description" class="form-control" rows="3"></textarea>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">SP Cost</label>
|
||||
<input @bind="_card.SpCost" type="number" min="0" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">ST Cost</label>
|
||||
<input @bind="_card.StCost" type="number" min="0" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Rarity</label>
|
||||
<select @bind="_card.Rarity" class="form-select">
|
||||
@foreach (var r in Enum.GetValues<CardRarity>())
|
||||
{
|
||||
<option value="@r">@r</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Collector #</label>
|
||||
<input @bind="_card.CollectorNumber" type="number" min="1" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-2 d-flex align-items-end">
|
||||
<div class="form-check">
|
||||
<input @bind="_card.IsPublished" type="checkbox" class="form-check-input" id="chkPublished" />
|
||||
<label class="form-check-label" for="chkPublished">Published</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- ── Stats ──────────────────────────────────────────────────────────── -->
|
||||
else if (_activeTab == "Stats")
|
||||
{
|
||||
@if (_card.CardType is CardType.ArchSpirit or CardType.Spirit)
|
||||
{
|
||||
<div class="row g-3">
|
||||
<div class="col-12"><h6 class="text-muted">Channeling</h6></div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Min Channel Range</label>
|
||||
<input @bind="_card.MinChannelRange" type="number" min="0" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Max Channel Range</label>
|
||||
<input @bind="_card.MaxChannelRange" type="number" min="0" class="form-control" />
|
||||
</div>
|
||||
@if (_card.CardType == CardType.ArchSpirit)
|
||||
{
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">Tier</label>
|
||||
<input @bind="_card.Tier" type="number" min="1" max="5" class="form-control" />
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="col-12"><h6 class="text-muted mt-2">Combat</h6></div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Attack Type</label>
|
||||
<select @bind="_card.AttackType" class="form-select">
|
||||
<option value="">– None –</option>
|
||||
@foreach (var t in Enum.GetValues<AttackType>())
|
||||
{
|
||||
<option value="@t">@t</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">Damage</label>
|
||||
<input @bind="_card.Damage" type="number" min="0" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">Health</label>
|
||||
<input @bind="_card.MaxHealth" type="number" min="0" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">Defense</label>
|
||||
<input @bind="_card.MaxDefense" type="number" min="0" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">Min Atk Range</label>
|
||||
<input @bind="_card.MinAttackRange" type="number" min="0" class="form-control" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">Max Atk Range</label>
|
||||
<input @bind="_card.MaxAttackRange" type="number" min="0" class="form-control" />
|
||||
</div>
|
||||
|
||||
<div class="col-12"><h6 class="text-muted mt-2">Movement</h6></div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Movement Type</label>
|
||||
<select @bind="_card.MovementType" class="form-select">
|
||||
<option value="">– None –</option>
|
||||
@foreach (var t in Enum.GetValues<MovementType>())
|
||||
{
|
||||
<option value="@t">@t</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label">Move Points</label>
|
||||
<input @bind="_card.MovementPoints" type="number" min="0" class="form-control" />
|
||||
</div>
|
||||
|
||||
<div class="col-12"><h6 class="text-muted mt-2">Flags</h6></div>
|
||||
@foreach (var flag in _unitFlags)
|
||||
{
|
||||
<div class="col-md-2">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input"
|
||||
id="flag_@flag.Label"
|
||||
checked="@flag.Get(_card)"
|
||||
@onchange="e => flag.Set(_card, (bool)(e.Value ?? false))" />
|
||||
<label class="form-check-label" for="flag_@flag.Label">@flag.Label</label>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="col-12"><h6 class="text-muted mt-2">Genus Tags</h6></div>
|
||||
<div class="col-md-6">
|
||||
<input @bind="_genusInput" class="form-control"
|
||||
placeholder="Comma-separated tags, e.g. Elemental, Beast" />
|
||||
<div class="form-text">Stored as a Postgres text[] array.</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else if (_card.CardType == CardType.Terramorpha)
|
||||
{
|
||||
<div class="row g-3">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">Terramorpha Mode</label>
|
||||
<select @bind="_card.TerramorphaMode" class="form-select">
|
||||
@foreach (var m in Enum.GetValues<TerramorphaMode>())
|
||||
{
|
||||
<option value="@m">@m</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="text-muted">No additional stats for @_card.CardType cards.</p>
|
||||
}
|
||||
}
|
||||
|
||||
<!-- ── Abilities / Effects ────────────────────────────────────────────── -->
|
||||
else if (_activeTab == "Abilities")
|
||||
{
|
||||
<div class="mb-2 text-muted small">
|
||||
@if (_card.CardType is CardType.Repentance or CardType.Instinct or CardType.Terramorpha)
|
||||
{
|
||||
<span>Effects JSON (Action[] array) — see <code>abilities.md</code> for schema.</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Abilities JSON (AbilityDefinition[] array) — see <code>abilities.md</code> for schema.</span>
|
||||
}
|
||||
</div>
|
||||
<textarea @bind="_abilitiesJson" class="form-control font-monospace"
|
||||
rows="20" spellcheck="false"
|
||||
placeholder="[ { "type": "Active", ... } ]"></textarea>
|
||||
}
|
||||
|
||||
<!-- ── Assets ─────────────────────────────────────────────────────────── -->
|
||||
else if (_activeTab == "Assets")
|
||||
{
|
||||
<h6 class="text-muted mb-3">Static Assets</h6>
|
||||
<div class="row g-3 mb-4">
|
||||
@foreach (var asset in _card.Assets)
|
||||
{
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<span class="badge bg-primary">@asset.AssetType</span>
|
||||
<button class="btn btn-sm btn-outline-danger"
|
||||
@onclick="() => RemoveAsset(asset)">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
<input @bind="asset.CdnUrl" class="form-control form-control-sm"
|
||||
placeholder="https://cdn.sor.gg/…" />
|
||||
<input @bind="asset.MimeType" class="form-control form-control-sm mt-1"
|
||||
placeholder="MIME type (e.g. image/webp)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<div class="col-12">
|
||||
<div class="d-flex gap-2">
|
||||
@foreach (var t in Enum.GetValues<CardAssetType>())
|
||||
{
|
||||
<button class="btn btn-sm btn-outline-secondary"
|
||||
@onclick="() => AddAsset(t)">
|
||||
<i class="bi bi-plus-lg me-1"></i>@t
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h6 class="text-muted mb-3">Animation Bindings</h6>
|
||||
<table class="table table-sm">
|
||||
<thead><tr><th>Action</th><th>CDN URL</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
@foreach (var anim in _card.AnimationBindings)
|
||||
{
|
||||
<tr>
|
||||
<td style="width:160px">
|
||||
<input @bind="anim.ActionName" class="form-control form-control-sm"
|
||||
placeholder="e.g. attack" />
|
||||
</td>
|
||||
<td>
|
||||
<input @bind="anim.AnimationCdnUrl" class="form-control form-control-sm"
|
||||
placeholder="https://cdn.sor.gg/…" />
|
||||
</td>
|
||||
<td style="width:50px">
|
||||
<button class="btn btn-sm btn-outline-danger"
|
||||
@onclick="() => RemoveAnimation(anim)">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<button class="btn btn-sm btn-outline-secondary" @onclick="AddAnimation">
|
||||
<i class="bi bi-plus-lg me-1"></i>Add Animation
|
||||
</button>
|
||||
}
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public Guid? Id { get; set; }
|
||||
|
||||
private CardDefinition? _card;
|
||||
private bool _isNew;
|
||||
private string _activeTab = "Basic";
|
||||
private readonly string[] _tabs = ["Basic", "Stats", "Abilities", "Assets"];
|
||||
private bool _saving;
|
||||
private string? _saveError;
|
||||
private bool _saveSuccess;
|
||||
private string _genusInput = string.Empty;
|
||||
private string _abilitiesJson = string.Empty;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_isNew = Id == null;
|
||||
|
||||
if (_isNew)
|
||||
{
|
||||
_card = new CardDefinition
|
||||
{
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
UpdatedAt = DateTimeOffset.UtcNow,
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
_card = await Db.CardDefinitions
|
||||
.Include(c => c.Assets)
|
||||
.Include(c => c.AnimationBindings)
|
||||
.FirstOrDefaultAsync(c => c.Id == Id);
|
||||
|
||||
if (_card != null)
|
||||
{
|
||||
_genusInput = _card.Genus != null
|
||||
? string.Join(", ", _card.Genus)
|
||||
: string.Empty;
|
||||
|
||||
_abilitiesJson = _card.CardType is CardType.Repentance
|
||||
or CardType.Instinct or CardType.Terramorpha
|
||||
? _card.EffectsJson ?? string.Empty
|
||||
: _card.AbilitiesJson ?? string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
if (_card == null) return;
|
||||
_saving = true;
|
||||
_saveError = null;
|
||||
_saveSuccess = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Flush genus input to array.
|
||||
_card.Genus = string.IsNullOrWhiteSpace(_genusInput)
|
||||
? null
|
||||
: _genusInput.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
|
||||
// Flush abilities JSON to the correct column.
|
||||
if (_card.CardType is CardType.Repentance or CardType.Instinct or CardType.Terramorpha)
|
||||
_card.EffectsJson = string.IsNullOrWhiteSpace(_abilitiesJson) ? null : _abilitiesJson;
|
||||
else
|
||||
_card.AbilitiesJson = string.IsNullOrWhiteSpace(_abilitiesJson) ? null : _abilitiesJson;
|
||||
|
||||
_card.UpdatedAt = DateTimeOffset.UtcNow;
|
||||
|
||||
if (_isNew)
|
||||
{
|
||||
Db.CardDefinitions.Add(_card);
|
||||
}
|
||||
|
||||
await Db.SaveChangesAsync();
|
||||
_saveSuccess = true;
|
||||
|
||||
if (_isNew)
|
||||
{
|
||||
_isNew = false;
|
||||
Nav.NavigateTo($"/cards/{_card.Id}", replace: true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_saveError = ex.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_saving = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeleteAsync()
|
||||
{
|
||||
if (_card == null || _isNew) return;
|
||||
Db.CardDefinitions.Remove(_card);
|
||||
await Db.SaveChangesAsync();
|
||||
Nav.NavigateTo("/cards");
|
||||
}
|
||||
|
||||
private void AddAsset(CardAssetType type)
|
||||
=> _card!.Assets.Add(new CardAsset
|
||||
{
|
||||
CardDefinitionId = _card.Id,
|
||||
AssetType = type,
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
});
|
||||
|
||||
private void RemoveAsset(CardAsset asset)
|
||||
{
|
||||
_card!.Assets.Remove(asset);
|
||||
if (asset.Id != Guid.Empty)
|
||||
Db.CardAssets.Remove(asset);
|
||||
}
|
||||
|
||||
private void AddAnimation()
|
||||
=> _card!.AnimationBindings.Add(new CardAnimationBinding
|
||||
{
|
||||
CardDefinitionId = _card.Id,
|
||||
});
|
||||
|
||||
private void RemoveAnimation(CardAnimationBinding anim)
|
||||
{
|
||||
_card!.AnimationBindings.Remove(anim);
|
||||
if (anim.Id != Guid.Empty)
|
||||
Db.AnimationBindings.Remove(anim);
|
||||
}
|
||||
|
||||
// ── Flag descriptors (avoids 10 identical checkboxes) ───────────────────
|
||||
|
||||
private sealed record FlagDescriptor(
|
||||
string Label,
|
||||
Func<CardDefinition, bool> Get,
|
||||
Action<CardDefinition, bool> Set);
|
||||
|
||||
private readonly FlagDescriptor[] _unitFlags =
|
||||
[
|
||||
new("Can Attack", c => c.CanAttack ?? false, (c, v) => c.CanAttack = v),
|
||||
new("Can Defend", c => c.CanDefend ?? false, (c, v) => c.CanDefend = v),
|
||||
new("Can Be Attacked", c => c.CanBeAttacked ?? false, (c, v) => c.CanBeAttacked = v),
|
||||
new("Can Be Blocked", c => c.CanBeBlocked ?? false, (c, v) => c.CanBeBlocked = v),
|
||||
new("Can Move", c => c.CanMove ?? false, (c, v) => c.CanMove = v),
|
||||
new("Can Be Obstructed",c => c.CanBeObstructed ?? false, (c, v) => c.CanBeObstructed = v),
|
||||
new("Requires LOS", c => c.RequiresLos ?? false, (c, v) => c.RequiresLos = v),
|
||||
new("Can Use Ability", c => c.CanUseAbility ?? false, (c, v) => c.CanUseAbility = v),
|
||||
new("Can Be Sacrificed",c => c.CanBeSacrificed ?? false, (c, v) => c.CanBeSacrificed = v),
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
@page "/cards"
|
||||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||||
@inject CatalogDbContext Db
|
||||
@inject NavigationManager Nav
|
||||
|
||||
<PageTitle>Cards – SOR Admin</PageTitle>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="mb-0">Cards</h1>
|
||||
<a class="btn btn-primary" href="/cards/new">
|
||||
<i class="bi bi-plus-lg me-1"></i>New Card
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm mb-3">
|
||||
<div class="card-body py-2">
|
||||
<div class="row g-2 align-items-center">
|
||||
<div class="col-md-4">
|
||||
<input value="@_search"
|
||||
@oninput="e => { _search = e.Value?.ToString() ?? string.Empty; Filter(); }"
|
||||
class="form-control form-control-sm" placeholder="Search by name…" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select @bind="_filterType" @bind:after="Filter" class="form-select form-select-sm">
|
||||
<option value="">All types</option>
|
||||
@foreach (var t in Enum.GetValues<CardType>())
|
||||
{
|
||||
<option value="@t">@t</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select @bind="_filterPublished" @bind:after="Filter" class="form-select form-select-sm">
|
||||
<option value="">All status</option>
|
||||
<option value="true">Published</option>
|
||||
<option value="false">Draft</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body p-0">
|
||||
@if (_cards == null)
|
||||
{
|
||||
<p class="p-3 text-muted">Loading…</p>
|
||||
}
|
||||
else if (_cards.Count == 0)
|
||||
{
|
||||
<p class="p-3 text-muted">No cards match the current filter.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Affinity</th>
|
||||
<th>SP</th>
|
||||
<th>ST</th>
|
||||
<th>Rarity</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var card in _cards)
|
||||
{
|
||||
<tr>
|
||||
<td class="fw-medium">@card.Name</td>
|
||||
<td><span class="badge bg-secondary">@card.CardType</span></td>
|
||||
<td>@card.Affinity</td>
|
||||
<td>@card.SpCost</td>
|
||||
<td>@card.StCost</td>
|
||||
<td>@card.Rarity</td>
|
||||
<td>
|
||||
@if (card.IsPublished)
|
||||
{
|
||||
<span class="badge bg-success">Published</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-warning text-dark">Draft</span>
|
||||
}
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<a class="btn btn-sm btn-outline-primary" href="/cards/@card.Id">
|
||||
<i class="bi bi-pencil"></i> Edit
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private List<CardDefinition>? _cards;
|
||||
private List<CardDefinition> _all = new();
|
||||
private string _search = string.Empty;
|
||||
private string _filterType = string.Empty;
|
||||
private string _filterPublished = string.Empty;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_all = await Db.CardDefinitions
|
||||
.OrderBy(c => c.Name)
|
||||
.ToListAsync();
|
||||
_cards = _all;
|
||||
}
|
||||
|
||||
private void Filter()
|
||||
{
|
||||
_cards = _all
|
||||
.Where(c => string.IsNullOrEmpty(_search) ||
|
||||
c.Name.Contains(_search, StringComparison.OrdinalIgnoreCase))
|
||||
.Where(c => string.IsNullOrEmpty(_filterType) ||
|
||||
c.CardType.ToString() == _filterType)
|
||||
.Where(c => string.IsNullOrEmpty(_filterPublished) ||
|
||||
c.IsPublished.ToString().ToLower() == _filterPublished)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
@page "/"
|
||||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||||
@inject CatalogDbContext CatalogDb
|
||||
@inject SorIdentityDbContext IdentityDb
|
||||
@inject BazaarDbContext BazaarDb
|
||||
|
||||
<PageTitle>Dashboard – SOR Admin</PageTitle>
|
||||
|
||||
<h1 class="mb-4">Dashboard</h1>
|
||||
|
||||
<div class="row g-4 mb-4">
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="card border-0 shadow-sm h-100">
|
||||
<div class="card-body">
|
||||
<div class="text-muted small mb-1"><i class="bi bi-collection me-1"></i>Total Cards</div>
|
||||
<div class="fs-2 fw-bold">@(_totalCards?.ToString("N0") ?? "–")</div>
|
||||
<div class="text-success small">@(_publishedCards?.ToString("N0") ?? "–") published</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="card border-0 shadow-sm h-100">
|
||||
<div class="card-body">
|
||||
<div class="text-muted small mb-1"><i class="bi bi-people me-1"></i>Accounts</div>
|
||||
<div class="fs-2 fw-bold">@(_totalAccounts?.ToString("N0") ?? "–")</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="card border-0 shadow-sm h-100">
|
||||
<div class="card-body">
|
||||
<div class="text-muted small mb-1"><i class="bi bi-shop me-1"></i>Active Listings</div>
|
||||
<div class="fs-2 fw-bold">@(_activeListings?.ToString("N0") ?? "–")</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-xl-3">
|
||||
<div class="card border-0 shadow-sm h-100">
|
||||
<div class="card-body">
|
||||
<div class="text-muted small mb-1"><i class="bi bi-arrow-left-right me-1"></i>Transactions</div>
|
||||
<div class="fs-2 fw-bold">@(_totalTransactions?.ToString("N0") ?? "–")</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private int? _totalCards;
|
||||
private int? _publishedCards;
|
||||
private int? _totalAccounts;
|
||||
private int? _activeListings;
|
||||
private int? _totalTransactions;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_totalCards = await CatalogDb.CardDefinitions.CountAsync();
|
||||
_publishedCards = await CatalogDb.CardDefinitions.CountAsync(c => c.IsPublished);
|
||||
_totalAccounts = await IdentityDb.Users.CountAsync();
|
||||
_activeListings = await BazaarDb.Listings.CountAsync(l => l.Status == BazaarListingStatus.Active);
|
||||
_totalTransactions = await BazaarDb.Transactions.CountAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
@page "/feature-flags"
|
||||
@attribute [Authorize(Roles = "Admin,SuperAdmin")]
|
||||
|
||||
<PageTitle>Feature Flags – SOR Admin</PageTitle>
|
||||
|
||||
<h1 class="mb-4">Feature Flags</h1>
|
||||
|
||||
<div class="alert alert-info">
|
||||
<i class="bi bi-info-circle me-2"></i>
|
||||
Feature flags are stored in Redis via <code>RedisKeys.FeatureFlag(flag)</code>.
|
||||
This UI will read/write those keys once the Redis connection is wired into the admin site.
|
||||
For now, use <code>redis-cli SET feature:bazaar_enabled 1</code> directly.
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header fw-medium">OAuth Providers</div>
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-dark">
|
||||
<tr><th>Provider</th><th>Status</th><th>Note</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><i class="bi bi-google me-2 text-danger"></i>Google</td>
|
||||
<td><span class="badge bg-warning text-dark">Stubbed</span></td>
|
||||
<td class="text-muted small">Enable via appsettings OAuth config</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="bi bi-steam me-2"></i>Steam</td>
|
||||
<td><span class="badge bg-warning text-dark">Stubbed</span></td>
|
||||
<td class="text-muted small">Requires OpenID 2.0 handler</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="bi bi-apple me-2"></i>Apple</td>
|
||||
<td><span class="badge bg-warning text-dark">Stubbed</span></td>
|
||||
<td class="text-muted small">Requires Sign in with Apple OIDC</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="bi bi-microsoft me-2 text-primary"></i>Microsoft</td>
|
||||
<td><span class="badge bg-warning text-dark">Stubbed</span></td>
|
||||
<td class="text-muted small">Enable via Azure AD app registration</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,45 @@
|
||||
@page "/login"
|
||||
@attribute [AllowAnonymous]
|
||||
@* Static SSR — no rendermode, keeps login available without a SignalR connection. *@
|
||||
|
||||
<PageTitle>Sign In – SOR Admin</PageTitle>
|
||||
|
||||
<div class="min-vh-100 d-flex align-items-center justify-content-center bg-dark">
|
||||
<div class="card shadow" style="width: 380px;">
|
||||
<div class="card-body p-4">
|
||||
<h1 class="h4 mb-1 fw-bold">
|
||||
<i class="bi bi-lightning-charge-fill text-warning me-2"></i>SOR Admin
|
||||
</h1>
|
||||
<p class="text-muted small mb-4">Sign in to continue</p>
|
||||
|
||||
@if (Error == "invalid")
|
||||
{
|
||||
<div class="alert alert-danger py-2">Invalid email or password.</div>
|
||||
}
|
||||
else if (Error == "locked")
|
||||
{
|
||||
<div class="alert alert-warning py-2">Account locked — try again later.</div>
|
||||
}
|
||||
|
||||
<form method="post" action="/auth/login">
|
||||
<input type="hidden" name="returnUrl" value="@ReturnUrl" />
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Email</label>
|
||||
<input name="email" type="email" class="form-control"
|
||||
placeholder="admin@example.com" required autofocus />
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="form-label">Password</label>
|
||||
<input name="password" type="password" class="form-control" required />
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100">Sign In</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[SupplyParameterFromQuery] public string? ReturnUrl { get; set; }
|
||||
[SupplyParameterFromQuery] public string? Error { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user