Files
mapo-core/MP.Prog/Components/RevList.razor.cs
T
2024-10-28 20:15:49 +01:00

127 lines
3.3 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.FileData;
using MP.FileData.DatabaseModels;
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; }
#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
/// <summary>
/// Restituisce size calcolata
/// </summary>
/// <param name="origSize"></param>
/// <returns></returns>
protected string CalcSize(long origSize)
{
return MeasureUtils.SizeSuffix(origSize, 1);
}
/// <summary>
/// forza approvazione utente corrente
/// </summary>
/// <returns></returns>
protected async Task FileSetUserApp(FileModel CurrRec)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler approvare il salvataggio automatico della nuova revisione?"))
return;
await FDService.FileSetUserApp(CurrRec, MServ.UserName);
await ReloadData();
}
/// <summary>
/// Imposta filtro x utente
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
protected async Task FilterUserName(string userName)
{
//SelUserName = userName;
//currPage = 1;
await Task.Delay(1);
//isLoading = false;
}
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<FileModel>();
}
await Task.Delay(1);
}
#endregion Protected Methods
#region Private Fields
private List<FileModel> 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.Deleted:
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
}
}