From 46adfd5e81e0e2596a5b4ac49a32c973f09784ed Mon Sep 17 00:00:00 2001 From: dingo Date: Thu, 25 Dec 2025 15:06:25 -0500 Subject: [PATCH] Admin v8 --- Services/Admin/Pages/Items/Index.cshtml | 6 +++--- Services/Admin/Pages/Items/Index.cshtml.cs | 9 +++++++++ Services/Admin/Pages/LootTables/Edit.cshtml | 2 +- Services/Admin/Pages/Mobs/Index.cshtml | 21 +++++++++++++++++++++ Services/Admin/Pages/Mobs/Index.cshtml.cs | 20 +++++++++++++++++++- 5 files changed, 53 insertions(+), 5 deletions(-) diff --git a/Services/Admin/Pages/Items/Index.cshtml b/Services/Admin/Pages/Items/Index.cshtml index d7aa70c..6e29003 100644 --- a/Services/Admin/Pages/Items/Index.cshtml +++ b/Services/Admin/Pages/Items/Index.cshtml @@ -75,7 +75,7 @@ @if (!string.IsNullOrEmpty(item.SpritePath)) { - @item.Name @@ -158,12 +158,12 @@
@if (Model.CurrentPage > 1) { - ← Prev + ← Prev } @Model.CurrentPage / @Model.TotalPages @if (Model.CurrentPage < Model.TotalPages) { - Next → + Next → }
diff --git a/Services/Admin/Pages/Items/Index.cshtml.cs b/Services/Admin/Pages/Items/Index.cshtml.cs index 70d0b6d..96af107 100644 --- a/Services/Admin/Pages/Items/Index.cshtml.cs +++ b/Services/Admin/Pages/Items/Index.cshtml.cs @@ -25,6 +25,15 @@ public class IndexModel : AdminPageModel public int TotalPages => (int)Math.Ceiling(TotalCount / (double)PageSize); public string CdnBaseUrl { get; set; } = "https://assets.aeternalisgames.com"; + public string GetPageUrl(int page) + { + var parts = new List { $"page={page}" }; + if (!string.IsNullOrEmpty(Search)) parts.Add($"search={Uri.EscapeDataString(Search)}"); + if (TypeFilter.HasValue) parts.Add($"type={TypeFilter}"); + if (RarityFilter.HasValue) parts.Add($"rarity={RarityFilter}"); + return "/admin/items?" + string.Join("&", parts); + } + public async Task OnGetAsync(string? search, ItemType? type, ItemRarity? rarity, int page = 1) { Search = search; diff --git a/Services/Admin/Pages/LootTables/Edit.cshtml b/Services/Admin/Pages/LootTables/Edit.cshtml index 062db5f..d4337b7 100644 --- a/Services/Admin/Pages/LootTables/Edit.cshtml +++ b/Services/Admin/Pages/LootTables/Edit.cshtml @@ -122,7 +122,7 @@ @if (entry.ItemDefinition != null && !string.IsNullOrEmpty(entry.ItemDefinition.SpritePath)) { - @entry.ItemDefinition.Name diff --git a/Services/Admin/Pages/Mobs/Index.cshtml b/Services/Admin/Pages/Mobs/Index.cshtml index 03d0199..63ca7ff 100644 --- a/Services/Admin/Pages/Mobs/Index.cshtml +++ b/Services/Admin/Pages/Mobs/Index.cshtml @@ -126,6 +126,27 @@ + + + @if (Model.TotalPages > 1) + { +
+

+ Showing @((Model.CurrentPage - 1) * Model.PageSize + 1)-@Math.Min(Model.CurrentPage * Model.PageSize, Model.TotalCount) of @Model.TotalCount +

+
+ @if (Model.CurrentPage > 1) + { + ← Prev + } + @Model.CurrentPage / @Model.TotalPages + @if (Model.CurrentPage < Model.TotalPages) + { + Next → + } +
+
+ } diff --git a/Services/Admin/Pages/Mobs/Index.cshtml.cs b/Services/Admin/Pages/Mobs/Index.cshtml.cs index 2b2010e..86815c3 100644 --- a/Services/Admin/Pages/Mobs/Index.cshtml.cs +++ b/Services/Admin/Pages/Mobs/Index.cshtml.cs @@ -19,12 +19,26 @@ public class IndexModel : AdminPageModel public string? Search { get; set; } public MobType? TypeFilter { get; set; } public MobCategory? CategoryFilter { get; set; } + public int CurrentPage { get; set; } = 1; + public int PageSize { get; set; } = 20; + public int TotalCount { get; set; } + public int TotalPages => (int)Math.Ceiling(TotalCount / (double)PageSize); - public async Task OnGetAsync(string? search, MobType? type, MobCategory? category) + public string GetPageUrl(int page) + { + var parts = new List { $"page={page}" }; + if (!string.IsNullOrEmpty(Search)) parts.Add($"search={Uri.EscapeDataString(Search)}"); + if (TypeFilter.HasValue) parts.Add($"type={TypeFilter}"); + if (CategoryFilter.HasValue) parts.Add($"category={CategoryFilter}"); + return "/admin/mobs?" + string.Join("&", parts); + } + + public async Task OnGetAsync(string? search, MobType? type, MobCategory? category, int page = 1) { Search = search; TypeFilter = type; CategoryFilter = category; + CurrentPage = Math.Max(1, page); var query = _db.DungeonMobDefinitions.AsQueryable(); @@ -37,8 +51,12 @@ public class IndexModel : AdminPageModel if (category.HasValue) query = query.Where(m => m.Category == category.Value); + TotalCount = await query.CountAsync(); + Mobs = await query .OrderBy(m => m.Id) + .Skip((CurrentPage - 1) * PageSize) + .Take(PageSize) .ToListAsync(); }