2025-10-05 19:30:32 -05:00
|
|
|
@using LANCommander.SDK.Extensions
|
2025-11-07 20:19:13 -06:00
|
|
|
@namespace LANCommander.Launcher.UI.Components
|
2024-07-08 19:15:57 -05:00
|
|
|
@inject LibraryService LibraryService
|
2025-02-28 23:59:18 -06:00
|
|
|
@inject NavigationManager NavigationManager
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
@inject LocalizationService LocalizationService
|
2024-07-08 19:15:57 -05:00
|
|
|
|
2024-10-30 00:22:24 -05:00
|
|
|
<Flex Vertical Class="library-list">
|
2025-03-11 17:27:57 -05:00
|
|
|
@if (LibraryService.Items == null || !LibraryService.Items.Any())
|
2025-02-28 23:59:18 -06:00
|
|
|
{
|
|
|
|
|
<Empty Simple Description="false">
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
<Button Type="ButtonType.Primary" OnClick="@(() => NavigationManager.NavigateTo("/Depot"))">@LocalizationService.GetString("BrowseDepot")</Button>
|
2025-02-28 23:59:18 -06:00
|
|
|
</Empty>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2025-03-11 17:27:57 -05:00
|
|
|
if (LibraryItems == null || !LibraryItems.Any())
|
|
|
|
|
{
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
<Empty Simple Description="@LocalizationService.GetString("NoResultsFound")">
|
|
|
|
|
<Button Type="ButtonType.Primary" OnClick="Filter.ResetFilter">@LocalizationService.GetString("ResetFilter")</Button>
|
2025-03-11 17:27:57 -05:00
|
|
|
</Empty>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
<Collapse>
|
|
|
|
|
@if (Groups.Count > 1)
|
2025-02-28 23:59:18 -06:00
|
|
|
{
|
2025-03-11 17:27:57 -05:00
|
|
|
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">
|
2025-10-05 19:30:32 -05:00
|
|
|
<LibraryListItem Model="@context" OnClick="() => SelectItem(context)" SelectedItem="_currentItemId"/>
|
2025-03-11 17:27:57 -05:00
|
|
|
</AntList>
|
|
|
|
|
</Panel>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
<Panel Class="no-header">
|
|
|
|
|
<AntList DataSource="LibraryItems" TItem="Models.ListItem" Class="ant-list-clickable" Size="ListSize.Small">
|
2025-10-05 19:30:32 -05:00
|
|
|
<LibraryListItem Model="@context" OnClick="() => SelectItem(context)" SelectedItem="_currentItemId" />
|
2025-02-28 23:59:18 -06:00
|
|
|
</AntList>
|
|
|
|
|
</Panel>
|
|
|
|
|
}
|
2025-03-11 17:27:57 -05:00
|
|
|
</Collapse>
|
|
|
|
|
}
|
2025-02-28 23:59:18 -06:00
|
|
|
|
2025-03-11 17:27:57 -05:00
|
|
|
<LibraryItemFilter @ref="Filter" />
|
2025-02-28 23:59:18 -06:00
|
|
|
}
|
2024-10-30 00:22:24 -05:00
|
|
|
</Flex>
|
2024-07-08 19:15:57 -05:00
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
[Parameter] public EventCallback<Guid> OnItemSelected { get; set; }
|
|
|
|
|
|
2024-11-13 00:57:00 -06:00
|
|
|
List<string> Groups = new();
|
2024-11-09 17:15:04 -06:00
|
|
|
IEnumerable<Models.ListItem> LibraryItems;
|
2025-03-11 17:27:57 -05:00
|
|
|
LibraryItemFilter Filter;
|
2025-10-05 19:30:32 -05:00
|
|
|
|
|
|
|
|
Guid _currentItemId { get; set; }
|
2024-07-08 19:44:23 -05:00
|
|
|
|
2024-10-30 00:22:24 -05:00
|
|
|
protected override async Task OnInitializedAsync()
|
2024-07-08 19:15:57 -05:00
|
|
|
{
|
2024-11-09 17:15:04 -06:00
|
|
|
LibraryService.OnItemsFiltered += LoadFilteredItems;
|
2024-07-11 18:50:24 -05:00
|
|
|
|
2024-11-09 17:15:04 -06:00
|
|
|
await LibraryService.RefreshItemsAsync();
|
2024-10-30 00:22:24 -05:00
|
|
|
}
|
|
|
|
|
|
2024-11-09 17:15:04 -06:00
|
|
|
async Task LoadFilteredItems(IEnumerable<Models.ListItem> libraryItems)
|
2024-10-30 00:22:24 -05:00
|
|
|
{
|
|
|
|
|
LibraryItems = libraryItems;
|
|
|
|
|
|
|
|
|
|
await UpdateGroups();
|
|
|
|
|
await InvokeAsync(StateHasChanged);
|
2024-07-08 19:15:57 -05:00
|
|
|
}
|
|
|
|
|
|
2024-11-09 17:15:04 -06:00
|
|
|
async Task SelectItem(Models.ListItem item)
|
2024-07-08 19:15:57 -05:00
|
|
|
{
|
2025-10-05 19:30:32 -05:00
|
|
|
_currentItemId = item.Key;
|
|
|
|
|
|
2024-07-08 19:15:57 -05:00
|
|
|
if (OnItemSelected.HasDelegate)
|
|
|
|
|
await OnItemSelected.InvokeAsync(item.Key);
|
|
|
|
|
}
|
2024-07-08 19:44:23 -05:00
|
|
|
|
2024-10-30 00:22:24 -05:00
|
|
|
async Task UpdateGroups()
|
2024-07-08 19:44:23 -05:00
|
|
|
{
|
2024-07-11 18:50:24 -05:00
|
|
|
Groups = LibraryItems.SelectMany(i => i.Groups).Distinct().ToList();
|
2024-07-08 19:44:23 -05:00
|
|
|
|
2024-07-11 18:50:24 -05:00
|
|
|
if (LibraryItems.Any(i => i.Groups == null || i.Groups.Length == 0))
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
Groups.Add(LocalizationService.GetString("Uncategorized"));
|
2024-07-08 19:44:23 -05:00
|
|
|
|
2024-07-13 12:55:42 -05:00
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2024-11-09 17:15:04 -06:00
|
|
|
LibraryService.OnItemsFiltered -= LoadFilteredItems;
|
2024-07-08 19:44:23 -05:00
|
|
|
}
|
2024-07-08 19:15:57 -05:00
|
|
|
}
|