CORS, Theme, Better flow and dotnet tools - II

This commit is contained in:
2023-01-05 12:40:46 -07:00
parent 978e698da5
commit 85028743ed
21 changed files with 246 additions and 69 deletions

20
Client/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,20 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Edge",
"port": 9222,
"request": "attach",
"type": "msedge",
"webRoot": "${workspaceFolder}",
"url": "http://localhost:5055/counter",
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
},
{
"name": "Launch Microsoft Edge and open the Edge DevTools",
"request": "launch",
"type": "vscode-edge-devtools.debug",
"url": "http://localhost:5055"
}
]
}

41
Client/.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Expose.MyIT.Client.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/Expose.MyIT.Client.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/Expose.MyIT.Client.csproj"
],
"problemMatcher": "$msCompile"
}
]
}

4
Client/App.razor.cs Normal file
View File

@ -0,0 +1,4 @@
namespace Expose.MyIT.Client;
public partial class App
{ }

View File

@ -9,12 +9,12 @@
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Runtime.WebAssembly.Sdk" Version="7.0.0" />
<PackageReference Include="MudBlazor" Version="6.0.13" />
<PackageReference Include="Microsoft.NET.Runtime.WebAssembly.Sdk" Version="7.0.1" />
<PackageReference Include="MudBlazor" Version="6.1.7" />
<PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00032" />
<PackageReference Include="Serilog.Sinks.BrowserConsole" Version="1.0.0" />
<PackageReference Include="Serilog.Sinks.BrowserHttp" Version="1.0.0-dev-00032" />

View File

@ -7,16 +7,24 @@ namespace Expose.MyIT.Client.Pages;
public partial class FetchData
{
[Inject] protected HttpClient? Http { get; set; }
[Inject] protected HttpClient? HttpClient { get; set; }
[Inject] protected ILogger<FetchData>? Logger { get; set; }
private WeatherForecast[]? _Forecasts;
protected override async Task OnInitializedAsync()
{
if (Http is null)
throw new NullReferenceException(nameof(Http));
string controllerName = MyIT.Shared.Models.Stateless.Methods.IWeatherForecastController.GetRouteName();
// _SsaOrders = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
_Forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>($"api/{controllerName}");
if (Logger is null)
throw new NullReferenceException(nameof(Logger));
if (HttpClient is null)
throw new NullReferenceException(nameof(HttpClient));
string controllerName = MyIT.Shared.Models.Stateless.IWeatherForecastController<object>.GetRouteName();
try
{ _Forecasts = await HttpClient.GetFromJsonAsync<WeatherForecast[]>($"api/{controllerName}"); }
catch (Exception)
{
string json = await HttpClient.GetStringAsync($"api/{controllerName}");
Logger.LogInformation(message: json);
}
}
}

View File

@ -1,4 +1,5 @@
using Expose.MyIT.Shared.ViewModels;
using Expose.MyIT.Shared.Models.Stateless;
using Expose.MyIT.Shared.ViewModels;
using Microsoft.AspNetCore.Components;
using System.Net.Http.Json;
@ -7,7 +8,8 @@ namespace Expose.MyIT.Client.Pages;
public partial class FetchServiceShopOrders
{
[Inject] protected HttpClient? Http { get; set; }
[Inject] protected HttpClient? HttpClient { get; set; }
[Inject] protected ILogger<FetchServiceShopOrders>? Logger { get; set; }
private ServiceShopOrder[]? _ServiceShopOrders;
@ -24,10 +26,18 @@ public partial class FetchServiceShopOrders
protected override async Task OnInitializedAsync()
{
if (Http is null)
throw new NullReferenceException(nameof(Http));
string controllerName = MyIT.Shared.Models.Stateless.Methods.IServiceShopOrderController.GetRouteName();
string actionName = nameof(MyIT.Shared.Models.Stateless.Methods.ISsaOrderController.GetAllSsaOrders).Substring(3, 3);
_ServiceShopOrders = await Http.GetFromJsonAsync<ServiceShopOrder[]>($"api/{controllerName}/{actionName}");
if (Logger is null)
throw new NullReferenceException(nameof(Logger));
if (HttpClient is null)
throw new NullReferenceException(nameof(HttpClient));
string actionName = nameof(IServiceShopOrderController<object>.Action.All);
string controllerName = IServiceShopOrderController<object>.GetRouteName();
try
{ _ServiceShopOrders = await HttpClient.GetFromJsonAsync<ServiceShopOrder[]>($"api/{controllerName}/{actionName}"); }
catch (Exception)
{
string json = await HttpClient.GetStringAsync($"api/{controllerName}/{actionName}");
Logger.LogInformation(message: json);
}
}
}

View File

@ -0,0 +1,42 @@
@page "/fetchssaorders"
@using Expose.MyIT.Shared.ViewModels
<PageTitle>SSA Orders</PageTitle>
<MudText Typo="Typo.h3" GutterBottom="true">SSA Orders</MudText>
@if (_SsaOrders == null)
{
<MudProgressCircular Color="Color.Default" Indeterminate="true" />
}
else
{
<MudTable Items="_SsaOrders" Hover="true" SortLabel="Sort By" Elevation="0">
<HeaderContent>
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.Id)">Id</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.Name)">Name</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.BookingNames)">Booking Names</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.Type)">Type</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.State)">State</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.ItemNumber)">Item Number</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel InitialDirection="SortDirection.Descending" SortBy="new Func<SsaOrder, object>(x=>x.CreatedDate)">Created Date</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.DecidedDate)">Decided Date</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.Recipient)">Recipient</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<SsaOrder, object>(x=>x.Requestor)">Requestor</MudTableSortLabel></MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Id">@context.Id</MudTd>
<MudTd DataLabel="Name">@context.Name</MudTd>
<MudTd DataLabel="BookingNames">@string.Join(' ', context.BookingNames)</MudTd>
<MudTd DataLabel="Type">@context.Type</MudTd>
<MudTd DataLabel="State">@context.State</MudTd>
<MudTd DataLabel="ItemNumber">@context.ItemNumber</MudTd>
<MudTd DataLabel="CreatedDate">@context.CreatedDate</MudTd>
<MudTd DataLabel="DecidedDate">@context.DecidedDate</MudTd>
<MudTd DataLabel="Recipient">@context.Recipient</MudTd>
<MudTd DataLabel="Requestor">@context.Requestor</MudTd>
</RowTemplate>
<PagerContent>
<MudTablePager PageSizeOptions="new int[]{50, 100}" />
</PagerContent>
</MudTable>
}

View File

@ -0,0 +1,43 @@
using Expose.MyIT.Shared.Models.Stateless;
using Expose.MyIT.Shared.ViewModels;
using Microsoft.AspNetCore.Components;
using System.Net.Http.Json;
namespace Expose.MyIT.Client.Pages;
public partial class FetchSsaOrders
{
[Inject] protected HttpClient? HttpClient { get; set; }
[Inject] protected ILogger<Counter>? Logger { get; set; }
private SsaOrder[]? _SsaOrders;
//Id
//Name
//BookingNames
//Type
//State
//ItemNumber
//CreatedDate
//DecidedDate
//Recipient
//Requestor
protected override async Task OnInitializedAsync()
{
if (Logger is null)
throw new NullReferenceException(nameof(Logger));
if (HttpClient is null)
throw new NullReferenceException(nameof(HttpClient));
string actionName = nameof(ISsaOrderController<object>.Action.All);
string controllerName = ISsaOrderController<object>.GetRouteName();
try
{ _SsaOrders = await HttpClient.GetFromJsonAsync<SsaOrder[]>($"api/{controllerName}/{actionName}"); }
catch (Exception)
{
string json = await HttpClient.GetStringAsync($"api/{controllerName}/{actionName}");
Logger.LogInformation(message: json);
}
}
}

View File

@ -0,0 +1,4 @@
namespace Expose.MyIT.Client.Pages;
public partial class Index
{ }

View File

@ -1,6 +1,5 @@
@inherits LayoutComponentBase
<MudThemeProvider />
<MudDialogProvider />
<MudSnackbarProvider />

View File

@ -0,0 +1,4 @@
namespace Expose.MyIT.Client.Shared;
public partial class NavMenu
{ }