80 lines
No EOL
2.1 KiB
Text
80 lines
No EOL
2.1 KiB
Text
@using LANCommander.Launcher.Data.Models
|
|
@using LANCommander.Launcher.Models
|
|
@inject UserService UserService
|
|
@inject ProfileService ProfileService
|
|
@inject AuthenticationService AuthenticationService
|
|
@inject NavigationManager NavigationManager
|
|
@inject ModalService ModalService
|
|
|
|
<Dropdown>
|
|
<Overlay>
|
|
<Menu>
|
|
<MenuItem OnClick="ChangeAlias" Disabled="ConnectionState.OfflineModeEnabled">
|
|
Change Name
|
|
</MenuItem>
|
|
<MenuItem OnClick="@(() => NavigationManager.NavigateTo("/Settings"))">
|
|
Settings
|
|
</MenuItem>
|
|
|
|
@if (!ConnectionState.OfflineModeEnabled)
|
|
{
|
|
<MenuItem OnClick="Logout">
|
|
Logout
|
|
</MenuItem>
|
|
}
|
|
</Menu>
|
|
</Overlay>
|
|
|
|
<ChildContent>
|
|
<Button Type="ButtonType.Primary" Class="appbar-profile-button">
|
|
@if (User != null && User.Avatar != null)
|
|
{
|
|
<MediaImage Id="@User.Avatar.Id" />
|
|
}
|
|
|
|
<span>@User?.Alias</span>
|
|
</Button>
|
|
</ChildContent>
|
|
</Dropdown>
|
|
|
|
@code {
|
|
[CascadingParameter] public ConnectionState ConnectionState { get; set; }
|
|
Models.Settings Settings = null;
|
|
|
|
User User;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
User = await UserService.GetCurrentUser();
|
|
}
|
|
|
|
async Task ChangeAlias()
|
|
{
|
|
var modalOptions = new ModalOptions()
|
|
{
|
|
Title = "Change Name",
|
|
Maximizable = false,
|
|
DefaultMaximized = false,
|
|
Closable = true,
|
|
Centered = true
|
|
};
|
|
|
|
var modalRef = ModalService.CreateModal<ChangeAliasDialog, string, string>(modalOptions, User.Alias);
|
|
|
|
modalRef.OnOk = async (newName) =>
|
|
{
|
|
await ProfileService.ChangeAlias(newName);
|
|
|
|
Settings = SettingService.GetSettings();
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
};
|
|
}
|
|
|
|
async Task Logout()
|
|
{
|
|
await AuthenticationService.Logout();
|
|
|
|
NavigationManager.NavigateTo("/Authenticate");
|
|
}
|
|
} |