using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using MP.Data.DatabaseModels; using MP.SPEC.Components; using MP.SPEC.Data; namespace MP.SPEC.Components { public partial class ODLPlot { #region Public Properties public int OdlId { get => _selParam; } [Parameter] public int SelectedOdl { get => _selParam; set => _selParam = value; } #endregion Public Properties #region Protected Properties //protected DataLogFilter _SelFilter { get; set; } = new DataLogFilter(); protected int _selParam { get; set; } = -1; #endregion Protected Properties #region Protected Methods private bool isLoading { get; set; } = false; protected override async Task OnInitializedAsync() { isLoading = true; await Task.Delay(1); } private List? ListRecords = null; protected override async Task OnParametersSetAsync() { await ReloadData(); await Task.Delay(1); } public List Data = new List(); public List Labels = new List(); public List colors = new List(); protected async Task ReloadData() { Data.Clear(); Labels.Clear(); colors.Clear(); ListRecords = await MDService.StatOdl(SelectedOdl); foreach (var record in ListRecords) { Data.Add(record.TotDurata); Labels.Add($"{record.Descrizione} - {record.TotDurata:N1}min"); if (record.Css == "yellow") { colors.Add(new DoughnutStyling("orange", "ccc")); } else if (record.Css == "blue") { colors.Add(new DoughnutStyling("#2874A6", "ccc")); } else { colors.Add(new DoughnutStyling(record.Css, "ccc")); } } await Task.Delay(1); isLoading = false; } [Inject] protected MpDataService MDService { get; set; } = null!; #endregion Protected Methods } }