Inizio aggiunta pagina enroll numerica

This commit is contained in:
Samuele E. Locatelli
2024-12-30 11:29:37 +01:00
parent bd68c9056e
commit 3d7466f176
6 changed files with 308 additions and 8 deletions
@@ -0,0 +1,52 @@
<div class="card shadow">
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="p-0 d-flex">
<div class="px-0">
<h5>Preliminary Enroll</h5>
</div>
@if (RemoteCallActive)
{
<div class="px-2">
<i class="fa-solid fa-cloud-arrow-down fs-4 text-success"></i>
</div>
}
</div>
<div class="p-0 d-flex">
<div class="px-1">
@if (PwdOk)
{
<div class="input-group">
<button class="btn btn-sm btn-outline-success shadow" @onclick="DoSave" title="Save All Changes"><i class="fa-regular fa-floppy-disk"></i> Save</button>
<button class="btn btn-sm btn-outline-secondary shadow" @onclick="DoCancel" title="Reload Saved"><i class="fa-solid fa-rotate"></i> Reload</button>
<button class="btn btn-sm btn-outline-danger shadow" @onclick="DoReset" title="Reset to Empty/Standard"><i class="fa-solid fa-ban"></i> Reset</button>
<button class="btn btn-sm btn-outline-dark" @onclick="ToggleSetup" title="Close Configuration Setup"><i class="fa-solid fa-angles-right"></i></button>
</div>
}
else
{
<div class="px-1">
<button class="btn btn-sm btn-outline-dark w-100" @onclick="ToggleSetup" title="Chiudi Setup Controlli"><i class="fa-solid fa-angles-right"></i></button>
</div>
}
</div>
</div>
</div>
</div>
<div class="card-body p-2">
<div class="row">
<div class="col-12 fs-4 text-center">
Auth Code
</div>
<div class="col-12 fs-1 text-center fw-bold">
12345678
</div>
</div>
<div class="d-flex my-2">
<div class="px-2">Istruzioni enroll: per autorizzare l'applicativo comunicare il codice di auth mostrato al personale EgalWare. Puoi farlovia telefono numero <b>035-460560</b> oppure via email all'indirizzo <a href="mailto:info@egalware.com">info@egalware.com</a></div>
</div>
</div>
</div>
@@ -0,0 +1,219 @@
using EgwControlCenter.Core.Models;
using EgwControlCenter.Core;
using Microsoft.AspNetCore.Components;
namespace EgwControlCenter.App.Components.Compo
{
public partial class AuthChallengeMan : IDisposable
{
#region Public Properties
[Parameter]
public EventCallback<bool> EC_GotoSetup { get; set; }
#endregion Public Properties
#region Public Methods
public void Dispose()
{
ACService.EA_ConfigUpdated -= ACService_EA_ConfigUpdated;
ACService.EA_RemoteCalling -= ACService_EA_RemoteCalling;
}
#endregion Public Methods
#region Protected Properties
[Inject]
protected AppControlService ACService { get; set; } = null!;
protected string AppKey
{
get => ACService.AppKey;
//set => ACService.AppKey = value;
}
protected string CodImpiego
{
get => ACService.CodImpiego;
//set => ACService.CodImpiego = value;
}
protected string MainKey
{
get => ACService.MainKey;
set => ACService.MainKey = value;
}
protected int RefreshPeriod
{
get => ACService.RefreshPeriod;
set => ACService.RefreshPeriod = value;
}
/// <summary>
/// Gestione evento chiamata verso server
/// </summary>
private async void ACService_EA_RemoteCalling()
{
RemoteCallActive = ACService.CloudCallActive;
await InvokeAsync(StateHasChanged);
}
protected bool RemoteCallActive { get; set; } = false;
#endregion Protected Properties
#region Protected Methods
protected void DoCancel()
{
ACService.DoReloadConfig();
}
protected void DoReset()
{
ACService.ResetConf();
}
protected void DoSave()
{
ACService.DoSaveConfig();
ACService.DoReloadConfig();
}
protected override void OnInitialized()
{
ACService.EA_ConfigUpdated += ACService_EA_ConfigUpdated;
ACService.EA_RemoteCalling += ACService_EA_RemoteCalling;
}
protected override void OnParametersSet()
{
ForceReload();
}
protected void SetNumRec(int newNum)
{
numRecord = newNum;
currPage = 1;
ForceReload();
}
protected void SetPage(int newNum)
{
currPage = newNum;
ForceReload();
}
protected async void ToggleSetup()
{
ReqSetup = !ReqSetup;
await EC_GotoSetup.InvokeAsync(ReqSetup);
}
#endregion Protected Methods
#region Private Fields
private bool ReqSetup = true;
#endregion Private Fields
#region Private Properties
private int currPage { get; set; } = 1;
private bool isLoading { get; set; } = false;
private List<ControlTarget> ListRecords { get; set; } = new List<ControlTarget>();
private int numRecord { get; set; } = 5;
private bool PwdOk
{
get => !string.IsNullOrEmpty(SetupPwd) && SetupPwd == EgwControlCenter.Core.Const.EditPwd;
}
private List<ControlTarget> SearchRecords
{
get => ACService.TargetList;
set => ACService.TargetList = value;
}
private string SetupPwd { get; set; } = "";
private int totalCount { get; set; } = 0;
private int VetoCheck
{
get => ACService.VetoCheck;
set => ACService.VetoCheck = value;
}
#endregion Private Properties
#region Private Methods
private void ACService_EA_ConfigUpdated()
{
ForceReload();
}
private void ForceReload()
{
totalCount = SearchRecords.Count;
ListRecords = SearchRecords
.Skip(numRecord * (currPage - 1))
.Take(numRecord)
.ToList();
}
#endregion Private Methods
private string btnSyncClass
{
get
{
string answ = "";
if (remoteCalling)
{
answ = "btn-info";
}
else
{
answ = ChannelAuth ? "btn-outline-success" : "btn-warning";
}
return answ;
}
}
private bool ChannelAuth
{
get => ACService.ChannelAuth;
}
private bool remoteCalling = false;
private async Task TrySync()
{
remoteCalling = true;
// verifico se ho CodImpiego
bool setCodImp = string.IsNullOrEmpty(CodImpiego);
bool setAppKey = string.IsNullOrEmpty(AppKey);
if (setCodImp || setAppKey)
{
ACService.ResetSubLic(setCodImp, setAppKey);
}
await Task.Delay(10);
bool fatto = await ACService.CheckAttivazioni();
if (fatto)
{
ACService.DoSaveConfig();
}
await Task.Delay(10);
remoteCalling = false;
}
}
}
@@ -5,9 +5,16 @@
<div class="mb-5">
@if (ReqSetup)
@if (MissingAuth)
{
<AuthChallengeMan></AuthChallengeMan>
}
else if (DoSetup)
{
<TargetSetup EC_GotoSetup="SetupMode"></TargetSetup>
}
else
{
@@ -13,6 +13,20 @@ namespace EgwControlCenter.App.Components.Pages
#endregion Protected Properties
protected override async Task OnInitializedAsync()
{
//return base.OnInitializedAsync();
// verifica presenza MainKey di auth, mostrando eventualmente la pagina di setup con codice numerico da autorizzare da LiMan
MissingAuth = string.IsNullOrEmpty(MainKey);
await Task.Delay(10);
}
protected string MainKey
{
get => ACService.MainKey;
set => ACService.MainKey = value;
}
#region Protected Methods
protected async Task ForceCheck()
@@ -22,8 +36,8 @@ namespace EgwControlCenter.App.Components.Pages
protected async Task SetupMode(bool reqSetup)
{
ReqSetup = reqSetup;
if (!ReqSetup)
DoSetup = reqSetup;
if (!DoSetup)
{
await ForceCheck();
}
@@ -31,14 +45,22 @@ namespace EgwControlCenter.App.Components.Pages
protected void ToggleSetup()
{
ReqSetup = !ReqSetup;
DoSetup = !DoSetup;
}
#endregion Protected Methods
#region Private Properties
private bool ReqSetup { get; set; } = false;
/// <summary>
/// Indica richiesta modifica setup applicazione
/// </summary>
private bool DoSetup { get; set; } = false;
/// <summary>
/// Indica mancanza auth di primo e secondo livello e relativa necessità auth da server LiMan o da config esplicito locale
/// </summary>
private bool MissingAuth { get; set; } = false;
#endregion Private Properties
}
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.1.2412.2810</Version>
<Version>1.1.2412.3011</Version>
<Configurations>Debug;Release;DEBUG_Local</Configurations>
</PropertyGroup>
<ItemGroup>
@@ -4,8 +4,8 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<ApplicationRevision>2810</ApplicationRevision>
<ApplicationVersion>1.1.2412.2810</ApplicationVersion>
<ApplicationRevision>3011</ApplicationRevision>
<ApplicationVersion>1.1.2412.3011</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Release</Configuration>
<CreateWebPageOnPublish>True</CreateWebPageOnPublish>