LANCommander/LANCommander.Server/UI/Components/StorageLocationSelector.razor

30 lines
No EOL
978 B
Text

@using LANCommander.SDK.Enums
@inject StorageLocationService StorageLocationService
<Select
DataSource="StorageLocations"
ItemValue="l => l"
ItemLabel="l => l.Path"
@bind-Value="Value"
OnSelectedItemChanged="ValueChanged" />
@code {
[Parameter] public StorageLocation Value { get; set; } = new();
[Parameter] public EventCallback<StorageLocation> ValueChanged { get; set; }
[Parameter] public StorageLocationType Type { get; set; } = StorageLocationType.Archive;
IEnumerable<StorageLocation> StorageLocations = new List<StorageLocation>();
protected override async Task OnInitializedAsync()
{
StorageLocations = await StorageLocationService
.AsNoTracking()
.SortBy(l => l.Path)
.GetAsync(l => l.Type == Type);
Value = StorageLocations.First();
if (ValueChanged.HasDelegate)
await ValueChanged.InvokeAsync(Value);
}
}