Skip to content

Commit

Permalink
Dashboard diagnostics (#1830)
Browse files Browse the repository at this point in the history
* Dashboard diagnostics
* add highlight.js
  • Loading branch information
rogeralsing authored Oct 22, 2022
1 parent ea96a2b commit 0af24c5
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/Proto.Cluster.Dashboard/Pages/ClusterDiagnostics.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@page "/ClusterDiagnostics"
@using Proto.Diagnostics
@using System.Text.Json
@inject ActorSystem System
@inject IJSRuntime JS
<PageTitle>Cluster Diagnostics</PageTitle>

@if (_diagnostics is not null)
{
<MudTable T="DiagnosticsEntry" Items="_diagnostics.OrderBy(e => e.Module).ThenBy(e => e.Message)">
<HeaderContent>
<MudTh>Module</MudTh>
<MudTh>Message</MudTh>
<MudTh>Data</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Nr">@context.Module</MudTd>
<MudTd DataLabel="Sign">@context.Message</MudTd>
<MudTd DataLabel="Name">
@if (context.Data is not null)
{
<pre>
<code class="language-json">@AsJson(context.Data)</code>
</pre>
}
</MudTd>
</RowTemplate>
</MudTable>
}

@code {
private DiagnosticsEntry[]? _diagnostics;

protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();

_diagnostics = await System.Diagnostics.GetDiagnostics();
}

private string AsJson(object? data)
{
if (data is null)
{
return "";
}
var res = JsonSerializer.Serialize(data, new JsonSerializerOptions()
{
WriteIndented = true
});
return res;
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
await JS.InvokeAsync<string>("hljs.highlightAll");
}

protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);

}

}
10 changes: 10 additions & 0 deletions src/Proto.Cluster.Dashboard/Pages/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet"/>
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet"/>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
<link rel="stylesheet"
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/styles/default.min.css">

<link rel="stylesheet" href="https://highlightjs.org/static/demo/styles/atom-one-dark.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/highlight.min.js"></script>


</head>
<body>

Expand All @@ -30,4 +37,7 @@

<script src="_framework/blazor.server.js"></script>
</body>
<script>
hljs.highlightAll();
</script>
</html>
1 change: 1 addition & 0 deletions src/Proto.Cluster.Dashboard/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<MudThemeProvider Theme="@MyCustomTheme" IsDarkMode="@_dark"/>
<MudDialogProvider/>
<MudSnackbarProvider/>

<style>
.mud-drawer-mini {
Expand Down
1 change: 1 addition & 0 deletions src/Proto.Cluster.Dashboard/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<MudNavLink Href="ClusterOverview" Match="NavLinkMatch.Prefix" Icon="@Icons.Filled.BarChart">Cluster Overview</MudNavLink>
<MudNavLink Href="ClusterState" Match="NavLinkMatch.Prefix" Icon="@Icons.Filled.RemoveRedEye">Cluster State</MudNavLink>
<MudNavLink Href="ActorDiagram" Match="NavLinkMatch.Prefix" Icon="@Icons.Filled.AccountTree">Actors</MudNavLink>
<MudNavLink Href="ClusterDiagnostics" Match="NavLinkMatch.Prefix" Icon="@Icons.Filled.Medication">Diagnostics</MudNavLink>
</MudNavMenu>

0 comments on commit 0af24c5

Please sign in to comment.