From e3c1c6baef9dc322e6289017ddaf7ecd7ff65b84 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 18 Apr 2026 10:19:37 +0200 Subject: [PATCH] update interafaccia Callstats --- MP.IOC/Components/Pages/CallStats.razor | 18 ++- MP.IOC/Components/Pages/CallStats.razor.cs | 137 +++++++++------------ MP.IOC/MP.IOC.csproj | 2 +- MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- 6 files changed, 79 insertions(+), 84 deletions(-) diff --git a/MP.IOC/Components/Pages/CallStats.razor b/MP.IOC/Components/Pages/CallStats.razor index 68cbe505..c4b4fda7 100644 --- a/MP.IOC/Components/Pages/CallStats.razor +++ b/MP.IOC/Components/Pages/CallStats.razor @@ -62,14 +62,28 @@ } else { - @currDetail if (tsDataDetail.Count == 0) {
← No data found
} else { - +
+
+
+ @currDetail +
+
+
+ # giorni + +
+
+
+
+ +
+
} } diff --git a/MP.IOC/Components/Pages/CallStats.razor.cs b/MP.IOC/Components/Pages/CallStats.razor.cs index 08767393..c758c683 100644 --- a/MP.IOC/Components/Pages/CallStats.razor.cs +++ b/MP.IOC/Components/Pages/CallStats.razor.cs @@ -9,6 +9,28 @@ namespace MP.IOC.Components.Pages { public partial class CallStats { + #region Protected Properties + + private int numDays + { + get => _numDays; + set + { + if (_numDays != value) + { + _numDays = value; + //_ = ShowDetail(currDetail); + } + } + } + private async Task OnDaysChangedAsync() + { + // Questo metodo viene invocato automaticamente dopo che numDays è stato aggiornato + await ShowDetail(currDetail); + // Non serve chiamare StateHasChanged(), Blazor lo fa al termine del Task + } + #endregion Protected Properties + #region Protected Methods protected override async Task OnInitializedAsync() @@ -20,6 +42,7 @@ namespace MP.IOC.Components.Pages #region Private Fields + private int _numDays = 5; private List currData = new(); private string currDetail = ""; @@ -64,17 +87,12 @@ namespace MP.IOC.Components.Pages private List DatiPareto { - get => currData.Where(x => x.Value > 10).OrderByDescending(x => x.Value).Take(ParetoTake).Select(x => x.Value).ToList(); + get => currData.OrderByDescending(x => x.Value).Take(ParetoTake).Select(x => x.Value).ToList(); } private List LabelPareto { - get => currData.Where(x => x.Value > 10).OrderByDescending(x => x.Value).Take(ParetoTake).Select(x => x.Label).ToList(); - } - - private int ParetoTake - { - get => currData.Count() <= 30 ? currData.Count() : 30; + get => currData.OrderByDescending(x => x.Value).Take(ParetoTake).Select(x => x.Label).ToList(); } private List LabelPlot @@ -96,6 +114,11 @@ namespace MP.IOC.Components.Pages get => GetDistinctColors(tsDataDetail.Count, "1"); } + private int ParetoTake + { + get => currData.Count() <= 30 ? currData.Count() : 30; + } + [Inject] private IStatsDetailService SDetService { get; set; } = null!; @@ -131,36 +154,37 @@ namespace MP.IOC.Components.Pages } } - private async Task ReloadData() + private List GetDistinctColors(int numRecords, string alpha) { - ParetoDay = await SDetService.GetParetoStatsDayAsync(); - } + List colors = new List(); + if (numRecords <= 0) return colors; - /// - /// Genera colori sfondo 33% rosso / arancione / giallo - /// - /// - /// - /// - private List semaphColors(int numRecords, string alpha) - { - List answ = new List(); - // verde... - for (int i = 0; i < numRecords / 3; i++) + // Partiamo dal Blu (240°) invece che dal Rosso (0°) + double startHue = 240.0; + + for (int i = 0; i < numRecords; 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}"); + // Distribuiamo la tonalità aggiungendo l'offset iniziale + // L'operatore % 360 assicura di rimanere nel cerchio se superiamo il rosso + double hue = (startHue + ((double)i * 360 / numRecords)) % 360; + + // Strategia di distinzione (attiva sempre, ma più efficace sopra i 5 colori) + // Alterniamo i valori per i record pari/dispari + string saturation = "70%"; + string lightness = "50%"; + + if (numRecords > 5) + { + // Se i colori sono molti, alterniamo luminosità e saturazione + // I record dispari saranno più chiari e saturi, i pari più scuri e tenui + lightness = (i % 2 == 0) ? "45%" : "65%"; + saturation = (i % 2 == 0) ? "80%" : "60%"; + } + + colors.Add($"hsla({hue:0.##}, {saturation}, {lightness}, {alpha})"); } - return answ; + return colors; } private List GetSemaforicColors(int numRecords, string alpha) @@ -202,53 +226,10 @@ namespace MP.IOC.Components.Pages return colors; } - //private List GetDistinctColors(int numRecords, string alpha) - //{ - // List colors = new List(); - // for (int i = 0; i < numRecords; i++) - // { - // // Distribuiamo la tonalità (Hue) uniformemente sui 360 gradi - // double hue = (double)i * 360 / numRecords; - - // // Usiamo il formato CSS hsla() che è più semplice da generare direttamente - // // Saturazione 70% e Luminosità 50-60% di solito danno colori vivaci e distinti - // colors.Add($"hsla({hue:0.##}, 70%, 50%, {alpha})"); - // } - - // return colors; - //} - private List GetDistinctColors(int numRecords, string alpha) + private async Task ReloadData() { - List colors = new List(); - if (numRecords <= 0) return colors; - - // Partiamo dal Blu (240°) invece che dal Rosso (0°) - double startHue = 240.0; - - for (int i = 0; i < numRecords; i++) - { - // Distribuiamo la tonalità aggiungendo l'offset iniziale - // L'operatore % 360 assicura di rimanere nel cerchio se superiamo il rosso - double hue = (startHue + ((double)i * 360 / numRecords)) % 360; - - // Strategia di distinzione (attiva sempre, ma più efficace sopra i 5 colori) - // Alterniamo i valori per i record pari/dispari - string saturation = "70%"; - string lightness = "50%"; - - if (numRecords > 5) - { - // Se i colori sono molti, alterniamo luminosità e saturazione - // I record dispari saranno più chiari e saturi, i pari più scuri e tenui - lightness = (i % 2 == 0) ? "45%" : "65%"; - saturation = (i % 2 == 0) ? "80%" : "60%"; - } - - colors.Add($"hsla({hue:0.##}, {saturation}, {lightness}, {alpha})"); - } - - return colors; + ParetoDay = await SDetService.GetParetoStatsDayAsync(); } /// @@ -260,7 +241,7 @@ namespace MP.IOC.Components.Pages currDetail = selDetail; // recupero dettaglio 7gg... DateTime adesso = DateTime.Now; - List rawData = await SDetService.GetFiltAsync(adesso.AddDays(-5), adesso, "", selDetail); + List rawData = await SDetService.GetFiltAsync(adesso.AddDays(-numDays), adesso, "", selDetail); // conversione con grouping tsData = rawData.Select(r => new chartJsData.chartJsTSerie() { x = r.Hour, y = (double)r.AvgDuration }) .OrderBy(o => o.x) diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index 3ace2348..e27b2a70 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 6.16.2604.1809 + 6.16.2604.1810 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index fd2338c6..7205caf2 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

Versione: 6.16.2604.1809

+

Versione: 6.16.2604.1810


Note di rilascio:
  • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index 91c01ecf..c12ee4c3 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2604.1809 +6.16.2604.1810 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index b484567c..ab333392 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2604.1809 + 6.16.2604.1810 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false