update nach Schuelererfassung
This commit is contained in:
158
BlazorApp - Kopie (4)/Shared/NavMenu.razor
Normal file
158
BlazorApp - Kopie (4)/Shared/NavMenu.razor
Normal file
@@ -0,0 +1,158 @@
|
||||
@using Microsoft.AspNetCore.Components
|
||||
@using Microsoft.AspNetCore.Http
|
||||
@using Radzen.Blazor
|
||||
@using Microsoft.AspNetCore.Authorization;
|
||||
@using Microsoft.AspNetCore.Identity;
|
||||
|
||||
@using Syncfusion.Blazor.Navigations
|
||||
@using BWPMModels
|
||||
@using Newtonsoft.Json
|
||||
@inject UserManager<IdentityUser> _UserManager
|
||||
@inherits LayoutComponentBase
|
||||
@inject ExampleService ExampleService
|
||||
@inject ThemeState ThemeState
|
||||
@inject NavigationManager UriHelper
|
||||
@inject IJSRuntime JSRuntime
|
||||
@inject IHttpContextAccessor httpContextAccessor
|
||||
|
||||
@if (Theme != "default.css")
|
||||
{
|
||||
<link href="_content/Radzen.Blazor/css/@(Theme)" rel="stylesheet" />
|
||||
}
|
||||
<RadzenDialog />
|
||||
<RadzenNotification />
|
||||
<RadzenTooltip />
|
||||
<RadzenContextMenu />
|
||||
|
||||
<RadzenHeader>
|
||||
<ChildContent>
|
||||
<div class="row justify-content-start align-items-center">
|
||||
<div class="col-6 d-flex align-items-center">
|
||||
<RadzenSidebarToggle Click="@(args => { sidebarExpanded = !sidebarExpanded; bodyExpanded = !bodyExpanded; })">
|
||||
</RadzenSidebarToggle>
|
||||
<RadzenLabel Text="Radzen Blazor Components">
|
||||
</RadzenLabel>
|
||||
</div>
|
||||
<div class="col-6 d-flex align-items-center justify-content-end">
|
||||
<label class="d-none d-sm-inline-block" style="margin-left: 1rem">Theme:</label>
|
||||
<RadzenDropDown style="margin:0 .5rem" TValue="string" TextProperty="Text" ValueProperty="Value" Data="@themes" Value="@ThemeState.CurrentTheme" Change="@ChangeTheme" />
|
||||
</div>
|
||||
</div>
|
||||
</ChildContent>
|
||||
</RadzenHeader>
|
||||
<div style="width:100%">
|
||||
<RadzenBody @ref="@body0" @bind-Expanded="@bodyExpanded">
|
||||
<ChildContent>
|
||||
<RadzenContentContainer Name="main">
|
||||
@Body
|
||||
</RadzenContentContainer>
|
||||
</ChildContent>
|
||||
</RadzenBody>
|
||||
</div>
|
||||
|
||||
<RadzenSidebar @ref="@sidebar0" @bind-Expanded="@sidebarExpanded">
|
||||
<ChildContent>
|
||||
<RadzenPanelMenu>
|
||||
<AuthorizeView Roles="Administrators">
|
||||
<Authorized>
|
||||
@foreach (var Menuentry in AdminMenu)
|
||||
{
|
||||
<RadzenPanelMenuItem @bind-Expanded="Menuentry.Expanded" Text="Menuentry.Name" Path="MenuEntry.Path" Icon="MenuEntry.Icon">
|
||||
</RadzenPanelMenuItem>
|
||||
}
|
||||
<RadzenPanelMenuItem Text="Abmelden" Path="/identity/account/logout" Icon=""></RadzenPanelMenuItem>
|
||||
</Authorized>
|
||||
<NotAuthorized>
|
||||
<RadzenPanelMenuItem Text="Anmelden" Path="/identity/account/login" Icon=""></RadzenPanelMenuItem>
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
</RadzenPanelMenu>
|
||||
|
||||
</ChildContent>
|
||||
</RadzenSidebar>
|
||||
<RadzenFooter>
|
||||
<ChildContent>
|
||||
<RadzenLabel Text="Radzen Blazor Components, Copyright © 2020">
|
||||
</RadzenLabel>
|
||||
<RadzenLink Text="[source]" Path="https://github.com/radzenhq/radzen-blazor" Target="_blank" Style="margin-left:5px;vertical-align:bottom;" />
|
||||
</ChildContent>
|
||||
</RadzenFooter>
|
||||
@code {
|
||||
|
||||
|
||||
RadzenSidebar sidebar0;
|
||||
RadzenBody body0;
|
||||
bool sidebarExpanded = true;
|
||||
bool bodyExpanded = false;
|
||||
|
||||
dynamic themes = new[]
|
||||
{
|
||||
new { Text = "Default", Value = "default"},
|
||||
new { Text = "Dark", Value="dark" },
|
||||
new { Text = "Software", Value = "software"},
|
||||
new { Text = "Humanistic", Value = "humanistic" }
|
||||
};
|
||||
|
||||
IEnumerable<BlazorApp.Models.MenuItem> AdminMenu;
|
||||
|
||||
string Theme
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"{ThemeState.CurrentTheme}.css";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
|
||||
|
||||
if (httpContextAccessor != null && httpContextAccessor.HttpContext != null &&
|
||||
httpContextAccessor.HttpContext.Request != null && httpContextAccessor.HttpContext.Request.Headers.ContainsKey("User-Agent"))
|
||||
{
|
||||
var userAgent = httpContextAccessor.HttpContext.Request.Headers["User-Agent"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(userAgent))
|
||||
{
|
||||
if (userAgent.Contains("iPhone") || userAgent.Contains("Android") || userAgent.Contains("Googlebot"))
|
||||
{
|
||||
sidebarExpanded = false;
|
||||
bodyExpanded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (!firstRender)
|
||||
{
|
||||
var example = ExampleService.FindCurrent(UriHelper.ToAbsoluteUri(UriHelper.Uri));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ChangeTheme(object value)
|
||||
{
|
||||
ThemeState.CurrentTheme = value.ToString();
|
||||
UriHelper.NavigateTo(UriHelper.ToAbsoluteUri(UriHelper.Uri).ToString());
|
||||
}
|
||||
|
||||
public class CustomMenuItem
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Text { get; set; }
|
||||
public string ParentId { get; set; }
|
||||
public string Url { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user