From 08c94fddcbfcc37641e4adbf6da32b42e923e7de Mon Sep 17 00:00:00 2001 From: Emmanuele Sassi Date: Thu, 7 Aug 2025 14:35:19 +0200 Subject: [PATCH] Lettura BTL e rappresentazione svg per Aedifica --- Test.UI/Components/Pages/Aedifica.razor | 6 +- Test.UI/Components/Pages/Aedifica.razor.cs | 87 +++++++++++++++++-- Test.UI/Components/Pages/Home.razor.cs | 5 +- .../Components/Pages/TestComponent.razor.cs | 4 +- Test.UI/Test.UI.csproj | 4 +- Test.UI/appsettings.json | 22 ++--- .../WebAedificaMaker.razor | 45 ++++++---- .../WebAedificaMaker.razor.cs | 39 ++++++++- 8 files changed, 166 insertions(+), 46 deletions(-) diff --git a/Test.UI/Components/Pages/Aedifica.razor b/Test.UI/Components/Pages/Aedifica.razor index 19535d2..34fb91c 100644 --- a/Test.UI/Components/Pages/Aedifica.razor +++ b/Test.UI/Components/Pages/Aedifica.razor @@ -3,8 +3,10 @@ Aedifica - + -

@currText

+@*

@currText

*@ diff --git a/Test.UI/Components/Pages/Aedifica.razor.cs b/Test.UI/Components/Pages/Aedifica.razor.cs index bd94bde..b9e26a7 100644 --- a/Test.UI/Components/Pages/Aedifica.razor.cs +++ b/Test.UI/Components/Pages/Aedifica.razor.cs @@ -1,12 +1,87 @@ -namespace Test.UI.Components.Pages +using EgwCoreLib.Lux.Core; +using EgwCoreLib.Lux.Core.RestPayload; +using EgwCoreLib.Lux.Data.Services; +using Microsoft.AspNetCore.Components; +using Newtonsoft.Json; + +namespace Test.UI.Components.Pages { - public partial class Aedifica + public partial class Aedifica : IDisposable { - protected string currText = "..."; - private async Task SaveText(string newText) + + private string subChannel = ""; + private string CalcUid = "Pizza"; + private string currSvg = ""; + private string apiUrl = ""; + private string calcTag = ""; + private string GenericBasePath = ""; + + [Inject] + protected IConfiguration Config { get; set; } = null!; + + [Inject] + protected DataLayerServices DLService { get; set; } = null!; + + [Inject] + protected ImageCacheService ICService { get; set; } = null!; + + public void Dispose() { - currText = newText; - await Task.Delay(100); + DLService.CalcDonePipe.EA_NewMessage -= CalcDonePipe_EA_NewMessage; } + + protected MarkupString JsonSer + { + get => (MarkupString)currSvg.Replace(Environment.NewLine, "
").Replace(" ", " "); + } + + protected Dictionary m_CurrArgs = new Dictionary(); + + protected override async Task OnInitializedAsync() + { + ConfInit(); + DLService.CalcDonePipe.EA_NewMessage += CalcDonePipe_EA_NewMessage; + //await ReloadData(); + await Task.Delay(1); + } + + private void ConfInit() + { + apiUrl = Config.GetValue("ServerConf:Prog.ApiUrl") ?? ""; + GenericBasePath = Config.GetValue("ServerConf:GenericBaseUrl") ?? ""; + //imgTag = Config.GetValue("ServerConf:ImageFileTag") ?? ""; + calcTag = Config.GetValue("ServerConf:CalcTag") ?? ""; + subChannel = Config.GetValue("ServerConf:SvgChannel") ?? ""; + } + + private async Task SaveText(Dictionary CurrArgs) + { + m_CurrArgs = CurrArgs; + // chiamo la chiamata POST alla API, che manda la richiesta via REDIS + if (m_CurrArgs != null) + { + CalcRequestDTO calcRequestDTO = new CalcRequestDTO(); + calcRequestDTO.EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM; + calcRequestDTO.DictExec = m_CurrArgs; + await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{CalcUid}", calcRequestDTO); + } + } + + private async void CalcDonePipe_EA_NewMessage(object? sender, EventArgs e) + { + // aggiorno visualizzazione + PubSubEventArgs currArgs = (PubSubEventArgs)e; + // conversione on-the-fly SVG da mostrare + if (!string.IsNullOrEmpty(currArgs.newMessage)) + { + if (currArgs.msgUid.Equals($"{subChannel}:{CalcUid}")) + { + currSvg = currArgs.newMessage; + } + await InvokeAsync(StateHasChanged); + } + await Task.Delay(1); + } + } } diff --git a/Test.UI/Components/Pages/Home.razor.cs b/Test.UI/Components/Pages/Home.razor.cs index 5710b0a..d64d9f9 100644 --- a/Test.UI/Components/Pages/Home.razor.cs +++ b/Test.UI/Components/Pages/Home.razor.cs @@ -140,7 +140,8 @@ namespace Test.UI.Components.Pages // calcolo URL immagini... DTO interno da rivedere? foreach (var item in rawList) { - item.ImageUrl = ICService.ImageUrl(imgBasePath, false, item.SVGFileName); + item.ImageUrl = ICService.ImageUrl($"{apiUrl}/{imgBasePath}", false, item.SVGFileName); + //item.ImageUrl = ICService.ImageUrl(imgBasePath, false, item.SVGFileName); AvailTemplateList.Add(item); } } @@ -152,7 +153,7 @@ namespace Test.UI.Components.Pages // chiamo la chiamata POST alla API, che manda la richiesta via REDIS if (currSel != null) { - await ICService.CallRestPost(apiUrl, $"{calcTag}/{windowUid}", currJwd); + await ICService.CallRestPost($"{apiUrl}/{imgBasePath}", $"{calcTag}/{windowUid}", currJwd); } } diff --git a/Test.UI/Components/Pages/TestComponent.razor.cs b/Test.UI/Components/Pages/TestComponent.razor.cs index 968a816..b6c0e38 100644 --- a/Test.UI/Components/Pages/TestComponent.razor.cs +++ b/Test.UI/Components/Pages/TestComponent.razor.cs @@ -140,7 +140,7 @@ namespace Test.UI.Components.Pages // calcolo URL immagini... DTO interno da rivedere? foreach (var item in rawList) { - item.ImageUrl = ICService.ImageUrl(imgBasePath, false, item.SVGFileName); + item.ImageUrl = ICService.ImageUrl($"{apiUrl}/{imgBasePath}", false, item.SVGFileName); AvailTemplateList.Add(item); } } @@ -152,7 +152,7 @@ namespace Test.UI.Components.Pages // chiamo la chiamata POST alla API, che manda la richiesta via REDIS if (currSel != null) { - await ICService.CallRestPost(apiUrl, $"{calcTag}/{windowUid}", currJwd); + await ICService.CallRestPost($"{apiUrl}/{imgBasePath}", $"{calcTag}/{windowUid}", currJwd); } } diff --git a/Test.UI/Test.UI.csproj b/Test.UI/Test.UI.csproj index 8cab8f8..3cc5853 100644 --- a/Test.UI/Test.UI.csproj +++ b/Test.UI/Test.UI.csproj @@ -28,8 +28,8 @@ - - + + diff --git a/Test.UI/appsettings.json b/Test.UI/appsettings.json index 5417cdf..06d2c7f 100644 --- a/Test.UI/appsettings.json +++ b/Test.UI/appsettings.json @@ -9,14 +9,16 @@ "ConnectionStrings": { "Redis": "redis.ufficio:26379, serviceName=devel, DefaultDatabase=6, keepAlive=180, connectTimeout=15000, syncTimeout=15000, asyncTimeout=15000, abortConnect=false, ssl=false, allowAdmin=true" }, - "ServerConf": { - "PubChannel": "EgwEngineInput", - "SubChannel": "EgwEngineOutput", - "SvgChannel": "svg:img", - "Prog.ApiUrl": "https://iis01.egalware.com/lux/srv/api/window", - "ImageBaseUrl": "https://iis01.egalware.com/lux/srv/api/window", - "ImageLiveTag": "svg", - "ImageFileTag": "svgfile", - "ImageCalcTag": "svg-preview" - } + "ServerConf": { + "PubChannel": "EgwEngineInput", + "SubChannel": "EgwEngineOutput", + "SvgChannel": "svg:img", + "Prog.ApiUrl": "https://iis01.egalware.com/lux/srv/api", + "ImageBaseUrl": "window", + "GenericBaseUrl": "generic", + "ImageLiveTag": "svg", + "ImageFileTag": "svgfile", + "ImageCalcTag": "svg-preview", + "CalcTag": "calc" + } } diff --git a/WebAedificaConfigurator/WebAedificaMaker.razor b/WebAedificaConfigurator/WebAedificaMaker.razor index 3ff8a18..f9f5550 100644 --- a/WebAedificaConfigurator/WebAedificaMaker.razor +++ b/WebAedificaConfigurator/WebAedificaMaker.razor @@ -1,22 +1,29 @@  -
-
- -
-
-
-
-
-
- +
+
+
+
+ +
+
+
+
+
+
+ -
-
+
+
+
-
-
-
+
+
+
+
+ @outSvg +
+
\ No newline at end of file diff --git a/WebAedificaConfigurator/WebAedificaMaker.razor.cs b/WebAedificaConfigurator/WebAedificaMaker.razor.cs index f9623ab..dcfd8a5 100644 --- a/WebAedificaConfigurator/WebAedificaMaker.razor.cs +++ b/WebAedificaConfigurator/WebAedificaMaker.razor.cs @@ -10,13 +10,46 @@ namespace WebAedificaConfigurator { public partial class WebAedificaMaker { - string text = ""; + string m_FilePath = ""; + string m_sSvg = ""; + [Parameter] - public EventCallback EC_OnSave { get; set; } + public EventCallback> EC_OnSave { get; set; } + + [Parameter] + public string CssSvg { get; set; } = "responsive-svg"; + + [Parameter] + public string LiveSVG + { + get => m_sSvg; + set => m_sSvg = value; + } protected async Task DoSave() { - await EC_OnSave.InvokeAsync(text); + Dictionary Args = new Dictionary(); + Args.Add("FilePath", m_FilePath); + Args.Add("Mode", 1.ToString()); + await EC_OnSave.InvokeAsync(Args); + } + + /// + /// Componente SVG da mostrare + /// + protected MarkupString outSvg + { + get + { + // aggiunta gestione classe svg per posizionamento con costraints + var newSvg = LiveSVG.Replace(" "col-6"; } } }