Inizio pagina route configuration

This commit is contained in:
Samuele Locatelli
2026-04-10 10:35:30 +02:00
parent 3ced78bcad
commit bf79ae7477
8 changed files with 177 additions and 63 deletions
+9
View File
@@ -0,0 +1,9 @@
namespace MP.Core.DTO
{
public class WeightDTO
{
public string Method { get; set; } = "";
public int OldWeight { get; set; } = 100;
public int NewWeight { get; set; } = 0;
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
<div class="card">
<div class="card shadow">
<div class="card-header">
<b>@Title</b>
</div>
@@ -20,7 +20,7 @@
}
</ul>
</div>
<div class="card-footer py-0 px-1">
<div class="card-footer py-0 px-1 small">
<EgwCoreLib.Razor.DataPager currPage="@pageNum" PageSize="@numRecPage" totalCount="@totalCount" numPageChanged="SavePage" numRecordChanged="SaveNumRec" DisplSize="DataPager.ObjSize.small"></EgwCoreLib.Razor.DataPager>
</div>
</div>
+49 -41
View File
@@ -6,6 +6,19 @@ 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()
@@ -17,13 +30,47 @@ namespace MP.IOC.Components.Pages
#region Private Fields
private List<StatDataDTO> currData = new();
private string currSelect = "";
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 void DoReset()
{
currSelect = "";
currData = new();
}
private void DoSelect(string reqKey)
{
if (ParetoDay.ContainsKey(reqKey))
@@ -33,19 +80,12 @@ namespace MP.IOC.Components.Pages
currData = ParetoDay[reqKey];
}
}
private string currSelect = "";
private string currTitle = "";
private List<StatDataDTO> currData = new();
private List<string> LabelPareto
private async Task ReloadData()
{
get => currData.Select(x => x.Label).ToList();
ParetoDay = await StatsDetService.GetParetoStatsDayAsync();
}
private List<double> DatiPareto
{
get => currData.Select(x => x.Value).ToList();
}
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
@@ -72,38 +112,6 @@ namespace MP.IOC.Components.Pages
return answ;
}
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <returns></returns>
protected List<string> bgColors
{
get => semaphColors(currData.Count, "0.3");
}
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <returns></returns>
private List<string> lineColors
{
get => semaphColors(currData.Count, "1");
}
#endregion Private Fields
#region Private Properties
[Inject]
private IStatsDetailService StatsDetService { get; set; } = null!;
#endregion Private Properties
#region Private Methods
private async Task ReloadData()
{
ParetoDay = await StatsDetService.GetParetoStatsDayAsync();
}
#endregion Private Methods
}
+26 -4
View File
@@ -1,5 +1,27 @@
@page "/RouteConf"
<h3>RouteConf</h3>
<div class="card shadow">
<div class="card-header">
<h3>Route Configuration (IO/IOC)</h3>
</div>
<div class="card-body p-1">
<table class="table table-sm table-striped">
<thead>
<tr>
<th>Metodo</th>
<th>IO %</th>
<th>IOC %</th>
</tr>
</thead>
<tbody>
@foreach (var record in ListPaged)
{
<tr class="@CheckSelect(record)">
<td>@record.Method</td>
<td>@record.OldWeight</td>
<td>@record.NewWeight</td>
</tr>
}
</tbody>
</table>
</div>
</div>
@@ -1,7 +1,82 @@
using Microsoft.AspNetCore.Components;
using MP.Core.DTO;
using MP.IOC.Services;
namespace MP.IOC.Components.Pages
{
public partial class RouteConf
{
#region Protected Methods
protected string CheckSelect(WeightDTO currRec)
{
return SelRecord != null && SelRecord.Method == currRec.Method ? "table-info" : "";
}
protected override async Task OnInitializedAsync()
{
//return base.OnInitializedAsync();
await ReloadData();
UpdateTable();
}
#endregion Protected Methods
#region Private Fields
private List<WeightDTO> ListComplete = new();
private List<WeightDTO> ListPaged = new();
private int numRecPage = 10;
private int pageNum = 1;
private WeightDTO? SelRecord = null;
private int totalCount = 0;
#endregion Private Fields
#region Private Properties
[Inject]
private IWeightProvider WService { get; set; } = null!;
#endregion Private Properties
#region Private Methods
private async Task ReloadData()
{
ListComplete = await WService.GetAllWeightsAsync();
totalCount = ListComplete.Count();
}
private void SaveNumRec(int newNum)
{
numRecPage = newNum;
UpdateTable();
}
private void SavePage(int newNum)
{
pageNum = newNum;
UpdateTable();
}
private void UpdateTable()
{
// esegue paginazione
if (totalCount > numRecPage)
{
ListPaged = ListComplete.Skip((pageNum - 1) * numRecPage).Take(numRecPage).ToList();
}
else
{
ListPaged = ListComplete;
}
}
#endregion Private Methods
}
}
+12 -14
View File
@@ -1,18 +1,10 @@
namespace MP.IOC.Services
{
public class WeightDTO
{
public string Method { get; set; } = "";
public int OldWeight { get; set; } = 100;
public int NewWeight { get; set; } = 0;
}
using MP.Core.DTO;
namespace MP.IOC.Services
{
public interface IWeightProvider
{
/// <summary>
/// Ritorna la coppia (oldWeight, newWeight) per scegliere dove instradare il metodo tra i 2 sistemi API.
/// </summary>
(int oldWeight, int newWeight) GetWeightsFor(string method);
#region Public Methods
/// <summary>
/// Ritorna l'intero elenco dei weight attivi nel formato WeightDTO
@@ -20,12 +12,18 @@
/// <returns></returns>
Task<List<WeightDTO>> GetAllWeightsAsync();
/// <summary>
/// Ritorna la coppia (oldWeight, newWeight) per scegliere dove instradare il metodo tra i 2 sistemi API.
/// </summary>
(int oldWeight, int newWeight) GetWeightsFor(string method);
/// <summary>
/// Aggiorna/Aggiuinge il valore del weight richiesto
/// </summary>
/// <param name=""></param>
/// <returns></returns>
bool UpsertWeight(WeightDTO updRecord);
}
}
#endregion Public Methods
}
}
+2 -1
View File
@@ -1,4 +1,5 @@
using System.Collections.Concurrent;
using MP.Core.DTO;
using System.Collections.Concurrent;
namespace MP.IOC.Services
{
+2 -1
View File
@@ -1,4 +1,5 @@
using StackExchange.Redis;
using MP.Core.DTO;
using StackExchange.Redis;
namespace MP.IOC.Services
{