diff --git a/radiuscontroller/Components/Pages/Admin/Dashboard.razor b/radiuscontroller/Components/Pages/Admin/Dashboard.razor index c1df37e..228754d 100644 --- a/radiuscontroller/Components/Pages/Admin/Dashboard.razor +++ b/radiuscontroller/Components/Pages/Admin/Dashboard.razor @@ -3,6 +3,7 @@ @inject IRadiusService RadiusService @inject AdminAuthService AuthService @inject NavigationManager NavManager +@implements IDisposable
@if (!AuthService.IsAuthenticated) @@ -406,6 +407,7 @@ private string activeTab = "users"; private string searchQuery = string.Empty; private string? notificationMessage; + private System.Threading.Timer? autoRefreshTimer; private SystemConfigDto? config; private List users = new(); @@ -434,9 +436,26 @@ await LoadDataAsync(); StateHasChanged(); + + autoRefreshTimer = new System.Threading.Timer(async _ => + { + await InvokeAsync(async () => + { + if (AuthService.IsAuthenticated) + { + await LoadDataAsync(); + StateHasChanged(); + } + }); + }, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10)); } } + public void Dispose() + { + autoRefreshTimer?.Dispose(); + } + private async Task LogoutAdmin() { await AuthService.LogoutAsync();