Update display aggiornamenti

- maca gestione timer autorefresh componente
- manca testing finale
- manca clickonce finale
This commit is contained in:
Samuele Locatelli
2024-09-21 12:44:06 +02:00
parent e3421fb657
commit c8b049be4f
9 changed files with 209 additions and 112 deletions
@@ -0,0 +1,87 @@
@using EgwControlCenter.Core
@using EgwControlCenter.Core.Models
@inject AppControlService ACService
<table class="table table-striped table-sm text-start shadow border">
<thead>
<tr class="bg-dark bg-gradient text-light">
@* <th class="text-center" style="width: 2rem;">
<button class="btn btn-primary btn-sm" @onclick="DoCancel"><i class="fa-solid fa-rotate"></i></button>
</th> *@
<th>Applicazione</th>
<th>Installed</th>
<th>Available</th>
<th class="text-center">Update</th>
<th class="text-end">Note</th>
</tr>
</thead>
<tbody>
@if (ListRecords == null || ListRecords.Count == 0)
{
<tr>
<td colspan="5">
<div class="alert alert-warning">Nessun aggiornamento disponibile!</div>
</td>
</tr>
}
else
{
@foreach (var item in ListRecords)
{
<tr>
<td>@item.CodApp</td>
<td>@item.VersNumCurr</td>
<td>@item.VersNumLast</td>
<td class="text-center">
@if (item.HasUpdate)
{
<i class="fa-solid fa-bell text-success"></i>
}
</td>
<td>@item.RelTagsLast</td>
</tr>
}
}
</tbody>
</table>
@code {
[Parameter]
public bool OnlyUpdate { get; set; } = false;
private List<VersStatusDTO>? ListRecords { get; set; } = null;
private List<VersStatusDTO> CurrRecords
{
get => ACService.ListAppStatus;
// set => ACService.ListAppStatus = value;
}
protected override void OnParametersSet()
{
// fix parametro visualizzazione solo update
ForceReload();
}
protected override void OnInitialized()
{
ACService.EA_StatusUpdated += ACService_EA_StatusUpdated;
}
private void ACService_EA_StatusUpdated()
{
// fermo il timer e lo riavvio...
ForceReload();
}
private void ForceReload()
{
// ListRecords = null;
ListRecords = CurrRecords
.Where(x => x.HasUpdate || !OnlyUpdate)
.ToList();
StateHasChanged();
}
}
@@ -1,6 +1,9 @@
<div class="d-flex justify-content-between text-light">
<div class="text-start">
<a class="text-light" href="https://iis01.egalware.com/Egalware/ACC/Publish.html" target="_blank">App Control Center</a> <span class="small">v.@AppVers</span>
<button class="btn btn-sm btn-outline-light py-0 px-1" @onclick="NavAbout">
@CurrAssembly.Name <span class="small">v.@AppVers</span>
</button>
@* <a class="text-light" href="https://iis01.egalware.com/Egalware/ACC/Publish.html" target="_blank">@CurrAssembly.Name</a> <span class="small">v.@AppVers</span> *@
</div>
<div class="text-end">
<span class="small px-1">@adesso</span>
@@ -27,6 +27,9 @@ namespace EgwControlCenter.App.Components.Compo
#endregion Protected Fields
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
[Inject]
protected AppControlService ACService { get; set; } = null!;
@@ -46,12 +49,13 @@ namespace EgwControlCenter.App.Components.Compo
protected override void OnInitialized()
{
StartTimer();
CurrAssembly = System.Reflection.Assembly.GetExecutingAssembly().GetName();
ACService.EA_ConfigUpdated += ACService_EA_ConfigUpdated;
}
private void ACService_EA_ConfigUpdated()
{
//fermo il timer e lo riavvio...
// fermo il timer e lo riavvio...
StartTimer();
}
@@ -68,8 +72,6 @@ namespace EgwControlCenter.App.Components.Compo
aTimer.Stop();
aTimer.Dispose();
}
//int tOutPeriod = 300000;
//int tOutPeriod = 1000;
int tOutPeriod = RefreshPeriod < 1000 ? RefreshPeriod * 1000 : RefreshPeriod;
aTimer = new System.Timers.Timer(tOutPeriod);
aTimer.Elapsed += ElapsedTimer;
@@ -100,7 +102,16 @@ namespace EgwControlCenter.App.Components.Compo
}
}
private System.Reflection.AssemblyName? CurrAssembly { get; set; } = System.Reflection.Assembly.GetExecutingAssembly().GetName();
private System.Reflection.AssemblyName CurrAssembly { get; set; } = null!;
private void NavAbout()
{
NavMan.NavigateTo("About");
}
private void NavContacts()
{
NavMan.NavigateTo("Contacts");
}
#endregion Private Properties
}
@@ -6,7 +6,7 @@
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="p-0">
<h1>About</h1>
<h1>EgwControlCenter.App</h1>
</div>
<div class="p-0">
<div class="d-flex flex-row-reverse">
@@ -20,48 +20,29 @@
</div>
</div>
<div class="card-body">
<p>Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
<br />
<div class="row my-2">
<div class="col">
<button class="btn btn-info w-100" @onclick="GoTo01">Nav 01</button>
</div>
<div class="col">
<button class="btn btn-info w-100" @onclick="GoTo02">Nav 02</button>
</div>
<div class="col">
<button class="btn btn-info w-100" @onclick="GoTo03">Nav 03</button>
</div>
<div class="fs-5 my-3">
Gestione stato aggiornamento applicazioni EgalWare.
<br />
Per maggiori informazioni e aggiornamenti del servizio, visitate il <a href="https://iis01.egalware.com/Egalware/ACC/Publish.html" target="_blank">sito di riferimento dell'applicazione.</a>
</div>
<br />
<div class="row mt-4">
<div class="col-4"></div>
<div class="col-4">
<button class="btn btn-primary w-100" @onclick="ReturnHome"><i class="fa-solid fa-house"></i> Return HomePage</button>
</div>
<div class="col-4"></div>
</div>
</div>
<div class="card-footer">
@if (CurrAssembly != null)
{
<small>@CurrAssembly.Name | @CurrAssembly.Version</small>
}
</div>
</div>
@code {
private int currentCount = 0;
private System.Reflection.AssemblyName? CurrAssembly { get; set; } = System.Reflection.Assembly.GetExecutingAssembly().GetName();
private void IncrementCount()
{
currentCount++;
}
private void GoTo01()
private void ReturnHome()
{
NavMan.NavigateTo("Nav01");
}
private void GoTo02()
{
NavMan.NavigateTo("Nav02");
}
private void GoTo03()
{
NavMan.NavigateTo("Nav03");
}
}
@@ -8,41 +8,38 @@
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="p-0">
<h1>App Control Center</h1>
<h5>App Control Center</h5>
@* <h1><b>EgalWare's</b> App Control Center</h1> *@
<div class="form-check form-switch">
<label class="form-check-label">@ShowUpdateText</label>
<input class="form-check-input" type="checkbox" @bind="@ShowOnlyUpdate">
</div>
</div>
<div class="p-0">
<button class="btn @SetupBtnClass w-100" @onclick="ToggleSetup"><i class="fa-solid fa-screwdriver-wrench"></i></button>
<div class="p-0 d-flex">
<div class="px-1">
<button class="btn btn-outline-success w-100" @onclick="ForceCheck">Check Now <i class="fa-solid fa-rotate"></i></button>
</div>
<div class="px-1">
<button class="btn @SetupBtnClass w-100" @onclick="ToggleSetup"><i class="fa-solid fa-screwdriver-wrench"></i></button>
</div>
</div>
</div>
</div>
<div class="card-body">
<div class="card-body px-2">
@if (ReqSetup)
{
<TargetSetup></TargetSetup>
}
else
{
<p>Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
<br />
<div class="row my-2">
<div class="col">
<button class="btn btn-info w-100" @onclick="GoTo01">Nav 01</button>
</div>
<div class="col">
<button class="btn btn-info w-100" @onclick="GoTo02">Nav 02</button>
</div>
<div class="col">
<button class="btn btn-info w-100" @onclick="GoTo03">Nav 03</button>
</div>
</div>
<ApplicationCheck OnlyUpdate="@ShowOnlyUpdate"></ApplicationCheck>
}
</div>
<div class="card-footer">
@* <div class="card-footer">
@if (CurrAssembly != null)
{
<small>@CurrAssembly.Name | @CurrAssembly.Version</small>
}
</div>
</div> *@
</div>
@@ -9,60 +9,44 @@ namespace EgwControlCenter.App.Components.Pages
#region Protected Properties
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
protected IJSRuntime JSRuntime { get; set; } = null!;
#endregion Protected Properties
#region Private Fields
private int currentCount = 0;
#endregion Private Fields
#region Private Properties
private System.Reflection.AssemblyName? CurrAssembly { get; set; } = System.Reflection.Assembly.GetExecutingAssembly().GetName();
#endregion Private Properties
#region Private Methods
private void GoTo01()
{
NavMan.NavigateTo("Nav01");
}
private void GoTo02()
{
NavMan.NavigateTo("Nav02");
}
private void GoTo03()
{
NavMan.NavigateTo("Nav03");
}
private void IncrementCount()
{
currentCount++;
}
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
private bool ReqSetup { get; set; } = false;
private string SetupBtnClass
{
get => ReqSetup ? "btn-info" : "btn-primary";
}
#region Protected Methods
protected void ToggleSetup()
{
ReqSetup = !ReqSetup;
}
#endregion Private Methods
protected void ForceCheck()
{
ACService.ForceCheck();
}
#endregion Protected Methods
[Inject]
protected AppControlService ACService { get; set; } = null!;
#region Private Properties
protected bool ShowOnlyUpdate { get; set; } = true;
private System.Reflection.AssemblyName? CurrAssembly { get; set; } = System.Reflection.Assembly.GetExecutingAssembly().GetName();
private bool ReqSetup { get; set; } = false;
private string SetupBtnClass
{
get => ReqSetup ? "btn-info" : "btn-primary";
}
private string ShowUpdateText
{
get => ShowOnlyUpdate ? "Aggiornamenti" : "Mostra Tutti";
}
#endregion Private Properties
}
}
+33 -5
View File
@@ -29,6 +29,7 @@ namespace EgwControlCenter.Core
#region Public Events
public event Action EA_ConfigUpdated = null!;
public event Action EA_StatusUpdated = null!;
#endregion Public Events
@@ -67,14 +68,34 @@ namespace EgwControlCenter.Core
get => CurrCheck.CurrPatrolCont.TargetList;
set
{
if (CurrCheck.CurrPatrolCont.TargetList != value)
{
CurrCheck.CurrPatrolCont.TargetList = value;
ReportConfigUpd();
}
CurrCheck.CurrPatrolCont.TargetList = value;
ReportConfigUpd();
}
}
public List<VersStatusDTO> ListAppStatus
{
get => CurrCheck.ListAppStatus;
set
{
CurrCheck.ListAppStatus = value;
ReportStatusUpd();
}
}
public void ForceCheck()
{
//// forzo rilettura...
//CurrCheck = new ReleaseChecker(ConfDir, DataDir);
// effettua un refresh del controllo status...
bool locCheckOk = CurrCheck.UpdateLocalStatus(true);
if (locCheckOk)
{
bool remCheckOk = CurrCheck.CheckRemoteReleases();
}
ReportStatusUpd();
}
#endregion Public Properties
#region Public Methods
@@ -147,6 +168,13 @@ namespace EgwControlCenter.Core
EA_ConfigUpdated?.Invoke();
}
}
private void ReportStatusUpd()
{
if (EA_StatusUpdated!= null)
{
EA_StatusUpdated?.Invoke();
}
}
#endregion Private Methods
}
@@ -33,6 +33,11 @@ namespace EgwControlCenter.Core.Models
/// </summary>
public string RelTagsLast { get; set; } = "";
/// <summary>
/// indica se esista un update alla versione
/// </summary>
public bool HasUpdate { get; set; } = false;
#endregion Public Properties
}
+3 -2
View File
@@ -443,13 +443,14 @@ namespace EgwControlCenter.Core
}
// aggiorno obj calcolato versioni...
ListAppStatus = ListStatus
.Where(x => x.HasUpdate())
//.Where(x => x.HasUpdate())
.Select(x => new VersStatusDTO
{
CodApp = x.CodApp,
VersNumCurr = x.CurrLocal.VersNum,
VersNumLast = x.CurrRemote.VersNum,
RelTagsLast = x.CurrRemote.RelTags
RelTagsLast = x.CurrRemote.RelTags,
HasUpdate= x.HasUpdate()
})
.ToList();
}