From 1ec3aa58d4e8d4d32db7316cfa2bec4a8ccb45dc Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 27 Jun 2025 17:54:43 +0200 Subject: [PATCH] Bozza pagine x elenco macchine --- MP.Land/Pages/IobList.razor | 59 +++++++++++++++++++++- MP.Land/Pages/IobList.razor.cs | 90 +++++++++++++++++++++++++++++++--- 2 files changed, 141 insertions(+), 8 deletions(-) diff --git a/MP.Land/Pages/IobList.razor b/MP.Land/Pages/IobList.razor index 16025fd2..fdd25c55 100644 --- a/MP.Land/Pages/IobList.razor +++ b/MP.Land/Pages/IobList.razor @@ -18,10 +18,67 @@
+ @if (isLoading || ListRecords == null) + { + + } + else if (totalCount == 0) + { +
Nessun record trovato
+ } + else + { +
+
+ + + + + + + + + + + + + + @foreach (var item in ListRecords) + { + + + + + + + + + + } + + + + + + +
MacchinaIdxCodDescrPosizNoteIOB
@item.Nome@item.IdxMacchina@item.CodMacchina@item.Descrizione + @if (string.IsNullOrEmpty(item.Locazione)) + { + - + } + else + { + @($"{item.Locazione} | ({item.RowNum},{item.ColNum})") + } + @item.Note...iob...
+ +
+
+
+ }
diff --git a/MP.Land/Pages/IobList.razor.cs b/MP.Land/Pages/IobList.razor.cs index ebf22f27..0630f816 100644 --- a/MP.Land/Pages/IobList.razor.cs +++ b/MP.Land/Pages/IobList.razor.cs @@ -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 /// private static Logger Log = LogManager.GetCurrentClassLogger(); - private List ListRecords; + private List ListRecords = new List(); + private List SearchRecords = new List(); + private List AllRecords = new List(); 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