feat: add search bar to the proxy configs page
All checks were successful
Caddy Manager CI build / docker (push) Successful in 1m42s
All checks were successful
Caddy Manager CI build / docker (push) Successful in 1m42s
This commit is contained in:
@@ -18,6 +18,10 @@
|
|||||||
{
|
{
|
||||||
<MudProgressCircular Color="Color.Primary" Indeterminate="true" Size="Size.Small"/>
|
<MudProgressCircular Color="Color.Primary" Indeterminate="true" Size="Size.Small"/>
|
||||||
}
|
}
|
||||||
|
<MudSpacer />
|
||||||
|
<MudTextField T="string" Placeholder="Search..." Adornment="Adornment.End" DebounceInterval="500"
|
||||||
|
OnDebounceIntervalElapsed="HandleIntervalElapsed" @bind-Value="_debouncedText"
|
||||||
|
AdornmentIcon="@Icons.Material.Filled.Search"/>
|
||||||
</MudContainer>
|
</MudContainer>
|
||||||
<MudList T="string" Style="padding-top: 16px;" SelectionMode="SelectionMode.MultiSelection"
|
<MudList T="string" Style="padding-top: 16px;" SelectionMode="SelectionMode.MultiSelection"
|
||||||
@bind-SelectedValues="_selectedCaddyConfigurations">
|
@bind-SelectedValues="_selectedCaddyConfigurations">
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public partial class CaddyReverseProxiesPage : ComponentBase
|
|||||||
private bool _isProcessing;
|
private bool _isProcessing;
|
||||||
private List<string> _availableCaddyConfigurations = [];
|
private List<string> _availableCaddyConfigurations = [];
|
||||||
private IReadOnlyCollection<string> _selectedCaddyConfigurations = [];
|
private IReadOnlyCollection<string> _selectedCaddyConfigurations = [];
|
||||||
|
private string _debouncedText = string.Empty;
|
||||||
|
|
||||||
[Inject] private ICaddyService CaddyService { get; set; } = null!;
|
[Inject] private ICaddyService CaddyService { get; set; } = null!;
|
||||||
|
|
||||||
@@ -61,7 +62,10 @@ public partial class CaddyReverseProxiesPage : ComponentBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void Refresh()
|
private void Refresh()
|
||||||
{
|
{
|
||||||
_availableCaddyConfigurations = CaddyService.GetExistingCaddyConfigurations();
|
var notSearching = string.IsNullOrWhiteSpace(_debouncedText);
|
||||||
|
_availableCaddyConfigurations = CaddyService.GetExistingCaddyConfigurations()
|
||||||
|
.Where(confName => notSearching || confName.Contains(_debouncedText, StringComparison.OrdinalIgnoreCase))
|
||||||
|
.ToList();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,4 +134,14 @@ public partial class CaddyReverseProxiesPage : ComponentBase
|
|||||||
Snackbar.Add("Failed to restart the Caddy container", Severity.Error);
|
Snackbar.Add("Failed to restart the Caddy container", Severity.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle the interval elapsed event for debounced text input for search functionality.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="debouncedText"></param>
|
||||||
|
private void HandleIntervalElapsed(string debouncedText)
|
||||||
|
{
|
||||||
|
// Simply refresh the page with the new debounced text
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user