From 1f95d577170143e51bc574770cfb18b158d0d803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Mon, 8 Dec 2025 21:28:24 +0100 Subject: [PATCH] JobList filter fix --- .gitignore | 9 +++++++- DiunaBI.API/Controllers/JobsController.cs | 11 +++++---- .../DiunaBI.Infrastructure.csproj | 2 -- DiunaBI.UI.Shared/Pages/Jobs/Index.razor | 11 +++++---- DiunaBI.UI.Shared/Pages/Jobs/Index.razor.cs | 23 +++++++++++++++---- DiunaBI.UI.Shared/Services/JobService.cs | 11 ++++++--- 6 files changed, 49 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index bf4dfc4..3607545 100644 --- a/.gitignore +++ b/.gitignore @@ -562,4 +562,11 @@ coverage/ ## Temporary folders ## tmp/ -temp/ \ No newline at end of file +temp/ + +## +## LocalDB Development Files +## +DevTools/LocalDB/backups/*.bak +DevTools/LocalDB/backups/*.bacpac +DevTools/LocalDB/data/ \ No newline at end of file diff --git a/DiunaBI.API/Controllers/JobsController.cs b/DiunaBI.API/Controllers/JobsController.cs index 0a489ab..ce4ed4d 100644 --- a/DiunaBI.API/Controllers/JobsController.cs +++ b/DiunaBI.API/Controllers/JobsController.cs @@ -36,7 +36,7 @@ public class JobsController : Controller public async Task GetAll( [FromQuery] int start = 0, [FromQuery] int limit = 50, - [FromQuery] JobStatus? status = null, + [FromQuery] List? statuses = null, [FromQuery] JobType? jobType = null, [FromQuery] Guid? layerId = null) { @@ -54,9 +54,9 @@ public class JobsController : Controller var query = _db.QueueJobs.AsQueryable(); - if (status.HasValue) + if (statuses != null && statuses.Count > 0) { - query = query.Where(j => j.Status == status.Value); + query = query.Where(j => statuses.Contains(j.Status)); } if (jobType.HasValue) @@ -71,8 +71,11 @@ public class JobsController : Controller var totalCount = await query.CountAsync(); + // Sort by: Priority ASC (0=highest), JobType, then CreatedAt DESC var items = await query - .OrderByDescending(j => j.CreatedAt) + .OrderBy(j => j.Priority) + .ThenBy(j => j.JobType) + .ThenByDescending(j => j.CreatedAt) .Skip(start) .Take(limit) .AsNoTracking() diff --git a/DiunaBI.Infrastructure/DiunaBI.Infrastructure.csproj b/DiunaBI.Infrastructure/DiunaBI.Infrastructure.csproj index fee4d4f..7b5d59c 100644 --- a/DiunaBI.Infrastructure/DiunaBI.Infrastructure.csproj +++ b/DiunaBI.Infrastructure/DiunaBI.Infrastructure.csproj @@ -22,8 +22,6 @@ - - diff --git a/DiunaBI.UI.Shared/Pages/Jobs/Index.razor b/DiunaBI.UI.Shared/Pages/Jobs/Index.razor index b3235d2..ece6b15 100644 --- a/DiunaBI.UI.Shared/Pages/Jobs/Index.razor +++ b/DiunaBI.UI.Shared/Pages/Jobs/Index.razor @@ -12,25 +12,28 @@ Expanded="true"> - @foreach (JobStatus status in Enum.GetValues(typeof(JobStatus))) { - @status.ToString() + @status.ToString() } @foreach (JobType type in Enum.GetValues(typeof(JobType))) { diff --git a/DiunaBI.UI.Shared/Pages/Jobs/Index.razor.cs b/DiunaBI.UI.Shared/Pages/Jobs/Index.razor.cs index 7d5e26c..c57ca8d 100644 --- a/DiunaBI.UI.Shared/Pages/Jobs/Index.razor.cs +++ b/DiunaBI.UI.Shared/Pages/Jobs/Index.razor.cs @@ -20,7 +20,7 @@ public partial class Index : ComponentBase, IDisposable private bool isLoading = false; private int currentPage = 1; private int pageSize = 50; - private JobStatus? selectedStatus = null; + private IEnumerable selectedStatuses = new HashSet(); private JobType? selectedJobType = null; protected override async Task OnInitializedAsync() @@ -60,7 +60,8 @@ public partial class Index : ComponentBase, IDisposable try { - jobs = await JobService.GetJobsAsync(currentPage, pageSize, selectedStatus, selectedJobType); + var statusList = selectedStatuses?.ToList(); + jobs = await JobService.GetJobsAsync(currentPage, pageSize, statusList, selectedJobType); } catch (Exception ex) { @@ -81,15 +82,29 @@ public partial class Index : ComponentBase, IDisposable private async Task ClearFilters() { - selectedStatus = null; + selectedStatuses = new HashSet(); selectedJobType = null; currentPage = 1; await LoadJobs(); } + private async Task OnStatusFilterChanged(IEnumerable values) + { + selectedStatuses = values; + currentPage = 1; + await LoadJobs(); + } + + private async Task OnJobTypeFilterChanged(JobType? value) + { + selectedJobType = value; + currentPage = 1; + await LoadJobs(); + } + private async Task OnStatusClear() { - selectedStatus = null; + selectedStatuses = new HashSet(); currentPage = 1; await LoadJobs(); } diff --git a/DiunaBI.UI.Shared/Services/JobService.cs b/DiunaBI.UI.Shared/Services/JobService.cs index 61b0723..5535dc9 100644 --- a/DiunaBI.UI.Shared/Services/JobService.cs +++ b/DiunaBI.UI.Shared/Services/JobService.cs @@ -19,13 +19,18 @@ public class JobService PropertyNameCaseInsensitive = true }; - public async Task> GetJobsAsync(int page = 1, int pageSize = 50, JobStatus? status = null, JobType? jobType = null, Guid? layerId = null) + public async Task> GetJobsAsync(int page = 1, int pageSize = 50, List? statuses = null, JobType? jobType = null, Guid? layerId = null) { var start = (page - 1) * pageSize; var query = $"Jobs?start={start}&limit={pageSize}"; - if (status.HasValue) - query += $"&status={(int)status.Value}"; + if (statuses != null && statuses.Count > 0) + { + foreach (var status in statuses) + { + query += $"&statuses={(int)status}"; + } + } if (jobType.HasValue) query += $"&jobType={(int)jobType.Value}";