blazing-console/Components/BlazingHeader.razor

58 lines
No EOL
2.2 KiB
Text

@*
* Copyright 2024 Ivy Collective <sys@ivycollective.dev>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*@
@inject NavigationManager Navigation
@using Blazored.LocalStorage
@inject ILocalStorageService localStorage
@inject APIService api
<FluentHeader>
<div style="display: flex; justify-content: space-between; flex-direction: row; align-items: center; width: 100%;">
<div>
Blazing Console
</div>
@if (Linked != null) {
<FluentProfileMenu
Image="@Linked.AvatarUrl()" FullName="@Linked.Username"
EMail="Blazing Console"
><HeaderTemplate /><FooterTemplate>
<FluentStack Orientation="Orientation.Horizontal" VerticalAlignment="VerticalAlignment.Center">
<FluentAnchor Href="#" OnClick="Logout" Appearance="Appearance.Hypertext">Logout</FluentAnchor>
<FluentLabel Color="Color.Accent">·</FluentLabel>
<FluentAnchor Href="/settings" Appearance="Appearance.Hypertext">Settings</FluentAnchor>
<FluentLabel Color="Color.Accent">·</FluentLabel>
<FluentAnchor Href="/about" Appearance="Appearance.Hypertext">About</FluentAnchor>
</FluentStack>
</FooterTemplate></FluentProfileMenu>
} else {
<FluentProgressRing />
}
</div>
</FluentHeader>
@code {
public LinkedUser? Linked { get; set; } = null;
protected override Task OnInitializedAsync() {
Linked = api.GetLinkedUser();
return Task.CompletedTask;
}
public async Task Logout() {
await localStorage.RemoveItemAsync("jwt");
Navigation.NavigateTo("/login");
}
}