Skip to content

Commit 0b5fd1f

Browse files
JamesNKCopilot
andauthored
Add more icons to dashboard property values (#10767)
* Add more icons to dashboard property values * More * Update src/Aspire.Dashboard/Model/TraceHelpers.cs Co-authored-by: Copilot <[email protected]> * Relationship icons --------- Co-authored-by: Copilot <[email protected]>
1 parent 907688e commit 0b5fd1f

File tree

13 files changed

+144
-32
lines changed

13 files changed

+144
-32
lines changed

src/Aspire.Dashboard/Components/Controls/PropertyValues/ResourceNameValue.razor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public partial class ResourceNameValue
1111
[Parameter, EditorRequired]
1212
public required string Value { get; set; }
1313

14-
[Parameter, EditorRequired]
15-
public required string HighlightText { get; set; }
14+
[Parameter]
15+
public string? HighlightText { get; set; }
1616

1717
[Parameter, EditorRequired]
1818
public required ResourceViewModel Resource { get; set; }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@using Aspire.Dashboard.Utils
2+
3+
@* Do this to trim significant whitespace so there isn't a space added between icon and text *@
4+
@{
5+
<FluentIcon Icon="Icons.Regular.Size16.GanttChart" Color="Color.Neutral" Class="severity-icon" />
6+
}
7+
<FluentHighlighter HighlightedText="@HighlightText" Text="@Value" />
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Microsoft.AspNetCore.Components;
5+
6+
namespace Aspire.Dashboard.Components.Controls.PropertyValues;
7+
8+
public partial class SpanIdValue
9+
{
10+
[Parameter, EditorRequired]
11+
public required string Value { get; set; }
12+
13+
[Parameter, EditorRequired]
14+
public required string HighlightText { get; set; }
15+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@using Aspire.Dashboard.Utils
2+
3+
@if (_icon != null)
4+
{
5+
<FluentIcon Value="@_icon" Color="Color.Neutral" Class="severity-icon" />
6+
}
7+
8+
<FluentHighlighter HighlightedText="@HighlightText" Text="@Value" />
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Aspire.Dashboard.Model;
5+
using Aspire.Dashboard.Otlp.Model;
6+
using Microsoft.AspNetCore.Components;
7+
using Microsoft.FluentUI.AspNetCore.Components;
8+
9+
namespace Aspire.Dashboard.Components.Controls.PropertyValues;
10+
11+
public partial class SpanKindValue
12+
{
13+
private Icon? _icon;
14+
15+
[Parameter, EditorRequired]
16+
public required string Value { get; set; }
17+
18+
[Parameter, EditorRequired]
19+
public required string HighlightText { get; set; }
20+
21+
[Parameter, EditorRequired]
22+
public required OtlpSpan Span { get; set; }
23+
24+
protected override void OnParametersSet()
25+
{
26+
_icon = TraceHelpers.TryGetSpanIcon(Span, IconVariant.Regular);
27+
}
28+
}

src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@using Aspire.Dashboard.Components.Controls.Grid
2+
@using Aspire.Dashboard.Components.Controls.PropertyValues
23
@using Aspire.Dashboard.Model
34
@using Aspire.Dashboard.Resources
45
@using Aspire.Dashboard.Utils
@@ -165,13 +166,13 @@
165166
GridTemplateColumns="1fr 1fr 0.5fr"
166167
ShowHover="true">
167168
<TemplateColumn Title="@ControlStringsLoc[nameof(ControlsStrings.ResourceDetailsResourceHeader)]">
168-
@context.ResourceName
169+
<ResourceNameValue Resource="@context.Resource" Value="@context.ResourceName" FormatName="@FormatName" />
169170
</TemplateColumn>
170171
<TemplateColumn Title="@ControlStringsLoc[nameof(ControlsStrings.ResourceDetailsTypeHeader)]" TooltipText="@(c => string.Join(", ", c.Types))">
171172
@string.Join(", ", context.Types)
172173
</TemplateColumn>
173174
<TemplateColumn Title="@ControlStringsLoc[nameof(ControlsStrings.ViewAction)]" Class="no-ellipsis">
174-
<FluentButton Appearance="Appearance.Lightweight" OnClick="@(() => OnViewRelationshipAsync(context))">@ControlStringsLoc[nameof(ControlsStrings.ViewAction)]</FluentButton>
175+
<FluentButton Appearance="Appearance.Lightweight" Class="button-hyperlink-no-icon" OnClick="@(() => OnViewRelationshipAsync(context))">@ControlStringsLoc[nameof(ControlsStrings.ViewAction)]</FluentButton>
175176
</TemplateColumn>
176177
</FluentDataGrid>
177178
</FluentAccordionItem>
@@ -194,13 +195,13 @@
194195
GridTemplateColumns="1fr 1fr 0.5fr"
195196
ShowHover="true">
196197
<TemplateColumn Title="@ControlStringsLoc[nameof(ControlsStrings.ResourceDetailsResourceHeader)]">
197-
@context.ResourceName
198+
<ResourceNameValue Resource="@context.Resource" Value="@context.ResourceName" FormatName="@FormatName" />
198199
</TemplateColumn>
199200
<TemplateColumn Title="@ControlStringsLoc[nameof(ControlsStrings.ResourceDetailsTypeHeader)]" TooltipText="@(c => string.Join(", ", c.Types))">
200201
@string.Join(", ", context.Types)
201202
</TemplateColumn>
202203
<TemplateColumn Title="@ControlStringsLoc[nameof(ControlsStrings.ViewAction)]" Class="no-ellipsis">
203-
<FluentButton Appearance="Appearance.Lightweight" OnClick="@(() => OnViewRelationshipAsync(context))">@ControlStringsLoc[nameof(ControlsStrings.ViewAction)]</FluentButton>
204+
<FluentButton Appearance="Appearance.Lightweight" Class="button-hyperlink-no-icon" OnClick="@(() => OnViewRelationshipAsync(context))">@ControlStringsLoc[nameof(ControlsStrings.ViewAction)]</FluentButton>
204205
</TemplateColumn>
205206
</FluentDataGrid>
206207
</FluentAccordionItem>

src/Aspire.Dashboard/Components/Controls/ResourceDetails.razor.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ protected override void OnParametersSet()
158158
[KnownProperties.Resource.DisplayName] = new ComponentMetadata
159159
{
160160
Type = typeof(ResourceNameValue),
161-
Parameters = { ["Resource"] = _resource, ["FormatName"] = (ResourceViewModel r) => ResourceViewModel.GetResourceName(r, ResourceByName) }
161+
Parameters = { ["Resource"] = _resource, ["FormatName"] = new Func<ResourceViewModel, string>(FormatName) }
162162
},
163163
[KnownProperties.Resource.HealthState] = new ComponentMetadata
164164
{
@@ -293,6 +293,11 @@ private void OnValueMaskedChanged(IPropertyGridItem vm)
293293
}
294294
}
295295

296+
private string FormatName(ResourceViewModel resource)
297+
{
298+
return ResourceViewModel.GetResourceName(resource, ResourceByName);
299+
}
300+
296301
public Task OnViewRelationshipAsync(ResourceDetailRelationshipViewModel relationship)
297302
{
298303
NavigationManager.NavigateTo(DashboardUrls.ResourcesUrl(resource: relationship.Resource.Name));

src/Aspire.Dashboard/Components/Controls/SpanDetails.razor

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@
116116
@WriteSpanLink(context)
117117
</TemplateColumn>
118118
<TemplateColumn Title="@Loc[nameof(ControlsStrings.SpanDetailsDetailsColumnHeader)]">
119-
<FluentButton Appearance="Appearance.Lightweight" OnClick="@(() => OnViewDetailsAsync(context))">@Loc[nameof(ControlsStrings.ViewAction)]</FluentButton>
119+
<FluentButton OnClick="@(() => OnViewDetailsAsync(context))" Appearance="Appearance.Lightweight" Class="button-hyperlink" IconStart="new Icons.Regular.Size16.GanttChart()">
120+
@OtlpHelpers.ToShortenedId(context.SpanId)
121+
</FluentButton>
120122
</TemplateColumn>
121123
</FluentDataGrid>
122124
</FluentAccordionItem>
@@ -142,7 +144,9 @@
142144
@WriteSpanLink(context)
143145
</TemplateColumn>
144146
<TemplateColumn Title="@Loc[nameof(ControlsStrings.SpanDetailsDetailsColumnHeader)]">
145-
<FluentButton Appearance="Appearance.Lightweight" OnClick="@(() => OnViewDetailsAsync(context))">@Loc[nameof(ControlsStrings.ViewAction)]</FluentButton>
147+
<FluentButton OnClick="@(() => OnViewDetailsAsync(context))" Appearance="Appearance.Lightweight" Class="button-hyperlink" IconStart="new Icons.Regular.Size16.GanttChart()">
148+
@OtlpHelpers.ToShortenedId(context.SpanId)
149+
</FluentButton>
146150
</TemplateColumn>
147151
</FluentDataGrid>
148152
</FluentAccordionItem>

src/Aspire.Dashboard/Components/Controls/SpanDetails.razor.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ protected override void OnParametersSet()
140140
Type = typeof(SpanStatusValue),
141141
Parameters = { ["Span"] = _viewModel.Span }
142142
},
143+
[KnownTraceFields.KindField] = new ComponentMetadata
144+
{
145+
Type = typeof(SpanKindValue),
146+
Parameters = { ["Span"] = _viewModel.Span }
147+
},
148+
[KnownTraceFields.SpanIdField] = new ComponentMetadata
149+
{
150+
Type = typeof(SpanIdValue)
151+
},
143152
};
144153
}
145154
}

src/Aspire.Dashboard/Components/Pages/TraceDetail.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
<FluentIcon Class="span-kind-icon"
153153
Color="Color.Custom"
154154
CustomColor="@ColorGenerator.Instance.GetColorHexByKey(GetResourceName(context.Span.Source))"
155-
Value="@GetSpanIcon(context.Span)"/>
155+
Value="@TraceHelpers.TryGetSpanIcon(context.Span, IconVariant.Filled)"/>
156156
}
157157

158158
@if (context.IsError)

0 commit comments

Comments
 (0)