Refactored pages to correct locations
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
@using LucideBlazor
|
||||
@using ShadcnBlazor.Emptys
|
||||
|
||||
<div class="m-10 flex items-center justify-center">
|
||||
<Empty>
|
||||
<EmptyHeader>
|
||||
<EmptyMedia Variant="EmptyMediaVariant.Icon">
|
||||
<BanIcon/>
|
||||
</EmptyMedia>
|
||||
<EmptyTitle>
|
||||
Permission denied
|
||||
</EmptyTitle>
|
||||
<EmptyDescription>
|
||||
You are not allowed to access this resource
|
||||
</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
@using LucideBlazor
|
||||
@using ShadcnBlazor.Emptys
|
||||
|
||||
<div class="h-screen w-full flex items-center justify-center">
|
||||
<Empty>
|
||||
<EmptyHeader>
|
||||
<EmptyMedia Variant="EmptyMediaVariant.Icon">
|
||||
<ScanFaceIcon/>
|
||||
</EmptyMedia>
|
||||
<EmptyTitle>
|
||||
Authenticating
|
||||
</EmptyTitle>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
</div>
|
||||
@@ -0,0 +1,62 @@
|
||||
@using ShadcnBlazor.Cards
|
||||
@using ShadcnBlazor.Spinners
|
||||
@using ShadcnBlazor.Buttons
|
||||
@using Moonlight.Shared.Http.Responses.Auth
|
||||
|
||||
@inject HttpClient HttpClient
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<div class="h-screen w-full flex items-center justify-center">
|
||||
<Card ClassName="w-full max-w-sm">
|
||||
@if (Schemes == null || Schemes.Length == 1)
|
||||
{
|
||||
<div class="w-full flex justify-center items-center">
|
||||
<Spinner ClassName="size-10"/>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<CardHeader>
|
||||
<CardTitle>Login to WebApp</CardTitle>
|
||||
<CardDescription>Select a login provider to continue</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div class="flex flex-col gap-y-1.5">
|
||||
@foreach (var scheme in Schemes)
|
||||
{
|
||||
<Button>
|
||||
<Slot>
|
||||
<a href="/api/auth/@scheme.Name" @attributes="context">
|
||||
Continue with @scheme.DisplayName
|
||||
</a>
|
||||
</Slot>
|
||||
</Button>
|
||||
}
|
||||
</div>
|
||||
</CardContent>
|
||||
}
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
@code
|
||||
{
|
||||
private SchemeResponse[]? Schemes;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (!firstRender)
|
||||
return;
|
||||
|
||||
var schemes = await HttpClient.GetFromJsonAsync<SchemeResponse[]>(
|
||||
"api/auth", Constants.SerializerOptions
|
||||
);
|
||||
|
||||
if (schemes == null)
|
||||
return;
|
||||
|
||||
Schemes = schemes;
|
||||
|
||||
if (schemes.Length == 1)
|
||||
Navigation.NavigateTo($"/api/auth/{schemes[0].Name}", true);
|
||||
}
|
||||
}
|
||||
24
Moonlight.Frontend/UI/Shared/NotFound.razor
Normal file
24
Moonlight.Frontend/UI/Shared/NotFound.razor
Normal file
@@ -0,0 +1,24 @@
|
||||
@page "/notfound"
|
||||
|
||||
@using LucideBlazor
|
||||
@using ShadcnBlazor.Emptys
|
||||
@using ShadcnBlazor.Buttons
|
||||
|
||||
<Empty>
|
||||
<EmptyHeader>
|
||||
<EmptyMedia Variant="EmptyMediaVariant.Icon">
|
||||
<FolderOpenIcon/>
|
||||
</EmptyMedia>
|
||||
<EmptyTitle>Page not found</EmptyTitle>
|
||||
<EmptyDescription>
|
||||
The page you requested could not be found
|
||||
</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
<EmptyContent>
|
||||
<Button>
|
||||
<Slot>
|
||||
<a href="/" @attributes="context">Go to home</a>
|
||||
</Slot>
|
||||
</Button>
|
||||
</EmptyContent>
|
||||
</Empty>
|
||||
9
Moonlight.Frontend/UI/Shared/Partials/AppHeader.razor
Normal file
9
Moonlight.Frontend/UI/Shared/Partials/AppHeader.razor
Normal file
@@ -0,0 +1,9 @@
|
||||
@using ShadcnBlazor.Sidebars
|
||||
|
||||
<header
|
||||
class="flex h-(--header-height) shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-(--header-height)"
|
||||
style="--header-height: calc(var(--spacing) * 12)">
|
||||
<div class="flex w-full items-center gap-1 px-4 lg:gap-2 lg:px-6">
|
||||
<SidebarTrigger ClassName="-ml-1"/>
|
||||
</div>
|
||||
</header>
|
||||
25
Moonlight.Frontend/UI/Shared/Partials/MainLayout.razor
Normal file
25
Moonlight.Frontend/UI/Shared/Partials/MainLayout.razor
Normal file
@@ -0,0 +1,25 @@
|
||||
@using ShadcnBlazor.Extras.AlertDialogs
|
||||
@using ShadcnBlazor.Extras.Alerts
|
||||
@using ShadcnBlazor.Extras.Dialogs
|
||||
@using ShadcnBlazor.Extras.Toasts
|
||||
@using ShadcnBlazor.Sidebars
|
||||
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
<SidebarProvider DefaultOpen="true">
|
||||
<AppSidebar/>
|
||||
|
||||
<SidebarInset>
|
||||
<AppHeader/>
|
||||
|
||||
<div class="mx-8 my-8 max-w-full">
|
||||
<AlertLauncher/>
|
||||
|
||||
@Body
|
||||
</div>
|
||||
|
||||
<ToastLauncher/>
|
||||
<DialogLauncher/>
|
||||
<AlertDialogLauncher/>
|
||||
</SidebarInset>
|
||||
</SidebarProvider>
|
||||
76
Moonlight.Frontend/UI/Shared/Partials/NavUser.razor
Normal file
76
Moonlight.Frontend/UI/Shared/Partials/NavUser.razor
Normal file
@@ -0,0 +1,76 @@
|
||||
@using System.Security.Claims
|
||||
@using LucideBlazor
|
||||
@using Microsoft.AspNetCore.Components.Authorization
|
||||
@using ShadcnBlazor.Avatars
|
||||
@using ShadcnBlazor.Dropdowns
|
||||
@using ShadcnBlazor.Interop
|
||||
@using ShadcnBlazor.Sidebars
|
||||
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger>
|
||||
<Slot>
|
||||
<SidebarMenuButton
|
||||
Size="SidebarMenuButtonSize.Lg"
|
||||
ClassName="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
|
||||
@attributes="context">
|
||||
<Avatar className="h-8 w-8 rounded-lg">
|
||||
<AvatarImage src="https://github.com/ghost.png" alt="Ghost"/>
|
||||
<AvatarFallback className="rounded-lg">GH</AvatarFallback>
|
||||
</Avatar>
|
||||
<div class="grid flex-1 text-left text-sm leading-tight">
|
||||
<span class="truncate font-medium">@Username</span>
|
||||
<span class="truncate text-xs">@Email</span>
|
||||
</div>
|
||||
|
||||
<ChevronsUpDownIcon ClassName="ml-auto size-4"/>
|
||||
</SidebarMenuButton>
|
||||
</Slot>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent
|
||||
ClassName="w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg"
|
||||
Side="@(SidebarProvider.IsMobile ? PositionSide.Bottom : PositionSide.Right)"
|
||||
Align="PositionAlignment.End">
|
||||
<DropdownMenuLabel ClassName="p-0 font-normal">
|
||||
<div class="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
|
||||
<Avatar ClassName="h-8 w-8 rounded-lg">
|
||||
<AvatarImage src="https://github.com/ghost.png" alt="Ghost"/>
|
||||
<AvatarFallback className="rounded-lg">GH</AvatarFallback>
|
||||
</Avatar>
|
||||
<div class="grid flex-1 text-left text-sm leading-tight">
|
||||
<span class="truncate font-medium">@Username</span>
|
||||
<span class="truncate text-xs">@Email</span>
|
||||
</div>
|
||||
</div>
|
||||
</DropdownMenuLabel>
|
||||
<DropdownMenuSeparator/>
|
||||
<DropdownMenuItem OnClick="Logout">
|
||||
<LogOutIcon/>
|
||||
Log out
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter] public SidebarProvider SidebarProvider { get; set; }
|
||||
[CascadingParameter] public Task<AuthenticationState> AuthState { get; set; }
|
||||
|
||||
private string Username;
|
||||
private string Email;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var authState = await AuthState;
|
||||
|
||||
Username = authState.User.FindFirst(ClaimTypes.Name)?.Value ?? "N/A";
|
||||
Email = authState.User.FindFirst(ClaimTypes.Email)?.Value ?? "N/A";
|
||||
}
|
||||
|
||||
private void Logout() => Navigation.NavigateTo("/api/auth/logout", true);
|
||||
}
|
||||
Reference in New Issue
Block a user