Refactored project to module structure
This commit is contained in:
97
Moonlight.Frontend/Infrastructure/Partials/App.razor
Normal file
97
Moonlight.Frontend/Infrastructure/Partials/App.razor
Normal file
@@ -0,0 +1,97 @@
|
||||
@using System.Net
|
||||
@using System.Reflection
|
||||
@using LucideBlazor
|
||||
@using Microsoft.AspNetCore.Components.Authorization
|
||||
@using Microsoft.Extensions.Options
|
||||
@using Moonlight.Frontend.Infrastructure.Configuration
|
||||
@using Moonlight.Frontend.Shared.Auth
|
||||
@using ShadcnBlazor.Emptys
|
||||
@using ShadcnBlazor.Extras.AlertDialogs
|
||||
@using ShadcnBlazor.Extras.Dialogs
|
||||
@using ShadcnBlazor.Extras.Toasts
|
||||
@using ShadcnBlazor.Portals
|
||||
@inject NavigationManager Navigation
|
||||
@inject IOptions<NavigationAssemblyOptions> NavigationOptions
|
||||
|
||||
<ErrorBoundary>
|
||||
<ChildContent>
|
||||
<AuthorizeView>
|
||||
<ChildContent>
|
||||
<LayoutMiddleware>
|
||||
<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="Assemblies"
|
||||
NotFoundPage="typeof(NotFound)">
|
||||
<Found Context="routeData">
|
||||
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(MainLayout)">
|
||||
<NotAuthorized Context="authRouteViewContext">
|
||||
<AccessDenied/>
|
||||
</NotAuthorized>
|
||||
</AuthorizeRouteView>
|
||||
</Found>
|
||||
</Router>
|
||||
</LayoutMiddleware>
|
||||
|
||||
<ToastLauncher/>
|
||||
<DialogLauncher/>
|
||||
<AlertDialogLauncher/>
|
||||
|
||||
<PortalOutlet/>
|
||||
</ChildContent>
|
||||
<Authorizing>
|
||||
<Authenticating/>
|
||||
</Authorizing>
|
||||
<NotAuthorized>
|
||||
@if (context.User.Identity?.IsAuthenticated ?? false)
|
||||
{
|
||||
<AccessDenied/>
|
||||
}
|
||||
else
|
||||
{
|
||||
var uri = new Uri(Navigation.Uri);
|
||||
|
||||
if (uri.LocalPath.StartsWith("/setup"))
|
||||
{
|
||||
<Setup/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Authentication/>
|
||||
}
|
||||
}
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
</ChildContent>
|
||||
<ErrorContent>
|
||||
@if (context is HttpRequestException { StatusCode: HttpStatusCode.Unauthorized })
|
||||
{
|
||||
<Authentication/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="m-10">
|
||||
<Empty>
|
||||
<EmptyHeader>
|
||||
<EmptyMedia Variant="EmptyMediaVariant.Icon">
|
||||
<OctagonAlertIcon ClassName="text-red-500/80"/>
|
||||
</EmptyMedia>
|
||||
<EmptyTitle>
|
||||
Critical Application Error
|
||||
</EmptyTitle>
|
||||
<EmptyDescription>
|
||||
@context.ToString()
|
||||
</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
</div>
|
||||
}
|
||||
</ErrorContent>
|
||||
</ErrorBoundary>
|
||||
|
||||
@code
|
||||
{
|
||||
private Assembly[] Assemblies;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Assemblies = NavigationOptions.Value.Assemblies.ToArray();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user