Added changelog component

This commit is contained in:
Thorsten Sommer 2024-06-02 20:52:30 +02:00
parent cac0ecc7e2
commit df8f207e7f
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,23 @@
namespace AIStudio.Components.Blocks;
public partial class Changelog
{
public readonly record struct Log(int Build, string Display, string Filename)
{
#region Overrides of ValueType
public override string ToString() => this.Display;
#endregion
}
public static readonly Log[] LOGS =
[
new (149, "v0.5.0, build 149 (2024-06-?? ??:?? UTC)", "v0.5.0.md"),
new (138, "v0.4.0, build 138 (2024-05-26 13:26 UTC)", "v0.4.0.md"),
new (120, "v0.3.0, build 120 (2024-05-18 21:57 UTC)", "v0.3.0.md"),
new (90, "v0.2.0, build 90 (2024-05-04 10:50 UTC)", "v0.2.0.md"),
new (45, "v0.1.0, build 45 (2024-04-20 21:27 UTC)", "v0.1.0.md"),
];
}

View File

@ -0,0 +1,9 @@
@using AIStudio.Tools
<MudSelect T="Log" @bind-Value="@this.SelectedLog" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Schedule" Margin="Margin.Dense" Label="Changelog" Class="mb-2 rounded-lg" Variant="Variant.Outlined" SelectedValuesChanged="() => this.ReadLogAsync()" OnKeyUp="() => this.ReadLogAsync()">
@foreach (var log in LOGS)
{
<MudSelectItem Value="@log"/>
}
</MudSelect>
<MudMarkdown Value="@this.LogContent" OverrideHeaderTypo="@Markdown.OverrideHeaderTypo"/>

View File

@ -0,0 +1,29 @@
using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks;
public partial class Changelog : ComponentBase
{
[Inject]
private HttpClient HttpClient { get; set; } = null!;
#region Overrides of ComponentBase
protected override async Task OnInitializedAsync()
{
await this.ReadLogAsync();
await base.OnInitializedAsync();
}
#endregion
private Log SelectedLog { get; set; } = LOGS.MaxBy(n => n.Build);
private string LogContent { get; set; } = string.Empty;
private async Task ReadLogAsync()
{
var response = await this.HttpClient.GetAsync($"changelog/{this.SelectedLog.Filename}");
this.LogContent = await response.Content.ReadAsStringAsync();
}
}