Added multiple qol imporvements

This commit is contained in:
2026-01-23 20:32:55 +01:00
parent dd1cfc15e5
commit cf24691b5e
8 changed files with 130 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
using HopFrame.Core.Config;
using HopFrame.Web.Components.Pages;
using HopFrame.Web.Plugins.Events;
using Microsoft.AspNetCore.Components;
using Microsoft.FluentUI.AspNetCore.Components;
@@ -6,10 +7,12 @@ using SpotiParty.Web.Models;
namespace SpotiParty.Web.Services;
public class AdminDashboardPlugin(NavigationManager navigator) {
public class AdminDashboardPlugin(NavigationManager navigator, DashboardAuthHandler auth, EventsDashboardRepo repo) {
private HopFrameTablePage _page;
[HopFrame.Web.Plugins.Annotations.EventHandler]
public void OnTableInitialized(TableInitializedEvent e) {
public async Task OnTableInitialized(TableInitializedEvent e) {
if (e.Table.TableType != typeof(Event)) return;
e.AddEntityButton(new IconInfo {
@@ -17,11 +20,27 @@ public class AdminDashboardPlugin(NavigationManager navigator) {
Size = IconSize.Size16,
Name = "Open"
}, OnButtonClicked);
var user = await auth.GetCurrentUser();
if (user is not null && user.IsAdmin) {
e.AddPageButton("Show all", ToggleAllEvents);
}
_page = e.Sender;
}
private void OnButtonClicked(object o, TableConfig config) {
var entity = (Event)o;
navigator.NavigateTo(navigator.BaseUri + $"enqueue/{entity.Id}");
}
private async Task ToggleAllEvents() {
if (repo.ShowAllEvents)
return;
repo.ShowAllEvents = true;
await _page.Reload();
}
}