138 lines
3.4 KiB
C#
138 lines
3.4 KiB
C#
using EgwControlCenter.Core;
|
|
using EgwControlCenter.Core.DTO;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace EgwControlCenter.App.Components.Compo
|
|
{
|
|
public partial class ApplicationCheck : IDisposable
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_GotoSetup { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
ACService.EA_StatusUpdated -= ACService_EA_StatusUpdated;
|
|
ACService.EA_RemoteCalling -= ACService_EA_RemoteCalling;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected AppControlService ACService { get; set; } = null!;
|
|
|
|
protected bool RemoteCallActive { get; set; } = false;
|
|
|
|
protected bool ShowOnlyUpdate
|
|
{
|
|
get => showOnlyUpdate;
|
|
set
|
|
{
|
|
showOnlyUpdate = value;
|
|
ForceReload();
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected async Task ForceCheck()
|
|
{
|
|
await ACService.DoFullCheckAsync(true);
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
ACService.EA_StatusUpdated += ACService_EA_StatusUpdated;
|
|
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()
|
|
{
|
|
await EC_GotoSetup.InvokeAsync(true);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Properties
|
|
|
|
private int currPage { get; set; } = 1;
|
|
|
|
private List<VersStatusDTO> CurrRecords
|
|
{
|
|
get => ACService.ListAppStatus;
|
|
}
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
private List<VersStatusDTO>? ListRecords { get; set; } = null;
|
|
|
|
private int numRecord { get; set; } = 5;
|
|
|
|
private List<VersStatusDTO>? SearchRecords { get; set; } = null;
|
|
|
|
private bool showOnlyUpdate { get; set; } = true;
|
|
|
|
private int totalCount { get; set; } = 0;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Gestione evento chiamata verso server
|
|
/// </summary>
|
|
private async void ACService_EA_RemoteCalling()
|
|
{
|
|
RemoteCallActive = ACService.CloudCallActive;
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
private void ACService_EA_StatusUpdated()
|
|
{
|
|
ForceReload();
|
|
}
|
|
|
|
private void ForceReload()
|
|
{
|
|
isLoading = true;
|
|
SearchRecords = CurrRecords
|
|
.Where(x => x.HasUpdate || !ShowOnlyUpdate)
|
|
.ToList();
|
|
totalCount = SearchRecords.Count;
|
|
ListRecords = SearchRecords
|
|
.Skip(numRecord * (currPage - 1))
|
|
.Take(numRecord)
|
|
.ToList();
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |