namespace Lux.UI.Components.Compo.WorkLoad { public partial class JobQueue { #region Public Properties [Parameter] public EventCallback EC_ReRunJob { get; set; } [Parameter] public EventCallback 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 QueueAll { get; set; } = new List(); [Parameter] public string QueueType { get; set; } = "Run"; [Parameter] public string TitleCss { get; set; } = "bg-success"; #endregion Public Properties #region Protected Methods protected override void OnParametersSet() { UpdateTable(); } #endregion Protected Methods #region Private Fields /// /// pagina attuale /// private int currPage = 1; /// /// elementi per pagina /// private int numRecord = 5; private string searchVal = ""; /// /// Numero tot records /// private int totalCount = 0; #endregion Private Fields #region Private Properties private IEnumerable? QueuePaged { get; set; } = null; private string SearchCss { get => !string.IsNullOrEmpty(searchVal) ? "btn-primary" : "btn-outline-secondary"; } private string SearchVal { get => searchVal; set { if (searchVal != value) { searchVal = value; UpdateTable(); } } } #endregion Private Properties #region Private Methods private Task ReRunJob(string? JobCode) { return EC_ReRunJob.InvokeAsync(JobCode); } private Task ResetQueue() { return EC_ResetQueue.InvokeAsync(QueueType); } private void ResetSearch(MouseEventArgs args) { SearchVal = ""; } private void SaveNumRec(int newNum) { numRecord = newNum; UpdateTable(); } private void SavePage(int newNum) { currPage = newNum; UpdateTable(); } /// /// Filtro e paginazione /// private void UpdateTable() { // eventuale filtro... List 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 } }