From 7173c0795a8cf82c5535ca7c1942d3828f44f23f Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Sat, 4 Feb 2023 10:37:35 -0700 Subject: [PATCH] Added Blazor back --- ClientHub/OI.Metrology.ClientHub.csproj | 1 + ClientHub/Pages/_Host.cshtml | 2 ++ ClientHub/Program.cs | 2 ++ View/OI.Metrology.View.csproj | 7 ++++--- View/Pages/Export.razor | 7 +------ View/Pages/Export.razor.cs | 22 ++++++---------------- View/Shared/MainLayout.razor | 4 ++++ 7 files changed, 20 insertions(+), 25 deletions(-) diff --git a/ClientHub/OI.Metrology.ClientHub.csproj b/ClientHub/OI.Metrology.ClientHub.csproj index b5d6b0a..405ce38 100644 --- a/ClientHub/OI.Metrology.ClientHub.csproj +++ b/ClientHub/OI.Metrology.ClientHub.csproj @@ -6,6 +6,7 @@ win-x64 + diff --git a/ClientHub/Pages/_Host.cshtml b/ClientHub/Pages/_Host.cshtml index 4fb7fd4..d09286c 100644 --- a/ClientHub/Pages/_Host.cshtml +++ b/ClientHub/Pages/_Host.cshtml @@ -24,6 +24,7 @@ + @@ -61,6 +62,7 @@ + diff --git a/ClientHub/Program.cs b/ClientHub/Program.cs index f86dc71..4c801d7 100644 --- a/ClientHub/Program.cs +++ b/ClientHub/Program.cs @@ -1,5 +1,6 @@ using IgniteUI.Blazor.Controls; using OI.Metrology.View.Models; +using MudBlazor.Services; using Serilog; using Serilog.Core; @@ -23,6 +24,7 @@ internal class Program AppSettings appSettings = View.Models.Binder.AppSettings.Get(builder.Configuration); // Add services to the container. _ = builder.Services.AddRazorPages(); + _ = builder.Services.AddMudServices(); _ = builder.Services.AddIgniteUIBlazor(typeof(IgbIconModule)); _ = builder.Services.AddServerSideBlazor(); _ = builder.Services.AddHttpContextAccessor(); diff --git a/View/OI.Metrology.View.csproj b/View/OI.Metrology.View.csproj index 98ae133..26a1fa7 100644 --- a/View/OI.Metrology.View.csproj +++ b/View/OI.Metrology.View.csproj @@ -8,6 +8,7 @@ + @@ -16,7 +17,7 @@ - - - + + + \ No newline at end of file diff --git a/View/Pages/Export.razor b/View/Pages/Export.razor index 704feae..31d7080 100644 --- a/View/Pages/Export.razor +++ b/View/Pages/Export.razor @@ -1,6 +1,6 @@ @page "/Export" -@using IgniteUI.Blazor.Controls +@using MudBlazor @using Microsoft.AspNetCore.Components.Web @using OI.Metrology.Shared.DataModels @@ -12,11 +12,6 @@
- - - Refresh - - @if (_TimeSpan is null || _DateRange is null || _ToolTypeNameId is null || _ToolTypeNameIdCollection is null) {

Loading...

diff --git a/View/Pages/Export.razor.cs b/View/Pages/Export.razor.cs index 79ad450..6cd6b64 100644 --- a/View/Pages/Export.razor.cs +++ b/View/Pages/Export.razor.cs @@ -2,6 +2,7 @@ using IgniteUI.Blazor.Controls; using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Logging; using Microsoft.JSInterop; +using MudBlazor; using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.Models.Stateless; using System.Net; @@ -13,11 +14,10 @@ public partial class Export { protected TimeSpan? _TimeSpan; - protected TimeSpan? _DateRange; + protected DateRange? _DateRange; protected ToolTypeNameId? _ToolTypeNameId; protected ToolTypeNameId[]? _ToolTypeNameIdCollection; - protected IgbIcon? IconRef { get; set; } [Inject] protected HttpClient? HttpClient { get; set; } [Inject] protected IJSRuntime? JSRuntime { get; set; } [Inject] protected Models.AppSettings? AppSettings { get; set; } @@ -27,15 +27,6 @@ public partial class Export protected override Task OnAfterRenderAsync(bool firstRender) { - if (firstRender && IconRef is not null) - { - // _ = IconRef.EnsureReady().ContinueWith(new Action((e) => - // IconRef.RegisterIconAsync("build", "https://unpkg.com/material-design-icons@3.0.1/action/svg/production/ic_build_24px.svg", "material"))); - const string buildIcon = ""; - // const string review = "Code Review IconA picture showing encircled angle brackets with a dot between them."; - _ = IconRef.EnsureReady().ContinueWith(new Action((e) => - IconRef.RegisterIconFromTextAsync("build", buildIcon, "material"))); - } if (firstRender) { if (JSRuntime is null) @@ -51,7 +42,7 @@ public partial class Export { _ToolTypeNameId ??= new(); _TimeSpan ??= new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, 00); - _DateRange ??= new TimeSpan(DateTime.Now.Date.Ticks - DateTime.Now.AddMonths(-1).Date.Ticks); + _DateRange ??= new DateRange(DateTime.Now.AddMonths(-1).Date, DateTime.Now.Date); if (Logger is null) throw new NullReferenceException(nameof(Logger)); if (HttpClient is null) @@ -76,12 +67,11 @@ public partial class Export throw new NullReferenceException(nameof(JSRuntime)); if (HttpClient is null) throw new NullReferenceException(nameof(HttpClient)); - if (_TimeSpan is null || _DateRange is null || _ToolTypeNameId is null || _ToolTypeNameIdCollection is null || _ToolTypeNameId.ToolTypeName is null || _DateRange is null) + if (_TimeSpan is null || _DateRange is null || _ToolTypeNameId is null || _ToolTypeNameIdCollection is null || _ToolTypeNameId.ToolTypeName is null || _DateRange.Start is null || _DateRange.End is null) return; - TimeSpan timeSpan = new(_TimeSpan.Value.Ticks); string controllerName = IToolTypesController.GetRouteName(); - string endTime = _DateRange.Value.Add(timeSpan).ToString(); - string startTime = _DateRange.Value.Add(new TimeSpan(_TimeSpan.Value.Ticks)).ToString(); + string endTime = _DateRange.End.Value.AddTicks(_TimeSpan.Value.Ticks).ToString(); + string startTime = _DateRange.Start.Value.AddTicks(_TimeSpan.Value.Ticks).ToString(); string fileName = $"Export_{_ToolTypeNameId.ToolTypeName}_{startTime:yyyyMMddHHmm}_to_{endTime:yyyyMMddHHmm}.csv"; string query = $"datebegin={startTime:MM/dd/yyyy hh:mm tt}&dateend={endTime:MM/dd/yyyy hh:mm tt}&filename={WebUtility.UrlEncode(fileName)}"; await JSRuntime.InvokeVoidAsync("triggerFileDownload", fileName, $"{HttpClient.BaseAddress}api/{controllerName}/{_ToolTypeNameId.ID}/csv?{query}"); diff --git a/View/Shared/MainLayout.razor b/View/Shared/MainLayout.razor index c01e3ef..9adfeaa 100644 --- a/View/Shared/MainLayout.razor +++ b/View/Shared/MainLayout.razor @@ -1,5 +1,9 @@ @inherits LayoutComponentBase @namespace OI.Metrology.View.Shared +@using MudBlazor + + +