Created View Project

This commit is contained in:
Mike Phares 2023-02-04 10:17:21 -07:00
parent ff64ac6d98
commit 2f1353d36c
43 changed files with 94 additions and 152 deletions

View File

@ -1,4 +0,0 @@
namespace OI.Metrology.ClientHub;
public partial class App
{ }

View File

@ -1,12 +0,0 @@
namespace OI.Metrology.ClientHub.Data;
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}

View File

@ -1,19 +0,0 @@
namespace OI.Metrology.ClientHub.Data;
public class WeatherForecastService
{
private static readonly string[] _Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
public Task<WeatherForecast[]> GetForecastAsync(DateOnly startDate)
{
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = startDate.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = _Summaries[Random.Shared.Next(_Summaries.Length)]
}).ToArray());
}
}

View File

@ -13,5 +13,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Shared\OI.Metrology.Shared.csproj" /> <ProjectReference Include="..\Shared\OI.Metrology.Shared.csproj" />
<ProjectReference Include="..\View\OI.Metrology.View.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,4 +1,4 @@
@page @page
@model OI.Metrology.ClientHub.Pages.ErrorModel @model OI.Metrology.ClientHub.Pages.ErrorModel
<!DOCTYPE html> <!DOCTYPE html>

View File

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics; using System.Diagnostics;

View File

@ -1,41 +0,0 @@
@page "/fetchdata"
@using OI.Metrology.ClientHub.Data
@using Microsoft.AspNetCore.Components.Web
@namespace OI.Metrology.ClientHub.Pages
<PageTitle>Weather forecast</PageTitle>
<h1>Weather forecast</h1>
<p>This component demonstrates fetching data from a service.</p>
@if (_WeatherForecasts is null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (WeatherForecast weatherForecast in _WeatherForecasts)
{
<tr>
<td>@weatherForecast.Date.ToShortDateString()</td>
<td>@weatherForecast.TemperatureC</td>
<td>@weatherForecast.TemperatureF</td>
<td>@weatherForecast.Summary</td>
</tr>
}
</tbody>
</table>
}

View File

@ -1,17 +0,0 @@
using Microsoft.AspNetCore.Components;
using OI.Metrology.ClientHub.Data;
namespace OI.Metrology.ClientHub.Pages;
public partial class FetchData
{
private WeatherForecast[]? _WeatherForecasts;
[Inject] protected WeatherForecastService? ForecastService { get; set; }
protected override async Task OnInitializedAsync()
{
if (ForecastService is null)
throw new NullReferenceException(nameof(ForecastService));
_WeatherForecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
}
}

View File

@ -1,7 +0,0 @@
@page "/fetchServiceShoporders"
@using Microsoft.AspNetCore.Components.Web
@namespace OI.Metrology.ClientHub.Pages
<PageTitle>Service-Shop Orders</PageTitle>

View File

@ -1,4 +0,0 @@
namespace OI.Metrology.ClientHub.Pages;
public partial class FetchServiceShopOrders
{ }

View File

@ -1,4 +0,0 @@
namespace OI.Metrology.ClientHub.Pages;
public partial class Index
{ }

View File

@ -47,7 +47,7 @@
</head> </head>
<body> <body>
<component type="typeof(App)" render-mode="ServerPrerendered" /> <component type="typeof(View.App)" render-mode="ServerPrerendered" />
<div id="blazor-error-ui"> <div id="blazor-error-ui">
<environment include="Staging,Production"> <environment include="Staging,Production">

View File

@ -1,6 +1,5 @@
using IgniteUI.Blazor.Controls; using IgniteUI.Blazor.Controls;
using OI.Metrology.ClientHub.Data; using OI.Metrology.View.Models;
using OI.Metrology.ClientHub.Models;
using Serilog; using Serilog;
using Serilog.Core; using Serilog.Core;
@ -21,7 +20,7 @@ internal class Program
Serilog.ILogger log = Log.ForContext<Program>(); Serilog.ILogger log = Log.ForContext<Program>();
try try
{ {
AppSettings appSettings = Models.Binder.AppSettings.Get(builder.Configuration); AppSettings appSettings = View.Models.Binder.AppSettings.Get(builder.Configuration);
// Add services to the container. // Add services to the container.
_ = builder.Services.AddRazorPages(); _ = builder.Services.AddRazorPages();
_ = builder.Services.AddIgniteUIBlazor(typeof(IgbIconModule)); _ = builder.Services.AddIgniteUIBlazor(typeof(IgbIconModule));
@ -29,8 +28,6 @@ internal class Program
_ = builder.Services.AddHttpContextAccessor(); _ = builder.Services.AddHttpContextAccessor();
_ = builder.Services.AddSingleton(_ => appSettings); _ = builder.Services.AddSingleton(_ => appSettings);
_ = builder.Services.AddSingleton<WeatherForecastService>();
_ = builder.Services.AddSingleton<WeatherForecastService>();
_ = builder.Services.AddScoped(serviceProvider => new HttpClient { BaseAddress = new Uri(appSettings.ApiUrl) }); _ = builder.Services.AddScoped(serviceProvider => new HttpClient { BaseAddress = new Uri(appSettings.ApiUrl) });
WebApplication app = builder.Build(); WebApplication app = builder.Build();

View File

@ -1,4 +0,0 @@
namespace OI.Metrology.ClientHub.Shared;
public partial class NavMenu
{ }

View File

@ -7,4 +7,3 @@
@using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop @using Microsoft.JSInterop
@using OI.Metrology.ClientHub @using OI.Metrology.ClientHub
@using OI.Metrology.ClientHub.Shared

View File

@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Archive", "Archive\OI.Metro
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\OI.Metrology.Shared.csproj", "{A807EAE3-7DCB-4E5E-BE54-0D7410D18B3E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\OI.Metrology.Shared.csproj", "{A807EAE3-7DCB-4E5E-BE54-0D7410D18B3E}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "View", "View\OI.Metrology.View.csproj", "{D7988D0C-FE5D-429B-AA1C-911A1A29A468}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\OI.Metrology.Server.csproj", "{25C86DF8-EC1A-4D4B-AD4E-6561174824B9}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\OI.Metrology.Server.csproj", "{25C86DF8-EC1A-4D4B-AD4E-6561174824B9}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\OI.Metrology.Tests.csproj", "{B67FB8C4-402E-4D53-90A6-90F6FDB9D082}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\OI.Metrology.Tests.csproj", "{B67FB8C4-402E-4D53-90A6-90F6FDB9D082}"
@ -36,5 +38,9 @@ Global
{B67FB8C4-402E-4D53-90A6-90F6FDB9D082}.Debug|Any CPU.Build.0 = Debug|Any CPU {B67FB8C4-402E-4D53-90A6-90F6FDB9D082}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B67FB8C4-402E-4D53-90A6-90F6FDB9D082}.Release|Any CPU.ActiveCfg = Release|Any CPU {B67FB8C4-402E-4D53-90A6-90F6FDB9D082}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B67FB8C4-402E-4D53-90A6-90F6FDB9D082}.Release|Any CPU.Build.0 = Release|Any CPU {B67FB8C4-402E-4D53-90A6-90F6FDB9D082}.Release|Any CPU.Build.0 = Release|Any CPU
{D7988D0C-FE5D-429B-AA1C-911A1A29A468}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D7988D0C-FE5D-429B-AA1C-911A1A29A468}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7988D0C-FE5D-429B-AA1C-911A1A29A468}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7988D0C-FE5D-429B-AA1C-911A1A29A468}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -1,4 +1,8 @@
@namespace OI.Metrology.ClientHub @using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using OI.Metrology.View.Shared
@namespace OI.Metrology.View
<Router AppAssembly="@typeof(App).Assembly"> <Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData"> <Found Context="routeData">

10
View/App.razor.cs Normal file
View File

@ -0,0 +1,10 @@
namespace OI.Metrology.View;
public partial class App : Microsoft.AspNetCore.Components.ComponentBase
{
public App()
{
}
}

View File

@ -1,6 +1,6 @@
using System.Text.Json; using System.Text.Json;
namespace OI.Metrology.ClientHub.Models; namespace OI.Metrology.View.Models;
public record AppSettings(string ApiUrl, public record AppSettings(string ApiUrl,
string BuildNumber, string BuildNumber,

View File

@ -1,7 +1,8 @@
using Microsoft.Extensions.Configuration;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text.Json; using System.Text.Json;
namespace OI.Metrology.ClientHub.Models.Binder; namespace OI.Metrology.View.Models.Binder;
public class AppSettings public class AppSettings
{ {

View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.2" />
<PackageReference Include="IgniteUI.Blazor" Version="22.2.24" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.BrowserConsole" Version="1.0.0" />
<PackageReference Include="Serilog.Sinks.BrowserHttp" Version="1.0.0-dev-00032" />
<PackageReference Include="System.Net.Http.Json" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\OI.Metrology.Shared.csproj" />
</ItemGroup>
</Project>

View File

@ -1,9 +1,9 @@
@page "/" @page "/"
@page "/AwaitingDisposition" @page "/AwaitingDisposition"
@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web
@namespace OI.Metrology.ClientHub.Pages @namespace OI.Metrology.View
<PageTitle>Awaiting Disposition</PageTitle> <PageTitle>Awaiting Disposition</PageTitle>
<h4>Awaiting Disposition</h4> <h4>Awaiting Disposition</h4>

View File

@ -1,8 +1,9 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Logging;
using Microsoft.JSInterop; using Microsoft.JSInterop;
using OI.Metrology.ClientHub.Models; using OI.Metrology.View.Models;
namespace OI.Metrology.ClientHub.Pages; namespace OI.Metrology.View;
public partial class AwaitingDisposition public partial class AwaitingDisposition
{ {

View File

@ -2,7 +2,7 @@
@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web
@namespace OI.Metrology.ClientHub.Pages @namespace OI.Metrology.View.Pages
<PageTitle>Counter</PageTitle> <PageTitle>Counter</PageTitle>

View File

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Components;
namespace OI.Metrology.ClientHub.Pages; namespace OI.Metrology.View.Pages;
public partial class Counter public partial class Counter
{ {

View File

@ -1,10 +1,10 @@
@page "/Export" @page "/Export"
@using IgniteUI.Blazor.Controls @using IgniteUI.Blazor.Controls
@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web
@using OI.Metrology.Shared.DataModels @using OI.Metrology.Shared.DataModels
@namespace OI.Metrology.ClientHub.Pages @namespace OI.Metrology.View
<PageTitle>Export Data</PageTitle> <PageTitle>Export Data</PageTitle>

View File

@ -1,11 +1,13 @@
using IgniteUI.Blazor.Controls; using IgniteUI.Blazor.Controls;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Logging;
using Microsoft.JSInterop; using Microsoft.JSInterop;
using OI.Metrology.Shared.DataModels; using OI.Metrology.Shared.DataModels;
using OI.Metrology.Shared.Models.Stateless; using OI.Metrology.Shared.Models.Stateless;
using System.Net; using System.Net;
using System.Net.Http.Json;
namespace OI.Metrology.ClientHub.Pages; namespace OI.Metrology.View;
public partial class Export public partial class Export
{ {

View File

@ -1,7 +1,7 @@
@page "/Index" @page "/index"
@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web
@namespace OI.Metrology.ClientHub.Pages @namespace OI.Metrology.View
<PageTitle>Index</PageTitle> <PageTitle>Index</PageTitle>

View File

@ -0,0 +1,4 @@
namespace OI.Metrology.View;
public partial class Index
{ }

View File

@ -1,8 +1,8 @@
@page "/RunHeaders" @page "/RunHeaders"
@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web
@namespace OI.Metrology.ClientHub.Pages @namespace OI.Metrology.View
<PageTitle>Run Headers</PageTitle> <PageTitle>Run Headers</PageTitle>

View File

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop; using Microsoft.JSInterop;
namespace OI.Metrology.ClientHub.Pages; namespace OI.Metrology.View;
public partial class RunHeaders public partial class RunHeaders
{ {

View File

@ -1,8 +1,8 @@
@page "/RunInfo/{ToolTypeId:int?}/{HeaderId:int?}" @page "/RunInfo/{ToolTypeId:int?}/{HeaderId:int?}"
@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web
@namespace OI.Metrology.ClientHub.Pages @namespace OI.Metrology.View
<PageTitle>Run Info</PageTitle> <PageTitle>Run Info</PageTitle>

View File

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop; using Microsoft.JSInterop;
namespace OI.Metrology.ClientHub.Pages; namespace OI.Metrology.View;
public partial class RunInfo public partial class RunInfo
{ {

View File

@ -1,5 +1,5 @@
@inherits LayoutComponentBase @inherits LayoutComponentBase
@namespace OI.Metrology.ClientHub.Shared @namespace OI.Metrology.View.Shared
<div class="navbar navbar-fixed-top @(AppSettings is not null && AppSettings.IsDevelopment ? "test-database" : "" )"> <div class="navbar navbar-fixed-top @(AppSettings is not null && AppSettings.IsDevelopment ? "test-database" : "" )">
<div class="container-fluid"> <div class="container-fluid">

View File

@ -1,20 +1,19 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using System.Diagnostics; using System.Diagnostics;
namespace OI.Metrology.ClientHub.Shared; namespace OI.Metrology.View.Shared;
public partial class MainLayout public partial class MainLayout
{ {
private string? _RequestId; private string? _RequestId;
[Inject] protected Models.AppSettings? AppSettings { get; set; } [Inject] protected Models.AppSettings? AppSettings { get; set; }
[Inject] protected IHttpContextAccessor? HttpContextAccessor { get; set; }
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
base.OnParametersSet(); base.OnParametersSet();
_RequestId = Activity.Current?.Id ?? HttpContextAccessor?.HttpContext?.TraceIdentifier; _RequestId = Activity.Current?.Id ?? string.Empty;
} }
} }

View File

@ -1,4 +1,7 @@
@namespace OI.Metrology.ClientHub.Shared @using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Routing
@namespace OI.Metrology.View.Shared
<div class="top-row ps-3 navbar navbar-dark"> <div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid"> <div class="container-fluid">

View File

@ -0,0 +1,4 @@
namespace OI.Metrology.View.Shared;
public partial class NavMenu
{ }