using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Components; using System.Net.Http; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Forms; using Microsoft.AspNetCore.Components.Routing; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web.Virtualization; using Microsoft.JSInterop; using MP.MONO.UI; using MP.MONO.UI.Shared; using MP.MONO.UI.Components; using MP.MONO.Core.DTO; using MP.MONO.UI.Data; using Newtonsoft.Json; using MP.MONO.Data; namespace MP.MONO.UI.Components { public partial class ToolsOverview { private List? ListRecords { get; set; } = null; protected override async Task OnInitializedAsync() { await ReloadData(); MMDataService.toolsPipe.EA_NewMessage += ToolsPipe_EA_NewMessage; } private void ToolsPipe_EA_NewMessage(object? sender, EventArgs e) { PubSubEventArgs currArgs = (PubSubEventArgs)e; if (!string.IsNullOrEmpty(currArgs.newMessage)) { try { ListRecords = JsonConvert.DeserializeObject>(currArgs.newMessage); } catch { } } InvokeAsync(() => { StateHasChanged(); }); } protected string percProgress(double num, double minVal, double maxVal) { string answ = "width: 0%;"; double den = (maxVal - minVal) != 0 ? (maxVal - minVal) : 1; double ratio = ((double)num) / den; answ = $"width: {ratio:P0};"; return answ; } protected async Task ReloadData() { ListRecords = await MMDataService.getTools(); } } }