mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Reworked Index.cshtml
This commit is contained in:
@@ -1,16 +1,55 @@
|
||||
@using Berufsschule_HAM.Services
|
||||
@using Microsoft.AspNetCore.Mvc.Localization
|
||||
@using Berufsschule_HAM.Models
|
||||
@using System.Security.Claims
|
||||
@model HomeIndexViewModel
|
||||
@inject IViewLocalizer T
|
||||
@inject LdapService _ldap
|
||||
@{
|
||||
ViewData["Title"] = T["Home Page"];
|
||||
bool hasName = User.Identity?.Name is not null;
|
||||
string? username;
|
||||
string name = "";
|
||||
UserModel? user;
|
||||
if (hasName && User.Identity is not null && User.Identity.Name is not null)
|
||||
{
|
||||
username = User.Identity.Name;
|
||||
user = await _ldap.GetUserByUidAsync(username);
|
||||
name = user.Cn ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
<div class="container py-4">
|
||||
<h2 class="mb-3">@T["Overview"]</h2>
|
||||
<div class="mb-4 d-flex flex-wrap gap-2">
|
||||
<button class="btn btn-primary">@T["Inventory asset"]</button>
|
||||
<button class="btn btn-primary">@T["Create user"]</button>
|
||||
<div class="row text-center">
|
||||
@if (name.Length > 0)
|
||||
{
|
||||
<h3>@T["Hi, {0}!", name]</h3>
|
||||
} else
|
||||
{
|
||||
<h3>@T["Hi!"]</h3>
|
||||
}
|
||||
<p>@T["Navigate from here or the navigation bar"]</p>
|
||||
<div class="mb-4 d-flex flex-wrap gap-2 justify-content-center">
|
||||
@if (User.HasClaim(ClaimTypes.Role, "CanInventorize"))
|
||||
{
|
||||
<a href="/Home/Inventory" class="btn btn-primary">@T["Inventory"]</a>
|
||||
}
|
||||
@if (User.HasClaim(ClaimTypes.Role, "CanManageAssets"))
|
||||
{
|
||||
<a href="/Home/Assets" class="btn btn-primary">@T["Manage Assets"]</a>
|
||||
}
|
||||
@if (User.HasClaim(ClaimTypes.Role, "CanManageLocations"))
|
||||
{
|
||||
<a href="/Home/Locations" class="btn btn-primary">@T["Manage Locations"]</a>
|
||||
}
|
||||
@if (User.HasClaim(ClaimTypes.Role, "CanManageUsers"))
|
||||
{
|
||||
<a href="/Home/Users" class="btn btn-primary">@T["Manage Users"]</a>
|
||||
}
|
||||
@if (User.HasClaim(ClaimTypes.Role, "CanManageGroups"))
|
||||
{
|
||||
<a href="/Home/Groups" class="btn btn-primary">@T["Manage Groups"]</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user