-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Dashboard diagnostics * add highlight.js
- Loading branch information
1 parent
ea96a2b
commit 0af24c5
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
src/Proto.Cluster.Dashboard/Pages/ClusterDiagnostics.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters