From dddfe51c44ad74851e6ef48987818c8b10cf0379 Mon Sep 17 00:00:00 2001 From: Callum Inglis <callum@4oh4.co> Date: Sat, 8 Jan 2022 19:02:21 +0000 Subject: [PATCH] .NET Update 5.0 --- Public API/Client/Pages/LatestData.razor | 2 +- Public API/Client/Program.cs | 2 +- Public API/Client/Public_API.Client.csproj | 15 +- Public API/Client/Shared/MainLayout.razor | 23 +-- Public API/Client/Shared/MainLayout.razor.css | 70 +++++++++ Public API/Client/Shared/NavMenu.razor.css | 62 ++++++++ Public API/Client/_Imports.razor | 4 +- Public API/Client/wwwroot/css/app.css | 143 +----------------- Public API/Client/wwwroot/index.html | 4 +- .../Server/Controllers/APIController.cs | 1 + Public API/Server/Public_API.Server.csproj | 10 +- Public API/Shared/Public_API.Shared.csproj | 2 +- 12 files changed, 173 insertions(+), 165 deletions(-) create mode 100644 Public API/Client/Shared/MainLayout.razor.css create mode 100644 Public API/Client/Shared/NavMenu.razor.css diff --git a/Public API/Client/Pages/LatestData.razor b/Public API/Client/Pages/LatestData.razor index 7cf171f..f83e377 100644 --- a/Public API/Client/Pages/LatestData.razor +++ b/Public API/Client/Pages/LatestData.razor @@ -55,6 +55,6 @@ protected override async Task OnInitializedAsync() { - sensorData = await http.GetFromJsonAsync<vw_SensorData[]>("frontend/LatestData"); + sensorData = await http.GetFromJsonAsync<vw_SensorData[]>("api/LatestData"); } } diff --git a/Public API/Client/Program.cs b/Public API/Client/Program.cs index 2feb57a..68d5c4f 100644 --- a/Public API/Client/Program.cs +++ b/Public API/Client/Program.cs @@ -31,7 +31,7 @@ namespace Public_API.Client BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); - builder.RootComponents.Add<App>("app"); + builder.RootComponents.Add<App>("#app"); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); diff --git a/Public API/Client/Public_API.Client.csproj b/Public API/Client/Public_API.Client.csproj index ce818e3..75a5246 100644 --- a/Public API/Client/Public_API.Client.csproj +++ b/Public API/Client/Public_API.Client.csproj @@ -1,16 +1,17 @@ -<Project Sdk="Microsoft.NET.Sdk.Web"> +<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> <PropertyGroup> - <TargetFramework>netstandard2.1</TargetFramework> - <RazorLangVersion>3.0</RazorLangVersion> + <TargetFramework>net5.0</TargetFramework> <AssemblyName>$(AssemblyName.Replace(' ', '_'))</AssemblyName> </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" /> - <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.1" PrivateAssets="all" /> - <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.1" PrivateAssets="all" /> - <PackageReference Include="System.Net.Http.Json" Version="3.2.0" /> + <PackageReference Include="Blazorise" Version="0.9.5.4" /> + <PackageReference Include="Blazorise.Bootstrap" Version="0.9.5.4" /> + <PackageReference Include="Blazorise.Icons.FontAwesome" Version="0.9.5.4" /> + <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.13" /> + <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.13" PrivateAssets="all" /> + <PackageReference Include="System.Net.Http.Json" Version="5.0.0" /> </ItemGroup> <ItemGroup> diff --git a/Public API/Client/Shared/MainLayout.razor b/Public API/Client/Shared/MainLayout.razor index 0f4e22a..688e25f 100644 --- a/Public API/Client/Shared/MainLayout.razor +++ b/Public API/Client/Shared/MainLayout.razor @@ -1,15 +1,16 @@ @inherits LayoutComponentBase - -<div class="sidebar"> - <NavMenu /> -</div> - -<div class="main"> - <div class="top-row px-4"> - <a href="http://blazor.net" target="_blank" class="ml-md-auto">About</a> +<div class="page"> + <div class="sidebar"> + <NavMenu /> </div> - <div class="content px-4"> - @Body + <div class="main"> + <div class="top-row px-4"> + <a href="http://blazor.net" target="_blank" class="ml-md-auto">About</a> + </div> + + <div class="content px-4"> + @Body + </div> </div> -</div> +</div> \ No newline at end of file diff --git a/Public API/Client/Shared/MainLayout.razor.css b/Public API/Client/Shared/MainLayout.razor.css new file mode 100644 index 0000000..599238d --- /dev/null +++ b/Public API/Client/Shared/MainLayout.razor.css @@ -0,0 +1,70 @@ +.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 .btn-link { + white-space: nowrap; + margin-left: 1.5rem; + } + + .top-row a:first-child { + overflow: hidden; + text-overflow: ellipsis; + } + +@media (max-width: 767.98px) { + .top-row:not(.auth) { + display: none; + } + + .top-row.auth { + justify-content: space-between; + } + + .top-row a, .top-row .btn-link { + margin-left: 0; + } +} + +@media (min-width: 768px) { + .page { + flex-direction: row; + } + + .sidebar { + width: 250px; + height: 100vh; + position: sticky; + top: 0; + } + + .top-row { + position: sticky; + top: 0; + z-index: 1; + } + + .main > div { + padding-left: 2rem !important; + padding-right: 1.5rem !important; + } +} diff --git a/Public API/Client/Shared/NavMenu.razor.css b/Public API/Client/Shared/NavMenu.razor.css new file mode 100644 index 0000000..c0fa289 --- /dev/null +++ b/Public API/Client/Shared/NavMenu.razor.css @@ -0,0 +1,62 @@ +.navbar-toggler { + background-color: rgba(255, 255, 255, 0.1); +} + +.top-row { + height: 3.5rem; + background-color: rgba(0,0,0,0.4); +} + +.navbar-brand { + font-size: 1.1rem; +} + +.oi { + width: 2rem; + font-size: 1.1rem; + vertical-align: text-top; + top: -2px; +} + +.nav-item { + font-size: 0.9rem; + padding-bottom: 0.5rem; +} + + .nav-item:first-of-type { + padding-top: 1rem; + } + + .nav-item:last-of-type { + padding-bottom: 1rem; + } + + .nav-item ::deep a { + color: #d7d7d7; + border-radius: 4px; + height: 3rem; + display: flex; + align-items: center; + line-height: 3rem; + } + + .nav-item ::deep a.active { + background-color: rgba(255,255,255,0.25); + color: white; + } + + .nav-item ::deep a:hover { + background-color: rgba(255,255,255,0.1); + color: white; + } + +@media (min-width: 768px) { + .navbar-toggler { + display: none; + } + + .collapse { + /* Never collapse the sidebar for wide screens */ + display: block; + } +} diff --git a/Public API/Client/_Imports.razor b/Public API/Client/_Imports.razor index 4248b66..d5ddf21 100644 --- a/Public API/Client/_Imports.razor +++ b/Public API/Client/_Imports.razor @@ -3,7 +3,9 @@ @using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.AspNetCore.Components.WebAssembly.Http @using Microsoft.JSInterop @using Public_API.Client -@using Public_API.Client.Shared \ No newline at end of file +@using Public_API.Client.Shared +@using Blazorise \ No newline at end of file diff --git a/Public API/Client/wwwroot/css/app.css b/Public API/Client/wwwroot/css/app.css index 4e4425c..82fc22a 100644 --- a/Public API/Client/wwwroot/css/app.css +++ b/Public API/Client/wwwroot/css/app.css @@ -14,97 +14,10 @@ a, .btn-link { border-color: #1861ac; } -app { - position: relative; - display: flex; - flex-direction: column; -} - -.top-row { - height: 3.5rem; - display: flex; - align-items: center; -} - -.main { - flex: 1; -} - - .main .top-row { - background-color: #f7f7f7; - border-bottom: 1px solid #d6d5d5; - justify-content: flex-end; - } - - .main .top-row > a, .main .top-row .btn-link { - white-space: nowrap; - margin-left: 1.5rem; - } - -.main .top-row a:first-child { - overflow: hidden; - text-overflow: ellipsis; -} - -.sidebar { - background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); -} - - .sidebar .top-row { - background-color: rgba(0,0,0,0.4); - } - - .sidebar .navbar-brand { - font-size: 1.1rem; - } - - .sidebar .oi { - width: 2rem; - font-size: 1.1rem; - vertical-align: text-top; - top: -2px; - } - - .sidebar .nav-item { - font-size: 0.9rem; - padding-bottom: 0.5rem; - } - - .sidebar .nav-item:first-of-type { - padding-top: 1rem; - } - - .sidebar .nav-item:last-of-type { - padding-bottom: 1rem; - } - - .sidebar .nav-item a { - color: #d7d7d7; - border-radius: 4px; - height: 3rem; - display: flex; - align-items: center; - line-height: 3rem; - } - - .sidebar .nav-item a.active { - background-color: rgba(255,255,255,0.25); - color: white; - } - - .sidebar .nav-item a:hover { - background-color: rgba(255,255,255,0.1); - color: white; - } - .content { padding-top: 1.1rem; } -.navbar-toggler { - background-color: rgba(255, 255, 255, 0.1); -} - .valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; } @@ -129,55 +42,9 @@ app { z-index: 1000; } -#blazor-error-ui .dismiss { - cursor: pointer; - position: absolute; - right: 0.75rem; - top: 0.5rem; -} - -@media (max-width: 767.98px) { - .main .top-row:not(.auth) { - display: none; - } - - .main .top-row.auth { - justify-content: space-between; - } - - .main .top-row a, .main .top-row .btn-link { - margin-left: 0; - } -} - -@media (min-width: 768px) { - app { - flex-direction: row; - } - - .sidebar { - width: 250px; - height: 100vh; - position: sticky; - top: 0; - } - - .main .top-row { - position: sticky; - top: 0; - } - - .main > div { - padding-left: 2rem !important; - padding-right: 1.5rem !important; - } - - .navbar-toggler { - display: none; + #blazor-error-ui .dismiss { + cursor: pointer; + position: absolute; + right: 0.75rem; + top: 0.5rem; } - - .sidebar .collapse { - /* Never collapse the sidebar for wide screens */ - display: block; - } -} diff --git a/Public API/Client/wwwroot/index.html b/Public API/Client/wwwroot/index.html index 8188970..623e678 100644 --- a/Public API/Client/wwwroot/index.html +++ b/Public API/Client/wwwroot/index.html @@ -12,10 +12,12 @@ <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" /> <link href="css/app.css" rel="stylesheet" /> + + <link href="Public_API.Client.styles.css" rel="stylesheet" /> </head> <body> - <app>Loading...</app> + <div id="app">Loading...</div> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script> diff --git a/Public API/Server/Controllers/APIController.cs b/Public API/Server/Controllers/APIController.cs index b74137a..c302937 100644 --- a/Public API/Server/Controllers/APIController.cs +++ b/Public API/Server/Controllers/APIController.cs @@ -2,6 +2,7 @@ using Public_API.Server.DAL; using Public_API.Shared.Models; using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Net; diff --git a/Public API/Server/Public_API.Server.csproj b/Public API/Server/Public_API.Server.csproj index 2f5b2c8..ae2db77 100644 --- a/Public API/Server/Public_API.Server.csproj +++ b/Public API/Server/Public_API.Server.csproj @@ -1,17 +1,19 @@ <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> - <TargetFramework>netcoreapp3.1</TargetFramework> + <TargetFramework>net5.0</TargetFramework> <RootNamespace>Public API.Server</RootNamespace> <AssemblyName>$(AssemblyName.Replace(' ', '_'))</AssemblyName> </PropertyGroup> <ItemGroup> + <PackageReference Include="Blazorise" Version="0.9.5.4" /> <PackageReference Include="Blazorise.Bootstrap" Version="0.9.5.4" /> - <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.1" /> + <PackageReference Include="Blazorise.Icons.FontAwesome" Version="0.9.5.4" /> + <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="5.0.13" /> <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" /> - <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.20" /> - <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.20" /> + <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.13" /> + <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.13" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.20"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> diff --git a/Public API/Shared/Public_API.Shared.csproj b/Public API/Shared/Public_API.Shared.csproj index fce8eef..ae53c33 100644 --- a/Public API/Shared/Public_API.Shared.csproj +++ b/Public API/Shared/Public_API.Shared.csproj @@ -1,7 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>netstandard2.1</TargetFramework> + <TargetFramework>net5.0</TargetFramework> </PropertyGroup> <ItemGroup> -- GitLab