show last update
This commit is contained in:
parent
fa6e8bf7cc
commit
12388b2c53
@ -1,4 +1,6 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using RBLNews.Shared.Services;
|
||||||
|
|
||||||
namespace RBLNews.Maui
|
namespace RBLNews.Maui
|
||||||
{
|
{
|
||||||
@ -17,6 +19,8 @@ namespace RBLNews.Maui
|
|||||||
builder.Services.AddMauiBlazorWebView();
|
builder.Services.AddMauiBlazorWebView();
|
||||||
builder.Services.AddBlazorBootstrap();
|
builder.Services.AddBlazorBootstrap();
|
||||||
|
|
||||||
|
builder.Services.AddSingleton<IFeedDataService, FeedDataService>();
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
builder.Services.AddBlazorWebViewDeveloperTools();
|
builder.Services.AddBlazorWebViewDeveloperTools();
|
||||||
builder.Logging.AddDebug();
|
builder.Logging.AddDebug();
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
|
|
||||||
<NavMenu />
|
<NavMenu />
|
||||||
|
|
||||||
<div class="page">
|
<div class="page">
|
||||||
|
|
||||||
|
|
||||||
@*<div class="sidebar">
|
@*<div class="sidebar">
|
||||||
<NavMenu />
|
<NavMenu />
|
||||||
</div> *@
|
</div> *@
|
||||||
@ -11,7 +10,6 @@
|
|||||||
@* <div class="top-row px-4">
|
@* <div class="top-row px-4">
|
||||||
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
|
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
|
||||||
</div> *@
|
</div> *@
|
||||||
|
|
||||||
<article class="content px-4">
|
<article class="content px-4">
|
||||||
@Body
|
@Body
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
@ -1,6 +1,15 @@
|
|||||||
<div class="top-row ps-3 navbar navbar-dark">
|
@using RBLNews.Shared.Services
|
||||||
|
|
||||||
|
@inject IFeedDataService feedDataService
|
||||||
|
|
||||||
|
<div class="top-row ps-3 navbar navbar-dark">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" href="">RBL News auf einen Blick!</a>
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<h3>RBL News auf einen Blick!</h3>
|
||||||
|
<Icon Name="IconName.InfoCircle" class="me-2"></Icon>Letztes Update @this.FeedDataService.Feeds?.LastUpdateDisplay
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@*
|
@*
|
||||||
@ -26,3 +35,10 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
*@
|
*@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Inject]
|
||||||
|
private IFeedDataService FeedDataService { get; set; }
|
||||||
|
}
|
||||||
@ -1,7 +1,11 @@
|
|||||||
@page "/"
|
@page "/"
|
||||||
@using RBLFeederCommon.Models.RssFeed
|
@using RBLFeederCommon.Models.RssFeed
|
||||||
@using RBLNews.Shared.Enums
|
@using RBLNews.Shared.Enums
|
||||||
@if (rssVM == null)
|
@using RBLNews.Shared.Services
|
||||||
|
|
||||||
|
@inject IFeedDataService feedDataService
|
||||||
|
|
||||||
|
@if (this.FeedDataService.Feeds == null)
|
||||||
{
|
{
|
||||||
<div class="d-flex justify-content-center">
|
<div class="d-flex justify-content-center">
|
||||||
Lade Feeds ...
|
Lade Feeds ...
|
||||||
@ -11,19 +15,27 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@foreach (FeedGroupVM feedGrp in rssVM.FeedGroups)
|
<div class="container">
|
||||||
|
@foreach (FeedGroupVM feedGrp in this.FeedDataService.Feeds.FeedGroups)
|
||||||
{
|
{
|
||||||
<h3>@feedGrp.PublishDate</h3>
|
<h4>@feedGrp.PublishDateDisplay</h4>
|
||||||
@foreach (FeedVM feed in feedGrp.Feeds)
|
@foreach (FeedVM feed in feedGrp.Feeds)
|
||||||
{
|
{
|
||||||
<div class="col-sm-12 col-md-9 col-lg-6">
|
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-4">
|
||||||
<Card>
|
<Card>
|
||||||
<CardBody>
|
<CardBody>
|
||||||
<CardTitle>@feed.Title</CardTitle>
|
<CardTitle>@feed.Title</CardTitle>
|
||||||
<CardText>@feed.Description</CardText>
|
<CardText>@feed.Description</CardText>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
<li class="list-group-item">
|
||||||
|
@GetRssSourceName((RssFeedSources)@feed.Source) | @feed.PubDate
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
<CardFooter>
|
<CardFooter>
|
||||||
@GetRssSourceName((RssFeedSources)@feed.Source) | @feed.PubDate <Button Color="ButtonColor.Primary" To="@feed.Link" Type="ButtonType.Link">Öffnen</Button>
|
<div class="row">
|
||||||
|
<Button Color="ButtonColor.Primary" Class="btn-sm align-self-end ml-auto" To="@feed.Link" Type="ButtonType.Link"><Icon Name="IconName.Link" /> Öffnen</Button>
|
||||||
|
</div>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
<br />
|
<br />
|
||||||
@ -32,14 +44,17 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
@code {
|
@code {
|
||||||
private RssVM rssVM;
|
|
||||||
HttpClient httpClient = new HttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
private IFeedDataService FeedDataService { get; set; }
|
||||||
|
|
||||||
protected async override Task OnInitializedAsync()
|
protected async override Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
rssVM = await httpClient.GetFromJsonAsync<RssVM>("https://rblnews.de/api/feeds");
|
this.FeedDataService.LoadFeeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetRssSourceName(RssFeedSources source)
|
private string GetRssSourceName(RssFeedSources source)
|
||||||
|
|||||||
@ -4,6 +4,8 @@ namespace RBLFeederCommon.Models.RssFeed;
|
|||||||
|
|
||||||
public class FeedGroupVM
|
public class FeedGroupVM
|
||||||
{
|
{
|
||||||
|
public string PublishDateDisplay { get => PublishDate.ToString("dd.MM.yyyy"); }
|
||||||
|
|
||||||
[JsonProperty("pubDate")]
|
[JsonProperty("pubDate")]
|
||||||
public DateTime PublishDate { get; set; }
|
public DateTime PublishDate { get; set; }
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,8 @@ namespace RBLFeederCommon.Models.RssFeed;
|
|||||||
|
|
||||||
public class RssVM
|
public class RssVM
|
||||||
{
|
{
|
||||||
|
public string LastUpdateDisplay { get => this.LastUpdate.ToLocalTime().ToString("dd.MM.yyyy HH:mm"); }
|
||||||
|
|
||||||
[JsonProperty("lastUpdate")]
|
[JsonProperty("lastUpdate")]
|
||||||
public DateTime LastUpdate { get; set; }
|
public DateTime LastUpdate { get; set; }
|
||||||
|
|
||||||
|
|||||||
30
RBLNews.Shared/Services/FeedDataService.cs
Normal file
30
RBLNews.Shared/Services/FeedDataService.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using RBLFeederCommon.Models.RssFeed;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Json;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RBLNews.Shared.Services
|
||||||
|
{
|
||||||
|
public interface IFeedDataService
|
||||||
|
{
|
||||||
|
public RssVM? Feeds { get; }
|
||||||
|
Task LoadFeeds();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FeedDataService : IFeedDataService
|
||||||
|
{
|
||||||
|
private static HttpClient httpClient = new HttpClient();
|
||||||
|
|
||||||
|
private RssVM? feeds;
|
||||||
|
public RssVM? Feeds { get => this.feeds; }
|
||||||
|
|
||||||
|
public async Task LoadFeeds()
|
||||||
|
{
|
||||||
|
feeds = await httpClient.GetFromJsonAsync<RssVM>("https://rblnews.de/api/feeds");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,9 @@
|
|||||||
/*html, body {
|
.top-row{
|
||||||
|
height: 5.1rem !important;
|
||||||
|
color: aqua;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*html, body {
|
||||||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using RBLNews.Shared.Services;
|
||||||
using RBLNews.Web.Components;
|
using RBLNews.Web.Components;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
@ -7,6 +8,8 @@ builder.Services.AddRazorComponents()
|
|||||||
.AddInteractiveServerComponents();
|
.AddInteractiveServerComponents();
|
||||||
builder.Services.AddBlazorBootstrap();
|
builder.Services.AddBlazorBootstrap();
|
||||||
|
|
||||||
|
builder.Services.AddSingleton<IFeedDataService, FeedDataService>();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user