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 = ""; _ = IconRef.EnsureReady().ContinueWith(new Action((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; } }