Skip to content

Commit

Permalink
Various bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed Nov 5, 2024
1 parent 3153219 commit 868759f
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
<FluentCheckbox Label="@ControlsStringsLoc[nameof(ControlsStrings.LabelAll)]"
ThreeState="true"
ShowIndeterminate="false"
onkeydown="e => console.log(e)"
ThreeStateOrderUncheckToIntermediate="true"
@bind-CheckState:get="@AreAllTypesVisible()"
@bind-CheckState:set="@OnAllResourceTypesCheckedChanged"
@bind-CheckState:set="@OnAllResourceTypesCheckedChangedAsync"
/>
@foreach (var (resourceType, _) in AllResourceTypes)
{
Expand All @@ -33,7 +32,7 @@
public required ConcurrentDictionary<string,bool> VisibleResourceTypes { get; set; }

[Parameter, EditorRequired]
public required Action<bool?> OnAllResourceTypesCheckedChanged { get; set; }
public required Func<bool?, Task> OnAllResourceTypesCheckedChangedAsync { get; set; }

[Parameter, EditorRequired]
public required Func<string, bool,Task> OnResourceTypeVisibilityChangedAsync { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions src/Aspire.Dashboard/Components/Pages/Resources.razor
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<SelectResourceTypes
AllResourceTypes="_allResourceTypes"
VisibleResourceTypes="_visibleResourceTypes"
OnAllResourceTypesCheckedChanged="@(b => AreAllTypesVisible = b)"
OnAllResourceTypesCheckedChangedAsync="@OnAllResourceTypesCheckedChangedAsync"
AreAllTypesVisible="@(() => AreAllTypesVisible)"
OnResourceTypeVisibilityChangedAsync="@OnResourceTypeVisibilityChangedAsync" />
</div>
Expand All @@ -62,7 +62,7 @@
<SelectResourceTypes
AllResourceTypes="_allResourceTypes"
VisibleResourceTypes="_visibleResourceTypes"
OnAllResourceTypesCheckedChanged="@(b => AreAllTypesVisible = b)"
OnAllResourceTypesCheckedChangedAsync="@OnAllResourceTypesCheckedChangedAsync"
AreAllTypesVisible="@(() => AreAllTypesVisible)"
OnResourceTypeVisibilityChangedAsync="@OnResourceTypeVisibilityChangedAsync" />
</Body>
Expand Down Expand Up @@ -97,7 +97,7 @@
@{
var indent = context.Depth * 16;
}
<span style="margin-left: @(indent)px;">
<span class="resources-name-container" style="margin-left: @(indent)px;">
<span @onclick:stopPropagation="true" class="main-grid-expand-container @(context.IsCollapsed ? "main-grid-collapsed" : "main-grid-expanded")">
@if (context.Children.Count > 0)
{
Expand Down
11 changes: 9 additions & 2 deletions src/Aspire.Dashboard/Components/Pages/Resources.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ public partial class Resources : ComponentBase, IAsyncDisposable

private bool Filter(ResourceViewModel resource) => _visibleResourceTypes.ContainsKey(resource.ResourceType) && (_filter.Length == 0 || resource.MatchesFilter(_filter)) && !resource.IsHiddenState();

private Task OnResourceTypeVisibilityChangedAsync(string resourceType, bool isVisible)
private async Task OnAllResourceTypesCheckedChangedAsync(bool? areAllTypesVisible)
{
AreAllTypesVisible = areAllTypesVisible;
await _dataGrid.SafeRefreshDataAsync();
}

private async Task OnResourceTypeVisibilityChangedAsync(string resourceType, bool isVisible)
{
if (isVisible)
{
Expand All @@ -80,7 +86,8 @@ private Task OnResourceTypeVisibilityChangedAsync(string resourceType, bool isVi
_visibleResourceTypes.TryRemove(resourceType, out _);
}

return ClearSelectedResourceAsync();
await ClearSelectedResourceAsync();
await _dataGrid.SafeRefreshDataAsync();
}

private Task HandleSearchFilterChangedAsync()
Expand Down
9 changes: 9 additions & 0 deletions src/Aspire.Dashboard/Components/Pages/Resources.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,12 @@
::deep fluent-data-grid {
overflow-x: clip;
}

::deep .resources-name-container {
height: 24px;
display: inline-block;
}

::deep .resource-name-text {
vertical-align: middle;
}
2 changes: 1 addition & 1 deletion src/Aspire.Dashboard/Components/Pages/TraceDetail.razor
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
}
}

<span style="margin-left: @(marginLeft)px;">
<span class="span-overview-container" style="margin-left: @(marginLeft)px;">
<span @onclick:stopPropagation="true" class="main-grid-expand-container @(context.IsCollapsed ? "main-grid-collapsed" : "main-grid-expanded")">
@if (context.Children.Count > 0)
{
Expand Down
8 changes: 6 additions & 2 deletions src/Aspire.Dashboard/Components/Pages/TraceDetail.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
}

::deep .span-name-container {
margin-left: -3px;
line-height: 28px;
vertical-align: middle;
}

::deep .span-container {
Expand Down Expand Up @@ -146,3 +145,8 @@
white-space: nowrap;
overflow: hidden;
}

::deep .span-overview-container {
height: 24px;
display: inline-block;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@inject IStringLocalizer<Columns> Loc

<span title="@FormatName(Resource)"><FluentHighlighter HighlightedText="@FilterText" Text="@FormatName(Resource)" /></span>
<span class="resource-name-text" title="@FormatName(Resource)"><FluentHighlighter HighlightedText="@FilterText" Text="@FormatName(Resource)" /></span>

@if (Resource.Properties.TryGetValue(KnownProperties.Container.Lifetime, out var value) &&
value.Value.HasStringValue &&
Expand Down
14 changes: 13 additions & 1 deletion src/Aspire.Dashboard/Model/ResourceGridViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static List<ResourceGridViewModel> OrderNestedResources(List<ResourceGrid
var gridViewModels = new List<ResourceGridViewModel>();
var depth = 0;

foreach (var gridVM in initialGridVMs.Where(r => r.Resource.GetResourcePropertyValue(KnownProperties.Resource.ParentName) is null))
foreach (var gridVM in initialGridVMs.Where(r => !HasParent(r)))
{
gridVM.Depth = depth;
gridVM.IsCollapsed = isCollapsed(gridVM.Resource);
Expand All @@ -70,5 +70,17 @@ void AddChildViewModel(ResourceViewModel resource, ResourceGridViewModel parent,
AddChildViewModel(childGridVM.Resource, childGridVM, depth + 1, hidden: childGridVM.IsHidden || childGridVM.IsCollapsed);
}
}

bool HasParent(ResourceGridViewModel gridViewModel)
{
var parentName = gridViewModel.Resource.GetResourcePropertyValue(KnownProperties.Resource.ParentName);
if (string.IsNullOrEmpty(parentName))
{
return false;
}

// Check that the name matches to a resource. Handle the situation where the parent resource is filtered out.
return initialGridVMs.Any(r => r.Resource.Name == parentName);
}
}
}

0 comments on commit 868759f

Please sign in to comment.