From e1ce5655bc4a3f97ffa154306b3c523eed2f5839 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 7 Apr 2023 14:56:58 +0200 Subject: [PATCH] Inizio modifica x spostare gestione su single instance --- .../Hardware/HardwareNewPanel.razor | 71 +++++------ .../Components/Hardware/SingleInstance.razor | 60 ++++++++++ .../Hardware/SingleInstance.razor.cs | 111 ++++++++++++++++++ 3 files changed, 207 insertions(+), 35 deletions(-) create mode 100644 WebDoorCreator.UI/Components/Hardware/SingleInstance.razor create mode 100644 WebDoorCreator.UI/Components/Hardware/SingleInstance.razor.cs diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor index bd629da..af6a6fe 100644 --- a/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor +++ b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor @@ -1,47 +1,48 @@ @if (DoorOp != null) { -
@foreach (var item in DoorOp) {
- + - @foreach (var graph in getGraphicParams()) - { - @foreach (var graphParam in graph.Value) - { - @if (graphParam.Value.Count == 1) - { -
- @translate(graphParam.Key) - -
- } - else - { -
- @translate(graphParam.Key) - -
- } + @* - } - } -
-
- Cancel -
-
- Save -
-
+ @foreach (var graph in getGraphicParams()) + { + @foreach (var graphParam in graph.Value) + { + @if (graphParam.Value.Count == 1) + { +
+ @translate(graphParam.Key) + +
+ } + else + { +
+ @translate(graphParam.Key) + +
+ } + + } + } +
+
+ Cancel +
+
+ Save +
+
*@
} diff --git a/WebDoorCreator.UI/Components/Hardware/SingleInstance.razor b/WebDoorCreator.UI/Components/Hardware/SingleInstance.razor new file mode 100644 index 0000000..88dd705 --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/SingleInstance.razor @@ -0,0 +1,60 @@ + +
+ Template + @if (listValuesFiles != null && listValuesFiles.Count > 0) + { + + } + else + { + + } +
+ +@foreach (var graph in getGraphicParams()) +{ + @foreach (var graphParam in graph.Value) + { + @if (graphParam.Value.Count == 1) + { +
+ @translate(graphParam.Key) + +
+ } + else + { +
+ @translate(graphParam.Key) + +
+ } + + } +} +
+
+ Cancel +
+
+ Save +
+
\ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/SingleInstance.razor.cs b/WebDoorCreator.UI/Components/Hardware/SingleInstance.razor.cs new file mode 100644 index 0000000..7b96880 --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/SingleInstance.razor.cs @@ -0,0 +1,111 @@ +using Microsoft.AspNetCore.Components; +using Newtonsoft.Json; +using WebDoorCreator.Data.DbModels; +using WebDoorCreator.UI.Data; + +namespace WebDoorCreator.UI.Components.Hardware +{ + public partial class SingleInstance + { + #region Public Properties + + [Parameter] + public DoorOpModel DoorOpInst { get; set; } = null!; + + [Parameter] + public string HwCode { get; set; } = ""; + + [Parameter] + public string Lingua { get; set; } = "EN"; + + #endregion Public Properties + + #region Public Methods + + public Dictionary>> getGraphicParams() + { + var deserialized = JsonConvert.DeserializeObject>>>(DoorOpInst.JsoncConfigVal!); + if (deserialized != null) + { + graphicParams = deserialized; + } + return graphicParams; + } + + #endregion Public Methods + + #region Protected Properties + + protected string _folderName { get; set; } = ""; + + protected string folderName + { + get => _folderName; + set + { + if (_folderName != value) + { + _folderName = value; + var pUpd = Task.Run(async () => await ReloadData(false)); + } + } + } + + protected Dictionary>> graphicParams { get; set; } = null!; + protected List? listValuesFiles { get; set; } = null!; + + protected List? listValuesFname { get; set; } = null!; + + [Inject] + protected WebDoorCreatorService WDCService { get; set; } = null!; + + [Inject] + protected WDCVocabularyService WDVService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnParametersSetAsync() + { + await ReloadData(true); + } + + protected string translate(string lemma) + { + string answ = ""; + + answ = WDVService.Traduci(Lingua, lemma); + + return answ; + } + + #endregion Protected Methods + + #region Private Methods + + private async Task ReloadData(bool isFirst) + { + var tempListVal = await WDCService.ListValuesGetAll(HwCode, "Folder"); + if (tempListVal != null) + { + listValuesFname = tempListVal; + if (listValuesFname != null) + { + if (isFirst) + { + folderName = listValuesFname.FirstOrDefault()?.Label!; + } + var tempListFiles = await WDCService.ListValuesGetAll(HwCode, "Template"); + + if (tempListFiles != null) + { + listValuesFiles = tempListFiles.Where(x => x.Value.Contains(folderName)).ToList(); + } + } + } + } + + #endregion Private Methods + } +} \ No newline at end of file