feat: enhance Caddy reverse proxy configuration with aggregated ports display
All checks were successful
Caddy Manager CI build / docker (push) Successful in 1m2s
All checks were successful
Caddy Manager CI build / docker (push) Successful in 1m2s
This commit is contained in:
@@ -84,9 +84,28 @@ public partial class CaddyReverseProxiesPage : ComponentBase
|
||||
private void Refresh()
|
||||
{
|
||||
var notSearching = string.IsNullOrWhiteSpace(_debouncedText);
|
||||
_availableCaddyConfigurations = [..CaddyService.GetExistingCaddyConfigurations()
|
||||
var configurations = CaddyService.GetExistingCaddyConfigurations()
|
||||
.Where(conf => notSearching || conf.FileName.Contains(_debouncedText, StringComparison.OrdinalIgnoreCase) || conf.ReverseProxyHostname.Contains(_debouncedText, StringComparison.OrdinalIgnoreCase))
|
||||
.OrderBy(conf => conf.FileName)];
|
||||
.OrderBy(conf => conf.FileName)
|
||||
.ToList();
|
||||
|
||||
// Optimize by grouping by ReverseProxyHostname and computing once per group
|
||||
var hostnameToAggregatedPorts = configurations
|
||||
.GroupBy(c => c.ReverseProxyHostname)
|
||||
.ToDictionary(
|
||||
g => g.Key,
|
||||
g => g.SelectMany(c => c.ReverseProxyPorts)
|
||||
.Distinct()
|
||||
.OrderBy(p => p)
|
||||
.ToList()
|
||||
);
|
||||
|
||||
foreach (var config in configurations)
|
||||
{
|
||||
config.AggregatedReverseProxyPorts = hostnameToAggregatedPorts[config.ReverseProxyHostname];
|
||||
}
|
||||
|
||||
_availableCaddyConfigurations = [..configurations];
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,20 @@
|
||||
<MudIcon Icon="@Icons.Custom.FileFormats.FileCode"></MudIcon>
|
||||
<MudText>@ConfigurationInfo.FileName</MudText>
|
||||
<MudSpacer/>
|
||||
<MudChip T="string" Variant="Variant.Outlined">@ConfigurationInfo.ReverseProxyHostname</MudChip>
|
||||
<MudTooltip Delay="0" Placement="Placement.Left">
|
||||
<ChildContent>
|
||||
<MudChip T="string" Variant="Variant.Outlined">@ConfigurationInfo.ReverseProxyHostname</MudChip>
|
||||
</ChildContent>
|
||||
<TooltipContent>
|
||||
@if (ConfigurationInfo.AggregatedReverseProxyPorts?.Count > 0)
|
||||
{
|
||||
@foreach (var port in ConfigurationInfo.AggregatedReverseProxyPorts.OrderBy(p => p))
|
||||
{
|
||||
<MudText Align="Align.Start">⏵ @port</MudText>
|
||||
}
|
||||
}
|
||||
</TooltipContent>
|
||||
</MudTooltip>
|
||||
<MudTooltip Delay="0" Placement="Placement.Left">
|
||||
<ChildContent>
|
||||
<MudChip T="string" Variant="Variant.Outlined" Style="width: 80px;"
|
||||
|
||||
@@ -24,4 +24,9 @@ public class CaddyConfigurationInfo
|
||||
/// The name of the configuration file.
|
||||
/// </summary>
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Aggregated ports for the reverse proxy hostname from all configurations.
|
||||
/// </summary>
|
||||
public List<int> AggregatedReverseProxyPorts { get; set; } = [];
|
||||
}
|
||||
Reference in New Issue
Block a user