Restructure solution into folders and fix persistence issues
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
37987a394a
commit
7c39cb5562
62 files changed
+219
-151
No files matched your search
@@ -1,14 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<base href="/" />
|
||||
<ResourcePreloader />
|
||||
<link rel="stylesheet" href="@Assets["app.css"]" />
|
||||
<link rel="stylesheet" href="@Assets["Flypaper.Web.styles.css"]" />
|
||||
<ImportMap />
|
||||
<HeadOutlet />
|
||||
</head>
|
||||
|
||||
|
||||
+5
-13
@@ -1,8 +1,8 @@
|
||||
@page "/"
|
||||
@using Flypaper.Core
|
||||
@using Flypaper.Storage
|
||||
@using Flypaper.Core.Abstractions
|
||||
@using Flypaper.Storage.Dashboard
|
||||
@inject DashboardQueries Queries
|
||||
@inject ConnectionGovernor Governor
|
||||
@inject IConnectionGovernor Governor
|
||||
|
||||
<PageTitle>Flypaper</PageTitle>
|
||||
<HeadContent>
|
||||
@@ -21,7 +21,7 @@
|
||||
<div class="metric"><span class="label">Letzte 24 h</span><span class="value">@data.CatchesLast24Hours.ToString("N0")</span></div>
|
||||
<div class="metric"><span class="label">Aktiv</span><span class="value">@Governor.ActiveConnections.ToString("N0")</span></div>
|
||||
<div class="metric"><span class="label">Eindeutige IPs</span><span class="value">@data.UniqueIps.ToString("N0")</span></div>
|
||||
<div class="metric"><span class="label">Haltezeit gesamt</span><span class="value">@FormatDuration(data.TotalHoldTime)</span></div>
|
||||
<div class="metric"><span class="label">Haltezeit gesamt</span><span class="value">@Formatting.Duration(data.TotalHoldTime)</span></div>
|
||||
<div class="metric"><span class="label">Abgelehnt</span><span class="value">@data.Rejected.ToString("N0")</span></div>
|
||||
</section>
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<td class="mono">@trapEvent.RemoteIp</td>
|
||||
<td class="mono clip" title="@trapEvent.Target">@trapEvent.Target</td>
|
||||
<td class="clip" title="@trapEvent.ClientInfo">@trapEvent.ClientInfo</td>
|
||||
<td class="num">@FormatDuration(TimeSpan.FromMilliseconds(trapEvent.DurationMs))</td>
|
||||
<td class="num">@Formatting.Duration(TimeSpan.FromMilliseconds(trapEvent.DurationMs))</td>
|
||||
<td class="num">@trapEvent.BytesSent.ToString("N0")</td>
|
||||
<td><span class="outcome @trapEvent.Outcome.ToString().ToLowerInvariant()">@trapEvent.Outcome</span></td>
|
||||
</tr>
|
||||
@@ -80,12 +80,4 @@
|
||||
_data = await Queries.GetAsync();
|
||||
_loadedAt = DateTime.Now;
|
||||
}
|
||||
|
||||
internal static string FormatDuration(TimeSpan duration) => duration switch
|
||||
{
|
||||
{ TotalDays: >= 1 } => $"{(int)duration.TotalDays} d {duration.Hours} h",
|
||||
{ TotalHours: >= 1 } => $"{duration.Hours} h {duration.Minutes} min",
|
||||
{ TotalMinutes: >= 1 } => $"{duration.Minutes} min {duration.Seconds} s",
|
||||
_ => $"{duration.TotalSeconds:0.0} s"
|
||||
};
|
||||
}
|
||||
+2
-3
@@ -1,5 +1,4 @@
|
||||
@using Flypaper.Storage
|
||||
|
||||
@using Flypaper.Storage.Dashboard
|
||||
<section class="card">
|
||||
<h2>@Title</h2>
|
||||
@if (Entries.Count == 0)
|
||||
@@ -22,7 +21,7 @@
|
||||
<tr>
|
||||
<td class="mono clip" title="@entry.Key">@entry.Key</td>
|
||||
<td class="num">@entry.Count.ToString("N0")</td>
|
||||
<td class="num">@Home.FormatDuration(entry.HoldTime)</td>
|
||||
<td class="num">@Formatting.Duration(entry.HoldTime)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
@@ -1,36 +1,21 @@
|
||||
@page "/Error"
|
||||
@page "/Error"
|
||||
@layout EmptyLayout
|
||||
@attribute [AllowAnonymous]
|
||||
@using System.Diagnostics
|
||||
|
||||
<PageTitle>Error</PageTitle>
|
||||
<PageTitle>Flypaper · Fehler</PageTitle>
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
|
||||
@if (ShowRequestId)
|
||||
<h1 class="login-title">Fehler</h1>
|
||||
<p>Bei der Verarbeitung der Anfrage ist ein Fehler aufgetreten.</p>
|
||||
@if (!string.IsNullOrEmpty(_requestId))
|
||||
{
|
||||
<p>
|
||||
<strong>Request ID:</strong> <code>@RequestId</code>
|
||||
</p>
|
||||
<p class="muted">Request-ID: <code>@_requestId</code></p>
|
||||
}
|
||||
|
||||
<h3>Development Mode</h3>
|
||||
<p>
|
||||
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
||||
</p>
|
||||
<p>
|
||||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||
It can result in displaying sensitive information from exceptions to end users.
|
||||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||
and restarting the app.
|
||||
</p>
|
||||
@code {
|
||||
private string? _requestId;
|
||||
|
||||
@code{
|
||||
[CascadingParameter]
|
||||
private HttpContext? HttpContext { get; set; }
|
||||
[CascadingParameter] private HttpContext? HttpContext { get; set; }
|
||||
|
||||
private string? RequestId { get; set; }
|
||||
private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
|
||||
protected override void OnInitialized() =>
|
||||
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
|
||||
protected override void OnInitialized() => _requestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
@layout EmptyLayout
|
||||
@attribute [AllowAnonymous]
|
||||
@using Flypaper.Web.Auth
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@inject AdminAuthenticator Admin
|
||||
|
||||
<PageTitle>Flypaper · Anmelden</PageTitle>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
@page "/not-found"
|
||||
@page "/not-found"
|
||||
@layout EmptyLayout
|
||||
@attribute [Microsoft.AspNetCore.Authorization.AllowAnonymous]
|
||||
@attribute [AllowAnonymous]
|
||||
|
||||
<h3>Not Found</h3>
|
||||
<p>Sorry, the content you are looking for does not exist.</p>
|
||||
<PageTitle>Flypaper · Nicht gefunden</PageTitle>
|
||||
|
||||
<h1 class="login-title">Nicht gefunden</h1>
|
||||
<p class="muted">Diese Seite gibt es nicht. <a href="/">Zum Dashboard</a></p>
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace Flypaper.Web.Components.Pages;
|
||||
namespace Flypaper.Web.Components.Pages.Settings;
|
||||
|
||||
public sealed class SettingsModel
|
||||
{
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
@page "/settings"
|
||||
@using System.Globalization
|
||||
@using Flypaper.Core
|
||||
@using Flypaper.Core.Settings
|
||||
@using Flypaper.Core.Strategies
|
||||
@using Flypaper.Http
|
||||
@using Flypaper.Storage
|
||||
@using Flypaper.Storage.Settings
|
||||
@using Flypaper.Web.Auth
|
||||
@using System.Globalization
|
||||
@using Microsoft.Data.Sqlite
|
||||
@using Microsoft.Extensions.Options
|
||||
@inject IOptionsMonitor<FlypaperOptions> Core
|
||||
@@ -1,6 +1,5 @@
|
||||
<Router AppAssembly="typeof(Program).Assembly" NotFoundPage="typeof(Pages.NotFound)">
|
||||
<Router AppAssembly="typeof(Program).Assembly" NotFoundPage="typeof(Pages.NotFound)">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
|
||||
<FocusOnNavigate RouteData="routeData" Selector="h1" />
|
||||
</Found>
|
||||
</Router>
|
||||
File renamed without changes.
@@ -0,0 +1,12 @@
|
||||
namespace Flypaper.Web.Components.Shared;
|
||||
|
||||
public static class Formatting
|
||||
{
|
||||
public static string Duration(TimeSpan duration) => duration switch
|
||||
{
|
||||
{ TotalDays: >= 1 } => $"{(int)duration.TotalDays} d {duration.Hours} h",
|
||||
{ TotalHours: >= 1 } => $"{duration.Hours} h {duration.Minutes} min",
|
||||
{ TotalMinutes: >= 1 } => $"{duration.Minutes} min {duration.Seconds} s",
|
||||
_ => $"{duration.TotalSeconds:0.0} s"
|
||||
};
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
@using System.Net.Http
|
||||
@using System.Net.Http.Json
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
||||
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||
@using Microsoft.JSInterop
|
||||
@using Flypaper.Web
|
||||
@using Flypaper.Web.Components
|
||||
@using Flypaper.Web.Components.Layout
|
||||
@using Flypaper.Web.Components.Shared
|
||||
@@ -5,6 +5,7 @@ using Flypaper.Web.Auth;
|
||||
using Flypaper.Web.Components;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -15,6 +16,12 @@ builder.Services.AddRazorComponents();
|
||||
builder.Services.AddFlypaperCore(builder.Configuration);
|
||||
builder.Services.AddFlypaperHttp(builder.Configuration);
|
||||
|
||||
var dataProtection = builder.Services.AddDataProtection().SetApplicationName("Flypaper");
|
||||
if (builder.Configuration["Flypaper:DataProtection:KeysPath"] is { Length: > 0 } keysPath)
|
||||
{
|
||||
dataProtection.PersistKeysToFileSystem(new DirectoryInfo(keysPath));
|
||||
}
|
||||
|
||||
builder.Services.Configure<AdminOptions>(builder.Configuration.GetSection(AdminOptions.SectionName));
|
||||
builder.Services.AddSingleton<AdminAuthenticator>();
|
||||
builder.Services
|
||||
|
||||
Reference in new issue
Block a user