AppSettings.ApiUrl

This commit is contained in:
2023-01-19 16:45:16 -07:00
parent a4d3a9899f
commit 10c823dca8
10 changed files with 202 additions and 39 deletions

View File

@ -1,5 +1,9 @@
{
"cSpell.words": [
"Blazor",
"Dispo",
"Hsts",
"Serilog",
"tooltype"
]
}

View File

@ -44,7 +44,7 @@
"args": [
"watch",
"--launch-profile",
"https",
"http",
"run",
"--project",
"${workspaceFolder}/OI.Metrology.ClientHub.csproj",

View File

@ -7,6 +7,7 @@ public partial class AwaitingDisposition
{
[Inject] protected IJSRuntime? JSRuntime { get; set; }
[Inject] protected Models.AppSettings? AppSettings { get; set; }
protected override Task OnAfterRenderAsync(bool firstRender)
{
@ -14,7 +15,9 @@ public partial class AwaitingDisposition
{
if (JSRuntime is null)
throw new NullReferenceException(nameof(JSRuntime));
return JSRuntime.InvokeVoidAsync("initAwaitingDisposition").AsTask();
if (AppSettings is null)
throw new NullReferenceException(nameof(AppSettings));
return JSRuntime.InvokeVoidAsync("initAwaitingDisposition", AppSettings.ApiUrl).AsTask();
}
return Task.CompletedTask;
}

View File

@ -7,6 +7,7 @@ public partial class Export
{
[Inject] protected IJSRuntime? JSRuntime { get; set; }
[Inject] protected Models.AppSettings? AppSettings { get; set; }
[Parameter] public Metrology.Shared.ViewModels.Export? Model { get; set; }
public Export()
@ -25,7 +26,9 @@ public partial class Export
{
if (JSRuntime is null)
throw new NullReferenceException(nameof(JSRuntime));
return JSRuntime.InvokeVoidAsync("initExport", DateTime.Now.AddMonths(-1), DateTime.Now).AsTask();
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;
}

View File

@ -7,6 +7,7 @@ public partial class RunHeaders
{
[Inject] protected IJSRuntime? JSRuntime { get; set; }
[Inject] protected Models.AppSettings? AppSettings { get; set; }
protected override Task OnAfterRenderAsync(bool firstRender)
{
@ -14,7 +15,9 @@ public partial class RunHeaders
{
if (JSRuntime is null)
throw new NullReferenceException(nameof(JSRuntime));
return JSRuntime.InvokeVoidAsync("initRunHeaders").AsTask();
if (AppSettings is null)
throw new NullReferenceException(nameof(AppSettings));
return JSRuntime.InvokeVoidAsync("initRunHeaders", AppSettings.ApiUrl).AsTask();
}
return Task.CompletedTask;
}

View File

@ -9,6 +9,7 @@ public partial class RunInfo
[Parameter] public Metrology.Shared.ViewModels.RunInfo? Model { get; set; }
[Inject] protected IJSRuntime? JSRuntime { get; set; }
[Inject] protected Models.AppSettings? AppSettings { get; set; }
protected override Task OnAfterRenderAsync(bool firstRender)
{
@ -16,10 +17,12 @@ public partial class RunInfo
{
if (JSRuntime is null)
throw new NullReferenceException(nameof(JSRuntime));
if (AppSettings is null)
throw new NullReferenceException(nameof(AppSettings));
int initialToolTypeID = Model is not null ? Model.ToolTypeID : 0;
int initialHeaderId = Model is not null ? Model.HeaderID : 0;
string initialHeaderAttachmentId = Model is not null ? Model.HeaderAttachmentID.ToString() : string.Empty;
return JSRuntime.InvokeVoidAsync("initRunInfo", initialToolTypeID, initialHeaderId, initialHeaderAttachmentId).AsTask();
return JSRuntime.InvokeVoidAsync("initRunInfo", AppSettings.ApiUrl, initialToolTypeID, initialHeaderId, initialHeaderAttachmentId).AsTask();
}
return Task.CompletedTask;
}

View File

@ -1,5 +1,6 @@
{
"ApiUrl": "https://localhost:7130",
"xApiUrl": "https://localhost:7130",
"ApiUrl": "http://messa010ec.ec.local:50301",
"DetailedErrors": true,
"IsDevelopment": true,
"IsStaging": false,

View File

@ -1,3 +1,4 @@
var _apiUrl = null;
var _initialHeaderAttachmentId = null;
var _initialHeaderId = null;
var _toolType = null;
@ -25,7 +26,8 @@ function loadRunInfoAwaitingDisposition() {
window.location.href = targetURL;
}
function initAwaitingDisposition() {
function initAwaitingDisposition(apiUrl) {
_apiUrl = apiUrl;
$("#grid").igGrid({
autoGenerateColumns: false,
width: "70%",
@ -45,7 +47,7 @@ function initAwaitingDisposition() {
{ key: "InsertDate", dataType: "date", width: "10%", format: "dateTime" },
{ key: "Expiration", dataType: "date", width: "10%", format: "dateTime" }
],
dataSource: "https://localhost:7130/api/awaitingdispo/",
dataSource: _apiUrl + "/api/awaitingdispo/",
responseDataKey: "Results",
tabIndex: 1,
features: [
@ -61,11 +63,12 @@ function initAwaitingDisposition() {
$("#grid").on("dblclick", "tr", loadRunInfoAwaitingDisposition);
};
function initExport(startTimeValue, endTimeValue) {
function initExport(apiUrl, startTimeValue, endTimeValue) {
_apiUrl = apiUrl;
var endTime = new Date(endTimeValue);
var startTime = new Date(startTimeValue);
$("#ToolType").igCombo({
dataSource: 'https://localhost:7130/api/tooltypes',
dataSource: _apiUrl + '/api/tooltypes',
responseDataKey: "Results",
textKey: "ToolTypeName",
valueKey: "ID",
@ -104,7 +107,7 @@ function loadHeaderGridRunHeaders() {
if (gridCreated)
$("#HeaderGrid").igGrid("destroy");
clearFieldsGridRunHeaders();
var headerURL = "https://localhost:7130/api/tooltypes/" + toolTypeID + "/headertitles";
var headerURL = _apiUrl + "/api/tooltypes/" + toolTypeID + "/headertitles";
$("#HeaderGrid").igGrid({
autoGenerateColumns: false,
primaryKey: "ID",
@ -134,7 +137,7 @@ function clearFieldsGridRunHeaders() {
function headerSelectionChangedRunHeaders(evt, ui) {
var toolTypeID = $("#ToolType").igCombo("value");
clearFieldsGridRunHeaders();
var url = "https://localhost:7130/api/tooltypes/" + toolTypeID + "/headers/" + ui.row.id + "/fields";
var url = _apiUrl + "/api/tooltypes/" + toolTypeID + "/headers/" + ui.row.id + "/fields";
$("#FieldsGrid").igGrid({
autoGenerateColumns: false,
primaryKey: "Column",
@ -153,9 +156,10 @@ function headerSelectionChangedRunHeaders(evt, ui) {
});
}
function initRunHeaders() {
function initRunHeaders(apiUrl) {
_apiUrl = apiUrl;
$("#ToolType").igCombo({
dataSource: 'https://localhost:7130/api/tooltypes',
dataSource: _apiUrl + '/api/tooltypes',
responseDataKey: "Results",
textKey: "ToolTypeName",
valueKey: "ID",
@ -181,7 +185,7 @@ function loadHeaderGridRunInfo() {
$("#HeaderGrid").igGrid("destroy");
$.ajax({
type: "GET",
url: "https://localhost:7130/api/tooltypes/" + toolTypeID + "?sortby=grid",
url: _apiUrl + "/api/tooltypes/" + toolTypeID + "?sortby=grid",
success: function (r) {
if ((r.Results == null) || (r.Results.ToolType == null) || (r.Results.Metadata == null))
ShowErrorMessage("Invalid tool type: " + toolTypeID);
@ -263,7 +267,7 @@ function detailSelectionChangedRunInfo(evt, ui) {
if (ui.row.index >= 0) {
var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index];
var toolTypeID = $("#ToolTypeID").text();
var attachmentUrlBase = 'https://localhost:7130/api/tooltypes/' + toolTypeID;
var attachmentUrlBase = _apiUrl + '/api/tooltypes/' + toolTypeID;
var attachmentId = rowData.AttachmentID;
if ((attachmentId == null) || (attachmentId === ''))
return;
@ -276,7 +280,7 @@ function detailSelectionChangedRunInfo(evt, ui) {
function loadHeaderAttachmentRunInfo() {
var toolTypeID = $("#ToolTypeID").text();
var attachmentId = $("#HeaderAttachmentId").text();
var attachmentUrlBase = 'https://localhost:7130/api/tooltypes/' + toolTypeID;
var attachmentUrlBase = _apiUrl + '/api/tooltypes/' + toolTypeID;
if ((attachmentId == null) || (attachmentId === '') || (_toolType.DisplayHeaderAttachment == null) || (_toolType.DisplayHeaderAttachment === '')) {
$("#HeaderAttachmentFrame").prop("src", "");
} else {
@ -290,7 +294,7 @@ function markAsReviewedRunInfo() {
var headerId = $("#HeaderId").text();
$.ajax({
type: "POST",
url: "https://localhost:7130/api/awaitingdispo/markasreviewed?tooltypeid=" + toolTypeId + "&headerid=" + headerId,
url: _apiUrl + "/api/awaitingdispo/markasreviewed?tooltypeid=" + toolTypeId + "&headerid=" + headerId,
success: function () {
},
error: function (e, ajaxOptions, ex) {
@ -308,7 +312,7 @@ function loadDetailsRunInfo() {
$("#DetailsGrid").igGrid("destroy");
var headerId = $("#HeaderId").text();
var toolTypeID = $("#ToolTypeID").text();
var detailsURL = "https://localhost:7130/api/tooltypes/" + toolTypeID + "/headers/" + headerId + "/data";
var detailsURL = _apiUrl + "/api/tooltypes/" + toolTypeID + "/headers/" + headerId + "/data";
var gridColumns = [
{ key: "AttachmentID", dataType: "string", hidden: true },
{ key: "Title", dataType: "string", hidden: true },
@ -372,7 +376,7 @@ function requestHeaderDataRunInfo() {
$("#HeaderAttachmentId").text(_initialHeaderAttachmentId);
_initialHeaderId = -1;
}
var headerURL = "https://localhost:7130/api/tooltypes/" + _toolType.ID + "/headers?" + $.param(parms);
var headerURL = _apiUrl + "/api/tooltypes/" + _toolType.ID + "/headers?" + $.param(parms);
var gridColumns = [
{ key: "ID", dataType: "number", hidden: true },
{ key: "AttachmentID", dataType: "string", hidden: true },
@ -428,7 +432,7 @@ function reviewButtonRunInfo() {
$("#ReviewButton").prop("disabled", true);
$.ajax({
type: "POST",
url: "https://localhost:7130/api/awaitingdispo/markasawaiting?tooltypeid=" + toolTypeId + "&headerid=" + headerId,
url: _apiUrl + "/api/awaitingdispo/markasawaiting?tooltypeid=" + toolTypeId + "&headerid=" + headerId,
success: function (e) {
DisplayWSMessage("info", "Marked as awaiting disposition", e);
$("#ReviewButton").prop("disabled", false);
@ -446,7 +450,7 @@ function oiExportButtonRunInfo() {
$("#OIExportButton").prop("disabled", true);
$.ajax({
type: "POST",
url: "https://localhost:7130/api/tooltypes/" + toolTypeID + "/headers/" + headerId + "/oiexport",
url: _apiUrl + "/api/tooltypes/" + toolTypeID + "/headers/" + headerId + "/oiexport",
success: function (r) {
$("#OIExportResult").text("Exported!");
},
@ -482,11 +486,12 @@ function setInitialDateTimesRunInfo() {
});
}
function initRunInfo(initialToolTypeID, initialHeaderId, initialHeaderAttachmentId) {
function initRunInfo(apiUrl, initialToolTypeID, initialHeaderId, initialHeaderAttachmentId) {
_apiUrl = apiUrl;
_initialHeaderId = initialHeaderId;
_initialHeaderAttachmentId = initialHeaderAttachmentId;
$("#ToolType").igCombo({
dataSource: 'https://localhost:7130/api/tooltypes',
dataSource: _apiUrl + '/api/tooltypes',
responseDataKey: "Results",
textKey: "ToolTypeName",
valueKey: "ID",