From 25f39344083f7ece04ba599913e369b6db731520 Mon Sep 17 00:00:00 2001 From: Andy Pack Date: Mon, 30 Sep 2024 17:16:59 +0100 Subject: [PATCH] updating deps, shifting pages and components into client library, using radzen layout --- Overflow.CLI/Overflow.CLI.csproj | 2 +- Overflow.Test/Overflow.Test.csproj | 16 +++- .../Components/SpillViewDialog.razor | 2 +- .../Components/SpillsCalendar.razor | 2 +- .../Components/SpillsTable.razor | 2 +- Overflow.Web.Client/Layout/MainLayout.razor | 45 ++++++--- Overflow.Web.Client/Layout/NavMenu.razor | 51 ++++------ .../Overflow.Web.Client.csproj | 6 +- Overflow.Web.Client/Pages/Counter.razor | 19 ---- Overflow.Web.Client/Pages/Home.razor | 58 ++++++++++- .../Pages/SouthernWater/About.razor | 0 .../Pages/SouthernWater/Spills.razor | 2 +- .../SouthernWater/SpillsCalendarPage.razor | 2 +- Overflow.Web.Client/Pages/Weather.razor | 60 ------------ Overflow.Web.Client/RenderModeSettings.cs | 8 ++ Overflow.Web.Client/_Imports.razor | 9 +- Overflow.Web/Components/App.razor | 21 +--- .../Components/Layout/MainLayout.razor | 19 ---- .../Components/Layout/MainLayout.razor.css | 96 ------------------- Overflow.Web/Components/Layout/NavMenu.razor | 24 ----- .../Components/Layout/NavMenu.razor.css | 0 Overflow.Web/Components/Pages/Home.razor | 59 ------------ Overflow.Web/Components/Routes.razor | 5 +- Overflow.Web/Components/_Imports.razor | 3 +- Overflow.Web/Overflow.Web.csproj | 24 +++-- Overflow.Web/Program.cs | 37 +++---- Overflow/Overflow.csproj | 6 +- 27 files changed, 185 insertions(+), 393 deletions(-) delete mode 100644 Overflow.Web.Client/Pages/Counter.razor rename {Overflow.Web/Components => Overflow.Web.Client}/Pages/SouthernWater/About.razor (100%) rename {Overflow.Web/Components => Overflow.Web.Client}/Pages/SouthernWater/Spills.razor (94%) rename {Overflow.Web/Components => Overflow.Web.Client}/Pages/SouthernWater/SpillsCalendarPage.razor (96%) delete mode 100644 Overflow.Web.Client/Pages/Weather.razor create mode 100644 Overflow.Web.Client/RenderModeSettings.cs delete mode 100644 Overflow.Web/Components/Layout/MainLayout.razor delete mode 100644 Overflow.Web/Components/Layout/MainLayout.razor.css delete mode 100644 Overflow.Web/Components/Layout/NavMenu.razor delete mode 100644 Overflow.Web/Components/Layout/NavMenu.razor.css delete mode 100644 Overflow.Web/Components/Pages/Home.razor diff --git a/Overflow.CLI/Overflow.CLI.csproj b/Overflow.CLI/Overflow.CLI.csproj index 5382511..05a83b4 100644 --- a/Overflow.CLI/Overflow.CLI.csproj +++ b/Overflow.CLI/Overflow.CLI.csproj @@ -12,7 +12,7 @@ - + diff --git a/Overflow.Test/Overflow.Test.csproj b/Overflow.Test/Overflow.Test.csproj index a156b64..e5fe097 100644 --- a/Overflow.Test/Overflow.Test.csproj +++ b/Overflow.Test/Overflow.Test.csproj @@ -10,11 +10,17 @@ - - - - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Overflow.Web.Client/Components/SpillViewDialog.razor b/Overflow.Web.Client/Components/SpillViewDialog.razor index 2491f90..ee0516f 100644 --- a/Overflow.Web.Client/Components/SpillViewDialog.razor +++ b/Overflow.Web.Client/Components/SpillViewDialog.razor @@ -1,5 +1,5 @@ @using Overflow.SouthernWater -@rendermode RenderMode.InteractiveAuto +@rendermode InteractiveRenderMode diff --git a/Overflow.Web.Client/Components/SpillsCalendar.razor b/Overflow.Web.Client/Components/SpillsCalendar.razor index 3ace1d8..27f1ced 100644 --- a/Overflow.Web.Client/Components/SpillsCalendar.razor +++ b/Overflow.Web.Client/Components/SpillsCalendar.razor @@ -1,5 +1,5 @@ @using Overflow.SouthernWater -@rendermode RenderMode.InteractiveAuto +@rendermode InteractiveRenderMode @inject DialogService DialogService @if (Job == null) diff --git a/Overflow.Web.Client/Components/SpillsTable.razor b/Overflow.Web.Client/Components/SpillsTable.razor index 91e8b98..f3e7fd7 100644 --- a/Overflow.Web.Client/Components/SpillsTable.razor +++ b/Overflow.Web.Client/Components/SpillsTable.razor @@ -1,6 +1,6 @@ @using System.Globalization @using Overflow.SouthernWater -@rendermode RenderMode.InteractiveAuto +@rendermode InteractiveRenderMode @if (Job == null) { diff --git a/Overflow.Web.Client/Layout/MainLayout.razor b/Overflow.Web.Client/Layout/MainLayout.razor index e7554be..4c40ec4 100644 --- a/Overflow.Web.Client/Layout/MainLayout.razor +++ b/Overflow.Web.Client/Layout/MainLayout.razor @@ -1,16 +1,37 @@ @inherits LayoutComponentBase -
- - -
-
- About + + +
+
+
+ @Body +
+
+
+ +
+ + AP + +
+
+ -
- @Body -
-
-
\ No newline at end of file +
+ An unhandled error has occurred. + Reload + 🗙 +
+ + \ No newline at end of file diff --git a/Overflow.Web.Client/Layout/NavMenu.razor b/Overflow.Web.Client/Layout/NavMenu.razor index 5c82393..70a701d 100644 --- a/Overflow.Web.Client/Layout/NavMenu.razor +++ b/Overflow.Web.Client/Layout/NavMenu.razor @@ -1,40 +1,25 @@ - +@rendermode InteractiveRenderMode - + + + + + + + + + + @code { - private bool collapseNavMenu = true; - private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; +void OnParentClicked(MenuItemEventArgs args) +{ - private void ToggleNavMenu() - { - collapseNavMenu = !collapseNavMenu; - } +} +void OnChildClicked(MenuItemEventArgs args) +{ + +} } \ No newline at end of file diff --git a/Overflow.Web.Client/Overflow.Web.Client.csproj b/Overflow.Web.Client/Overflow.Web.Client.csproj index bfdbc31..1d58fa1 100644 --- a/Overflow.Web.Client/Overflow.Web.Client.csproj +++ b/Overflow.Web.Client/Overflow.Web.Client.csproj @@ -9,9 +9,9 @@ - - - + + + diff --git a/Overflow.Web.Client/Pages/Counter.razor b/Overflow.Web.Client/Pages/Counter.razor deleted file mode 100644 index 372905f..0000000 --- a/Overflow.Web.Client/Pages/Counter.razor +++ /dev/null @@ -1,19 +0,0 @@ -@page "/counter" - -Counter - -

Counter

- -

Current count: @currentCount

- - - -@code { - private int currentCount = 0; - - private void IncrementCount() - { - currentCount++; - } - -} \ No newline at end of file diff --git a/Overflow.Web.Client/Pages/Home.razor b/Overflow.Web.Client/Pages/Home.razor index dfcdf75..aacb4f3 100644 --- a/Overflow.Web.Client/Pages/Home.razor +++ b/Overflow.Web.Client/Pages/Home.razor @@ -1,7 +1,59 @@ @page "/" -Home +Overflow -

Hello, world!

+
+ Overflow +
-Welcome to your new app. \ No newline at end of file +
+ + + + + + + Woops + + +

During times of overwhelming rainfall in the UK, storm overflows release unprocessed sewage into waterways and oceans to avoid sewage systems backing up and eventually flooding.

+

There have been controversies for many of the private water companies of the UK that suggest these storm overflows are overused - contaminating British waterways and oceans.

+
+
+ + + + + + Having a look + + +

I have found that the websites that the water companies use to report overflow usage can be poor at best. Overflow aims to cache this data and present it in an easier to consume fashion

+
+
+ + + + + + Context + + +

Like a lot of UK public infrastructure, the water utility companies were privatised in the 1980s.

+

The UK is one of very few countries to have a fully privatised water system and was the first to do so.

+
+
+ + + + + + Investment/Plundering + + + While that investment in UK water systems has only increased since privatisation, + has found that investors have managed to withdraw £85.2bn between 1989 and 2023. + + +
+
\ No newline at end of file diff --git a/Overflow.Web/Components/Pages/SouthernWater/About.razor b/Overflow.Web.Client/Pages/SouthernWater/About.razor similarity index 100% rename from Overflow.Web/Components/Pages/SouthernWater/About.razor rename to Overflow.Web.Client/Pages/SouthernWater/About.razor diff --git a/Overflow.Web/Components/Pages/SouthernWater/Spills.razor b/Overflow.Web.Client/Pages/SouthernWater/Spills.razor similarity index 94% rename from Overflow.Web/Components/Pages/SouthernWater/Spills.razor rename to Overflow.Web.Client/Pages/SouthernWater/Spills.razor index 731adb7..c09eb51 100644 --- a/Overflow.Web/Components/Pages/SouthernWater/Spills.razor +++ b/Overflow.Web.Client/Pages/SouthernWater/Spills.razor @@ -1,7 +1,7 @@ @page "/spills" @using MongoDB.Driver @using Overflow.SouthernWater -@rendermode RenderMode.InteractiveServer +@rendermode InteractiveRenderMode Southern Water Spills diff --git a/Overflow.Web/Components/Pages/SouthernWater/SpillsCalendarPage.razor b/Overflow.Web.Client/Pages/SouthernWater/SpillsCalendarPage.razor similarity index 96% rename from Overflow.Web/Components/Pages/SouthernWater/SpillsCalendarPage.razor rename to Overflow.Web.Client/Pages/SouthernWater/SpillsCalendarPage.razor index d9d28de..d2ab653 100644 --- a/Overflow.Web/Components/Pages/SouthernWater/SpillsCalendarPage.razor +++ b/Overflow.Web.Client/Pages/SouthernWater/SpillsCalendarPage.razor @@ -1,7 +1,7 @@ @page "/spills-cal" @using MongoDB.Driver @using Overflow.SouthernWater -@rendermode RenderMode.InteractiveServer +@rendermode InteractiveRenderMode Southern Water Spills diff --git a/Overflow.Web.Client/Pages/Weather.razor b/Overflow.Web.Client/Pages/Weather.razor deleted file mode 100644 index 6770b4c..0000000 --- a/Overflow.Web.Client/Pages/Weather.razor +++ /dev/null @@ -1,60 +0,0 @@ -@page "/weather" -@inject HttpClient Http - -Weather - -

Weather

- -

This component demonstrates fetching data from the server.

- -@if (forecasts == null) -{ -

- Loading... -

-} -else -{ - - - - - - - - - - - @foreach (var forecast in forecasts) - { - - - - - - - } - -
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
-} - -@code { - private WeatherForecast[]? forecasts; - - protected override async Task OnInitializedAsync() - { - forecasts = await Http.GetFromJsonAsync("sample-data/weather.json"); - } - - public class WeatherForecast - { - public DateOnly Date { get; set; } - - public int TemperatureC { get; set; } - - public string? Summary { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - } - -} \ No newline at end of file diff --git a/Overflow.Web.Client/RenderModeSettings.cs b/Overflow.Web.Client/RenderModeSettings.cs new file mode 100644 index 0000000..12d774e --- /dev/null +++ b/Overflow.Web.Client/RenderModeSettings.cs @@ -0,0 +1,8 @@ +using Microsoft.AspNetCore.Components; + +namespace Overflow.Web.Client; + +public static class RenderModeSettings +{ + public static IComponentRenderMode? InteractiveRenderMode { get; set; } +} \ No newline at end of file diff --git a/Overflow.Web.Client/_Imports.razor b/Overflow.Web.Client/_Imports.razor index 737c8e0..01f0eed 100644 --- a/Overflow.Web.Client/_Imports.razor +++ b/Overflow.Web.Client/_Imports.razor @@ -3,10 +3,13 @@ @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.AspNetCore.Components.WebAssembly.Http @using Microsoft.JSInterop -@using Overflow.Web.Client +@using Overflow.Web +@using Overflow.Web.Client.Pages +@using Overflow.Web.Client.Components @using Overflow.Web.Client.Layout @using Radzen -@using Radzen.Blazor \ No newline at end of file +@using Radzen.Blazor +@using static RenderModeSettings \ No newline at end of file diff --git a/Overflow.Web/Components/App.razor b/Overflow.Web/Components/App.razor index c1711f6..54275d2 100644 --- a/Overflow.Web/Components/App.razor +++ b/Overflow.Web/Components/App.razor @@ -5,11 +5,12 @@ - + + @@ -19,22 +20,4 @@ -
-
- © 2024 - Overflow -
-
- - AP - -
-
- \ No newline at end of file diff --git a/Overflow.Web/Components/Layout/MainLayout.razor b/Overflow.Web/Components/Layout/MainLayout.razor deleted file mode 100644 index 162217e..0000000 --- a/Overflow.Web/Components/Layout/MainLayout.razor +++ /dev/null @@ -1,19 +0,0 @@ -@inherits LayoutComponentBase - - - -
-
-
- @Body -
-
-
- -
- An unhandled error has occurred. - Reload - 🗙 -
- - \ No newline at end of file diff --git a/Overflow.Web/Components/Layout/MainLayout.razor.css b/Overflow.Web/Components/Layout/MainLayout.razor.css deleted file mode 100644 index 038baf1..0000000 --- a/Overflow.Web/Components/Layout/MainLayout.razor.css +++ /dev/null @@ -1,96 +0,0 @@ -.page { - position: relative; - display: flex; - flex-direction: column; -} - -main { - flex: 1; -} - -.sidebar { - background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); -} - -.top-row { - background-color: #f7f7f7; - border-bottom: 1px solid #d6d5d5; - justify-content: flex-end; - height: 3.5rem; - display: flex; - align-items: center; -} - - .top-row ::deep a, .top-row ::deep .btn-link { - white-space: nowrap; - margin-left: 1.5rem; - text-decoration: none; - } - - .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { - text-decoration: underline; - } - - .top-row ::deep a:first-child { - overflow: hidden; - text-overflow: ellipsis; - } - -@media (max-width: 640.98px) { - .top-row { - justify-content: space-between; - } - - .top-row ::deep a, .top-row ::deep .btn-link { - margin-left: 0; - } -} - -@media (min-width: 641px) { - .page { - flex-direction: row; - } - - .sidebar { - width: 250px; - height: 100vh; - position: sticky; - top: 0; - } - - .top-row { - position: sticky; - top: 0; - z-index: 1; - } - - .top-row.auth ::deep a:first-child { - flex: 1; - text-align: right; - width: 0; - } - - .top-row, article { - padding-left: 2rem !important; - padding-right: 1.5rem !important; - } -} - -#blazor-error-ui { - background: lightyellow; - bottom: 0; - box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); - display: none; - left: 0; - padding: 0.6rem 1.25rem 0.7rem 1.25rem; - position: fixed; - width: 100%; - z-index: 1000; -} - - #blazor-error-ui .dismiss { - cursor: pointer; - position: absolute; - right: 0.75rem; - top: 0.5rem; - } diff --git a/Overflow.Web/Components/Layout/NavMenu.razor b/Overflow.Web/Components/Layout/NavMenu.razor deleted file mode 100644 index c0f339a..0000000 --- a/Overflow.Web/Components/Layout/NavMenu.razor +++ /dev/null @@ -1,24 +0,0 @@ -@rendermode InteractiveServer - - - - - - - - - - - -@code { - - void OnParentClicked(MenuItemEventArgs args) - { - - } - - void OnChildClicked(MenuItemEventArgs args) - { - - } -} \ No newline at end of file diff --git a/Overflow.Web/Components/Layout/NavMenu.razor.css b/Overflow.Web/Components/Layout/NavMenu.razor.css deleted file mode 100644 index e69de29..0000000 diff --git a/Overflow.Web/Components/Pages/Home.razor b/Overflow.Web/Components/Pages/Home.razor deleted file mode 100644 index aacb4f3..0000000 --- a/Overflow.Web/Components/Pages/Home.razor +++ /dev/null @@ -1,59 +0,0 @@ -@page "/" - -Overflow - -
- Overflow -
- -
- - - - - - - Woops - - -

During times of overwhelming rainfall in the UK, storm overflows release unprocessed sewage into waterways and oceans to avoid sewage systems backing up and eventually flooding.

-

There have been controversies for many of the private water companies of the UK that suggest these storm overflows are overused - contaminating British waterways and oceans.

-
-
- - - - - - Having a look - - -

I have found that the websites that the water companies use to report overflow usage can be poor at best. Overflow aims to cache this data and present it in an easier to consume fashion

-
-
- - - - - - Context - - -

Like a lot of UK public infrastructure, the water utility companies were privatised in the 1980s.

-

The UK is one of very few countries to have a fully privatised water system and was the first to do so.

-
-
- - - - - - Investment/Plundering - - - While that investment in UK water systems has only increased since privatisation, - has found that investors have managed to withdraw £85.2bn between 1989 and 2023. - - -
-
\ No newline at end of file diff --git a/Overflow.Web/Components/Routes.razor b/Overflow.Web/Components/Routes.razor index bf0ce0b..3b9281f 100644 --- a/Overflow.Web/Components/Routes.razor +++ b/Overflow.Web/Components/Routes.razor @@ -1,6 +1,7 @@ - + - + \ No newline at end of file diff --git a/Overflow.Web/Components/_Imports.razor b/Overflow.Web/Components/_Imports.razor index 170cc09..0afdf73 100644 --- a/Overflow.Web/Components/_Imports.razor +++ b/Overflow.Web/Components/_Imports.razor @@ -11,4 +11,5 @@ @using Overflow.Web.Client.Pages @using Overflow.Web.Client.Components @using Radzen -@using Radzen.Blazor \ No newline at end of file +@using Radzen.Blazor +@using static Overflow.Web.Client.RenderModeSettings \ No newline at end of file diff --git a/Overflow.Web/Overflow.Web.csproj b/Overflow.Web/Overflow.Web.csproj index ed76358..14e8c8b 100644 --- a/Overflow.Web/Overflow.Web.csproj +++ b/Overflow.Web/Overflow.Web.csproj @@ -7,16 +7,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -36,5 +36,9 @@ PreserveNewest + + + + diff --git a/Overflow.Web/Program.cs b/Overflow.Web/Program.cs index f7f108c..487b7bf 100644 --- a/Overflow.Web/Program.cs +++ b/Overflow.Web/Program.cs @@ -1,34 +1,38 @@ -using Overflow.Web.Components; +using Microsoft.AspNetCore.Components.Web; using Overflow; using MongoDB.Driver; using NLog.Extensions.Logging; using Overflow.SouthernWater; +using Overflow.Web.Client; using Quartz; using Quartz.AspNetCore; using Radzen; +using App = Overflow.Web.Components.App; + +RenderModeSettings.InteractiveRenderMode = RenderMode.InteractiveAuto; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorComponents() - .AddInteractiveServerComponents() - .AddInteractiveWebAssemblyComponents(); + .AddInteractiveServerComponents() + .AddInteractiveWebAssemblyComponents(); builder.Logging.ClearProviders(); builder.Logging.AddNLog(builder.Configuration); var driver = new MongoClient(builder.Configuration.GetConnectionString("Default")); -builder.Services.AddSingleton(driver); -builder.Services.AddScoped(s => s.GetRequiredService().GetDatabase(Static.DatabaseName)); +builder.Services.AddSingleton(driver) + .AddScoped(s => s.GetRequiredService().GetDatabase(Static.DatabaseName)); builder.Services.AddControllers(); // base configuration from appsettings.json -builder.Services.Configure(builder.Configuration.GetSection("Quartz")); +builder.Services.Configure(builder.Configuration.GetSection("Quartz")) // if you are using persistent job store, you might want to alter some options -builder.Services.Configure(options => + .Configure(options => { options.Scheduling.IgnoreDuplicates = true; // default: false options.Scheduling.OverWriteExistingData = true; // default: true @@ -85,14 +89,14 @@ builder.Services.AddQuartzServer(options => options.WaitForJobsToComplete = false; }); -builder.Services.AddHttpClient(); -builder.Services.AddSingleton(); -builder.Services.AddScoped(); -builder.Services.AddTransient(); +builder.Services.AddHttpClient() + .AddSingleton() + .AddScoped() + .AddTransient(); -builder.Services.AddSingleton(); -builder.Services.AddSingleton(); -builder.Services.AddHostedService(); +builder.Services.AddSingleton() + .AddSingleton() + .AddHostedService(); builder.Services.AddRadzenComponents(); @@ -108,11 +112,12 @@ if (!app.Environment.IsDevelopment()) app.UseHttpsRedirection(); -app.UseStaticFiles(); -app.UseAntiforgery(); +app.UseStaticFiles() + .UseAntiforgery(); app.MapControllers(); app.MapRazorComponents() + .AddAdditionalAssemblies(typeof(Overflow.Web.Client.Components.SpillsCalendar).Assembly) .AddInteractiveServerRenderMode() .AddInteractiveWebAssemblyRenderMode(); diff --git a/Overflow/Overflow.csproj b/Overflow/Overflow.csproj index d13b979..715848f 100644 --- a/Overflow/Overflow.csproj +++ b/Overflow/Overflow.csproj @@ -8,12 +8,12 @@ - + - - + +