diff --git a/src/MaxInventory.Web/Components/Shared/RelatedRecordsPanel.razor b/src/MaxInventory.Web/Components/Shared/RelatedRecordsPanel.razor
index f50c35b..8f9464d 100644
--- a/src/MaxInventory.Web/Components/Shared/RelatedRecordsPanel.razor
+++ b/src/MaxInventory.Web/Components/Shared/RelatedRecordsPanel.razor
@@ -48,7 +48,7 @@
}
- @foreach (var row in context.Details)
+ @foreach (var row in GetPrimaryDetails(context))
{
@row.Label
@@ -56,6 +56,32 @@
}
+
+ @if (GetSecondaryDetails(context).Any())
+ {
+ var detailSectionKey = BuildDetailsSectionKey(context);
+ var detailsExpanded = IsDetailsExpanded(detailSectionKey);
+
+
+
+
+
+ @if (detailsExpanded)
+ {
+
+ @foreach (var row in GetSecondaryDetails(context))
+ {
+
+
@row.Label
+
@row.Value
+
+ }
+
+ }
+ }
@@ -73,58 +99,63 @@
var visibleItems = GetVisibleGroupItems(context, group);
}
@@ -162,6 +193,8 @@
private readonly List _stack = new();
private readonly Dictionary _groupFilters = new();
private readonly Dictionary _groupSorts = new();
+ private readonly HashSet _expandedGroups = new(StringComparer.Ordinal);
+ private readonly HashSet _expandedDetailSections = new(StringComparer.Ordinal);
private string _cacheFingerprint = string.Empty;
protected override async Task OnParametersSetAsync()
@@ -169,6 +202,8 @@
if (!IsVisible || Entity is null)
{
_stack.Clear();
+ _expandedGroups.Clear();
+ _expandedDetailSections.Clear();
_cacheFingerprint = string.Empty;
return;
}
@@ -591,11 +626,8 @@
if (_groupFilters.TryGetValue(groupKey, out var filter) && !string.IsNullOrWhiteSpace(filter))
{
- items = items.Where(item => group.Fields.Any(field =>
- {
- var value = GetDisplayValue(item, field);
- return value.Contains(filter, StringComparison.OrdinalIgnoreCase);
- }));
+ var parsedFilter = ParseGroupFilter(filter);
+ items = items.Where(item => MatchesGroupFilter(item, group, parsedFilter));
}
if (_groupSorts.TryGetValue(groupKey, out var sortState))
@@ -612,6 +644,131 @@
return items.ToList().AsReadOnly();
}
+ private IReadOnlyList GetPrimaryDetails(InspectContext context)
+ {
+ var primaryLabels = GetPrimaryDetailLabels(context.ContentType);
+ return context.Details
+ .Where(row => primaryLabels.Contains(row.Label))
+ .ToList()
+ .AsReadOnly();
+ }
+
+ private IReadOnlyList GetSecondaryDetails(InspectContext context)
+ {
+ var primaryLabels = GetPrimaryDetailLabels(context.ContentType);
+ return context.Details
+ .Where(row => !primaryLabels.Contains(row.Label))
+ .ToList()
+ .AsReadOnly();
+ }
+
+ private static HashSet GetPrimaryDetailLabels(ContentTypeName contentType)
+ {
+ var labels = contentType switch
+ {
+ ContentTypeName.Systems => new[] { "Status", "Short Name", "Host", "Function", "Env" },
+ ContentTypeName.Devices => new[] { "Status", "Name", "Data Center", "Location" },
+ ContentTypeName.Ips => new[] { "Proto", "IP", "Host", "Purpose" },
+ ContentTypeName.Subnets => new[] { "Proto", "Prefix", "Mask" },
+ ContentTypeName.Vms => new[] { "Status", "Short Name", "Host", "Function", "Env" },
+ _ => Array.Empty()
+ };
+
+ return labels.ToHashSet(StringComparer.OrdinalIgnoreCase);
+ }
+
+ private static string BuildDetailsSectionKey(InspectContext context)
+ {
+ return $"details:{context.ContentType}:{context.Entity.Id}";
+ }
+
+ private bool IsDetailsExpanded(string key)
+ {
+ return _expandedDetailSections.Contains(key);
+ }
+
+ private void ToggleDetailsExpanded(string key)
+ {
+ if (!_expandedDetailSections.Add(key))
+ {
+ _expandedDetailSections.Remove(key);
+ }
+ }
+
+ private bool IsGroupExpanded(string groupKey)
+ {
+ return _expandedGroups.Contains(groupKey);
+ }
+
+ private void ToggleGroupExpanded(string groupKey)
+ {
+ if (!_expandedGroups.Add(groupKey))
+ {
+ _expandedGroups.Remove(groupKey);
+ }
+ }
+
+ private static ParsedGroupFilter ParseGroupFilter(string rawFilter)
+ {
+ var parsed = new ParsedGroupFilter();
+
+ foreach (var token in rawFilter.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
+ {
+ if (token.StartsWith('['))
+ {
+ var closeBracketIndex = token.IndexOf(']');
+ if (closeBracketIndex > 1 && closeBracketIndex < token.Length - 1)
+ {
+ parsed.PropertyFilters.Add(new PropertyFilter
+ {
+ Property = token[1..closeBracketIndex].Trim(),
+ Value = token[(closeBracketIndex + 1)..].Trim()
+ });
+ continue;
+ }
+ }
+
+ parsed.FreeTextFilters.Add(token.Trim());
+ }
+
+ return parsed;
+ }
+
+ private bool MatchesGroupFilter(IInventoryEntity item, RelatedGroupView group, ParsedGroupFilter filter)
+ {
+ foreach (var propertyFilter in filter.PropertyFilters)
+ {
+ var field = group.Fields.FirstOrDefault(f =>
+ string.Equals(f.PropertyName, propertyFilter.Property, StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(f.DisplayName, propertyFilter.Property, StringComparison.OrdinalIgnoreCase));
+
+ if (field is null)
+ {
+ return false;
+ }
+
+ var value = GetDisplayValue(item, field);
+ if (!value.Contains(propertyFilter.Value, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+ }
+
+ foreach (var freeText in filter.FreeTextFilters)
+ {
+ if (!group.Fields.Any(field =>
+ {
+ var value = GetDisplayValue(item, field);
+ return value.Contains(freeText, StringComparison.OrdinalIgnoreCase);
+ }))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
private async Task CloseAt(int index)
{
@@ -847,6 +1004,18 @@
return null;
}
+ private sealed class ParsedGroupFilter
+ {
+ public List PropertyFilters { get; } = new();
+ public List FreeTextFilters { get; } = new();
+ }
+
+ private sealed class PropertyFilter
+ {
+ public required string Property { get; init; }
+ public required string Value { get; init; }
+ }
+
private sealed class InspectContext
{
public required IInventoryEntity Entity { get; init; }