TLC Admin Portal

This commit is contained in:
dingo
2026-01-10 11:20:06 -05:00
parent ecac99ee89
commit c43a334d8b
5 changed files with 284 additions and 45 deletions
@@ -8,18 +8,43 @@ namespace Server.Services.Admin.Pages.SpriteSheets;
public class IndexModel : AdminPageModel
{
private readonly GameDbContext _db;
private readonly IConfiguration _config;
public IndexModel(GameDbContext db)
public IndexModel(GameDbContext db, IConfiguration config)
{
_db = db;
_config = config;
}
public List<MobSpriteSheet> SpriteSheets { get; set; } = new();
public string? Search { get; set; }
public bool? EnabledFilter { get; set; }
public int TotalCount { get; set; }
public async Task OnGetAsync()
public async Task OnGetAsync(string? search, bool? enabled)
{
SpriteSheets = await _db.MobSpriteSheets
Search = search;
EnabledFilter = enabled;
var query = _db.MobSpriteSheets
.Include(s => s.Animations)
.AsQueryable();
if (!string.IsNullOrEmpty(search))
{
query = query.Where(s =>
s.Name.Contains(search) ||
(s.CdnPath != null && s.CdnPath.Contains(search)));
}
if (enabled.HasValue)
{
query = query.Where(s => s.IsEnabled == enabled.Value);
}
TotalCount = await query.CountAsync();
SpriteSheets = await query
.OrderBy(s => s.Name)
.ToListAsync();
}
@@ -51,4 +76,17 @@ public class IndexModel : AdminPageModel
}
return RedirectToPage();
}
public string GetCdnUrl(string? path)
{
if (string.IsNullOrEmpty(path)) return "";
var baseUrl = _config["Cdn:BaseUrl"]?.TrimEnd('/') ?? "https://assets.aeternalisgames.com";
if (!baseUrl.EndsWith("/downloads", StringComparison.OrdinalIgnoreCase))
{
baseUrl += "/downloads";
}
return $"{baseUrl}/{path.TrimStart('/')}";
}
}