Recipe fix

This commit is contained in:
dingo
2025-12-28 09:01:40 -05:00
parent 0589ecb783
commit f1b2749526
3 changed files with 85 additions and 7 deletions
+40 -6
View File
@@ -12,12 +12,20 @@
<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 class="flex items-center gap-2">
<button type="button" onclick="refreshCache()" class="btn btn-secondary flex items-center gap-2" title="Refresh server recipe cache">
<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="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
Refresh Cache
</button>
<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>
</div>
<!-- Filters -->
@@ -199,6 +207,32 @@
@section Scripts {
<script>
async function refreshCache() {
const btn = event.target.closest('button');
const originalText = btn.innerHTML;
btn.disabled = true;
btn.innerHTML = '<svg class="w-5 h-5 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> Refreshing...';
try {
const response = await fetch('/api/admin/cache/refresh?type=recipes', {
method: 'POST',
headers: { 'Authorization': 'Bearer ' + (localStorage.getItem('adminToken') || '') }
});
const data = await response.json();
if (response.ok) {
alert('Recipe cache refreshed! ' + (data.refreshed?.join(', ') || ''));
} else {
alert('Error: ' + (data.error || 'Failed to refresh cache'));
}
} catch (err) {
alert('Error: ' + err.message);
} finally {
btn.disabled = false;
btn.innerHTML = originalText;
}
}
function confirmDelete(id, name) {
document.getElementById('deleteItemId').value = id;
document.getElementById('deleteItemName').textContent = name;