- Moves authentication back to a /Authenticate page route - Flatten the namespaces of page components - Implement top-level layouts as windows - Move handling of redirecting to /Authenticate with component inside of an AuthenticatedLayout - Use individiual injected services instead of SDK.Client - Wipe out tokens on logout - Process logout even if server can't be reached
97 lines
No EOL
3.3 KiB
Text
97 lines
No EOL
3.3 KiB
Text
@using LANCommander.SDK.Extensions
|
|
@namespace LANCommander.Launcher.UI.Components
|
|
@inject LibraryService LibraryService
|
|
@inject NavigationManager NavigationManager
|
|
@inject LocalizationService LocalizationService
|
|
|
|
<Flex Vertical Class="library-list">
|
|
@if (LibraryService.Items == null || !LibraryService.Items.Any())
|
|
{
|
|
<Empty Simple Description="false">
|
|
<Button Type="ButtonType.Primary" OnClick="@(() => NavigationManager.NavigateTo("/Depot"))">@LocalizationService.GetString("BrowseDepot")</Button>
|
|
</Empty>
|
|
}
|
|
else
|
|
{
|
|
if (LibraryItems == null || !LibraryItems.Any())
|
|
{
|
|
<Empty Simple Description="@LocalizationService.GetString("NoResultsFound")">
|
|
<Button Type="ButtonType.Primary" OnClick="Filter.ResetFilter">@LocalizationService.GetString("ResetFilter")</Button>
|
|
</Empty>
|
|
}
|
|
else
|
|
{
|
|
<Collapse>
|
|
@if (Groups.Count > 1)
|
|
{
|
|
foreach (var group in Groups.OrderByTitle(g => g))
|
|
{
|
|
<Panel Header="@group" Key="@group">
|
|
<AntList DataSource="@(LibraryItems.Where(i => i.Groups.Contains(group) || (group == "Uncategorized" && !i.Groups.Any())))" TItem="Models.ListItem" Class="ant-list-clickable" Size="ListSize.Small">
|
|
<LibraryListItem Model="@context" OnClick="() => SelectItem(context)" SelectedItem="_currentItemId"/>
|
|
</AntList>
|
|
</Panel>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
<Panel Class="no-header">
|
|
<AntList DataSource="LibraryItems" TItem="Models.ListItem" Class="ant-list-clickable" Size="ListSize.Small">
|
|
<LibraryListItem Model="@context" OnClick="() => SelectItem(context)" SelectedItem="_currentItemId" />
|
|
</AntList>
|
|
</Panel>
|
|
}
|
|
</Collapse>
|
|
}
|
|
|
|
<LibraryItemFilter @ref="Filter" />
|
|
}
|
|
</Flex>
|
|
|
|
@code {
|
|
[Parameter] public EventCallback<Guid> OnItemSelected { get; set; }
|
|
|
|
List<string> Groups = new();
|
|
IEnumerable<Models.ListItem> LibraryItems;
|
|
LibraryItemFilter Filter;
|
|
|
|
Guid _currentItemId { get; set; }
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
LibraryService.OnItemsFiltered += LoadFilteredItems;
|
|
|
|
await LibraryService.RefreshItemsAsync();
|
|
}
|
|
|
|
async Task LoadFilteredItems(IEnumerable<Models.ListItem> libraryItems)
|
|
{
|
|
LibraryItems = libraryItems;
|
|
|
|
await UpdateGroups();
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
async Task SelectItem(Models.ListItem item)
|
|
{
|
|
_currentItemId = item.Key;
|
|
|
|
if (OnItemSelected.HasDelegate)
|
|
await OnItemSelected.InvokeAsync(item.Key);
|
|
}
|
|
|
|
async Task UpdateGroups()
|
|
{
|
|
Groups = LibraryItems.SelectMany(i => i.Groups).Distinct().ToList();
|
|
|
|
if (LibraryItems.Any(i => i.Groups == null || i.Groups.Length == 0))
|
|
Groups.Add(LocalizationService.GetString("Uncategorized"));
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
LibraryService.OnItemsFiltered -= LoadFilteredItems;
|
|
}
|
|
} |