215 lines
11 KiB
Plaintext
215 lines
11 KiB
Plaintext
@page "/admin/items"
|
|
@model VoidScavengers.Admin.Pages.Items.IndexModel
|
|
@{
|
|
ViewData["Title"] = "Items";
|
|
}
|
|
|
|
<div class="space-y-6">
|
|
<!-- Header -->
|
|
<div class="flex items-center justify-between">
|
|
<div>
|
|
<h1 class="text-3xl font-bold text-white">Items</h1>
|
|
<p class="text-gray-400 mt-1">Manage item definitions</p>
|
|
</div>
|
|
<a href="/admin/items/edit" class="btn btn-primary flex items-center gap-2">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
|
|
</svg>
|
|
Create Item
|
|
</a>
|
|
</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="Search by name..." />
|
|
</div>
|
|
<div class="w-48">
|
|
<label class="label">Type</label>
|
|
<select name="type" class="input">
|
|
<option value="">All Types</option>
|
|
@foreach (var type in Enum.GetValues<Server.Data.Enums.ItemType>())
|
|
{
|
|
<option value="@type" selected="@(Model.TypeFilter == type)">@type</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
<div class="w-48">
|
|
<label class="label">Rarity</label>
|
|
<select name="rarity" class="input">
|
|
<option value="">All Rarities</option>
|
|
@foreach (var rarity in Enum.GetValues<Server.Data.Enums.ItemRarity>())
|
|
{
|
|
<option value="@rarity" selected="@(Model.RarityFilter == rarity)">@rarity</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
<button type="submit" class="btn btn-secondary">Filter</button>
|
|
<a href="/admin/items" class="btn btn-secondary">Clear</a>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Items Table -->
|
|
<div class="card overflow-hidden">
|
|
<table class="w-full">
|
|
<thead class="bg-gray-900">
|
|
<tr>
|
|
<th class="table-header">ID</th>
|
|
<th class="table-header">Icon</th>
|
|
<th class="table-header">Name</th>
|
|
<th class="table-header">Type</th>
|
|
<th class="table-header">Rarity</th>
|
|
<th class="table-header">Stackable</th>
|
|
<th class="table-header">Enabled</th>
|
|
<th class="table-header">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-700">
|
|
@foreach (var item in Model.Items)
|
|
{
|
|
<tr class="hover:bg-gray-700/50">
|
|
<td class="table-cell font-mono text-gray-400">@item.Id</td>
|
|
<td class="table-cell">
|
|
@if (!string.IsNullOrEmpty(item.SpritePath))
|
|
{
|
|
<img src="@Model.CdnBaseUrl/@item.SpritePath"
|
|
alt="@item.Name"
|
|
class="w-10 h-10 object-contain bg-gray-900 rounded"
|
|
onerror="this.style.display='none'" />
|
|
}
|
|
else
|
|
{
|
|
<div class="w-10 h-10 bg-gray-900 rounded flex items-center justify-center text-gray-600">
|
|
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/>
|
|
</svg>
|
|
</div>
|
|
}
|
|
</td>
|
|
<td class="table-cell font-medium text-white">@item.Name</td>
|
|
<td class="table-cell">@item.Type</td>
|
|
<td class="table-cell">
|
|
<span class="badge badge-@item.Rarity.ToString().ToLower()">@item.Rarity</span>
|
|
</td>
|
|
<td class="table-cell">
|
|
@if (item.Stackable)
|
|
{
|
|
<span class="text-green-400">Yes (@item.MaxStack)</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="text-gray-500">No</span>
|
|
}
|
|
</td>
|
|
<td class="table-cell">
|
|
@if (item.IsEnabled)
|
|
{
|
|
<span class="inline-flex items-center gap-1 text-green-400">
|
|
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
|
|
</svg>
|
|
Yes
|
|
</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="inline-flex items-center gap-1 text-red-400">
|
|
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
|
|
</svg>
|
|
No
|
|
</span>
|
|
}
|
|
</td>
|
|
<td class="table-cell">
|
|
<div class="flex items-center gap-2">
|
|
<a href="/admin/items/edit?id=@item.Id" class="text-indigo-400 hover:text-indigo-300" title="Edit">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
|
|
</svg>
|
|
</a>
|
|
<button type="button"
|
|
onclick="confirmDelete(@item.Id, '@item.Name.Replace("'", "\\'")}')"
|
|
class="text-red-400 hover:text-red-300"
|
|
title="Delete">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
}
|
|
|
|
@if (!Model.Items.Any())
|
|
{
|
|
<tr>
|
|
<td colspan="8" class="table-cell text-center text-gray-500 py-8">
|
|
No items found.
|
|
<a href="/admin/items/edit" class="text-indigo-400 hover:text-indigo-300">Create one?</a>
|
|
</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.Page - 1) * Model.PageSize + 1) to @Math.Min(Model.Page * Model.PageSize, Model.TotalCount) of @Model.TotalCount items
|
|
</p>
|
|
<div class="flex items-center gap-2">
|
|
@if (Model.Page > 1)
|
|
{
|
|
<a href="/admin/items?page=@(Model.Page - 1)&search=@Model.Search&type=@Model.TypeFilter&rarity=@Model.RarityFilter" class="btn btn-secondary">Previous</a>
|
|
}
|
|
<span class="text-gray-400">Page @Model.Page of @Model.TotalPages</span>
|
|
@if (Model.Page < Model.TotalPages)
|
|
{
|
|
<a href="/admin/items?page=@(Model.Page + 1)&search=@Model.Search&type=@Model.TypeFilter&rarity=@Model.RarityFilter" class="btn btn-secondary">Next</a>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
|
|
<!-- Delete confirmation modal -->
|
|
<div id="deleteModal" class="fixed inset-0 bg-black/50 hidden items-center justify-center z-50">
|
|
<div class="bg-gray-800 rounded-xl p-6 max-w-md w-full mx-4 border border-gray-700">
|
|
<h3 class="text-lg font-semibold text-white mb-2">Delete Item</h3>
|
|
<p class="text-gray-400 mb-4">Are you sure you want to delete "<span id="deleteItemName"></span>"? This action cannot be undone.</p>
|
|
<form id="deleteForm" method="post" asp-page-handler="Delete" class="flex justify-end gap-3">
|
|
@Html.AntiForgeryToken()
|
|
<input type="hidden" name="id" id="deleteItemId" />
|
|
<button type="button" onclick="closeDeleteModal()" class="btn btn-secondary">Cancel</button>
|
|
<button type="submit" class="btn btn-danger">Delete</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
@section Scripts {
|
|
<script>
|
|
function confirmDelete(id, name) {
|
|
document.getElementById('deleteItemId').value = id;
|
|
document.getElementById('deleteItemName').textContent = name;
|
|
document.getElementById('deleteModal').classList.remove('hidden');
|
|
document.getElementById('deleteModal').classList.add('flex');
|
|
}
|
|
|
|
function closeDeleteModal() {
|
|
document.getElementById('deleteModal').classList.add('hidden');
|
|
document.getElementById('deleteModal').classList.remove('flex');
|
|
}
|
|
|
|
// Close modal on escape key
|
|
document.addEventListener('keydown', (e) => {
|
|
if (e.key === 'Escape') closeDeleteModal();
|
|
});
|
|
</script>
|
|
}
|