RBLNews/RBLNews.Shared/Components/Pages/Feeds.razor
2024-09-09 12:21:47 +02:00

68 lines
2.0 KiB
Plaintext

@page "/"
@using RBLFeederCommon.Models.RssFeed
@using RBLNews.Shared.Enums
@if (rssVM == null)
{
<div class="d-flex justify-content-center">
Lade Feeds ...
<Spinner Type="SpinnerType.Grow" Color="SpinnerColor.Primary" Size="SpinnerSize.Large" />
</div>
}
else
{
<div class="row">
@foreach (FeedGroupVM feedGrp in rssVM.FeedGroups)
{
<h3>@feedGrp.PublishDate</h3>
@foreach (FeedVM feed in feedGrp.Feeds)
{
<div class="col-sm-12 col-md-9 col-lg-6">
<Card>
<CardBody>
<CardTitle>@feed.Title</CardTitle>
<CardText>@feed.Description</CardText>
</CardBody>
<CardFooter>
@GetRssSourceName((RssFeedSources)@feed.Source) | @feed.PubDate <Button Color="ButtonColor.Primary" To="@feed.Link" Type="ButtonType.Link">Öffnen</Button>
</CardFooter>
</Card>
<br />
</div>
}
}
</div>
}
@code {
private RssVM rssVM;
HttpClient httpClient = new HttpClient();
protected async override Task OnInitializedAsync()
{
rssVM = await httpClient.GetFromJsonAsync<RssVM>("https://rblnews.de/api/feeds");
}
private string GetRssSourceName(RssFeedSources source)
{
switch (source)
{
case RssFeedSources.RbLive:
case RssFeedSources.NitterRbLive:
return "RBLive!";
case RssFeedSources.NitterFabrizioRomano:
return "Fabrizio Romano";
case RssFeedSources.Lvz:
return "LVZ";
case RssFeedSources.Kicker:
return "Kicker";
case RssFeedSources.Bild:
return "BILD";
case RssFeedSources.Transfermarkt:
return "Transfermarkt";
default:
return "?";
}
}
}