item details modal to show a compact summary first and hide the rest behind an expand button per content type in RelatedRecordsPanel.razor. Systems and VMs now pin Status, Short Name, Host, Function, Env; Devices pin Status, Name, Data Center, Location; IPs pin Proto, IP, Host, Purpose; Subnets pin Proto, Prefix, Mask.
Related record groups now start collapsed and expand individually with a count badge, and the filter box supports mixed filters like [Host]esx01;[Status]Active;prod. Property-scoped filters match by property name or display label, while plain tokens still search across all visible columns.
This commit is contained in:
@@ -48,7 +48,7 @@
|
||||
}
|
||||
</div>
|
||||
<div style="display: grid; gap: 0.35rem;">
|
||||
@foreach (var row in context.Details)
|
||||
@foreach (var row in GetPrimaryDetails(context))
|
||||
{
|
||||
<div style="display: grid; grid-template-columns: minmax(180px, 220px) 1fr; gap: 0.75rem; border-top: 1px solid var(--border-color); padding-top: 0.35rem;">
|
||||
<div style="font-weight: 600;">@row.Label</div>
|
||||
@@ -56,6 +56,32 @@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (GetSecondaryDetails(context).Any())
|
||||
{
|
||||
var detailSectionKey = BuildDetailsSectionKey(context);
|
||||
var detailsExpanded = IsDetailsExpanded(detailSectionKey);
|
||||
|
||||
<div style="margin-top: 0.75rem;">
|
||||
<button class="btn btn-sm btn-outline-secondary"
|
||||
@onclick="() => ToggleDetailsExpanded(detailSectionKey)">
|
||||
@(detailsExpanded ? "Hide More Details" : "Expand Details")
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (detailsExpanded)
|
||||
{
|
||||
<div style="display: grid; gap: 0.35rem; margin-top: 0.75rem;">
|
||||
@foreach (var row in GetSecondaryDetails(context))
|
||||
{
|
||||
<div style="display: grid; grid-template-columns: minmax(180px, 220px) 1fr; gap: 0.75rem; border-top: 1px solid var(--border-color); padding-top: 0.35rem;">
|
||||
<div style="font-weight: 600;">@row.Label</div>
|
||||
<div class="text-muted" style="word-break: break-word;">@row.Value</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</section>
|
||||
|
||||
<section>
|
||||
@@ -73,58 +99,63 @@
|
||||
var visibleItems = GetVisibleGroupItems(context, group);
|
||||
|
||||
<div class="related-group" style="margin-bottom: 1rem;">
|
||||
<div class="related-group-label" style="margin-bottom: 0.5rem;">
|
||||
@group.Label (@visibleItems.Count)
|
||||
</div>
|
||||
<button class="btn btn-sm btn-outline-secondary"
|
||||
style="margin-bottom: 0.5rem;"
|
||||
@onclick="() => ToggleGroupExpanded(groupKey)">
|
||||
@group.Label (@visibleItems.Count) @(IsGroupExpanded(groupKey) ? "v" : "^")
|
||||
</button>
|
||||
|
||||
<div style="margin-bottom: 0.5rem;">
|
||||
<input class="form-control form-control-sm"
|
||||
style="max-width: 320px;"
|
||||
placeholder="Filter related records..."
|
||||
value="@GetGroupFilter(groupKey)"
|
||||
@oninput="(e) => SetGroupFilter(groupKey, e.Value?.ToString() ?? string.Empty)" />
|
||||
</div>
|
||||
@if (IsGroupExpanded(groupKey))
|
||||
{
|
||||
<div style="margin-bottom: 0.5rem;">
|
||||
<input class="form-control form-control-sm"
|
||||
style="max-width: 420px;"
|
||||
placeholder="Filter related records... [Property]Value;[Property]Value"
|
||||
value="@GetGroupFilter(groupKey)"
|
||||
@oninput="(e) => SetGroupFilter(groupKey, e.Value?.ToString() ?? string.Empty)" />
|
||||
</div>
|
||||
|
||||
<div style="overflow-x: auto;">
|
||||
<table class="data-grid-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@foreach (var field in group.Fields)
|
||||
{
|
||||
<th style="cursor: pointer;"
|
||||
@onclick="() => ToggleGroupSort(groupKey, field.PropertyName)">
|
||||
@field.DisplayName @GetSortIndicator(groupKey, field.PropertyName)
|
||||
</th>
|
||||
}
|
||||
@if (CanEdit)
|
||||
{
|
||||
<th>Actions</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in visibleItems)
|
||||
{
|
||||
<tr style="cursor: pointer;" @onclick="() => OpenEntity(item, group.ContentType)">
|
||||
<div style="overflow-x: auto;">
|
||||
<table class="data-grid-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@foreach (var field in group.Fields)
|
||||
{
|
||||
<td>@GetDisplayValue(item, field)</td>
|
||||
<th style="cursor: pointer;"
|
||||
@onclick="() => ToggleGroupSort(groupKey, field.PropertyName)">
|
||||
@field.DisplayName @GetSortIndicator(groupKey, field.PropertyName)
|
||||
</th>
|
||||
}
|
||||
@if (CanEdit)
|
||||
{
|
||||
<td>
|
||||
<button class="btn btn-sm btn-outline-primary"
|
||||
@onclick:stopPropagation
|
||||
@onclick="() => RequestEdit(group.ContentType, item.Id)">
|
||||
<i class="bi bi-pencil"></i> Edit
|
||||
</button>
|
||||
</td>
|
||||
<th>Actions</th>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in visibleItems)
|
||||
{
|
||||
<tr style="cursor: pointer;" @onclick="() => OpenEntity(item, group.ContentType)">
|
||||
@foreach (var field in group.Fields)
|
||||
{
|
||||
<td>@GetDisplayValue(item, field)</td>
|
||||
}
|
||||
@if (CanEdit)
|
||||
{
|
||||
<td>
|
||||
<button class="btn btn-sm btn-outline-primary"
|
||||
@onclick:stopPropagation
|
||||
@onclick="() => RequestEdit(group.ContentType, item.Id)">
|
||||
<i class="bi bi-pencil"></i> Edit
|
||||
</button>
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -162,6 +193,8 @@
|
||||
private readonly List<InspectContext> _stack = new();
|
||||
private readonly Dictionary<string, string> _groupFilters = new();
|
||||
private readonly Dictionary<string, GroupSortState> _groupSorts = new();
|
||||
private readonly HashSet<string> _expandedGroups = new(StringComparer.Ordinal);
|
||||
private readonly HashSet<string> _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<DetailRow> GetPrimaryDetails(InspectContext context)
|
||||
{
|
||||
var primaryLabels = GetPrimaryDetailLabels(context.ContentType);
|
||||
return context.Details
|
||||
.Where(row => primaryLabels.Contains(row.Label))
|
||||
.ToList()
|
||||
.AsReadOnly();
|
||||
}
|
||||
|
||||
private IReadOnlyList<DetailRow> GetSecondaryDetails(InspectContext context)
|
||||
{
|
||||
var primaryLabels = GetPrimaryDetailLabels(context.ContentType);
|
||||
return context.Details
|
||||
.Where(row => !primaryLabels.Contains(row.Label))
|
||||
.ToList()
|
||||
.AsReadOnly();
|
||||
}
|
||||
|
||||
private static HashSet<string> 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<string>()
|
||||
};
|
||||
|
||||
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<PropertyFilter> PropertyFilters { get; } = new();
|
||||
public List<string> 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; }
|
||||
|
||||
Reference in New Issue
Block a user