Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
72 changes: 38 additions & 34 deletions src/Aspire.Dashboard/Components/Pages/SemanticLogs.razor
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,37 @@
}
<FluentButton slot="end" Appearance="Appearance.Stealth" aria-label="Add Filter" OnClick="() => OpenFilterAsync(null)"><FluentIcon Value="@(new Icons.Regular.Size16.Filter())" /></FluentButton>
</FluentToolbar>
<div class="datagrid-overflow-area SemanticLogsOverflow" tabindex="-1">
<div class="datagrid-overflow-area continuous-scroll-overflow" tabindex="-1">
<FluentDataGrid Class="SemanticLogsDataGrid" Virtualize="true" GenerateHeader="GenerateHeaderOption.Sticky" ItemSize="48" ResizableColumns="true" ItemsProvider="@GetData" TGridItem="OtlpLogEntry" GridTemplateColumns="1fr 1fr 1fr 5fr 0.8fr 0.8fr">
<ChildContent>
<TemplateColumn Title="Service">
<span style="padding-left:5px; border-left-width: 5px; border-left-style: solid; border-left-color: @ColorGenerator.Instance.GetColorHexByKey(context.Application.ApplicationName);">
@context.Application.ApplicationName
</span>
</TemplateColumn>
<PropertyColumn Title="Severity" Property="@(context => context.Severity)" />
<PropertyColumn Title="Timestamp" Property="@(context => OtlpHelpers.FormatTimeStamp(context.TimeStamp))" />
<PropertyColumn Title="Message" Tooltip=true Property="@(context => context.Message)" />
<TemplateColumn Title="Trace">
@if (!string.IsNullOrEmpty(context.TraceId))
{
<FluentAnchor Appearance="Appearance.Hypertext" Href="@($"/Traces/Trace/{HttpUtility.UrlEncode(context.TraceId)}")">
@OtlpHelpers.ToShortenedId(context.TraceId)
</FluentAnchor>
}
</TemplateColumn>
<TemplateColumn>
<FluentButton Appearance="Appearance.Lightweight" OnClick="() => OnShowProperties(context)">View</FluentButton>
</TemplateColumn>
</ChildContent>
<EmptyContent>
<FluentIcon Icon="Icons.Regular.Size24.SlideTextSparkle" />&nbsp;No semantic logs found
</EmptyContent>
</FluentDataGrid>
</div>
<TotalItemsFooter @ref="totalItemsFooter" />
}
</FluentStack>
</div>
}
<ChildContent>
<TemplateColumn Title="Service">
<span style="padding-left:5px; border-left-width: 5px; border-left-style: solid; border-left-color: @(ColorGenerator.Instance.GetColorHexByKey(context.Application.ApplicationName));">
@context.Application.ApplicationName
</span>
</TemplateColumn>
<PropertyColumn Title="Severity" Property="@(context => context.Severity)" />
<PropertyColumn Title="Timestamp" Property="@(context => OtlpHelpers.FormatTimeStamp(context.TimeStamp))" />
<PropertyColumn Title="Message" Tooltip=true Property="@(context => context.Message)" />
<TemplateColumn Title="Trace">
@if (!string.IsNullOrEmpty(context.TraceId))
{
<FluentAnchor Appearance="Appearance.Hypertext" Href="@($"/Traces/Trace/{HttpUtility.UrlEncode(context.TraceId)}")">
@OtlpHelpers.ToShortenedId(context.TraceId)
</FluentAnchor>
}
</TemplateColumn>
<TemplateColumn>
<FluentButton Appearance="Appearance.Lightweight" OnClick="() => OnShowProperties(context)">View</FluentButton>
</TemplateColumn>
</ChildContent>
<EmptyContent>
<FluentIcon Icon="Icons.Regular.Size24.SlideTextSparkle" />&nbsp;No semantic logs found
</EmptyContent>
</FluentDataGrid>
</div>
<TotalItemsFooter @ref="totalItemsFooter" />
</FluentStack>
</div>

@code {
private static readonly ApplicationViewModel AllApplication = new ApplicationViewModel { Id = null, Name = "(All)" };
Expand Down Expand Up @@ -142,6 +140,7 @@
_applications = TelemetryRepository.GetApplications().Select(a => new ApplicationViewModel { Id = a.InstanceId, Name = a.ApplicationName }).ToList();
_applications.Insert(0, AllApplication);
_selectedApplication = _applications.SingleOrDefault(e => e.Id == ApplicationInstanceId) ?? AllApplication;
UpdateSubscription();

return Task.CompletedTask;
}
Expand All @@ -150,6 +149,8 @@
{
NavigationManager.NavigateTo($"/SemanticLogs/{_selectedApplication.Id}");
_applicationChanged = true;
UpdateSubscription();

return Task.CompletedTask;
}

Expand Down Expand Up @@ -225,10 +226,13 @@
{
if (_applicationChanged)
{
await JS.InvokeVoidAsync("switchLogsApplication");
await JS.InvokeVoidAsync("resetContinuousScrollPosition");
_applicationChanged = false;
}
await JS.InvokeVoidAsync("scollToLogsEnd");
if (firstRender)
{
await JS.InvokeVoidAsync("initializeContinuousScroll");
}
}

public void Dispose()
Expand Down
7 changes: 4 additions & 3 deletions src/Aspire.Dashboard/Components/Pages/Traces.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@bind-SelectedOption="_selectedApplication"
@bind-SelectedOption:after="HandleSelectedApplicationChangedAsync" />
</FluentToolbar>
<div class="datagrid-overflow-area SemanticLogsOverflow" tabindex="-1">
<div class="datagrid-overflow-area continuous-scroll-overflow" tabindex="-1">
<FluentDataGrid Class="SemanticLogsDataGrid" Virtualize="true" RowStyle="@GetRowStyle" GenerateHeader="GenerateHeaderOption.Sticky" ItemSize="48" ResizableColumns="true" ItemsProvider="@GetData" TGridItem="OtlpTrace" GridTemplateColumns="0.8fr 2fr 3fr 0.5fr 0.5fr">
<ChildContent>
<PropertyColumn Title="Timestamp" Property="@(context => OtlpHelpers.FormatTimeStamp(context.FirstSpan.StartTime))" />
Expand Down Expand Up @@ -138,6 +138,7 @@
_applications = TelemetryRepository.GetApplications().Select(a => new ApplicationViewModel { Id = a.InstanceId, Name = a.ApplicationName }).ToList();
_applications.Insert(0, AllApplication);
_selectedApplication = _applications.SingleOrDefault(e => e.Id == ApplicationInstanceId) ?? AllApplication;
UpdateSubscription();

return Task.CompletedTask;
}
Expand Down Expand Up @@ -171,10 +172,10 @@
{
if (_applicationChanged)
{
await JS.InvokeVoidAsync("switchLogsApplication");
await JS.InvokeVoidAsync("resetContinuousScrollPosition");
_applicationChanged = false;
}
await JS.InvokeVoidAsync("scollToLogsEnd");
await JS.InvokeVoidAsync("initializeContinuousScroll");
}

public void Dispose()
Expand Down
4 changes: 2 additions & 2 deletions src/Aspire.Dashboard/wwwroot/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fluent-toolbar[orientation=horizontal] {
width: 100%;
overflow: auto;
}
.datagrid-overflow-area fluent-data-grid {
.datagrid-overflow-area .empty-content {
width: 100%;
height: 100%;
height: 100px;
}
13 changes: 7 additions & 6 deletions src/Aspire.Dashboard/wwwroot/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ window.scrollToEndInTextArea = function (classSelector) {

let isScrolledToContent = false;

window.switchLogsApplication = function () {
window.resetContinuousScrollPosition = function () {
// Reset to scrolling to the end of the content after switching.
isScrolledToContent = false;
}

window.scollToLogsEnd = function () {
const container = document.querySelector('.SemanticLogsOverflow');
const grid = document.querySelector('.SemanticLogsDataGrid');
if (container == null || grid == null) {
window.initializeContinuousScroll = function () {
const container = document.querySelector('.continuous-scroll-overflow');
if (container == null) {
return;
}

Expand All @@ -50,7 +49,9 @@ window.scollToLogsEnd = function () {
container.scrollTop = container.scrollHeight;
}
});
observer.observe(grid);
for (const child of container.children) {
observer.observe(child);
}
};

function isScrolledToBottom(container) {
Expand Down