Files
lux/Lux.UI/Components/Compo/WorkLoad/JobQueue.razor.cs
T
Samuele Locatelli 3ff92c093b Update display queue
2026-01-19 16:15:13 +01:00

146 lines
3.5 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.JSInterop;
namespace Lux.UI.Components.Compo.WorkLoad
{
public partial class JobQueue
{
#region Public Properties
[Parameter]
public EventCallback<string> EC_ReRunJob { get; set; }
[Parameter]
public EventCallback<string> EC_ResetQueue { get; set; }
[Parameter]
public bool EnableClear { get; set; } = false;
[Parameter]
public bool EnableReRun { get; set; } = false;
[Parameter]
public bool EnableReset { get; set; } = false;
[Parameter]
public List<string> QueueAll { get; set; } = new List<string>();
[Parameter]
public string QueueType { get; set; } = "Run";
[Parameter]
public string TitleCss { get; set; } = "bg-success";
#endregion Public Properties
#region Protected Properties
protected string SearchCss
{
get => !string.IsNullOrEmpty(searchVal) ? "btn-primary" : "btn-outline-secondary";
}
protected string SearchVal
{
get => searchVal;
set
{
if (searchVal != value)
{
searchVal = value;
UpdateTable();
}
}
}
#endregion Protected Properties
#region Protected Methods
protected override void OnParametersSet()
{
UpdateTable();
}
protected async Task ReRunJob(string? JobCode)
{
await EC_ReRunJob.InvokeAsync(JobCode);
}
protected async Task ResetQueue()
{
await EC_ResetQueue.InvokeAsync(QueueType);
}
protected void SaveNumRec(int newNum)
{
numRecord = newNum;
UpdateTable();
}
protected void SavePage(int newNum)
{
currPage = newNum;
UpdateTable();
}
#endregion Protected Methods
#region Private Fields
/// <summary>
/// pagina attuale
/// </summary>
private int currPage = 1;
/// <summary>
/// elementi per pagina
/// </summary>
private int numRecord = 5;
private string searchVal = "";
/// <summary>
/// Numero tot records
/// </summary>
private int totalCount = 0;
#endregion Private Fields
#region Private Properties
private IEnumerable<string>? QueuePaged { get; set; } = null;
#endregion Private Properties
#region Private Methods
private void ResetSearch(MouseEventArgs args)
{
SearchVal = "";
}
/// <summary>
/// Filtro e paginazione
/// </summary>
private void UpdateTable()
{
// eventuale filtro...
List<string> QueueFilt = QueueAll;
if (!string.IsNullOrEmpty(SearchVal) && SearchVal.Count() > 1)
{
QueueFilt = QueueAll
.Where(x => x.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase))
.ToList();
}
// fix paginazione
QueuePaged = QueueFilt
.Skip(numRecord * (currPage - 1))
.Take(numRecord);
totalCount = QueueFilt.Count();
}
#endregion Private Methods
}
}