diff --git a/MP-TAB/MP-TAB.Client/Components/TcHistoryFilter.razor b/MP-TAB/MP-TAB.Client/Components/TcHistoryFilter.razor index c59af214..7e82ac44 100644 --- a/MP-TAB/MP-TAB.Client/Components/TcHistoryFilter.razor +++ b/MP-TAB/MP-TAB.Client/Components/TcHistoryFilter.razor @@ -1,7 +1,9 @@ -@using NLog; +@using MP.Data.Services; +@using NLog; @using System.Net.Http @using System.Net.Http.Json @inject HttpClient Http +@inject MemStorUtil CIServ
@@ -141,11 +143,14 @@ } protected async Task ReloadMacchine() { - string ApiUrl = $"{BaseAddr}api/ListSelect/GetDictMacc?MatrOpr={MatrOpr}"; - var rawData = await Http.GetFromJsonAsync>(ApiUrl); - if (rawData != null) + if (ListMacchineAll == null || ListMacchineAll.Count == 0) { - ListMacchineAll = rawData; + string ApiUrl = $"{BaseAddr}api/ListSelect/GetDictMacc?MatrOpr={MatrOpr}"; + var rawData = await Http.GetFromJsonAsync>(ApiUrl); + if (rawData != null) + { + ListMacchineAll = rawData; + } } } @@ -194,7 +199,12 @@ } protected string IdxMaccSel { get; set; } = ""; - protected Dictionary ListMacchineAll { get; set; } = new Dictionary(); + protected Dictionary ListMacchineAll + { + get => MemStorUtil.DictMacchine; + set => MemStorUtil.DictMacchine = value; + } + protected Dictionary ListArticoliAll { get; set; } = new Dictionary(); protected Dictionary? ListArticoli { get; set; } = null; protected int TotalCount { get; set; } = 0; diff --git a/MP-TAB/MP-TAB.Client/Pages/StatusMap.razor b/MP-TAB/MP-TAB.Client/Pages/StatusMap.razor index d8e54b27..8c086c66 100644 --- a/MP-TAB/MP-TAB.Client/Pages/StatusMap.razor +++ b/MP-TAB/MP-TAB.Client/Pages/StatusMap.razor @@ -1,5 +1,5 @@ -@* @attribute [RenderModeAuto] *@ -@attribute [RenderModeServer] +@attribute [RenderModeAuto] +@* @attribute [RenderModeServer] *@ @using MP.Data.Services; @using MP.Data; diff --git a/MP-TAB/MP-TAB.Client/Program.cs b/MP-TAB/MP-TAB.Client/Program.cs index 7eeaa159..6d829ac2 100644 --- a/MP-TAB/MP-TAB.Client/Program.cs +++ b/MP-TAB/MP-TAB.Client/Program.cs @@ -1,7 +1,11 @@ using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using MP.Data.Services; var builder = WebAssemblyHostBuilder.CreateDefault(args); +// servizio cache locale dati +builder.Services.AddScoped(); + // aggiunto x gestione chiamate WebAPI builder.Services.AddScoped(sp => new HttpClient @@ -9,4 +13,5 @@ builder.Services.AddScoped(sp => BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); + await builder.Build().RunAsync(); diff --git a/MP-TAB/MP-TAB/Components/App.razor b/MP-TAB/MP-TAB/Components/App.razor index 040d30a9..2f9c30df 100644 --- a/MP-TAB/MP-TAB/Components/App.razor +++ b/MP-TAB/MP-TAB/Components/App.razor @@ -9,9 +9,8 @@ - + - @* *@ diff --git a/MP-TAB/MP-TAB/Components/Layout/MainLayout.razor b/MP-TAB/MP-TAB/Components/Layout/MainLayout.razor index 4584de42..c11f0962 100644 --- a/MP-TAB/MP-TAB/Components/Layout/MainLayout.razor +++ b/MP-TAB/MP-TAB/Components/Layout/MainLayout.razor @@ -1,5 +1,8 @@ @inherits LayoutComponentBase + +@inject NavigationManager NavMan @inject ListSelectDataSrv MDataService +@inject MemStorUtil MStor
@@ -21,7 +24,7 @@ @*
*@
- +
@@ -32,7 +35,7 @@ @Body
@@ -50,10 +53,11 @@ /// Elenco items da menù per pagina corrente... /// protected List CurrMenuItems { get; set; } = new List(); + /// /// Livello corrente del menu /// - protected string CurrLevel = "T2H"; + protected string CurrLevel { get; set; } = ""; /// /// Init struttura dati @@ -61,8 +65,16 @@ /// protected override async Task OnInitializedAsync() { + CurrLevel = MemStorUtil.PageLevel(NavMan.Uri); + if (MemStorUtil.DictMenu.ContainsKey(CurrLevel)) + { + CurrMenuItems = MemStorUtil.DictMenu[CurrLevel]; + } + else + { + CurrMenuItems = await MDataService.ListLinkFilt(CurrLevel); + MemStorUtil.DictMenu.Add(CurrLevel, CurrMenuItems); + } await Task.Delay(1); - CurrMenuItems = await MDataService.ListLinkFilt(CurrLevel); - // return base.OnInitializedAsync(); } } \ No newline at end of file diff --git a/MP-TAB/MP-TAB/Components/Layout/NavMenu.razor b/MP-TAB/MP-TAB/Components/Layout/NavMenu.razor index ad904f29..8cf6091f 100644 --- a/MP-TAB/MP-TAB/Components/Layout/NavMenu.razor +++ b/MP-TAB/MP-TAB/Components/Layout/NavMenu.razor @@ -1,4 +1,5 @@ -@inject ListSelectDataSrv MDataService +@inject NavigationManager NavMan +@inject ListSelectDataSrv MDataService @*
*@ @*
diff --git a/MP-TAB/MP-TAB/Components/Layout/SlideMenu.razor b/MP-TAB/MP-TAB/Components/Layout/SlideMenu.razor new file mode 100644 index 00000000..f569bac8 --- /dev/null +++ b/MP-TAB/MP-TAB/Components/Layout/SlideMenu.razor @@ -0,0 +1,15 @@ +@inject NavigationManager NavMan +@inject ListSelectDataSrv MDataService +@inject MemStorUtil MStor + +@* @attribute [StreamRendering(true)] *@ + + + + +@code { + + [Parameter] + public List MenuItems { get; set; } = new List(); + +} diff --git a/MP-TAB/MP-TAB/Components/Pages/StatusMap.razor b/MP-TAB/MP-TAB/Components/Pages/StatusMap.razor index 81c3810e..43783059 100644 --- a/MP-TAB/MP-TAB/Components/Pages/StatusMap.razor +++ b/MP-TAB/MP-TAB/Components/Pages/StatusMap.razor @@ -4,9 +4,6 @@ @* @attribute [StreamRendering(true)] *@ - - - @* @if (listMSE == null || listMSE.Count == 0) {
@@ -21,4 +18,7 @@ else { } *@ + + + diff --git a/MP-TAB/MP-TAB/Components/_Imports.razor b/MP-TAB/MP-TAB/Components/_Imports.razor index 40a1a57c..8bb2ba63 100644 --- a/MP-TAB/MP-TAB/Components/_Imports.razor +++ b/MP-TAB/MP-TAB/Components/_Imports.razor @@ -12,3 +12,7 @@ @using MP.Data.Services @using MP_TAB @using MP_TAB.Components +@* +@using MP_TAB.Client.Components +@using MP_TAB.Client.Pages +*@ \ No newline at end of file diff --git a/MP-TAB/MP-TAB/Controllers/ODLController.cs b/MP-TAB/MP-TAB/Controllers/ODLController.cs index 3e62d12a..a6a0b3eb 100644 --- a/MP-TAB/MP-TAB/Controllers/ODLController.cs +++ b/MP-TAB/MP-TAB/Controllers/ODLController.cs @@ -20,7 +20,7 @@ namespace MP_TAB.Controllers Log.Info("Starting ODLController"); _configuration = configuration; CtrDataServ = DataService; - Log.Info("Avviato ODLController"); + Log.Trace("Avviato ODLController"); } #endregion Public Constructors diff --git a/MP-TAB/MP-TAB/MP-TAB.csproj b/MP-TAB/MP-TAB/MP-TAB.csproj index 09aa5521..614b03dd 100644 --- a/MP-TAB/MP-TAB/MP-TAB.csproj +++ b/MP-TAB/MP-TAB/MP-TAB.csproj @@ -110,6 +110,12 @@ Always + + Always + + + Always + Always diff --git a/MP-TAB/MP-TAB/Program.cs b/MP-TAB/MP-TAB/Program.cs index 8228ff64..862cc434 100644 --- a/MP-TAB/MP-TAB/Program.cs +++ b/MP-TAB/MP-TAB/Program.cs @@ -19,6 +19,7 @@ builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddScoped(); +builder.Services.AddScoped(); // nuova versione contenuti... builder.Services.AddRazorComponents() diff --git a/MP-TAB/MP-TAB/wwwroot/favicon.png b/MP-TAB/MP-TAB/wwwroot/favicon.png deleted file mode 100644 index 8422b596..00000000 Binary files a/MP-TAB/MP-TAB/wwwroot/favicon.png and /dev/null differ diff --git a/MP-TAB/MP-TAB/wwwroot/favicon.ico b/MP-TAB/MP-TAB/wwwroot/images/favicon.ico similarity index 100% rename from MP-TAB/MP-TAB/wwwroot/favicon.ico rename to MP-TAB/MP-TAB/wwwroot/images/favicon.ico diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index f0952b6a..79db52c5 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -581,11 +581,11 @@ namespace MP.Data.Controllers using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx - .DbSetLinkMenu - .Where(x => x.TipoLink == tipoLink) - .AsNoTracking() - .OrderBy(x => x.ordine) - .ToList(); + .DbSetLinkMenu + .Where(x => x.TipoLink == tipoLink) + .AsNoTracking() + .OrderBy(x => x.ordine) + .ToList(); } return dbResult; } diff --git a/MP.Data/Services/MemStorUtil.cs b/MP.Data/Services/MemStorUtil.cs new file mode 100644 index 00000000..c605d146 --- /dev/null +++ b/MP.Data/Services/MemStorUtil.cs @@ -0,0 +1,55 @@ +using MP.Data.DatabaseModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MP.Data.Services +{ + public class MemStorUtil + { + + /// + /// Matricola operatore corrente (x filtraggio dati) + /// ToDo: gestire login!!! + /// + public static int MatrOpr = 102; + + /// + /// Dizionario macchine + /// + public static Dictionary DictMacchine { get; set; } = new Dictionary(); + + /// + /// Dizionario Menu + /// + public static Dictionary> DictMenu {get;set;} = new Dictionary>(); + + /// + /// Reset cache memory + /// + public void ResetCache() + { + DictMacchine = new Dictionary(); + DictMenu = new Dictionary>(); + } + + /// + /// Restituisce il livello pagina dato URL + /// - se contiene ?IdxMacc --> T2D (detail) + /// - altrimenti --> T2H + /// + /// + /// + public static string PageLevel(string pageUrl) + { + string answ = "T2H"; + if(pageUrl.Contains("?IdxMacc=")) + { + answ = "T2D"; + } + return answ; + } + } +}