diff --git a/EgwControlCenter.App/Components/Compo/AuthChallengeMan.razor b/EgwControlCenter.App/Components/Compo/AuthChallengeMan.razor index 987f8e1..aac36c2 100644 --- a/EgwControlCenter.App/Components/Compo/AuthChallengeMan.razor +++ b/EgwControlCenter.App/Components/Compo/AuthChallengeMan.razor @@ -33,17 +33,31 @@ -
-
-
+
+
+
Auth Code
-
- 12345678 +
+
+
+ @($"{passcode:00 00 00 00}")
+ @*
+ @($"{passcode}") +
*@
-
Istruzioni enroll: per autorizzare l'applicativo comunicare il codice di auth mostrato al personale EgalWare. Puoi farlovia telefono numero 035-460560 oppure via email all'indirizzo info@egalware.com
+
+ Istruzioni enroll: per autorizzare l'applicativo comunicare il codice di auth mostrato al personale EgalWare.
+ Puoi farlo tramite telefono al numero 035-460560 oppure via email all'indirizzo info@egalware.com +
+ @*
+ +
*@ +
+ +
diff --git a/EgwControlCenter.App/Components/Compo/AuthChallengeMan.razor.cs b/EgwControlCenter.App/Components/Compo/AuthChallengeMan.razor.cs index 523e5db..3d9fe2d 100644 --- a/EgwControlCenter.App/Components/Compo/AuthChallengeMan.razor.cs +++ b/EgwControlCenter.App/Components/Compo/AuthChallengeMan.razor.cs @@ -1,11 +1,32 @@ using EgwControlCenter.Core.Models; using EgwControlCenter.Core; using Microsoft.AspNetCore.Components; +using EgwCoreLib.Razor; namespace EgwControlCenter.App.Components.Compo { public partial class AuthChallengeMan : IDisposable { + #region Protected Fields + + protected int tCounter = 0; + + #endregion Protected Fields + + #region Private Fields + + private string bandColor = "13FD13"; + private int passcode = 0; + + private PeriodicTimer periodicTimer = new(TimeSpan.FromSeconds(1)); + private bool remoteCalling = false; + + private bool ReqSetup = true; + + private int startCounter = 20; + + #endregion Private Fields + #region Public Properties [Parameter] @@ -13,16 +34,6 @@ namespace EgwControlCenter.App.Components.Compo #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] @@ -52,76 +63,35 @@ namespace EgwControlCenter.App.Components.Compo set => ACService.RefreshPeriod = value; } - /// - /// Gestione evento chiamata verso server - /// - 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 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 int currPage { get; set; } = 1; private bool isLoading { get; set; } = false; @@ -153,6 +123,72 @@ namespace EgwControlCenter.App.Components.Compo #endregion Private Properties + #region Public Methods + + public void Dispose() + { + periodicTimer?.Dispose(); + ACService.EA_ConfigUpdated -= ACService_EA_ConfigUpdated; + ACService.EA_RemoteCalling -= ACService_EA_RemoteCalling; + } + + #endregion Public Methods + + #region Protected Methods + + protected void DoCancel() + { + ACService.DoReloadConfig(); + } + + protected void DoReset() + { + ACService.ResetConf(); + } + + protected void DoSave() + { + ACService.DoSaveConfig(); + ACService.DoReloadConfig(); + } + + protected override void OnInitialized() + { + // mi faccio staccare un codice di auth da remoto + passcode = ACService.GetAuthPassocde(); + tCounter = startCounter; + RunTimer(); + // aggancio gestione eventi + 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 Methods private void ACService_EA_ConfigUpdated() @@ -160,6 +196,15 @@ namespace EgwControlCenter.App.Components.Compo ForceReload(); } + /// + /// Gestione evento chiamata verso server + /// + private async void ACService_EA_RemoteCalling() + { + RemoteCallActive = ACService.CloudCallActive; + await InvokeAsync(StateHasChanged); + } + private void ForceReload() { totalCount = SearchRecords.Count; @@ -169,33 +214,36 @@ namespace EgwControlCenter.App.Components.Compo .ToList(); } - #endregion Private Methods - - private string btnSyncClass + private async void RunTimer() { - get + while (await periodicTimer.WaitForNextTickAsync()) { - string answ = ""; - if (remoteCalling) + tCounter--; + if (tCounter < 0) { - answ = "btn-info"; + tCounter = startCounter; + } + // aggiungo colore secondo valore... + if (tCounter > startCounter * 0.6) + { + bandColor = "#00FF00"; + } + else if (tCounter > startCounter * 0.3) + { + bandColor = "#26ED26"; + } + else if (tCounter > startCounter * 0.1) + { + bandColor = "#DCFD15"; } else { - answ = ChannelAuth ? "btn-outline-success" : "btn-warning"; + bandColor = "#DC2615"; } - - return answ; + await InvokeAsync(StateHasChanged); } } - private bool ChannelAuth - { - get => ACService.ChannelAuth; - } - - private bool remoteCalling = false; - private async Task TrySync() { remoteCalling = true; @@ -215,5 +263,7 @@ namespace EgwControlCenter.App.Components.Compo await Task.Delay(10); remoteCalling = false; } + + #endregion Private Methods } } \ No newline at end of file diff --git a/EgwControlCenter.App/EgwControlCenter.App.csproj b/EgwControlCenter.App/EgwControlCenter.App.csproj index 96c37b3..ef07fb3 100644 --- a/EgwControlCenter.App/EgwControlCenter.App.csproj +++ b/EgwControlCenter.App/EgwControlCenter.App.csproj @@ -5,7 +5,7 @@ enable true enable - 1.1.2412.3011 + 1.1.2412.3016 Debug;Release;DEBUG_Local diff --git a/EgwControlCenter.App/Properties/PublishProfiles/ClickOnceProfile.pubxml b/EgwControlCenter.App/Properties/PublishProfiles/ClickOnceProfile.pubxml index 7c79f57..60a8d5f 100644 --- a/EgwControlCenter.App/Properties/PublishProfiles/ClickOnceProfile.pubxml +++ b/EgwControlCenter.App/Properties/PublishProfiles/ClickOnceProfile.pubxml @@ -4,8 +4,8 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - 3011 - 1.1.2412.3011 + 3016 + 1.1.2412.3016 True Release True diff --git a/EgwControlCenter.App/wwwroot/css/app.css b/EgwControlCenter.App/wwwroot/css/app.css index 2fcd330..89c9b1b 100644 --- a/EgwControlCenter.App/wwwroot/css/app.css +++ b/EgwControlCenter.App/wwwroot/css/app.css @@ -29,6 +29,10 @@ a, .btn-link { color: #0071c1; } +.text-center { + display: flex; + justify-content: center; +} .btn-primary { color: #fff; background-color: #1b6ec2; diff --git a/EgwControlCenter.App/wwwroot/css/app.less b/EgwControlCenter.App/wwwroot/css/app.less index 8f57c7f..3f9e6b6 100644 --- a/EgwControlCenter.App/wwwroot/css/app.less +++ b/EgwControlCenter.App/wwwroot/css/app.less @@ -23,6 +23,11 @@ a, .btn-link { color: #0071c1; } +.text-center { + display: flex; + justify-content: center; +} + .btn-primary { color: #fff; background-color: #1b6ec2; diff --git a/EgwControlCenter.App/wwwroot/css/app.min.css b/EgwControlCenter.App/wwwroot/css/app.min.css index b925241..6639967 100644 --- a/EgwControlCenter.App/wwwroot/css/app.min.css +++ b/EgwControlCenter.App/wwwroot/css/app.min.css @@ -1 +1 @@ -h1,h2,h3,h4,h5,h6,b,display-1,display-2,display-3,display-4{font-family:'Lato',sans-serif;}html,body{font-family:'Roboto Condensed',sans-serif;line-height:1.3;}h1:focus{outline:0;}a,.btn-link{color:#0071c1;}.btn-primary{color:#fff;background-color:#1b6ec2;border-color:#1861ac;}.valid.modified:not([type=checkbox]){outline:1px solid #26b050;}.invalid{outline:1px solid #f00;}.validation-message{color:#f00;}#blazor-error-ui{background:#ffffe0;bottom:0;box-shadow:0 -1px 2px rgba(0,0,0,.2);display:none;left:0;padding:.6rem 1.25rem .7rem 1.25rem;position:fixed;width:100%;z-index:1000;}#blazor-error-ui .dismiss{cursor:pointer;position:absolute;right:.75rem;top:.5rem;}.bottom-row{color:#dedede;background-color:#000;height:1.6rem;align-items:center;}@media(max-width:640px){body{font-size:.8em;line-height:1.1;}}@media(max-width:1650px){body{font-size:.9em;line-height:1.2;}} \ No newline at end of file +h1,h2,h3,h4,h5,h6,b,display-1,display-2,display-3,display-4{font-family:'Lato',sans-serif;}html,body{font-family:'Roboto Condensed',sans-serif;line-height:1.3;}h1:focus{outline:0;}a,.btn-link{color:#0071c1;}.text-center{display:flex;justify-content:center;}.btn-primary{color:#fff;background-color:#1b6ec2;border-color:#1861ac;}.valid.modified:not([type=checkbox]){outline:1px solid #26b050;}.invalid{outline:1px solid #f00;}.validation-message{color:#f00;}#blazor-error-ui{background:#ffffe0;bottom:0;box-shadow:0 -1px 2px rgba(0,0,0,.2);display:none;left:0;padding:.6rem 1.25rem .7rem 1.25rem;position:fixed;width:100%;z-index:1000;}#blazor-error-ui .dismiss{cursor:pointer;position:absolute;right:.75rem;top:.5rem;}.bottom-row{color:#dedede;background-color:#000;height:1.6rem;align-items:center;}@media(max-width:640px){body{font-size:.8em;line-height:1.1;}}@media(max-width:1650px){body{font-size:.9em;line-height:1.2;}} \ No newline at end of file diff --git a/EgwControlCenter.Core/AppControlService.cs b/EgwControlCenter.Core/AppControlService.cs index 076c790..e191550 100644 --- a/EgwControlCenter.Core/AppControlService.cs +++ b/EgwControlCenter.Core/AppControlService.cs @@ -81,6 +81,19 @@ namespace EgwControlCenter.Core } } + private Random rnd = new Random(); + + /// + /// Restituisce un codice di auth temporaneo da autorizzare + /// + /// + public int GetAuthPassocde() + { + // fixme todo !!! implementare da lettura remota oppure gen locale... + int tempCode = rnd.Next(10000000, 99999999); + return tempCode; + } + /// /// verifica autorizzazione al canale, ovvero /// - deve avere tutte le chiavi/registri di comunicazione