Iceshrimp.NET/Iceshrimp.Frontend/Pages/Settings/About.razor
2024-09-13 21:44:31 +02:00

56 lines
No EOL
1.8 KiB
Text

@page "/settings/about"
@using System.Text
@using Iceshrimp.Frontend.Core.InMemoryLogger
@using Iceshrimp.Frontend.Core.Services
@using Iceshrimp.Frontend.Localization
@using Microsoft.AspNetCore.Authorization
@using Microsoft.Extensions.Localization
@attribute [Authorize]
@layout SettingsLayout;
@inject VersionService Version;
@inject IStringLocalizer<Localization> Loc;
@inject IJSRuntime Js;
@inject InMemoryLogService LogService;
<div class="version">
<h1>@Loc["Version Information"]</h1>
<span class="name">Iceshrimp.NET</span>
<span class="value">
<code>@Version.Version</code>
</span>
<span class="name">Codename</span>
<span class="value">
<code>@Version.Codename</code>
</span>
@if (Version.CommitHash != null)
{
<span class="name">Commit</span>
<span class="value">
<code>@Version.CommitHash</code>
</span>
}
<span class="name">.NET Runtime</span>
<span class="value">
<code>@Environment.Version</code>
</span>
</div>
<div class="logs">
<h1>@Loc["Logs"]</h1>
@Loc["These logs may contain sensitive information, please do not post them publicly.\n" + "Providing them to developers upon request may help with debugging."]
<button class="btn" @onclick="DownloadLogs">@Loc["Download Logs"]</button>
</div>
@code {
private IJSInProcessObjectReference _module = null!;
protected override async Task OnInitializedAsync()
{
_module = (IJSInProcessObjectReference)await Js.InvokeAsync<IJSObjectReference>("import", "./Components/ErrorUi.razor.js");
}
private void DownloadLogs()
{
var logBytes = LogService.GetLogs().SelectMany(p => Encoding.UTF8.GetBytes(p)).ToArray();
_module.InvokeVoid("DownloadFile", "log.txt", "text/plain", logBytes);
}
}