From 63e60a82a7d4cbb3d34eceb6fde7828c6fc12e26 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 25 Oct 2021 10:29:03 +0200 Subject: [PATCH] aggiunta componente editing parametri --- GWMS.UI/Components/ParamEditor.razor | 49 ++++++++++++++ GWMS.UI/Components/ParamEditor.razor.cs | 88 +++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 GWMS.UI/Components/ParamEditor.razor create mode 100644 GWMS.UI/Components/ParamEditor.razor.cs diff --git a/GWMS.UI/Components/ParamEditor.razor b/GWMS.UI/Components/ParamEditor.razor new file mode 100644 index 0000000..1ee6e2d --- /dev/null +++ b/GWMS.UI/Components/ParamEditor.razor @@ -0,0 +1,49 @@ +@using Blazorise +@using GWMS.UI.Components +@using Microsoft.AspNetCore.Components.Authorization +@using GWMS.UI.Data +@using Microsoft.Extensions.Configuration + +
+
+ Modifica +
+
+ + +
+
+
+
+ @_currItem.uid +
+
+ @_currItem.name +
+
+
+
+
+
+ + Valore rilevato: @_currItem.value + +
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+
+
\ No newline at end of file diff --git a/GWMS.UI/Components/ParamEditor.razor.cs b/GWMS.UI/Components/ParamEditor.razor.cs new file mode 100644 index 0000000..2b95e90 --- /dev/null +++ b/GWMS.UI/Components/ParamEditor.razor.cs @@ -0,0 +1,88 @@ +using AutoMapper.Configuration; +using GWMS.Data.DTO; +using GWMS.UI.Data; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Identity; +using Microsoft.JSInterop; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using static GWMS.Data.IobObjects; + +namespace GWMS.UI.Components +{ + public partial class ParamEditor + { + #region Protected Fields + + protected objItem _currItem = new objItem(); + + #endregion Protected Fields + + #region Private Properties + + [Inject] + private IJSRuntime JSRuntime { get; set; } + + #endregion Private Properties + + #region Protected Properties + + [Inject] + protected GWMSDataService DataService { get; set; } + + #endregion Protected Properties + + #region Public Properties + + [Parameter] + public objItem currItem + { + get + { + return _currItem; + } + set + { + _currItem = value; + } + } + + [Parameter] + public EventCallback DataReset { get; set; } + + [Parameter] + public EventCallback DataUpdated { get; set; } + + [Parameter] + public string IdxMacchina { get; set; } = ""; + + #endregion Public Properties + + #region Private Methods + + private async Task cancelUpdate() + { + await DataReset.InvokeAsync(0); + } + + private async Task saveUpdate() + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler inviare il valore per parametro richiesto?")) + return; + + if (_currItem != null) + { + await DataService.updateMachineParameter(IdxMacchina, _currItem.uid, _currItem.reqValue); + await DataUpdated.InvokeAsync(0); + } + else + { + Console.WriteLine("Record null!"); + } + } + + #endregion Private Methods + } +} \ No newline at end of file