Completata prima versione gestione impianti selezionati

This commit is contained in:
Samuele Locatelli
2025-07-07 09:58:52 +02:00
parent d45dd62401
commit 814de375ff
6 changed files with 43 additions and 49 deletions
+6 -7
View File
@@ -4,18 +4,17 @@
<div class="modal-title bg-primary bg-opacity-50 bg-gradient p-2">
<div class="d-flex justify-content-between">
<div class="px-0">
<h3>Selezione Macchine</h3>
<h3>Imp Sel: <b>@ListSelected</b></h3>
</div>
<div class="px-0">
<button class="btn btn-outline-dark" @onclick="() => SearchMaccToggle()"><i class="fa-solid fa-xmark"></i></button>
<button class="btn btn-outline-dark" @onclick="() => SearchMaccToggle()"><i class="fa-solid fa-save"></i> @numSelected / @MaxSelection</button>
</div>
</div>
<div class="input-group input-group-lg my-2 shadow">
<span class="input-group-text bg-dark text-light bg-gradient">Selezione:</span>
@* <div class="input-group input-group-lg my-2 shadow">
<span class="input-group-text bg-dark text-light bg-gradient">Sel. Impianti:</span>
<span class="form-control">@ListSelected</span>
<span class="input-group-text bg-dark text-light bg-gradient">(@numSelected / @MaxSelection)</span>
@* <button class="btn btn-sm @CssClear" @onclick="ClearSel"><i class="fa-solid fa-rotate-right"></i></button> *@
</div>
</div> *@
</div>
<div class="modal-body px-2">
<div class="input-group mb-3">
@@ -37,7 +36,7 @@
{
<tr>
<td>
@if (currList.Contains(record.ValueField))
@if (CurrList.Contains(record.ValueField))
{
<button class="btn btn-sm btn-info" @onclick="() => ToggleSel(record.ValueField)"><i class="fa-solid fa-minus"></i></button>
}
+14 -15
View File
@@ -14,6 +14,9 @@ namespace MP.Stats.Components
[Parameter]
public List<AutocompleteModel> AllRecords { get; set; } = null!;
[Parameter]
public List<string> CurrList { get; set; } = new List<string>();
[Parameter]
public EventCallback<bool> EC_CloseSearch { get; set; }
@@ -29,7 +32,7 @@ namespace MP.Stats.Components
protected string CssClear
{
get => currList == null || currList.Count == 0 ? "btn-outline-secondary" : "btn-primary";
get => CurrList == null || CurrList.Count == 0 ? "btn-outline-secondary" : "btn-primary";
}
protected string CssReset
@@ -38,18 +41,19 @@ namespace MP.Stats.Components
}
protected List<AutocompleteModel> ListRecords { get; set; } = null!;
protected List<AutocompleteModel> SearchRecords { get; set; } = null!;
protected string ListSelected
{
get => currList != null && currList.Count > 0 ? string.Join(", ", currList) : "-- nessuna selezione --";
get => CurrList != null && CurrList.Count > 0 ? string.Join(", ", CurrList) : "-";
}
protected int numSelected
{
get => currList.Count;
get => CurrList.Count;
}
protected List<AutocompleteModel> SearchRecords { get; set; } = null!;
protected string SearchVal
{
get => _searchVal;
@@ -69,7 +73,7 @@ namespace MP.Stats.Components
protected void ClearSel()
{
currList.Clear();
CurrList.Clear();
}
protected override void OnParametersSet()
@@ -112,20 +116,16 @@ namespace MP.Stats.Components
protected async Task ToggleSel(string newVal)
{
if (!currList.Contains(newVal))
if (!CurrList.Contains(newVal))
{
currList.Add(newVal);
CurrList.Add(newVal);
}
else
{
currList.Remove(newVal);
CurrList.Remove(newVal);
}
// riordino
currList = currList.OrderBy(x => x).ToList();
#if false
// sollevo evento notifica
await EC_ListUpdated.InvokeAsync(currList);
#endif
CurrList = CurrList.OrderBy(x => x).ToList();
}
#endregion Protected Methods
@@ -133,7 +133,6 @@ namespace MP.Stats.Components
#region Private Fields
private string _searchVal = "";
private List<string> currList = new List<string>();
private int currPage = 1;
private int numRecord = 10;
private int totalCount = 0;
@@ -144,7 +143,7 @@ namespace MP.Stats.Components
private async Task SearchMaccToggle()
{
await EC_ListUpdated.InvokeAsync(currList);
await EC_ListUpdated.InvokeAsync(CurrList);
await EC_CloseSearch.InvokeAsync(true);
}
+3 -15
View File
@@ -2,7 +2,7 @@
@if (showAddMacc)
{
<ModalSearchMacc EC_CloseSearch="ToggleAddMacc" AllRecords="ddlMacchineMult" EC_ListUpdated="SaveMaccList"></ModalSearchMacc>
<ModalSearchMacc EC_CloseSearch="ToggleAddMacc" AllRecords="ddlMacchineMult" EC_ListUpdated="SaveMaccList" MaxSelection="MaxNumMacc" CurrList="ListIdxMaccSel"></ModalSearchMacc>
}
<EditForm Model="@SelFilter">
@@ -41,20 +41,8 @@
{
<label class="small">macchine sel:</label>
<div class="input-group input-group-sm text-nowrap">
<button class="btn btn-sm btn-primary" @onclick="ShowAdd"><i class="fa-solid fa-plus"></i></button>
@if (showAddMacc)
{
<select @bind="@IdxMacchina" class="form-select">
@foreach (var item in ddlMacchineMult)
{
<option value="@item.ValueField">@item.LabelField</option>
}
</select>
}
else
{
<span class="form-control disabled">@listSelected</span>
}
<button class="btn btn-sm btn-primary" @onclick="ShowAdd"><i class="fa-solid fa-pen"></i></button>
<span class="form-control disabled">@listSelected</span>
<button class="btn btn-sm btn-primary" @onclick="ResetSelMacchine"><i class="fa-solid fa-rotate-right"></i></button>
</div>
}
+7 -5
View File
@@ -55,6 +55,9 @@ namespace MP.Stats.Components
[Parameter]
public SelectData SelFilter { get; set; }
[Parameter]
public int MaxNumMacc { get; set; } = 10;
#endregion Public Properties
#region Protected Fields
@@ -165,9 +168,6 @@ namespace MP.Stats.Components
protected void ResetSelMacchine()
{
#if false
ListIdxMaccSel.Clear();
#endif
ListIdxMaccSel = new List<string>();
showAddMacc = false;
}
@@ -190,7 +190,8 @@ namespace MP.Stats.Components
protected List<AutocompleteModel> ddlMacchineMult
{
get
get => ddlMacchine.Where(x => x.ValueField != "*").ToList();
#if false
{
List<AutocompleteModel> answ = new List<AutocompleteModel>();
foreach (var item in ddlMacchine)
@@ -201,7 +202,8 @@ namespace MP.Stats.Components
}
}
return answ;
}
}
#endif
}
protected List<string> ListIdxMaccSel
+1 -1
View File
@@ -5,7 +5,7 @@
<div class="card">
<div class="card-header table-primary p-1">
<SelectionFilter SelFilter="currFilter" filterChanged="DoFilter" filterReset="ResetFilter" ChartEnabled="false" OnlyEnergy="true"></SelectionFilter>
<SelectionFilter SelFilter="currFilter" filterChanged="DoFilter" filterReset="ResetFilter" ChartEnabled="false" OnlyEnergy="true" MaxNumMacc="MaxDisplay"></SelectionFilter>
</div>
<div class="card-body py-0 px-1">
@if (isLoading)
+12 -6
View File
@@ -202,7 +202,7 @@ namespace MP.Stats.Pages
#endregion Private Properties
private int maxDisplay = 5;
private int MaxDisplay = 5;
#region Private Methods
@@ -230,14 +230,20 @@ namespace MP.Stats.Pages
// per ogni valore recupero timeserie downsampled fino al num max di quelle ottenibili...
int numAdd = 0;
var listSel = currFilter.ListIdxMaccSel;
foreach (var item in grpDict)
{
numAdd++;
// ora effettuo deduplica valori per tenere un subset minore ed evitare problemi visualizzazione...
PlotRecords.AddRange(TimeSeriesUtils.DownsampleFluxModels(item.Value, MaxPoints));
if(numAdd >= maxDisplay)
// verifico se sia tra le macchine selezionate...
if (listSel.Contains(item.Key))
{
return;
numAdd++;
// ora effettuo deduplica valori per tenere un subset minore ed evitare problemi visualizzazione...
PlotRecords.AddRange(TimeSeriesUtils.DownsampleFluxModels(item.Value, MaxPoints));
// verifico comunque superamento limite amcchine
if (numAdd >= MaxDisplay)
{
return;
}
}
}
}