93 lines
3.4 KiB
Plaintext
93 lines
3.4 KiB
Plaintext
@inherits LayoutComponentBase
|
|
|
|
@using System.Security.Claims
|
|
@using Microsoft.AspNetCore.Components.Authorization
|
|
@using Syncfusion.Blazor.Navigations
|
|
@using static Syncfusion.Blazor.Navigations.Orientation
|
|
@using Syncfusion.Blazor.Buttons
|
|
@inject NavigationManager NavigationManager
|
|
@inject CustomAuthenticationStateProvider AuthenticationStateProvider
|
|
|
|
<div class="page h-100 d-flex flex-column">
|
|
<main class="container-fluid d-flex flex-column h-100">
|
|
<div class="bb-top-row px-4 d-flex justify-content-between align-items-center mb-3 shadow-sm"
|
|
style="background-color: #f8f9fa;">
|
|
<div class="d-flex align-items-center">
|
|
<img src="logo.svg" class="me-2" width="35" height="35" alt="Icon">
|
|
<h3 class="text-primary m-0">FA Krosno Manager</h3>
|
|
</div>
|
|
@* <div class="d-flex align-items-center"> *@
|
|
@* @if (IsAuthenticated) *@
|
|
@* { *@
|
|
@* <span class="me-2">Jesteś zalogowany jako <strong>@UserName</strong></span> *@
|
|
@* <SfButton CssClass="e-primary" IsPrimary="true" @onclick="Logout">Wyloguj</SfButton> *@
|
|
@* } *@
|
|
@* else *@
|
|
@* { *@
|
|
@* <a href="/login" class="text-muted">Zaloguj</a> *@
|
|
@* } *@
|
|
@* </div> *@
|
|
</div>
|
|
<div class="row gx-1 flex-grow-1">
|
|
<div class="col-auto custom-menu-width">
|
|
<SfMenu TValue="MenuItem" HamburgerMode="true" Orientation="Vertical" Title="Menu">
|
|
<MenuItems>
|
|
<MenuItem Text="Zamówienia DELFOR" Url="/" IconCss="fa-solid fa-landmark"></MenuItem>
|
|
<MenuItem Text="Zamówienia klienta EDI" Url="/EdiCustomerOrders" IconCss="fa-solid fa-list-check"></MenuItem>
|
|
<MenuItem Text="Zamówienia klienta" Url="/CustomerOrders" IconCss="fa-solid fa-database"></MenuItem>
|
|
@if (UserName == "pkus")
|
|
{
|
|
<MenuItem Text="Admin" IconCss="fa-solid fa-screwdriver-wrench">
|
|
<MenuItems>
|
|
<MenuItem Text = "Użytkownicy" Url = "/Admin/UsersManager" IconCss="fa-solid fa-user-tie"></MenuItem>
|
|
<MenuItem Text= "Scheduler" Url = "/Admin/Scheduler" IconCss="fa-solid fa-calendar-week"></MenuItem>
|
|
</MenuItems>
|
|
</MenuItem>
|
|
}
|
|
</MenuItems>
|
|
<MenuAnimationSettings Effect="MenuEffect.SlideDown" Duration="800"></MenuAnimationSettings>
|
|
</SfMenu>
|
|
</div>
|
|
<article class="content col d-flex flex-column">
|
|
<div class="py-2 flex-grow-1">@Body</div>
|
|
<footer class="text-center text-muted py-2">
|
|
<small>FA Krosno Manager © @(DateTime.Now.Year)</small>
|
|
</footer>
|
|
</article>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
@code {
|
|
private bool IsAuthenticated { get; set; }
|
|
private string UserName { get; set; } = string.Empty;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
// ClaimsPrincipal currentUser = AuthenticationStateProvider.GetCurrentUser();
|
|
// IsAuthenticated = currentUser.Identity?.IsAuthenticated == true;
|
|
// UserName = currentUser.Identity?.Name ?? "Nieznany użytkownik";
|
|
//
|
|
// AuthenticationStateProvider.AuthenticationStateChanged += OnAuthenticationStateChanged;
|
|
}
|
|
|
|
private async void OnAuthenticationStateChanged(Task<AuthenticationState> task)
|
|
{
|
|
var authState = await task;
|
|
IsAuthenticated = authState.User.Identity?.IsAuthenticated ?? false;
|
|
UserName = IsAuthenticated ? authState.User.Identity?.Name ?? "Nieznany użytkownik" : string.Empty;
|
|
StateHasChanged();
|
|
}
|
|
|
|
private void Logout()
|
|
{
|
|
NavigationManager.NavigateTo("/");
|
|
}
|
|
|
|
}
|
|
|
|
<div id="blazor-error-ui">
|
|
An unhandled error has occurred.
|
|
<a href="" class="reload">Reload</a>
|
|
<a class="dismiss">🗙</a>
|
|
</div> |