Merge pull request 'features/loading-data-by-source' (#3) from features/loading-data-by-source into main
Reviewed-on: #3
This commit is contained in:
commit
cd61504a39
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@ -0,0 +1,3 @@
|
||||
appsettings.json
|
||||
**/bin/
|
||||
**/obj/
|
12
.drone.yml
12
.drone.yml
@ -6,15 +6,17 @@ name: build
|
||||
steps:
|
||||
- name: build image
|
||||
image: plugins/docker
|
||||
environment:
|
||||
PAT:
|
||||
from_secret: DockerPushPat
|
||||
settings:
|
||||
repo: 192.168.1.196:5000/jtom38/newsbot-portal
|
||||
registry: 192.168.1.196:5000
|
||||
insecure: true
|
||||
tags:
|
||||
- latest
|
||||
username: jtom38
|
||||
password: $PAT
|
||||
repo: jtom38/newsbot-portal
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
- releases/*
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
|
@ -2,6 +2,6 @@ namespace Newsbot.Portal.Blazor.Server;
|
||||
|
||||
public static class Global
|
||||
{
|
||||
public static HttpClient HttpClient { get; set; }
|
||||
public static HttpClient? HttpClient { get; set; }
|
||||
public static string? DefaultInstanceUri { get; set; }
|
||||
}
|
@ -7,12 +7,6 @@
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\.dockerignore">
|
||||
<Link>.dockerignore</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Newsbot.Collector.Client\Newsbot.Collector.Client.csproj" />
|
||||
</ItemGroup>
|
||||
|
@ -1,7 +1,9 @@
|
||||
@page "/articles/newest"
|
||||
@page "/articles/latest"
|
||||
@using Newsbot.Collector.Client
|
||||
@using Newsbot.Collector.Client.Domain.Dto
|
||||
<h3>List Articles</h3>
|
||||
|
||||
<PageTitle>Latest</PageTitle>
|
||||
<h3>Latest Posts</h3>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
@ -11,7 +13,10 @@
|
||||
<div class="card" style="width: 18rem;">
|
||||
<img src="@item.Thumbnail" class="card-img-top" alt="...">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">@item.Title</h5>
|
||||
<h5 class="card-title">
|
||||
<a href="@item.Url" target="_blank">@item.Title</a>
|
||||
</h5>
|
||||
<p class="card-text">@item.PubDate</p>
|
||||
<p class="card-text">@item.Description</p>
|
||||
<a href="@item.Url" class="btn btn-primary" target="_blank">View</a>
|
||||
</div>
|
@ -2,32 +2,42 @@
|
||||
@using Newsbot.Collector.Client.Domain.Dto
|
||||
@using Newsbot.Collector.Client
|
||||
|
||||
<h3>ListBySource</h3>
|
||||
<PageTitle>@Record?.Name</PageTitle>
|
||||
<h3>@Record?.Name</h3>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>Title</td>
|
||||
<td>Publish Date</td>
|
||||
</tr>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
@foreach (var item in Data ??= new List<ArticlesDto>())
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<a href="@item.Url" target="_blank">@item.Title</a><br/>
|
||||
</td>
|
||||
<td>@item.PubDate</td>
|
||||
</tr>
|
||||
<div class="col-sm">
|
||||
<div class="card" style="width: 18rem;">
|
||||
<img src="@item.Thumbnail" class="card-img-top" alt="...">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
<a href="@item.Url" target="_blank">@item.Title</a>
|
||||
</h5>
|
||||
<p class="card-text">@item.PubDate</p>
|
||||
<p class="card-text">@item.Description</p>
|
||||
<a href="@item.Url" class="btn btn-primary" target="_blank">View</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public string? Id { get; set; }
|
||||
|
||||
List<ArticlesDto>? Data { get; set; }
|
||||
SourcesDto? Record { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var s = new SourcesClient(Global.HttpClient, Global.DefaultInstanceUri ?? "");
|
||||
Record = await s.GetAsync(Guid.Parse(Id ?? ""));
|
||||
|
||||
var c = new ArticlesClient(Global.HttpClient, Global.DefaultInstanceUri ?? "");
|
||||
var items = await c.ListBySourceAsync(Guid.Parse(Id ?? ""));
|
||||
Data = items;
|
||||
|
@ -1,33 +0,0 @@
|
||||
@page "/articles/sources"
|
||||
@using Newsbot.Collector.Client
|
||||
@using Newsbot.Collector.Client.Domain.Dto
|
||||
<h3>Select Source</h3>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>Source</td>
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
</tr>
|
||||
@foreach (var item in Items ??= new List<SourcesDto>())
|
||||
{
|
||||
<tr>
|
||||
<td>@item.Source</td>
|
||||
<td>
|
||||
<a href="/articles/sources/@item.Id">@item.Name</a>
|
||||
</td>
|
||||
<td>@item.Type</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
|
||||
@code {
|
||||
private List<SourcesDto>? Items { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var c = new SourcesClient(Global.HttpClient, Global.DefaultInstanceUri ?? "");
|
||||
Items = await c.ListAsync();
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
@page "/sources/list"
|
||||
@page "/sources"
|
||||
@using Newsbot.Collector.Client
|
||||
@using Newsbot.Collector.Client.Domain.Dto
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
<tr>
|
||||
<td>Title</td>
|
||||
<td>Publish Date</td>
|
||||
<td>Tags</td>
|
||||
</tr>
|
||||
@foreach (var item in Data ??= new List<SourcesDto>())
|
||||
{
|
||||
@ -21,12 +22,34 @@
|
||||
<a href="@item.Url" target="_blank">@item.Name</a><br/>
|
||||
</td>
|
||||
<td>@item.Source</td>
|
||||
<td>@FlattenTags(@item.Tags ??= new List<string>())</td>
|
||||
<td>
|
||||
<a href="/articles/sources/@item.Id">View News</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
|
||||
@code {
|
||||
private List<SourcesDto> Data { get; set; }
|
||||
private List<SourcesDto>? Data { get; set; }
|
||||
|
||||
private string FlattenTags(List<string> tags)
|
||||
{
|
||||
|
||||
string res = "";
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
if (res == "")
|
||||
{
|
||||
res = tag;
|
||||
}
|
||||
else
|
||||
{
|
||||
res += $", {tag}";
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
<PageTitle>Newsbot.Portal.Blazor.Server</PageTitle>
|
||||
<PageTitle>Newsbot</PageTitle>
|
||||
|
||||
<div class="page">
|
||||
<div class="sidebar">
|
||||
@ -8,8 +8,10 @@
|
||||
</div>
|
||||
|
||||
<main>
|
||||
|
||||
<div class="top-row px-4">
|
||||
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
|
||||
<a href="">Login</a>
|
||||
</div>
|
||||
|
||||
<article class="content px-4">
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div class="top-row ps-3 navbar navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="">Newsbot.Portal.Blazor.Server</a>
|
||||
<a class="navbar-brand" href="">Newsbot</a>
|
||||
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
@ -20,8 +20,8 @@
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="sources/list">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
|
||||
<NavLink class="nav-link" href="sources">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> Sources
|
||||
</NavLink>
|
||||
</div>
|
||||
</nav>
|
||||
|
16
docker-compose.yml
Normal file
16
docker-compose.yml
Normal file
@ -0,0 +1,16 @@
|
||||
version: "3"
|
||||
|
||||
networks:
|
||||
newsbot:
|
||||
|
||||
services:
|
||||
portal:
|
||||
image: newsbot.portal:latest
|
||||
environment:
|
||||
Logging__LogLevel__Default: "Information"
|
||||
Logging__LogLevel__Microsoft.AspNetCore: "Warning"
|
||||
DefaultInstanceUri: "http://192.168.1.225:5001"
|
||||
ports:
|
||||
- "5002:80"
|
||||
networks:
|
||||
- newsbot
|
20
makefile
Normal file
20
makefile
Normal file
@ -0,0 +1,20 @@
|
||||
.PHONY: help
|
||||
help: ## Shows this help command
|
||||
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
build: ## builds the application
|
||||
dotnet restore
|
||||
dotnet build
|
||||
|
||||
pub: ## Build and publish the artifacts
|
||||
dotnet restore
|
||||
dotnet publish -o out
|
||||
rm ./out/appsettings.json
|
||||
|
||||
docker-build: ## Generates the docker image
|
||||
docker build -t "newsbot.portal" .
|
||||
docker image ls | grep newsbot.portal
|
||||
|
||||
docker-run: ## Runs the docker compose
|
||||
docker compose up -d
|
||||
|
Loading…
Reference in New Issue
Block a user