diff --git a/ClientHub/OI.Metrology.ClientHub.csproj b/ClientHub/OI.Metrology.ClientHub.csproj index 1b7a81f..5277eae 100644 --- a/ClientHub/OI.Metrology.ClientHub.csproj +++ b/ClientHub/OI.Metrology.ClientHub.csproj @@ -5,6 +5,12 @@ enable win-x64 + + + + + + diff --git a/ClientHub/Pages/AwaitingDisposition.razor b/ClientHub/Pages/AwaitingDisposition.razor index 4cc90d7..922cf54 100644 --- a/ClientHub/Pages/AwaitingDisposition.razor +++ b/ClientHub/Pages/AwaitingDisposition.razor @@ -1,6 +1,7 @@ @page "/AwaitingDisposition" @using Microsoft.AspNetCore.Components.Web +@using MudBlazor @namespace OI.Metrology.ClientHub.Pages @@ -11,12 +12,12 @@
-
+
- + Open
- + Refresh
diff --git a/ClientHub/Pages/Export.razor b/ClientHub/Pages/Export.razor index 21b75cb..ea2a3ec 100644 --- a/ClientHub/Pages/Export.razor +++ b/ClientHub/Pages/Export.razor @@ -10,7 +10,7 @@
-
+
diff --git a/ClientHub/Pages/RunHeaders.razor b/ClientHub/Pages/RunHeaders.razor index 7915cf1..3bd1873 100644 --- a/ClientHub/Pages/RunHeaders.razor +++ b/ClientHub/Pages/RunHeaders.razor @@ -19,7 +19,7 @@ - +
diff --git a/ClientHub/Pages/RunInfo.razor b/ClientHub/Pages/RunInfo.razor index 131200b..8f7e0ec 100644 --- a/ClientHub/Pages/RunInfo.razor +++ b/ClientHub/Pages/RunInfo.razor @@ -1,6 +1,7 @@ @page "/RunInfo/{Model?}" @using Microsoft.AspNetCore.Components.Web +@using MudBlazor @namespace OI.Metrology.ClientHub.Pages @@ -24,7 +25,7 @@
  
- + Load Headers
  
diff --git a/ClientHub/Pages/_Host.cshtml b/ClientHub/Pages/_Host.cshtml index c050772..87aa5b7 100644 --- a/ClientHub/Pages/_Host.cshtml +++ b/ClientHub/Pages/_Host.cshtml @@ -1,7 +1,6 @@ @page "/" @model OI.Metrology.ClientHub.Pages.Host -@using OI.Metrology.ClientHub.Models @using Microsoft.AspNetCore.Components.Web @namespace OI.Metrology.ClientHub.Pages @@ -25,6 +24,7 @@ + @@ -104,6 +104,7 @@ + diff --git a/ClientHub/Program.cs b/ClientHub/Program.cs index 06adbc2..6d4ce44 100644 --- a/ClientHub/Program.cs +++ b/ClientHub/Program.cs @@ -1,5 +1,8 @@ +using MudBlazor.Services; using OI.Metrology.ClientHub.Data; using OI.Metrology.ClientHub.Models; +using Serilog; +using Serilog.Core; namespace OI.Metrology.ClientHub; @@ -8,34 +11,51 @@ internal class Program private static void Main(string[] args) { WebApplicationBuilder builder = WebApplication.CreateBuilder(args); - AppSettings appSettings = Models.Binder.AppSettings.Get(builder.Configuration); - - // Add services to the container. - _ = builder.Services.AddRazorPages(); - _ = builder.Services.AddServerSideBlazor(); - - _ = builder.Services.AddSingleton(_ => appSettings); - _ = builder.Services.AddSingleton(); - - WebApplication app = builder.Build(); - - // Configure the HTTP request pipeline. - if (!app.Environment.IsDevelopment()) + LoggingLevelSwitch levelSwitch = new(); + LoggerConfiguration loggerConfiguration = new(); + // _ = loggerConfiguration.WriteTo.BrowserConsole(); + // _ = loggerConfiguration.MinimumLevel.ControlledBy(levelSwitch); + // _ = loggerConfiguration.Enrich.WithProperty("InstanceId", Guid.NewGuid().ToString("n")); + // _ = loggerConfiguration.WriteTo.BrowserHttp($"{apiUrl}ingest", controlLevelSwitch: levelSwitch); + Log.Logger = loggerConfiguration.CreateLogger(); + Serilog.ILogger log = Log.ForContext(); + try { - _ = app.UseExceptionHandler("/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - _ = app.UseHsts(); + AppSettings appSettings = Models.Binder.AppSettings.Get(builder.Configuration); + // Add services to the container. + _ = builder.Services.AddRazorPages(); + _ = builder.Services.AddMudServices(); + _ = builder.Services.AddServerSideBlazor(); + + _ = builder.Services.AddSingleton(_ => appSettings); + _ = builder.Services.AddSingleton(); + _ = builder.Services.AddScoped(serviceProvider => new HttpClient { BaseAddress = new Uri(appSettings.ApiUrl) }); + + WebApplication app = builder.Build(); + + // Configure the HTTP request pipeline. + if (!app.Environment.IsDevelopment()) + { + _ = app.UseExceptionHandler("/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + _ = app.UseHsts(); + } + + _ = app.UseHttpsRedirection(); + + _ = app.UseStaticFiles(); + + _ = app.UseRouting(); + + _ = app.MapBlazorHub(); + _ = app.MapFallbackToPage("/_Host"); + + app.Run(); + } + catch (Exception ex) + { + log.Fatal(ex, "An exception occurred while creating the WASM host"); + throw; } - - _ = app.UseHttpsRedirection(); - - _ = app.UseStaticFiles(); - - _ = app.UseRouting(); - - _ = app.MapBlazorHub(); - _ = app.MapFallbackToPage("/_Host"); - - app.Run(); } } \ No newline at end of file diff --git a/ClientHub/Shared/MainLayout.razor b/ClientHub/Shared/MainLayout.razor index b012d87..77bac2d 100644 --- a/ClientHub/Shared/MainLayout.razor +++ b/ClientHub/Shared/MainLayout.razor @@ -1,14 +1,14 @@ @inherits LayoutComponentBase @namespace OI.Metrology.ClientHub.Shared +@using MudBlazor -ClientHub + + -
- + -
- @Body -
-
+ + @Body + + + diff --git a/ClientHub/Shared/MainLayout.razor.cs b/ClientHub/Shared/MainLayout.razor.cs index f486cc1..92878ce 100644 --- a/ClientHub/Shared/MainLayout.razor.cs +++ b/ClientHub/Shared/MainLayout.razor.cs @@ -1,4 +1,23 @@ -namespace OI.Metrology.ClientHub.Shared; +using MudBlazor; + +namespace OI.Metrology.ClientHub.Shared; public partial class MainLayout -{ } \ No newline at end of file +{ + + bool _DrawerOpen = true; + private bool _IsDarkMode; + private MudThemeProvider? _MudThemeProvider; + + void DrawerToggle() => _DrawerOpen = !_DrawerOpen; + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender && _MudThemeProvider is not null) + { + _IsDarkMode = await _MudThemeProvider.GetSystemPreference(); + StateHasChanged(); + } + } + +} \ No newline at end of file