Added admin page navigation

This commit is contained in:
2025-01-14 12:46:47 +01:00
parent f0bc9e23b8
commit 313f6e046a
12 changed files with 211 additions and 42 deletions

View File

@@ -0,0 +1,46 @@
@using System.Text
@using HopFrame.Core.Config
@using HopFrame.Core.Services
<FluentHeader Class="hopframe-header">
<a href="/admin" style="text-decoration: none; color: @Color.Neutral.ToAttributeValue()">HopFrame</a>
<FluentSpacer/>
@if (Config.DisplayUserInfo) {
<FluentPersona Name="@_displayName" Initials="@_initials" ImageSize="32px" TextPosition="TextPosition.Start"/>
}
</FluentHeader>
@inject HopFrameConfig Config
@inject IServiceProvider Provider
@code {
private string? _displayName;
private string? _initials;
protected override async Task OnInitializedAsync() {
if (Config.DisplayUserInfo) {
var handler = Provider.GetService(Config.AuthHandler!) as IHopFrameAuthHandler;
_displayName = await handler!.GetCurrentUserDisplayNameAsync();
_initials = GetInitials(_displayName);
}
}
private static string GetInitials(string input) {
if (string.IsNullOrEmpty(input))
return string.Empty;
StringBuilder initials = new StringBuilder();
string[] words = input.Split([' ', '.', '_'], StringSplitOptions.RemoveEmptyEntries);
foreach (string word in words) {
if (!string.IsNullOrEmpty(word) && char.IsLetter(word[0]))
initials.Append(word[0]);
}
return initials.ToString().ToUpper();
}
}