143 lines
3.8 KiB
C#
143 lines
3.8 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.Core.DTO;
|
|
using MP.Data.Services.Utils;
|
|
|
|
namespace MP.IOC.Components.Pages
|
|
{
|
|
public partial class CallStats
|
|
{
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Genera colori sfondo 33% rosso / arancione / giallo
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected List<string> bgColors
|
|
{
|
|
get => semaphColors(currData.Count, "0.3");
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private List<StatDataDTO> currData = new();
|
|
|
|
private string currHistId = "";
|
|
private string currPieId = "";
|
|
|
|
private string currTitle = "";
|
|
|
|
private Dictionary<string, List<StatDataDTO>> ParetoDay = new();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private List<double> DatiPareto
|
|
{
|
|
get => currData.Select(x => x.Value).ToList();
|
|
}
|
|
|
|
private List<string> LabelPareto
|
|
{
|
|
get => currData.Select(x => x.Label).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Genera colori sfondo 33% rosso / arancione / giallo
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private List<string> lineColors
|
|
{
|
|
get => semaphColors(currData.Count, "1");
|
|
}
|
|
|
|
[Inject]
|
|
private IStatsDetailService StatsDetService { get; set; } = null!;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private string CheckSelect(string curKey)
|
|
{
|
|
return !string.IsNullOrEmpty(currHistId) && currHistId == curKey ? "active" : "";
|
|
}
|
|
|
|
private void DoReset()
|
|
{
|
|
currHistId = "";
|
|
currPieId = "";
|
|
currData = new();
|
|
}
|
|
|
|
private void DoSelect(string reqKey)
|
|
{
|
|
if (ParetoDay.ContainsKey(reqKey))
|
|
{
|
|
currHistId = $"Bar_{reqKey}";
|
|
currPieId = $"Pie_{reqKey}";
|
|
currTitle = $"Pareto | {reqKey}";
|
|
currData = ParetoDay[reqKey];
|
|
}
|
|
}
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
ParetoDay = await StatsDetService.GetParetoStatsDayAsync();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Genera colori sfondo 33% rosso / arancione / giallo
|
|
/// </summary>
|
|
/// <param name="numRecords"></param>
|
|
/// <param name="alpha"></param>
|
|
/// <returns></returns>
|
|
private List<string> semaphColors(int numRecords, string alpha)
|
|
{
|
|
List<string> answ = new List<string>();
|
|
// verde...
|
|
for (int i = 0; i < numRecords / 3; i++)
|
|
{
|
|
answ.Add($"rgba(54, 235, 82, {alpha})");
|
|
}
|
|
// arancione
|
|
for (int i = 0; i < numRecords / 3; i++)
|
|
{
|
|
answ.Add($"rgba(255, 206, 86, {alpha})");
|
|
}
|
|
while (answ.Count < numRecords)
|
|
{
|
|
answ.Add($"rgba(255, 99, 132, {alpha}");
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
private string currDetail = "";
|
|
|
|
/// <summary>
|
|
/// abilita visualizzaione grafico dettagli x metodo indicato
|
|
/// </summary>
|
|
/// <param name="selDetail"></param>
|
|
private async Task ShowDetail(string selDetail)
|
|
{
|
|
currDetail = selDetail;
|
|
// recupero dettaglio 7gg...
|
|
DateTime adesso = DateTime.Now;
|
|
var detailList = await StatsDetService.GetFiltAsync(adesso.AddDays(-3), adesso, "", selDetail);
|
|
}
|
|
}
|
|
} |