1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2024-11-22 08:42:44 +01:00
Minecraft-Phantom-Panel/Server/Phantom.Server.Web/Layout/NavMenu.razor
2023-02-24 17:22:19 +01:00

62 lines
1.8 KiB
Plaintext

@using Phantom.Server.Services
@inject ServiceConfiguration Configuration
@inject PermissionManager PermissionManager
<div class="navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">Phantom Panel</a>
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
<div class="navbar-menu @NavMenuCssClass" @onclick="ToggleNavMenu">
<nav>
<NavMenuItem Label="Home" Icon="home" Match="NavLinkMatch.All" />
<AuthorizeView>
<NotAuthorized>
<NavMenuItem Label="Login" Icon="account-login" Href="login" />
</NotAuthorized>
<Authorized>
@{ var permissions = PermissionManager.GetPermissions(context.User); }
@if (permissions.Check(Permission.ViewInstances)) {
<NavMenuItem Label="Instances" Icon="folder" Href="instances" />
}
<NavMenuItem Label="Agents" Icon="cloud" Href="agents" />
@if (permissions.Check(Permission.ViewUsers)) {
<NavMenuItem Label="Users" Icon="person" Href="users" />
}
@if (permissions.Check(Permission.ViewAudit)) {
<NavMenuItem Label="Audit Log" Icon="clipboard" Href="audit" />
}
@if (permissions.Check(Permission.ViewEvents)) {
<NavMenuItem Label="Event Log" Icon="project" Href="events" />
}
<NavMenuItem Label="Logout" Icon="account-logout" Href="logout" />
</Authorized>
</AuthorizeView>
</nav>
<footer>
Build @Configuration.Version
</footer>
</div>
@code {
private bool collapseNavMenu = true;
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
private void ToggleNavMenu() {
collapseNavMenu = !collapseNavMenu;
}
}