Add identity first iteration

This commit is contained in:
2025-10-06 18:45:27 +09:00
parent cb8b9bbf6b
commit c29f7ef7dd
16 changed files with 1046 additions and 10 deletions

View File

@ -1,5 +1,7 @@
@inherits LayoutComponentBase
@implements IDisposable
@inject NavigationManager NavigationManager
<RadzenComponents @rendermode="InteractiveServer" />
@ -12,12 +14,30 @@
</RadzenStack>
</RadzenHeader>
<RadzenSidebar @bind-Expanded="@sidebarExpanded">
<RadzenPanelMenu>
<RadzenPanelMenuItem Click="@(() => NavigationManager.NavigateTo("/"))" Text="Главная" Icon="home" />
<RadzenPanelMenuItem Text="Тестирование" Icon="simulation">
<RadzenPanelMenuItem Click="@(() => NavigationManager.NavigateTo("/test/export"))" Text="Экспорт" Icon="arrow_outward" />
</RadzenPanelMenuItem>
</RadzenPanelMenu>
<RadzenStack Style="height: 100%" JustifyContent="JustifyContent.SpaceBetween">
<RadzenPanelMenu>
<RadzenPanelMenuItem Click="@(() => NavigationManager.NavigateTo("/"))" Text="Главная" Icon="home" />
<RadzenPanelMenuItem Text="Тестирование" Icon="simulation">
<RadzenPanelMenuItem Click="@(() => NavigationManager.NavigateTo("/test/export"))" Text="Экспорт" Icon="arrow_outward" />
</RadzenPanelMenuItem>
</RadzenPanelMenu>
<RadzenPanelMenu>
<AuthorizeView>
<Authorized>
<RadzenPanelMenuItem Text="@context.User.Identity?.Name" />
<RadzenPanelMenuItem Path="javascript:document.forms['logout'].submit();" Text="Выйти" Icon="logout" />
<form action="account/logout" method="post" name="logout">
<AntiforgeryToken />
<input type="hidden" name="ReturnUrl" value="@currentUrl" />
</form>
</Authorized>
<NotAuthorized>
<RadzenPanelMenuItem Click="@(() => NavigationManager.NavigateTo("/account/register"))" Text="Регистрация" Icon="person_add" />
<RadzenPanelMenuItem Click="@(() => NavigationManager.NavigateTo("/account/login"))" Text="Вход" Icon="login" />
</NotAuthorized>
</AuthorizeView>
</RadzenPanelMenu>
</RadzenStack>
</RadzenSidebar>
<RadzenBody>
@Body
@ -32,4 +52,24 @@
@code {
bool sidebarExpanded = true;
string? currentUrl;
protected override void OnInitialized()
{
currentUrl = NavigationManager.ToBaseRelativePath(NavigationManager.Uri);
NavigationManager.LocationChanged += OnLocationChanged;
}
public void Dispose()
{
NavigationManager.LocationChanged -= OnLocationChanged;
}
private void OnLocationChanged(object? sender, LocationChangedEventArgs e)
{
currentUrl = NavigationManager.ToBaseRelativePath(e.Location);
StateHasChanged();
}
}

View File

@ -1,5 +1,6 @@
@page "/test/export"
@using Microsoft.AspNetCore.Authorization
@using Hcs.Broker
@using Hcs.Broker.Logger
@using Hcs.Broker.MessageCapturer
@ -8,6 +9,10 @@
@using Hcs.WebApp.Config
@using Hcs.WebApp.Utils
@implements IDisposable
@attribute [Authorize]
@inject NavigationManager NavigationManager
@inject IConfiguration Configuration
@ -82,6 +87,14 @@
client.SetSigningCertificate(brokerConfig.CertificateSerialNumber);
}
public void Dispose()
{
if (messageCapturer != null)
{
messageCapturer.OnFileWritten -= OnFileWritten;
}
}
void OnLog(string log)
{
console.Log(log);

View File

@ -1,12 +1,14 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using Hcs.WebApp
@using Hcs.WebApp.Components
@using Radzen
@using Radzen.Blazor
@using Hcs.WebApp
@using Hcs.WebApp.Components
@using static Microsoft.AspNetCore.Components.Web.RenderMode