168 lines
7.6 KiB
Plaintext
168 lines
7.6 KiB
Plaintext
@page "/admin/players"
|
|
@model Players.IndexModel
|
|
@using DataServer.Data
|
|
@{
|
|
ViewData["Title"] = "Players";
|
|
}
|
|
|
|
<div class="space-y-6">
|
|
<!-- Header -->
|
|
<div class="flex items-center justify-between">
|
|
<div>
|
|
<h1 class="text-3xl font-bold text-white">Players</h1>
|
|
<p class="text-gray-400 mt-1">Manage player accounts</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Filters -->
|
|
<div class="card p-4">
|
|
<form method="get" class="flex flex-wrap items-end gap-4">
|
|
<div class="flex-1 min-w-[200px]">
|
|
<label class="label">Search</label>
|
|
<input type="text" name="search" value="@Model.Search" class="input" placeholder="Username or email..." />
|
|
</div>
|
|
<div class="w-40">
|
|
<label class="label">Role</label>
|
|
<select name="role" class="input">
|
|
<option value="">All Roles</option>
|
|
@foreach (var r in Enum.GetValues<AccountRole>())
|
|
{
|
|
<option value="@r" selected="@(Model.RoleFilter == r)">@r</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
<div class="w-40">
|
|
<label class="label">Status</label>
|
|
<select name="status" class="input">
|
|
<option value="">All</option>
|
|
<option value="active" selected="@(Model.StatusFilter == "active")">Active</option>
|
|
<option value="banned" selected="@(Model.StatusFilter == "banned")">Banned</option>
|
|
</select>
|
|
</div>
|
|
<button type="submit" class="btn btn-secondary">Filter</button>
|
|
<a href="/admin/players" class="btn btn-secondary">Clear</a>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Stats -->
|
|
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
|
|
<div class="card p-4">
|
|
<p class="text-2xl font-bold text-white">@Model.TotalCount</p>
|
|
<p class="text-sm text-gray-400">Total Accounts</p>
|
|
</div>
|
|
<div class="card p-4">
|
|
<p class="text-2xl font-bold text-green-400">@Model.ActiveCount</p>
|
|
<p class="text-sm text-gray-400">Active</p>
|
|
</div>
|
|
<div class="card p-4">
|
|
<p class="text-2xl font-bold text-red-400">@Model.BannedCount</p>
|
|
<p class="text-sm text-gray-400">Banned</p>
|
|
</div>
|
|
<div class="card p-4">
|
|
<p class="text-2xl font-bold text-indigo-400">@Model.AdminCount</p>
|
|
<p class="text-sm text-gray-400">Admins</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Players Table -->
|
|
<div class="card overflow-hidden">
|
|
<table class="w-full">
|
|
<thead class="bg-gray-800">
|
|
<tr>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase">ID</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase">Username</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase">Email</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase">Role</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase">Status</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-400 uppercase">Created</th>
|
|
<th class="px-4 py-3 text-right text-xs font-medium text-gray-400 uppercase">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-700">
|
|
@foreach (var account in Model.Accounts)
|
|
{
|
|
var isBanned = account.IsBanned || (account.BannedUntil.HasValue && account.BannedUntil > DateTime.UtcNow);
|
|
<tr class="hover:bg-gray-800/50">
|
|
<td class="px-4 py-3 text-sm text-gray-400">@account.Id</td>
|
|
<td class="px-4 py-3">
|
|
<span class="text-white font-medium">@account.Username</span>
|
|
</td>
|
|
<td class="px-4 py-3 text-sm text-gray-400">@(account.Email ?? "-")</td>
|
|
<td class="px-4 py-3">
|
|
@{
|
|
var roleColor = account.Role switch
|
|
{
|
|
AccountRole.SuperAdmin => "bg-red-600",
|
|
AccountRole.Admin => "bg-orange-600",
|
|
AccountRole.Moderator => "bg-yellow-600",
|
|
AccountRole.Vip => "bg-purple-600",
|
|
_ => "bg-gray-600"
|
|
};
|
|
}
|
|
<span class="px-2 py-1 text-xs rounded @roleColor text-white">@account.Role</span>
|
|
</td>
|
|
<td class="px-4 py-3">
|
|
@if (isBanned)
|
|
{
|
|
<span class="px-2 py-1 text-xs rounded bg-red-900 text-red-300">
|
|
@if (account.BannedUntil.HasValue && account.BannedUntil > DateTime.UtcNow)
|
|
{
|
|
<text>Until @account.BannedUntil.Value.ToString("MMM d")</text>
|
|
}
|
|
else
|
|
{
|
|
<text>Permanent</text>
|
|
}
|
|
</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="px-2 py-1 text-xs rounded bg-green-900 text-green-300">Active</span>
|
|
}
|
|
</td>
|
|
<td class="px-4 py-3 text-sm text-gray-400">@account.CreatedAt.ToString("yyyy-MM-dd")</td>
|
|
<td class="px-4 py-3 text-right">
|
|
<a href="/admin/players/edit?id=@account.Id" class="btn btn-secondary text-xs px-2 py-1">Edit</a>
|
|
</td>
|
|
</tr>
|
|
}
|
|
|
|
@if (!Model.Accounts.Any())
|
|
{
|
|
<tr>
|
|
<td colspan="7" class="px-4 py-8 text-center text-gray-400">No accounts found.</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
@if (Model.TotalPages > 1)
|
|
{
|
|
<div class="flex items-center justify-between">
|
|
<p class="text-sm text-gray-400">
|
|
Showing @((Model.CurrentPage - 1) * Model.PageSize + 1)-@Math.Min(Model.CurrentPage * Model.PageSize, Model.TotalCount) of @Model.TotalCount
|
|
</p>
|
|
<div class="flex items-center gap-2">
|
|
@if (Model.CurrentPage > 1)
|
|
{
|
|
<a href="@Model.GetPageUrl(Model.CurrentPage - 1)" class="btn btn-secondary">← Prev</a>
|
|
}
|
|
<span class="text-gray-400 px-2">@Model.CurrentPage / @Model.TotalPages</span>
|
|
@if (Model.CurrentPage < Model.TotalPages)
|
|
{
|
|
<a href="@Model.GetPageUrl(Model.CurrentPage + 1)" class="btn btn-secondary">Next →</a>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
@if (!string.IsNullOrEmpty(Model.Message))
|
|
{
|
|
<div class="fixed bottom-4 right-4 p-4 rounded-lg @(Model.IsError ? "bg-red-900 border border-red-700" : "bg-green-900 border border-green-700") text-white shadow-lg z-50">
|
|
@Model.Message
|
|
</div>
|
|
}
|