Merge pull request 'adding a basic page to dump sources' (#2) from features/list-sources into main

Reviewed-on: #2
This commit is contained in:
jtom38 2023-06-12 13:17:21 -07:00
commit f77481152f
2 changed files with 32 additions and 2 deletions

View File

@ -4,5 +4,4 @@ public static class Global
{ {
public static HttpClient HttpClient { get; set; } public static HttpClient HttpClient { get; set; }
public static string? DefaultInstanceUri { get; set; } public static string? DefaultInstanceUri { get; set; }
} }

View File

@ -1,6 +1,37 @@
@page "/sources/list" @page "/sources/list"
<h3>list</h3> @using Newsbot.Collector.Client
@using Newsbot.Collector.Client.Domain.Dto
<h3>Available Sources</h3>
<table>
<tr>
<td>Title</td>
<td>Publish Date</td>
</tr>
@foreach (var item in Data ??= new List<SourcesDto>())
{
if (!item.Enabled)
{
continue;
}
<tr>
<td>
<a href="@item.Url" target="_blank">@item.Name</a><br/>
</td>
<td>@item.Source</td>
</tr>
}
</table>
@code { @code {
private List<SourcesDto> Data { get; set; }
protected override async Task OnInitializedAsync()
{
var c = new SourcesClient(Global.HttpClient, Global.DefaultInstanceUri ?? "");
var items = await c.ListAsync();
Data = items;
}
} }