Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add visible labels to resource select component and filter dialog #3727

Merged
merged 7 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<FluentDataGrid Items="@Queryable.AsQueryable(ChartViewModel.DimensionFilters)" GridTemplateColumns="200px 1fr auto" GenerateHeader="GenerateHeaderOption.None">
<ChildContent>
<PropertyColumn Tooltip="true" TooltipText="@(c => c.Name)" Property="@(c => c.Name)"/>
<TemplateColumn Tooltip="true" TooltipText="@(c => c.SelectedValues.Count == 0 ? Loc[nameof(ControlsStrings.ChartContainerNoneSelected)] : string.Join(", ", c.SelectedValues.Select(v => v.Name)))">
<TemplateColumn Tooltip="true" TooltipText="@(c => c.SelectedValues.Count == 0 ? Loc[nameof(ControlsStrings.None)] : string.Join(", ", c.SelectedValues.Select(v => v.Name)))">
<FluentOverflow Class="dimension-overflow">
<ChildContent>
@if (context.SelectedValues.Count == 0)
{
<FluentBadge>@Loc[nameof(ControlsStrings.ChartContainerNoneSelected)]</FluentBadge>
<FluentBadge>@Loc[nameof(ControlsStrings.None)]</FluentBadge>
}
else
{
Expand Down
8 changes: 8 additions & 0 deletions src/Aspire.Dashboard/Components/Controls/ResourceSelect.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
@using Aspire.Dashboard.Resources

@inject IStringLocalizer<ControlsStrings> Loc

<FluentInputLabel
Label="@Loc[nameof(ControlsStrings.SelectAResource)]"
ForId="@_selectId"
Orientation="Orientation.Horizontal" />

<FluentSelect @ref="_resourceSelectComponent"
Items="Resources"
Id="@_selectId"
OptionValue="@(c => c!.Name)"
OptionDisabled="@(c => c!.Id?.Type is Otlp.Model.OtlpApplicationType.ReplicaSet)"
SelectedOption="SelectedResource"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public partial class ResourceSelect
private const int MaxVisibleResourceOptions = 15;
private const int SelectPadding = 8; // 4px top + 4px bottom

private readonly string _selectId = $"resource-select-{Guid.NewGuid():N}";

[Parameter]
public IEnumerable<SelectViewModel<ResourceTypeDetails>> Resources { get; set; } = default!;

Expand Down
37 changes: 25 additions & 12 deletions src/Aspire.Dashboard/Components/Dialogs/FilterDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,33 @@
<EditForm EditContext="@EditContext" OnValidSubmit="@Apply">
<DataAnnotationsValidator />

<FluentStack Orientation="Orientation.Vertical" VerticalGap="8">
<FluentCombobox TOption="SelectViewModel<string>"
Placeholder="@Loc[nameof(Dialogs.FilterDialogFieldPlaceholder)]"
Items="@_parameters"
@bind-SelectedOption="@_formModel.Parameter"
Width="100%"
Height="500px"
OptionText="@(c => c.Name)"
OptionDisabled="@(c => c.Id is null)" />
<FluentStack Orientation="Orientation.Vertical" VerticalGap="12">
<div class="filter-input-container">
<FluentCombobox TOption="SelectViewModel<string>"
Placeholder="@Loc[nameof(Dialogs.FilterDialogFieldPlaceholder)]"
Label="@Loc[nameof(Dialogs.FilterDialogParameterInputLabel)]"
Items="@_parameters"
@bind-SelectedOption="@_formModel.Parameter"
Width="100%"
Height="500px"
OptionText="@(c => c.Name)"
OptionDisabled="@(c => c.Id is null)" />
</div>

<FluentSelect TOption="SelectViewModel<FilterCondition>" Items="@_filterConditions" @bind-SelectedOption="@_formModel.Condition" aria-label="@Loc[Dialogs.FilterDialogConditionSelectLabel]" OptionText="@(i => i.Name)" Width="100%" />
<div class="filter-input-container">
<FluentSelect TOption="SelectViewModel<FilterCondition>"
Items="@_filterConditions"
@bind-SelectedOption="@_formModel.Condition"
Label="@Loc[nameof(Dialogs.FilterDialogConditionInputLabel)]"
OptionText="@(i => i.Name)"
Width="100%" />
</div>

<FluentTextField @bind-Value="_formModel.Value" Placeholder="@Loc[nameof(Dialogs.FilterDialogTextValuePlaceholder)]" />
<ValidationMessage For="() => _formModel.Value" />
<div class="filter-input-container">
<FluentTextField @bind-Value="_formModel.Value"
Label="@Loc[nameof(Dialogs.FilterDialogTextValuePlaceholder)]" />
<ValidationMessage For="() => _formModel.Value" />
</div>

<FluentStack Orientation="Orientation.Horizontal" HorizontalAlignment="HorizontalAlignment.Right">
<FluentButton OnClick="Cancel">@Loc[nameof(Dialogs.FilterDialogCancelButtonText)]</FluentButton>
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public sealed partial class ConsoleLogs : ComponentBase, IAsyncDisposable, IPage

protected override async Task OnInitializedAsync()
{
_noSelection = new() { Id = null, Name = ControlsStringsLoc[nameof(ControlsStrings.SelectAResource)] };
_noSelection = new() { Id = null, Name = ControlsStringsLoc[nameof(ControlsStrings.None)] };
PageViewModel = new ConsoleLogsViewModel { SelectedOption = _noSelection, SelectedResource = null, Status = Loc[nameof(Dashboard.Resources.ConsoleLogs.ConsoleLogsLoadingResources)] };

var loadingTcs = new TaskCompletionSource();
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Dashboard/Components/Pages/Metrics.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected override Task OnInitializedAsync()
_selectApplication = new SelectViewModel<ResourceTypeDetails>
{
Id = null,
Name = ControlsStringsLoc[ControlsStrings.SelectAResource]
Name = ControlsStringsLoc[ControlsStrings.None]
};

PageViewModel = new MetricsViewModel
Expand Down
4 changes: 2 additions & 2 deletions src/Aspire.Dashboard/Components/Pages/StructuredLogs.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ protected override Task OnInitializedAsync()
_allApplication = new()
{
Id = null,
Name = Loc[nameof(Dashboard.Resources.ControlsStrings.All)]
Name = ControlsStringsLoc[nameof(Dashboard.Resources.ControlsStrings.All)]
};

_logLevels = new List<SelectViewModel<LogLevel?>>
{
new SelectViewModel<LogLevel?> { Id = null, Name = $"({Loc[nameof(Dashboard.Resources.ControlsStrings.All)]})" },
new SelectViewModel<LogLevel?> { Id = null, Name = ControlsStringsLoc[nameof(Dashboard.Resources.ControlsStrings.All)] },
new SelectViewModel<LogLevel?> { Id = LogLevel.Trace, Name = "Trace" },
new SelectViewModel<LogLevel?> { Id = LogLevel.Debug, Name = "Debug" },
new SelectViewModel<LogLevel?> { Id = LogLevel.Information, Name = "Information" },
Expand Down
2 changes: 1 addition & 1 deletion src/Aspire.Dashboard/Components/Pages/Traces.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ await MessageService.ShowMessageBarAsync(options =>

protected override Task OnInitializedAsync()
{
_allApplication = new SelectViewModel<ResourceTypeDetails> { Id = null, Name = $"({ControlsStringsLoc[nameof(ControlsStrings.All)]})" };
_allApplication = new SelectViewModel<ResourceTypeDetails> { Id = null, Name = ControlsStringsLoc[nameof(ControlsStrings.All)] };
PageViewModel = new TracesPageViewModel { SelectedApplication = _allApplication };

UpdateApplications();
Expand Down
Loading