From 4b44775ce9129d02e23a83c87eb34519d206ec12 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Mon, 23 Jan 2023 13:48:43 -0700 Subject: [PATCH] Main Layout --- ClientHub/Pages/_Host.cshtml | 45 +--------------------------- ClientHub/Pages/_Host.cshtml.cs | 13 +------- ClientHub/Program.cs | 1 + ClientHub/Shared/MainLayout.razor | 45 ++++++++++++++++++++++++++-- ClientHub/Shared/MainLayout.razor.cs | 14 ++++++++- ClientHub/wwwroot/styles/Site.css | 2 +- 6 files changed, 60 insertions(+), 60 deletions(-) diff --git a/ClientHub/Pages/_Host.cshtml b/ClientHub/Pages/_Host.cshtml index 87aa5b7..d2ebf58 100644 --- a/ClientHub/Pages/_Host.cshtml +++ b/ClientHub/Pages/_Host.cshtml @@ -47,50 +47,7 @@ - -
- -
-
-

© @DateTime.Now.Year - Infineon Technologies

- @if (@Model.AppSettings.IsDevelopment) - { -

Request ID:@Model.RequestId

- } -
-
- -
+
diff --git a/ClientHub/Pages/_Host.cshtml.cs b/ClientHub/Pages/_Host.cshtml.cs index e809ada..5824d44 100644 --- a/ClientHub/Pages/_Host.cshtml.cs +++ b/ClientHub/Pages/_Host.cshtml.cs @@ -1,17 +1,6 @@ using Microsoft.AspNetCore.Mvc.RazorPages; -using OI.Metrology.ClientHub.Models; -using System.Diagnostics; namespace OI.Metrology.ClientHub.Pages; public partial class Host : PageModel -{ - - public AppSettings AppSettings { get; } - public string? RequestId { get; private set; } - - public Host(AppSettings appSettings) => AppSettings = appSettings; - - public void OnGet() => RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; - -} \ No newline at end of file +{ } \ No newline at end of file diff --git a/ClientHub/Program.cs b/ClientHub/Program.cs index 6d4ce44..bc4374f 100644 --- a/ClientHub/Program.cs +++ b/ClientHub/Program.cs @@ -26,6 +26,7 @@ internal class Program _ = builder.Services.AddRazorPages(); _ = builder.Services.AddMudServices(); _ = builder.Services.AddServerSideBlazor(); + _ = builder.Services.AddHttpContextAccessor(); _ = builder.Services.AddSingleton(_ => appSettings); _ = builder.Services.AddSingleton(); diff --git a/ClientHub/Shared/MainLayout.razor b/ClientHub/Shared/MainLayout.razor index 77bac2d..e076fe7 100644 --- a/ClientHub/Shared/MainLayout.razor +++ b/ClientHub/Shared/MainLayout.razor @@ -8,7 +8,48 @@ - @Body + +
+ @Body +
+
+ +

© @DateTime.Now.Year - Infineon Technologies

+ @if (AppSettings is not null && AppSettings.IsDevelopment) + { +

Request ID:@_RequestId

+ } +
+
- +
diff --git a/ClientHub/Shared/MainLayout.razor.cs b/ClientHub/Shared/MainLayout.razor.cs index 92878ce..4f9d334 100644 --- a/ClientHub/Shared/MainLayout.razor.cs +++ b/ClientHub/Shared/MainLayout.razor.cs @@ -1,4 +1,6 @@ -using MudBlazor; +using Microsoft.AspNetCore.Components; +using MudBlazor; +using System.Diagnostics; namespace OI.Metrology.ClientHub.Shared; @@ -7,10 +9,20 @@ public partial class MainLayout bool _DrawerOpen = true; private bool _IsDarkMode; + private string? _RequestId; private MudThemeProvider? _MudThemeProvider; + [Inject] protected Models.AppSettings? AppSettings { get; set; } + [Inject] protected IHttpContextAccessor? HttpContextAccessor { get; set; } + void DrawerToggle() => _DrawerOpen = !_DrawerOpen; + protected override void OnParametersSet() + { + base.OnParametersSet(); + _RequestId = Activity.Current?.Id ?? HttpContextAccessor?.HttpContext?.TraceIdentifier; + } + protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender && _MudThemeProvider is not null) diff --git a/ClientHub/wwwroot/styles/Site.css b/ClientHub/wwwroot/styles/Site.css index 1992cbc..418f67e 100644 --- a/ClientHub/wwwroot/styles/Site.css +++ b/ClientHub/wwwroot/styles/Site.css @@ -1,7 +1,7 @@ body { padding-top: 50px; padding-bottom: 20px; - background-color: #fafafa; + background-color:darkgrey; } /* Set padding to keep content from hitting the edges */