using Microsoft.AspNetCore.Components; using MP.MONO.Data; using MP.MONO.Data.DbModels; using MP.MONO.UI.Data; using static MP.MONO.Core.Enums; namespace MP.MONO.UI.Components { public partial class MultiToolPlot { #region Public Properties public string pcss { get { string answ = "col-12"; int numPar = SelectedTools.Count; if (numPar > 6) { answ = "col-4"; } else if (numPar > 3) { answ = "col-6"; } return answ; } } [Parameter] public List SelectedTools { get => _selTools; set => _selTools = value; } [Parameter] public DataLogFilter SelFilter { get => _SelFilter; set { _SelFilter = value; } } #endregion Public Properties #region Protected Fields protected DateTime lastRec = DateTime.Now.AddMinutes(-1); #endregion Protected Fields #region Protected Properties protected DataLogFilter _SelFilter { get; set; } = new DataLogFilter(); protected List _selTools { get; set; } = new List(); #endregion Protected Properties #region Protected Methods protected override async Task OnInitializedAsync() { //await ReloadData(); await Task.Delay(1); } protected override async Task OnParametersSetAsync() { isLoading = true; await ReloadData(); await Task.Delay(1); } protected async Task ReloadData() { isLoading = true; ListRecords = null; await Task.Delay(1); ListRecords = await MMDataService.DataLogGetFilt(DataLogType.Tools, StartDate, EndDate); await Task.Delay(1); isLoading = false; } #endregion Protected Methods #region Private Fields private List? ListRecords = null; #endregion Private Fields #region Private Properties private DateTime EndDate { get => _SelFilter.DtEnd; } private bool isLoading { get; set; } = false; private DateTime StartDate { get => _SelFilter.DtStart; } #endregion Private Properties #region Private Methods private List val2plot(string fluxType) { List answ = new List(); if (ListRecords != null) { answ = ListRecords .Where(x => x.FluxType == fluxType) .Select(l => new chartJsData.chartJsTSerie() { x = l.DtRif, y = l.ValNum }) .ToList(); } return answ; } #endregion Private Methods } }