You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
3.4 KiB
129 lines
3.4 KiB
@inherits LayoutComponentBase
|
|
@using Microsoft.AspNetCore.Authorization;
|
|
@using Microsoft.AspNetCore.Identity;
|
|
@inject UserManager<IdentityUser> _UserManager
|
|
|
|
|
|
|
|
@using Syncfusion.Blazor.Navigations
|
|
@using BWPMModels
|
|
@using Newtonsoft.Json
|
|
|
|
|
|
<div class="sidebar">
|
|
<MyLogin></MyLogin>
|
|
@* <NavMenu />*@
|
|
|
|
</div>
|
|
|
|
<div class="main">
|
|
<div class="top-row">
|
|
<SfMenu Items="@Mitems"></SfMenu>
|
|
</div>
|
|
|
|
<div class="content px-4">
|
|
@Body
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@code {
|
|
|
|
|
|
[CascadingParameter]
|
|
private Task<AuthenticationState> authenticationStateTask { get; set; }
|
|
System.Security.Claims.ClaimsPrincipal CurrentUser;
|
|
|
|
public List<BWPMModels.MenuItem> MenuItems = new List<BWPMModels.MenuItem>();
|
|
public List<CustomMenuItem> Mitems = new List<CustomMenuItem>();
|
|
|
|
int menutype = 0;
|
|
bool showlogoff = false;
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper();
|
|
|
|
CurrentUser = (await authenticationStateTask).User;
|
|
if (!CurrentUser.Identity.IsAuthenticated)
|
|
{
|
|
menutype = 0;
|
|
showlogoff = false;
|
|
}
|
|
else
|
|
{
|
|
var user = await _UserManager.FindByNameAsync(CurrentUser.Identity.Name);
|
|
var UserResult = await _UserManager.IsInRoleAsync(user, "Administrators");
|
|
if (UserResult) { menutype = 9; }
|
|
showlogoff = true;
|
|
}
|
|
|
|
|
|
httpcli.CallService("MenuItem", menutype.ToString(), "GET", null);
|
|
|
|
List<BWPMModels.MenuItem> MenuItems = JsonConvert.DeserializeObject<List<BWPMModels.MenuItem>>(httpcli.Results.daten);
|
|
CustomMenuItem mitem = new CustomMenuItem();
|
|
if (!showlogoff)
|
|
{
|
|
mitem.Id = "999";
|
|
mitem.Text = "Anmelden";
|
|
mitem.Url = "/identity/account/login";
|
|
}
|
|
else
|
|
{
|
|
mitem.Id = "999";
|
|
mitem.Text = "Abmelden";
|
|
mitem.Url = "/identity/account/logout";
|
|
}
|
|
|
|
foreach (BWPMModels.MenuItem item in MenuItems)
|
|
{
|
|
if (item.parentId == "0")
|
|
{
|
|
Mitems.Add(new CustomMenuItem { Id = item.ID, Text = item.text, Url = item.url });
|
|
}
|
|
else
|
|
{
|
|
Mitems.Add(new CustomMenuItem { Id = item.ID, Text = item.text, ParentId = item.parentId, Url = item.url });
|
|
};
|
|
|
|
};
|
|
|
|
Mitems.Add(mitem);
|
|
}
|
|
|
|
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
return;
|
|
Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper();
|
|
|
|
httpcli.CallService("MenuItem", "0", "GET", null);
|
|
|
|
List<BWPMModels.MenuItem> MenuItems = JsonConvert.DeserializeObject<List<BWPMModels.MenuItem>>(httpcli.Results.daten);
|
|
|
|
foreach (BWPMModels.MenuItem item in MenuItems)
|
|
{
|
|
if (item.parentId == "0")
|
|
{
|
|
Mitems.Add(new CustomMenuItem { Id = item.ID, Text = item.text, Url = item.url });
|
|
|
|
}
|
|
else
|
|
{
|
|
Mitems.Add(new CustomMenuItem { Id = item.ID, Text = item.text, ParentId = item.parentId, Url = item.url });
|
|
};
|
|
|
|
};
|
|
}
|
|
|
|
|
|
public class CustomMenuItem
|
|
{
|
|
public string Id { get; set; }
|
|
public string Text { get; set; }
|
|
public string ParentId { get; set; }
|
|
public string Url { get; set; }
|
|
}
|
|
}
|