using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using MP.SPEC.Components; using MP.SPEC.Data; namespace MP.SPEC.Pages { public partial class PARAMS { #region Public Methods #endregion Public Methods #region Protected Fields protected string _selFlux = "*"; protected string _selMacchina = "*"; protected string lastUpdate = "-"; protected bool liveUpdate = true; protected DataPager pagerODL; protected bool reqNew = false; #endregion Protected Fields #region Protected Properties [Inject] protected IJSRuntime JSRuntime { get; set; } [Inject] protected MpDataService MDService { get; set; } [Inject] protected MessageService MsgService { get; set; } [Inject] protected NavigationManager NavManager { get; set; } #endregion Protected Properties #region Protected Methods protected void ForceReload(int newNum) { numRecord = newNum; } protected void ForceReloadPage(int newNum) { liveUpdate = newNum == 1; currPage = newNum; } protected override async Task OnInitializedAsync() { // abilito ricerca... MsgService.ShowSearch = false; // resetto search MsgService.SearchVal = ""; ListMacchine = await MDService.MacchineGetAll(); // carico dati lastUpdate = $"Updated: {DateTime.Now:yyyy/MM/dd HH:mm:ss}"; await reloadFilters(); await reloadData(); } protected async Task pgResetReq(bool doReset) { if (doReset) { await pagerODL.resetCurrPage(); } } /// /// Crea nuovo record e va in editing... /// /// protected async Task reqNewPODL() { reqNew = !reqNew; await Task.Delay(1); } protected async Task toggleUpdate() { liveUpdate = !liveUpdate; await reloadData(); } #endregion Protected Methods #region Private Fields private List? ListFlux; private List? ListMacchine; #endregion Private Fields #region Private Properties private int currPage { get => MsgService.currPage; set => MsgService.currPage = value; } private bool isLoading { get; set; } = false; private int numRecord { get => MsgService.numRecord; set => MsgService.numRecord = value; } private string selFlux { get => _selFlux; set { if (_selFlux != value) { isLoading = true; ForceReloadPage(1); _selFlux = value; isLoading = false; } } } private string selMacchina { get => _selMacchina; set { if (_selMacchina != value) { isLoading = true; ForceReloadPage(1); _selMacchina = value; isLoading = false; } } } private int totalCount { get => MsgService.totalCount; set => MsgService.totalCount = value; } private int maxRecord { get => _maxRecord; set { _maxRecord = value; if (value > 100 && liveUpdate) { liveUpdate = false; } } } private int _maxRecord = 100; #endregion Private Properties #region Private Methods private async Task reloadData() { isLoading = true; await Task.Delay(1); if (!liveUpdate) { lastUpdate = $"Last Snapshot: {DateTime.Now:yyyy/MM/dd HH:mm:ss}"; } isLoading = false; await Task.Delay(1); } private async Task reloadFilters() { await Task.Delay(1); ListFlux = await MDService.ParametriGetFilt(selMacchina); } #endregion Private Methods } }