Skip to content

Commit 34b7c0e

Browse files
adamintdanmoseleyJamesNK
authored
Add pause warning to metrics (#9207)
Co-authored-by: Dan Moseley <[email protected]> Co-authored-by: James Newton-King <[email protected]>
1 parent b78fa30 commit 34b7c0e

38 files changed

+918
-500
lines changed

src/Aspire.Dashboard/Components/Controls/Chart/ChartContainer.razor

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ else
1515
<div class="metrics-chart-header">
1616
<h3>@_instrument.Summary.Name</h3>
1717
<p>@_instrument.Summary.Description</p>
18+
1819
@if (_instrument.HasOverflow)
1920
{
2021
<div class="block-warning">
@@ -51,5 +52,11 @@ else
5152
</div>
5253
</FluentTab>
5354
</FluentTabs>
55+
<div class="metrics-chart-footer">
56+
@if (PauseText is not null)
57+
{
58+
<PauseWarning PauseText="@PauseText" />
59+
}
60+
</div>
5461
</div>
5562
}

src/Aspire.Dashboard/Components/Controls/Chart/ChartContainer.razor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public partial class ChartContainer : ComponentBase, IAsyncDisposable
4343
[Parameter, EditorRequired]
4444
public required List<OtlpApplication> Applications { get; set; }
4545

46+
[Parameter, EditorRequired]
47+
public required string? PauseText { get; set; }
48+
4649
[Inject]
4750
public required TelemetryRepository TelemetryRepository { get; init; }
4851

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@using Aspire.Dashboard.Resources
2+
3+
@inject IStringLocalizer<ControlsStrings> Loc
4+
5+
<div class="block-warning">
6+
<div class="block-warning-icon">
7+
<FluentIcon Value="new Icons.Filled.Size16.Warning()" Color="Color.Warning" />
8+
</div>
9+
10+
<div class="block-warning-message">
11+
<span class="title">@Loc[nameof(ControlsStrings.PauseWarningTitle)]</span>
12+
@PauseText
13+
</div>
14+
</div>
15+
16+
@code {
17+
[Parameter, EditorRequired]
18+
public required string PauseText { get; set; }
19+
}

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,7 @@
99

1010
@if (PauseText is not null)
1111
{
12-
<div class="block-warning">
13-
<div class="block-warning-icon">
14-
<FluentIcon Value="new Icons.Filled.Size16.Warning()" Color="Color.Warning" />
15-
</div>
16-
17-
<div class="block-warning-message">
18-
<span class="title">@Loc[nameof(ControlsStrings.TotalItemsFooterCapturePaused)]</span>
19-
@PauseText
20-
</div>
21-
</div>
12+
<PauseWarning PauseText="@PauseText" />
2213
}
2314
</div>
2415

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@
108108
Duration="PageViewModel.SelectedDuration.Id"
109109
ActiveView="@(PageViewModel.SelectedViewKind ?? Metrics.MetricViewKind.Graph)"
110110
OnViewChangedAsync="@OnViewChangedAsync"
111-
Applications="@_applications" />
111+
Applications="@_applications"
112+
PauseText="@PauseText" />
112113
}
113114
else if (PageViewModel.SelectedMeter != null)
114115
{

src/Aspire.Dashboard/Components/Pages/Metrics.razor.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ public partial class Metrics : IDisposable, IComponentWithTelemetry, IPageWithSe
7070
[Inject]
7171
public required PauseManager PauseManager { get; init; }
7272

73+
[Inject]
74+
public required BrowserTimeProvider TimeProvider { get; init; }
75+
7376
[CascadingParameter]
7477
public required ViewportInformation ViewportInformation { get; init; }
7578

@@ -218,6 +221,13 @@ private Task HandleSelectedDurationChangedAsync()
218221
return this.AfterViewModelChangedAsync(_contentLayout, waitToApplyMobileChange: true);
219222
}
220223

224+
private string? PauseText => PauseManager.AreMetricsPaused(out var startTime)
225+
? string.Format(
226+
CultureInfo.CurrentCulture,
227+
Loc[nameof(Dashboard.Resources.Metrics.PauseInProgressText)],
228+
FormatHelpers.FormatTimeWithOptionalDate(TimeProvider, startTime.Value, MillisecondsDisplay.Truncated))
229+
: null;
230+
221231
public sealed class MetricsViewModel
222232
{
223233
public FluentTreeItem? SelectedTreeItem { get; set; }

src/Aspire.Dashboard/Components/Pages/Metrics.razor.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
grid-template-rows: auto 1fr;
2929
grid-template-areas:
3030
"header"
31-
"chart";
31+
"chart"
32+
"footer";
3233
width: 100%;
3334
gap: calc(var(--design-unit) * 4px);
3435
}
@@ -44,6 +45,11 @@
4445
overflow-x: hidden;
4546
}
4647

48+
::deep .metrics-chart-footer {
49+
grid-area: footer;
50+
margin-bottom: calc(var(--design-unit) * 4px);
51+
}
52+
4753
::deep .metrics-chart-header h3 {
4854
overflow: hidden;
4955
text-overflow: ellipsis;

src/Aspire.Dashboard/Components/Pages/Traces.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ private void OnBrowserResize(object? o, EventArgs args)
249249
private string? PauseText => PauseManager.AreTracesPaused(out var startTime)
250250
? string.Format(
251251
CultureInfo.CurrentCulture,
252-
Loc[nameof(Dashboard.Resources.StructuredLogs.PauseInProgressText)],
252+
Loc[nameof(Dashboard.Resources.Traces.PauseInProgressText)],
253253
FormatHelpers.FormatTimeWithOptionalDate(TimeProvider, startTime.Value, MillisecondsDisplay.Truncated))
254254
: null;
255255

0 commit comments

Comments
 (0)