using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using MP.FileData; using MP.FileData.DbModels; using MP.Prog.Data; using System.Collections.Generic; using System.Threading.Tasks; namespace MP.Prog.Components { public partial class RevList { #region Public Properties [Parameter] public FileModel CurrRec { get; set; } /// /// Evento selezione rev x confronto, valore = rev /// [Parameter] public EventCallback EC_selRev { get; set; } /// /// Evento richiesta approvazione versione, valore = record /// [Parameter] public EventCallback EC_reqAppr { get; set; } /// /// Evento richeista eliminazione da DB del File /// [Parameter] public EventCallback EC_reqDelete { get; set; } #endregion Public Properties #region Protected Properties [Inject] protected FileArchDataService FDService { get; set; } = null!; [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; [Inject] protected MessageService MServ { get; set; } = null!; #endregion Protected Properties #region Protected Methods /// /// Restituisce size calcolata /// /// /// protected string CalcSize(long origSize) { return MeasureUtils.SizeSuffix(origSize, 1); } /// /// Forza approvazione utente corrente /// /// protected async Task FileSetUserApp(FileModel CurrRec) { await EC_reqAppr.InvokeAsync(CurrRec); await Task.Delay(100); await ReloadData(); } /// /// Selezione Rev x display confronto /// /// protected async Task SelRev(FileModel CurrRec) { await EC_selRev.InvokeAsync(CurrRec.Rev); await ReloadData(); } /// /// Elimina record (non approvato) corrente e riattiva precedente /// /// protected async Task DeleteRec(FileModel CurrRec) { await EC_reqDelete.InvokeAsync(CurrRec); await Task.Delay(100); await ReloadData(); } protected override async Task OnParametersSetAsync() { await ReloadData(); } protected async Task ReloadData() { // valutare recupero info + redis + pagiazione EX POST... if (CurrRec != null) { ListRecords = FDService.FileGetAllRevByKey(CurrRec.FileId); } else { ListRecords = new List(); } await Task.Delay(1); } #endregion Protected Methods #region Private Fields private List ListRecords; #endregion Private Fields #region Private Methods private string cssStatusByCod(FileState currStatus) { string answ = "badge"; switch (currStatus) { case FileState.Changed: answ += " text-bg-warning"; break; case FileState.Missing: answ += " text-bg-danger"; break; case FileState.Ok: answ += " text-bg-success"; break; case FileState.ND: default: answ += " text-bg-light"; break; } return answ; } #endregion Private Methods } }