Pageing on CDN Assets Page, and Player management
This commit is contained in:
@@ -0,0 +1,222 @@
|
||||
@page "/admin/players/edit"
|
||||
@model Players.EditModel
|
||||
@using Server.Data
|
||||
@{
|
||||
ViewData["Title"] = Model.IsNew ? "New Account" : $"Edit: {Model.Account.Username}";
|
||||
}
|
||||
|
||||
<div class="space-y-6">
|
||||
<!-- Header -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<a href="/admin/players" class="text-gray-400 hover:text-white text-sm">← Back to Players</a>
|
||||
<h1 class="text-3xl font-bold text-white mt-2">@(Model.IsNew ? "New Account" : Model.Account.Username)</h1>
|
||||
@if (!Model.IsNew)
|
||||
{
|
||||
<p class="text-gray-400 mt-1">Account ID: @Model.Account.Id • Created: @Model.Account.CreatedAt.ToString("yyyy-MM-dd HH:mm")</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.Message))
|
||||
{
|
||||
<div class="p-4 rounded-lg @(Model.IsError ? "bg-red-900/50 border border-red-700 text-red-300" : "bg-green-900/50 border border-green-700 text-green-300")">
|
||||
@Model.Message
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<!-- Account Info -->
|
||||
<div class="card p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Account Information</h2>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="label">Username</label>
|
||||
<input type="text" value="@Model.Account.Username" class="input bg-gray-800" readonly />
|
||||
<p class="text-xs text-gray-500 mt-1">Username cannot be changed</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="label">Email</label>
|
||||
<input type="text" value="@(Model.Account.Email ?? "Not set")" class="input bg-gray-800" readonly />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="label">Account Created</label>
|
||||
<input type="text" value="@Model.Account.CreatedAt.ToString("yyyy-MM-dd HH:mm:ss UTC")" class="input bg-gray-800" readonly />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="label">Last Updated</label>
|
||||
<input type="text" value="@Model.Account.UpdatedAt.ToString("yyyy-MM-dd HH:mm:ss UTC")" class="input bg-gray-800" readonly />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Role Management -->
|
||||
<div class="card p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Role Management</h2>
|
||||
|
||||
<form method="post" asp-page-handler="SetRole" class="space-y-4">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="hidden" name="accountId" value="@Model.Account.Id" />
|
||||
|
||||
<div>
|
||||
<label class="label">Current Role</label>
|
||||
@{
|
||||
var roleColor = Model.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="inline-block px-3 py-1 text-sm rounded @roleColor text-white">@Model.Account.Role</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="label">Change Role To</label>
|
||||
<select name="newRole" class="input">
|
||||
@foreach (var r in Enum.GetValues<AccountRole>())
|
||||
{
|
||||
<option value="@r" selected="@(Model.Account.Role == r)">@r</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary w-full">Update Role</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Ban Management -->
|
||||
<div class="card p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Ban Management</h2>
|
||||
|
||||
@{
|
||||
var isBanned = Model.Account.IsBanned || (Model.Account.BannedUntil.HasValue && Model.Account.BannedUntil > DateTime.UtcNow);
|
||||
}
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="label">Current Status</label>
|
||||
@if (isBanned)
|
||||
{
|
||||
<div class="p-3 bg-red-900/30 border border-red-700 rounded">
|
||||
<span class="text-red-400 font-medium">BANNED</span>
|
||||
@if (Model.Account.IsBanned)
|
||||
{
|
||||
<span class="text-red-300 text-sm ml-2">(Permanent)</span>
|
||||
}
|
||||
else if (Model.Account.BannedUntil.HasValue)
|
||||
{
|
||||
<span class="text-red-300 text-sm ml-2">(Until @Model.Account.BannedUntil.Value.ToString("yyyy-MM-dd HH:mm UTC"))</span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="p-3 bg-green-900/30 border border-green-700 rounded">
|
||||
<span class="text-green-400 font-medium">ACTIVE</span>
|
||||
<span class="text-green-300 text-sm ml-2">Account in good standing</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (isBanned)
|
||||
{
|
||||
<form method="post" asp-page-handler="Unban">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="hidden" name="accountId" value="@Model.Account.Id" />
|
||||
<button type="submit" class="btn bg-green-700 hover:bg-green-600 text-white w-full">
|
||||
Remove Ban
|
||||
</button>
|
||||
</form>
|
||||
}
|
||||
else
|
||||
{
|
||||
<form method="post" asp-page-handler="Ban" class="space-y-4">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="hidden" name="accountId" value="@Model.Account.Id" />
|
||||
|
||||
<div>
|
||||
<label class="label">Ban Type</label>
|
||||
<select name="banType" class="input" id="banType" onchange="toggleBanDate()">
|
||||
<option value="permanent">Permanent Ban</option>
|
||||
<option value="temporary">Temporary Ban</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div id="banDateContainer" style="display: none;">
|
||||
<label class="label">Ban Until</label>
|
||||
<input type="datetime-local" name="bannedUntil" class="input" />
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn bg-red-700 hover:bg-red-600 text-white w-full">
|
||||
Ban Account
|
||||
</button>
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Password Reset -->
|
||||
<div class="card p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Password Reset</h2>
|
||||
|
||||
<form method="post" asp-page-handler="ResetPassword" class="space-y-4">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="hidden" name="accountId" value="@Model.Account.Id" />
|
||||
|
||||
<div>
|
||||
<label class="label">New Password</label>
|
||||
<input type="password" name="newPassword" class="input" required minlength="6" placeholder="Enter new password..." />
|
||||
<p class="text-xs text-gray-500 mt-1">Minimum 6 characters</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="label">Confirm Password</label>
|
||||
<input type="password" name="confirmPassword" class="input" required minlength="6" placeholder="Confirm new password..." />
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary w-full" onclick="return confirm('Reset password for this account?')">
|
||||
Reset Password
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Characters Section -->
|
||||
@if (Model.Characters.Any())
|
||||
{
|
||||
<div class="card p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Characters (@Model.Characters.Count)</h2>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
@foreach (var character in Model.Characters)
|
||||
{
|
||||
<div class="bg-gray-800 rounded-lg p-4">
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<span class="text-white font-medium">@character.Name</span>
|
||||
<span class="text-xs text-gray-400">Lv @character.Level</span>
|
||||
</div>
|
||||
<div class="text-sm text-gray-400">
|
||||
<p>Gold: @character.Gold.ToString("N0")</p>
|
||||
<p>Created: @character.CreatedAt.ToString("yyyy-MM-dd")</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
function toggleBanDate() {
|
||||
const banType = document.getElementById('banType').value;
|
||||
const dateContainer = document.getElementById('banDateContainer');
|
||||
dateContainer.style.display = banType === 'temporary' ? 'block' : 'none';
|
||||
}
|
||||
</script>
|
||||
}
|
||||
Reference in New Issue
Block a user