Bozza pagine x elenco macchine

This commit is contained in:
Samuele E. Locatelli
2025-06-27 17:54:43 +02:00
parent 37e4db9dcd
commit 1ec3aa58d4
2 changed files with 141 additions and 8 deletions
+58 -1
View File
@@ -18,10 +18,67 @@
</div>
</div>
<div class="card-body">
@if (isLoading || ListRecords == null)
{
<LoadingData></LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
}
else
{
<div class="row">
<div class="col-12">
<table class="table table-sm table-striped">
<thead>
<tr>
<th>Macchina</th>
<th>Idx</th>
<th>Cod</th>
<th>Descr</th>
<th>Posiz</th>
<th>Note</th>
<th>IOB</th>
</tr>
</thead>
<tbody>
@foreach (var item in ListRecords)
{
<tr class="@checkSelect(item)">
<td>@item.Nome</td>
<td>@item.IdxMacchina</td>
<td>@item.CodMacchina</td>
<td>@item.Descrizione</td>
<td>
@if (string.IsNullOrEmpty(item.Locazione))
{
<span>-</span>
}
else
{
@($"{item.Locazione} | ({item.RowNum},{item.ColNum})")
}
</td>
<td>@item.Note</td>
<td>...iob...</td>
</tr>
}
</tbody>
<tfoot>
<tr>
<td colspan="7">
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="SetNumRec" numPageChanged="SetPage" totalCount="totalCount" showLoading="isLoading" />
</td>
</tr>
</tfoot>
</table>
</div>
</div>
}
</div>
<div class="card-footer py-1">
</div>
</div>
</div>
+83 -7
View File
@@ -1,6 +1,8 @@
using DnsClient.Protocol;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Configuration;
using Microsoft.JSInterop;
using MP.AppAuth.Models;
using MP.AppAuth.Services;
using MP.Land.Data;
using NLog;
@@ -20,7 +22,9 @@ namespace MP.Land.Pages
/// </summary>
private static Logger Log = LogManager.GetCurrentClassLogger();
private List<MP.AppAuth.Models.UpdMan> ListRecords;
private List<MacchineModel> ListRecords = new List<MacchineModel>();
private List<MacchineModel> SearchRecords = new List<MacchineModel>();
private List<MacchineModel> AllRecords = new List<MacchineModel>();
private string Titolo = "";
@@ -49,6 +53,7 @@ namespace MP.Land.Pages
public void Dispose()
{
ListRecords = null;
AppMService.EA_SearchUpdated -= AppMService_EA_SearchUpdated;
GC.Collect();
}
@@ -56,22 +61,93 @@ namespace MP.Land.Pages
#region Protected Methods
protected override async Task OnInitializedAsync()
protected override void OnInitialized()
{
ListRecords = null;
Titolo = "Elenco IOB Amministrati";
AppMService.ShowSearch = true;
AppMService.PageName = "IobList";
AppMService.PageIcon = "fas fa-computer pe-2";
await ReloadData();
AppMService.EA_SearchUpdated += AppMService_EA_SearchUpdated;
DataInit();
}
protected async Task ReloadData()
private string searchVal = "";
private void AppMService_EA_SearchUpdated()
{
isLoading = true;
searchVal = AppMService.SearchVal;
currPage = 1;
RefreshDisplay();
isLoading = false;
}
protected void DataInit()
{
isLoading = true;
// importante altrimenti NON mostra update UI
ListRecords = await AppDService.UpdManList();
totalCount = ListRecords.Count();
AllRecords = AppDService.MacchineGetAll();
RefreshDisplay();
isLoading = false;
}
private bool isLoading = false;
private int currPage = 1;
private int numRecord = 10;
protected void SetNumRec(int newNum)
{
numRecord = newNum;
RefreshDisplay();
}
protected void SetPage(int newNum)
{
currPage = newNum;
RefreshDisplay();
}
private void RefreshDisplay()
{
// se ho ricerca filtro...
if (string.IsNullOrEmpty(searchVal))
{
SearchRecords = AllRecords;
}
else
{
SearchRecords = AllRecords
.Where(x => x.Nome.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase)
|| x.CodMacchina.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase)
|| x.Descrizione.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase)
|| x.IdxMacchina.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase))
.ToList();
}
// conto record
totalCount = SearchRecords.Count();
// fix paginazione
ListRecords = SearchRecords
.Skip(numRecord * (currPage - 1))
.Take(numRecord)
.ToList();
}
protected string checkSelect(MacchineModel IdxODL)
{
string answ = "";
#if false
if (currRecord != null)
{
try
{
answ = (currRecord.IdxOdl == IdxODL) ? "table-info" : "";
}
catch
{ }
}
#endif
return answ;
}
#endregion Protected Methods