215 lines
10 KiB
Plaintext
215 lines
10 KiB
Plaintext
@page "/admin/recipes"
|
|
@model Recipes.IndexModel
|
|
@using Server.Data.Entities
|
|
@{
|
|
ViewData["Title"] = "Recipes";
|
|
}
|
|
|
|
<div class="space-y-6">
|
|
<!-- Header -->
|
|
<div class="flex items-center justify-between">
|
|
<div>
|
|
<h1 class="text-3xl font-bold text-white">Crafting Recipes</h1>
|
|
<p class="text-gray-400 mt-1">Manage crafting recipes</p>
|
|
</div>
|
|
<a href="/admin/recipes/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 Recipe
|
|
</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-40">
|
|
<label class="label">Skill</label>
|
|
<select name="skill" class="input">
|
|
<option value="">All Skills</option>
|
|
@foreach (var s in Enum.GetValues<CraftingSkillType>())
|
|
{
|
|
<option value="@s" selected="@(Model.SkillFilter == s)">@s</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
<button type="submit" class="btn btn-secondary">Filter</button>
|
|
<a href="/admin/recipes" class="btn btn-secondary">Clear</a>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Recipes Table -->
|
|
<div class="card overflow-hidden">
|
|
<table class="w-full">
|
|
<thead class="bg-gray-900/50">
|
|
<tr>
|
|
<th class="table-header w-16">ID</th>
|
|
<th class="table-header">Recipe</th>
|
|
<th class="table-header">Output</th>
|
|
<th class="table-header w-28">Skill</th>
|
|
<th class="table-header w-20">Lvl</th>
|
|
<th class="table-header w-24">Ingredients</th>
|
|
<th class="table-header w-20">Base</th>
|
|
<th class="table-header w-20">Enabled</th>
|
|
<th class="table-header w-24">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-700">
|
|
@foreach (var recipe in Model.Recipes)
|
|
{
|
|
<tr class="hover:bg-gray-700/30">
|
|
<td class="table-cell font-mono text-gray-500">@recipe.Id</td>
|
|
<td class="table-cell">
|
|
<span class="font-medium text-white">@recipe.Name</span>
|
|
@if (!string.IsNullOrEmpty(recipe.Description))
|
|
{
|
|
<p class="text-xs text-gray-500 truncate max-w-xs">@recipe.Description</p>
|
|
}
|
|
</td>
|
|
<td class="table-cell">
|
|
@if (recipe.OutputItem != null)
|
|
{
|
|
<div class="flex items-center gap-2">
|
|
@if (!string.IsNullOrEmpty(recipe.OutputItem.SpritePath))
|
|
{
|
|
<img src="@Html.Raw(Model.CdnBaseUrl)/downloads/@recipe.OutputItem.SpritePath"
|
|
class="w-8 h-8 object-contain bg-gray-900 rounded"
|
|
onerror="this.style.display='none'" />
|
|
}
|
|
<div>
|
|
<span class="text-gray-300">@recipe.OutputItem.Name</span>
|
|
@if (recipe.OutputQuantity > 1)
|
|
{
|
|
<span class="text-gray-500">x@recipe.OutputQuantity</span>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<span class="text-red-400">Missing Item #@recipe.OutputItemDefinitionId</span>
|
|
}
|
|
</td>
|
|
<td class="table-cell">
|
|
<span class="badge @GetSkillBadgeClass(recipe.SkillType)">@recipe.SkillType</span>
|
|
</td>
|
|
<td class="table-cell text-gray-400">@recipe.RequiredLevel</td>
|
|
<td class="table-cell">
|
|
<span class="badge badge-common">@recipe.Ingredients.Count</span>
|
|
</td>
|
|
<td class="table-cell">
|
|
@if (recipe.IsBaseRecipe)
|
|
{
|
|
<span class="text-green-400">✓</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="text-gray-600">-</span>
|
|
}
|
|
</td>
|
|
<td class="table-cell">
|
|
@if (recipe.IsEnabled)
|
|
{
|
|
<span class="w-3 h-3 bg-green-500 rounded-full inline-block"></span>
|
|
}
|
|
else
|
|
{
|
|
<span class="w-3 h-3 bg-red-500 rounded-full inline-block"></span>
|
|
}
|
|
</td>
|
|
<td class="table-cell">
|
|
<div class="flex items-center gap-1">
|
|
<a href="/admin/recipes/edit?id=@recipe.Id" class="p-1.5 hover:bg-gray-700 rounded" title="Edit">
|
|
<svg class="w-4 h-4 text-indigo-400" 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(@recipe.Id, '@recipe.Name.Replace("'", "\\'"))" class="p-1.5 hover:bg-gray-700 rounded" title="Delete">
|
|
<svg class="w-4 h-4 text-red-400" 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.Recipes.Any())
|
|
{
|
|
<tr>
|
|
<td colspan="9" class="table-cell text-center text-gray-500 py-12">
|
|
No recipes found. <a href="/admin/recipes/edit" class="text-indigo-400 hover:underline">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.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>
|
|
|
|
<!-- Delete 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 Recipe</h3>
|
|
<p class="text-gray-400 mb-4">Are you sure you want to delete "<span id="deleteItemName" class="text-white"></span>"?</p>
|
|
<form 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>
|
|
|
|
@functions {
|
|
string GetSkillBadgeClass(CraftingSkillType skill) => skill switch
|
|
{
|
|
CraftingSkillType.Smithing => "badge-common",
|
|
CraftingSkillType.Fletching => "badge-uncommon",
|
|
CraftingSkillType.Jewelry => "badge-rare",
|
|
CraftingSkillType.Alchemy => "badge-epic",
|
|
CraftingSkillType.Academic => "badge-legendary",
|
|
_ => "badge-common"
|
|
};
|
|
}
|
|
|
|
@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');
|
|
}
|
|
document.addEventListener('keydown', e => { if (e.key === 'Escape') closeDeleteModal(); });
|
|
</script>
|
|
}
|