Test Pinned via API

This commit is contained in:
2023-02-08 10:53:51 -07:00
parent 662863a11e
commit 8e471e278e
73 changed files with 1375 additions and 962 deletions

View File

@ -0,0 +1,23 @@
@page "/"
@page "/AwaitingDisposition"
@using MudBlazor
@using Microsoft.AspNetCore.Components.Web
@namespace OI.Metrology.View
<PageTitle>Awaiting Disposition</PageTitle>
<h4>Awaiting Disposition</h4>
<div style="height: 450px;">
<table id="grid"></table>
</div>
<div class="row" style="margin-top: 10px; margin-bottom: 20px;">
<MudChip Icon="@Icons.Material.Filled.FileOpen" Color="Color.Primary" Label="true" id="OpenButton">Open</MudChip>
<MudChip Icon="@Icons.Material.Filled.Refresh" Color="Color.Primary" Label="true" id="RefreshButton">Refresh</MudChip>
</div>
<script suppress-error="BL9992">
setInterval(function () { $("#RefreshButton").click(); }, 60000);
</script>

View File

@ -0,0 +1,45 @@
// using IgniteUI.Blazor.Controls;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Logging;
using Microsoft.JSInterop;
using OI.Metrology.View.Models;
namespace OI.Metrology.View;
public partial class AwaitingDisposition
{
// protected IgbIcon? OpenIconRef { get; set; }
// protected IgbIcon? RefreshIconRef { get; set; }
[Inject] protected IJSRuntime? JSRuntime { get; set; }
[Inject] protected HttpClient? HttpClient { get; set; }
[Inject] protected AppSettings? AppSettings { get; set; }
[Inject] protected ILogger<AwaitingDisposition>? Logger { get; set; }
protected override Task OnAfterRenderAsync(bool firstRender)
{
// if (firstRender && OpenIconRef is not null)
// {
// const string svg = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='512' height='512' aria-labelledby='gyjump-down-desc gyjump-down-title'><title id='gyjump-down-title'>Jump Down Icon</title><desc id='gyjump-down-desc'>A picture showing a bent arrow pointing down towards a line.</desc><path d='M21.5 18.5v2h-16v-2h16zm-8-15c1.6 0 3 .5 4.3 1.2l-1.5 1.5c-.8-.4-1.8-.7-2.8-.7-3.3 0-6 2.7-6 6h3l-4 4-4-4h3c0-1.5.4-2.9 1.2-4.2.6-1 1.4-1.8 2.4-2.5 1.2-.8 2.8-1.3 4.4-1.3z'/></svg>";
// _ = OpenIconRef.EnsureReady().ContinueWith(new Action<Task>((e) =>
// OpenIconRef.RegisterIconFromTextAsync("jump-down", svg, "material")));
// }
// if (firstRender && RefreshIconRef is not null)
// {
// const string svg = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='512' height='512' aria-labelledby='lzsystem-update-desc lzsystem-update-title'><title id='lzsystem-update-title'>System Update Icon</title><desc id='lzsystem-update-desc'>A picture depicting a computer screen with a reload symbol in the middle.</desc><path d='M20 2H4a2 2 0 00-2 2v12a2 2 0 002 2h6l-2 4h8l-2-4h6a2 2 0 002-2V4a2 2 0 00-2-2zm-8.194 2.923a5.077 5.077 0 104.724 6.923h.982a6.019 6.019 0 11-.237-4.277l.919-.2-.85 2.631-1.85-2.049.857-.184a5.1 5.1 0 00-4.545-2.844zM14 11.424l-.8.8-2-2V6.715h1.139v3.042z'/></svg>";
// _ = RefreshIconRef.EnsureReady().ContinueWith(new Action<Task>((e) =>
// RefreshIconRef.RegisterIconFromTextAsync("system-update", svg, "material")));
// }
if (firstRender)
{
if (JSRuntime is null)
throw new NullReferenceException(nameof(JSRuntime));
if (AppSettings is null)
throw new NullReferenceException(nameof(AppSettings));
return JSRuntime.InvokeVoidAsync("initAwaitingDisposition", AppSettings.ApiUrl).AsTask();
}
return Task.CompletedTask;
}
}

View File

@ -0,0 +1 @@


13
View/Pages/Counter.razor Normal file
View File

@ -0,0 +1,13 @@
@page "/counter"
@using Microsoft.AspNetCore.Components.Web
@namespace OI.Metrology.View.Pages
<PageTitle>Counter</PageTitle>
<h1>Counter - Bye</h1>
<p role="status">Current count: @_CurrentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

View File

@ -0,0 +1,21 @@
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Components;
namespace OI.Metrology.View.Pages;
public partial class Counter
{
[Inject] protected ILogger<Counter>? Logger { get; set; }
private int _CurrentCount = 0;
private void IncrementCount()
{
if (Logger is null)
throw new NullReferenceException(nameof(Logger));
Logger.LogWarning("Someone has clicked me!");
_CurrentCount++;
}
}

42
View/Pages/Export.razor Normal file
View File

@ -0,0 +1,42 @@
@page "/Export"
@using MudBlazor
@using Microsoft.AspNetCore.Components.Web
@using OI.Metrology.Shared.DataModels
@namespace OI.Metrology.View
<PageTitle>Export Data</PageTitle>
<h3>Export Data</h3>
<hr />
@if (_TimeSpan is null || _DateRange is null || _ToolTypeNameId is null || _ToolTypeNameIdCollection is null)
{
<p><em>Loading...</em></p>
}
else
{
<table id="ExportData">
<tr>
<td>
<MudSelect @bind-Value="_ToolTypeNameId" ToStringFunc="@_ConvertFunc" Label="Tool Type" Placeholder="Please Select" AdornmentColor="Color.Primary">
@foreach (ToolTypeNameId toolTypeNameId in _ToolTypeNameIdCollection)
{
<MudSelectItem Value="@toolTypeNameId" />
}
</MudSelect>
</td>
<td>
<MudDateRangePicker Label="Date Range" @bind-DateRange="_DateRange" />
</td>
<td>
<MudTimePicker Label="Start and End Time" AmPm="true" @bind-Time="_TimeSpan" />
</td>
<td>
<MudButton Variant="Variant.Filled" Color="Color.Info" OnClick="DownloadAsync">Download</MudButton>
</td>
</tr>
</table>
}

View File

@ -0,0 +1,80 @@
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;
using System.Net.Http.Json;
namespace OI.Metrology.View;
public partial class Export
{
protected TimeSpan? _TimeSpan;
protected DateRange? _DateRange;
protected ToolTypeNameId? _ToolTypeNameId;
protected ToolTypeNameId[]? _ToolTypeNameIdCollection;
[Inject] protected HttpClient? HttpClient { get; set; }
[Inject] protected IJSRuntime? JSRuntime { get; set; }
[Inject] protected Models.AppSettings? AppSettings { get; set; }
[Inject] protected ILogger<AwaitingDisposition>? Logger { get; set; }
protected Func<ToolTypeNameId, string> _ConvertFunc = toolTypeNameId => string.Concat(toolTypeNameId?.ToolTypeName);
protected override Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
if (JSRuntime is null)
throw new NullReferenceException(nameof(JSRuntime));
if (AppSettings is null)
throw new NullReferenceException(nameof(AppSettings));
return JSRuntime.InvokeVoidAsync("initExport", AppSettings.ApiUrl, DateTime.Now.AddMonths(-1), DateTime.Now).AsTask();
}
return Task.CompletedTask;
}
protected override async Task OnInitializedAsync()
{
_ToolTypeNameId ??= new();
_TimeSpan ??= new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, 00);
_DateRange ??= new DateRange(DateTime.Now.AddMonths(-1).Date, DateTime.Now.Date);
if (Logger is null)
throw new NullReferenceException(nameof(Logger));
if (HttpClient is null)
throw new NullReferenceException(nameof(HttpClient));
string controllerName = IToolTypesController<object>.GetRouteName();
try
{
Result<ToolTypeNameId[]>? result = await HttpClient.GetFromJsonAsync<Result<ToolTypeNameId[]>>($"api/{controllerName}");
if (result is not null)
_ToolTypeNameIdCollection = result.Results;
}
catch (Exception)
{
string json = await HttpClient.GetStringAsync($"api/{controllerName}");
Logger.LogInformation(message: json);
}
}
protected async Task DownloadAsync()
{
if (JSRuntime is null)
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.Start is null || _DateRange.End is null)
return;
string controllerName = IToolTypesController<object>.GetRouteName();
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}");
}
}

View File

@ -0,0 +1,4 @@
td {
padding-bottom: 2em;
padding-right: 1em;
}

15
View/Pages/Index.razor Normal file
View File

@ -0,0 +1,15 @@
@page "/index"
@using Microsoft.AspNetCore.Components.Web
@using IgniteUI.Blazor.Controls
@namespace OI.Metrology.View
<PageTitle>Index</PageTitle>
<IgbChip Size="SizableComponentSize.Medium" Selectable="false" Removable="false">
<span slot="start">
<IgbIcon @ref="@BrushIconRef" IconName="brush" Collection="material" ></IgbIcon>
</span>
Start Slot
</IgbChip>

32
View/Pages/Index.razor.cs Normal file
View File

@ -0,0 +1,32 @@
using IgniteUI.Blazor.Controls;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace OI.Metrology.View;
public partial class Index
{
[Inject] protected IJSRuntime? JSRuntime { get; set; }
protected IgbIcon? BrushIconRef { get; set; }
protected override Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender && BrushIconRef is not null)
{
string refreshIcon = "<svg width='24px' height='24px' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-refresh-ccw'><polyline points='1 4 1 10 7 10'></polyline><polyline points='23 20 23 14 17 14'></polyline><path d='M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15'></path></svg>";
string brushIcon = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' aria-labelledby='bqbrush-desc bqbrush-title'><title id='bqbrush-title'>Brush Icon</title><desc id='bqbrush-desc'>A picture showing a painting brush.</desc><path d='M13.093 6.743a1.074 1.074 0 011.306.251l.237.237-6.4 6.4-.242-.231a1.074 1.074 0 01-.251-1.306c.446-.693 1.553-2.516.515-3.554-1.584-1.585-2.225-.94-3.809-2.528S2.714 3 3.354 2.354s2.073-.489 3.658 1.095.943 2.225 2.527 3.809c1.038 1.042 2.861-.069 3.554-.515zm6.93 5.874L15.31 7.9 8.9 14.31l4.433 4.433c-.039.159-.084.327-.137.508 0 0-.8 2.749.8 2.749s.8-2.749.8-2.749a10.75 10.75 0 01-.272-1.14L16.2 16.44a8.944 8.944 0 00-2.072-3.314s.555-.545 3.323 2.063l.811-.811-1.54-2.5 2.5 1.539z'/></svg>";
_ = BrushIconRef.EnsureReady().ContinueWith(new Action<Task>((e) =>
BrushIconRef.RegisterIconFromTextAsync("brush", brushIcon, "material")));
}
if (firstRender)
{
if (JSRuntime is null)
throw new NullReferenceException(nameof(JSRuntime));
return JSRuntime.InvokeVoidAsync("initIndex").AsTask();
}
return Task.CompletedTask;
}
}

View File

@ -0,0 +1,40 @@
@page "/RunHeaders"
@using Microsoft.AspNetCore.Components.Web
@namespace OI.Metrology.View
<PageTitle>Run Headers</PageTitle>
<h4>Run Headers</h4>
<table>
<tr>
<td>
<label for="ToolType">Tool Type:</label>
</td>
<td>
<div id="ToolType"></div>
</td>
</tr>
</table>
<table width="100%" height="80%" style="min-height:480px;">
<tr>
<td width="50%">
<table id="HeaderGrid"></table>
</td>
<td width="50%">
<table id="FieldsGrid"></table>
</td>
</tr>
</table>
<div class="row" style="margin-top: 10px; margin-bottom: 20px;">
<div class="col-xs-1">
<input type="button" class="btn" id="OpenButton" value="Open" />
</div>
<div class="col-xs-1">
<input type="button" class="btn" id="RefreshButton" value="Refresh" />
</div>
</div>

View File

@ -0,0 +1,34 @@
using IgniteUI.Blazor.Controls;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace OI.Metrology.View;
public partial class RunHeaders
{
protected IgbIcon? IconRef { get; set; }
[Inject] protected IJSRuntime? JSRuntime { get; set; }
[Inject] protected Models.AppSettings? AppSettings { get; set; }
protected override Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender && IconRef is not null)
{
const string buildIcon = "<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path d='M22.7 19l-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4z'/></svg>";
_ = IconRef.EnsureReady().ContinueWith(new Action<Task>((e) =>
IconRef.RegisterIconFromTextAsync("build", buildIcon, "material")));
}
if (firstRender)
{
if (JSRuntime is null)
throw new NullReferenceException(nameof(JSRuntime));
if (AppSettings is null)
throw new NullReferenceException(nameof(AppSettings));
return JSRuntime.InvokeVoidAsync("initRunHeaders", AppSettings.ApiUrl).AsTask();
}
return Task.CompletedTask;
}
}

View File

@ -0,0 +1,17 @@
html,
body {
height: 100%;
}
div.container-fluid {
height: 90%;
}
#HeaderGrid,
#FieldsGrid {
font-size: 12px;
}
.FieldTitle {
font-weight: bold;
}

69
View/Pages/RunInfo.razor Normal file
View File

@ -0,0 +1,69 @@
@page "/RunInfo/{ToolTypeId:int?}/{HeaderId:int?}"
@using Microsoft.AspNetCore.Components.Web
@namespace OI.Metrology.View
<PageTitle>Run Info</PageTitle>
<h4>Run Information</h4>
<form class="form-inline mb-4">
<div class="form-group">
<label for="ToolType">Tool Type</label>
<div class="form-control" id="ToolType"></div>
</div>
<div class="form-group">
<label for="StartDate">Start Time</label>
<div class="form-control mb-2 mr-sm-2" id="StartDate"></div>
<div class="form-control mb-2 mr-sm-2" id="StartTime"></div>
</div>
<div class="form-group">
<label for="EndDate">End Time</label>
<div class="form-control mb-2 mr-sm-2" id="EndDate"></div>
<div class="form-control mb-2 mr-sm-2" id="EndTime"></div>
</div>&nbsp;&nbsp;
<div class="form-group">
<input class="btn btn-primary" type="button" value="Load Headers" id="LoadHeadersButton" />
</div>&nbsp;&nbsp;
<div class="form-group">
<label class="form-check-label" for="chkAutoRefresh">
Auto-Refresh
</label>
<input class="form-check-input" type="checkbox" id="chkAutoRefresh">
</div>
</form>
<div style="height: 300px;" id="HeaderGridDiv">
<span id="ToolTypeID" hidden></span>
<table id="HeaderGrid"></table>
</div>
<div class="row" style="margin-top: 10px; margin-bottom: 20px;">
<div class="col-xs-1">
<input type="button" class="btn" id="GetDataButton" value="Get Data" disabled />
</div>
<div class="col-xs-1">
<input type="button" class="btn" id="ReviewButton" value="Review" disabled />
</div>
</div>
<div id="DetailsDiv" hidden>
<span id="HeaderId" hidden></span>
<span id="HeaderAttachmentId" hidden></span>
<div style="padding-bottom: 20px;" id="DetailsGridDiv">
<table id="DetailsGrid"></table>
</div>
<div id="ExportDiv" style="margin-top: 10px;" hidden>
<input type="button" class="btn" value="Send to OpenInsight" id="OIExportButton" />
<span id="OIExportResult" style="margin-left: 10px; font-weight: bold; color: #366b02;"></span>
</div>
<p style="text-align: center; margin-top: 20px;">
<iframe id="DataAttachmentFrame" style="height:900px; border-width:thin; margin-right: 10px;" hidden></iframe>
<iframe id="HeaderAttachmentFrame" style="height:900px; border-width:thin;" hidden></iframe>
</p>
</div>

View File

@ -0,0 +1,41 @@
using IgniteUI.Blazor.Controls;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace OI.Metrology.View;
public partial class RunInfo
{
protected IgbIcon? IconRef { get; set; }
[Parameter] public int? HeaderId { get; set; }
[Parameter] public int? ToolTypeId { get; set; }
[Inject] protected IJSRuntime? JSRuntime { get; set; }
[Inject] protected Models.AppSettings? AppSettings { get; set; }
protected override Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender && IconRef is not null)
{
const string buildIcon = "<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><path d='M22.7 19l-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4z'/></svg>";
_ = IconRef.EnsureReady().ContinueWith(new Action<Task>((e) =>
IconRef.RegisterIconFromTextAsync("build", buildIcon, "material")));
}
if (firstRender)
{
if (JSRuntime is null)
throw new NullReferenceException(nameof(JSRuntime));
if (AppSettings is null)
throw new NullReferenceException(nameof(AppSettings));
Metrology.Shared.ViewModels.RunInfo? model = null;
int initialHeaderId = model is not null ? model.HeaderID : HeaderId is not null ? HeaderId.Value : 0;
string initialHeaderAttachmentId = model is not null ? model.HeaderAttachmentID.ToString() : string.Empty;
int initialToolTypeID = model is not null ? model.ToolTypeID : ToolTypeId is not null ? ToolTypeId.Value : 1;
return JSRuntime.InvokeVoidAsync("initRunInfo", AppSettings.ApiUrl, initialToolTypeID, initialHeaderId, initialHeaderAttachmentId).AsTask();
}
return Task.CompletedTask;
}
}

View File

@ -0,0 +1,8 @@
#HeaderGridDiv,
#DetailsGridDiv {
font-size: 12px;
}
p {
color: red;
background-color: aqua;
}