@page "/serilogs" @using Microsoft.AspNetCore.Authorization @using Indotalent.Infrastructure.Authorization.Identity @attribute [Authorize(Roles = ApplicationRoles.Admin)] @using Indotalent.Features.Serilogs.Database @using Indotalent.Features.Serilogs.Database.Components @using Indotalent.Features.Serilogs.File @using Indotalent.Features.Serilogs.File.Components @using MudBlazor @inject NavigationManager NavigationManager
@code { private int _activeTabIndex = 0; protected override void OnInitialized() { var uri = NavigationManager.ToAbsoluteUri(NavigationManager.Uri); if (Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(uri.Query).TryGetValue("tab", out var tabValue)) { _activeTabIndex = tabValue.ToString().ToLower() switch { "database" => 0, "file" => 1, _ => 0 }; } } private void OnTabChanged(int index) { _activeTabIndex = index; string tabName = index switch { 0 => "database", 1 => "file", _ => "database" }; NavigationManager.NavigateTo($"/serilogs?tab={tabName}", replace: false); } }