112 lines
No EOL
3.1 KiB
Text
112 lines
No EOL
3.1 KiB
Text
@using LANCommander.Client.Models
|
|
@using Photino.Blazor.CustomWindow.Components
|
|
@inherits LayoutComponentBase
|
|
@inject ImportService ImportService
|
|
@inject ProfileService ProfileService
|
|
@inject IMessageService MessageService
|
|
@inject NavigationManager NavigationManager
|
|
@inject ModalService ModalService
|
|
|
|
<CustomWindow HeaderHeight="37">
|
|
<HeaderExtraControlsLayout>
|
|
<Space Direction="@DirectionVHType.Horizontal">
|
|
@if (Settings != null && Settings.Profile != null && ProfileService.IsAuthenticated())
|
|
{
|
|
<SpaceItem>
|
|
<Button Type="@ButtonType.Text" Icon="@IconType.Outline.Sync" OnClick="Import" Loading="@Importing" />
|
|
</SpaceItem>
|
|
|
|
<SpaceItem>
|
|
<Dropdown>
|
|
<Overlay>
|
|
<Menu>
|
|
<MenuItem OnClick="ChangeAlias">
|
|
Change Name
|
|
</MenuItem>
|
|
<MenuItem OnClick="Logout">
|
|
Logout
|
|
</MenuItem>
|
|
</Menu>
|
|
</Overlay>
|
|
|
|
<ChildContent>
|
|
<Button Type="@ButtonType.Primary" Class="appbar-profile-button">
|
|
<img src="data:image/png;base64,@(Settings.Profile.Avatar)" />
|
|
@Settings.Profile.Alias
|
|
</Button>
|
|
</ChildContent>
|
|
</Dropdown>
|
|
|
|
</SpaceItem>
|
|
}
|
|
</Space>
|
|
</HeaderExtraControlsLayout>
|
|
<WindowContent>
|
|
@Body
|
|
|
|
<AntContainer />
|
|
<RedirectToLogin />
|
|
</WindowContent>
|
|
</CustomWindow>
|
|
|
|
@code {
|
|
Settings Settings = null;
|
|
|
|
bool Importing = false;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
Settings = SettingService.GetSettings();
|
|
}
|
|
|
|
async Task Logout()
|
|
{
|
|
await ProfileService.Logout();
|
|
|
|
NavigationManager.NavigateTo("/Authenticate");
|
|
}
|
|
|
|
async Task ChangeAlias()
|
|
{
|
|
var settings = SettingService.GetSettings();
|
|
|
|
var modalOptions = new ModalOptions()
|
|
{
|
|
Title = "Change Name",
|
|
Maximizable = false,
|
|
DefaultMaximized = false,
|
|
Closable = true,
|
|
Centered = true
|
|
};
|
|
|
|
var modalRef = ModalService.CreateModal<ChangeAliasDialog, string, string>(modalOptions, settings.Profile.Alias);
|
|
|
|
modalRef.OnOk = async (newName) =>
|
|
{
|
|
await ProfileService.ChangeAlias(newName);
|
|
|
|
Settings = SettingService.GetSettings();
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
};
|
|
}
|
|
|
|
async void Import()
|
|
{
|
|
var config = new MessageConfig()
|
|
{
|
|
Content = "Importing...",
|
|
Duration = 0
|
|
};
|
|
|
|
Importing = true;
|
|
|
|
var task = MessageService.Loading(config);
|
|
|
|
await ImportService.ImportAsync();
|
|
|
|
task.Start();
|
|
|
|
Importing = true;
|
|
}
|
|
} |