Some checks failed
Build Docker Images / test (map[name:Morska plugin_project:DiunaBI.Plugins.Morska]) (push) Failing after 1m14s
Build Docker Images / test (map[name:PedrolloPL plugin_project:DiunaBI.Plugins.PedrolloPL]) (push) Failing after 1m10s
Build Docker Images / build-and-push (map[image_suffix:morska name:Morska plugin_project:DiunaBI.Plugins.Morska]) (push) Failing after 1m12s
Build Docker Images / build-and-push (map[image_suffix:pedrollopl name:PedrolloPL plugin_project:DiunaBI.Plugins.PedrolloPL]) (push) Failing after 1m7s
111 lines
2.9 KiB
C#
111 lines
2.9 KiB
C#
using DiunaBI.UI.Shared.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using DiunaBI.Application.DTOModels.Common;
|
|
using DiunaBI.Domain.Entities;
|
|
using MudBlazor;
|
|
using Microsoft.JSInterop;
|
|
|
|
namespace DiunaBI.UI.Shared.Components;
|
|
|
|
public partial class JobListComponent : ComponentBase
|
|
{
|
|
[Inject] private JobService JobService { get; set; } = default!;
|
|
[Inject] private ISnackbar Snackbar { get; set; } = default!;
|
|
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
|
|
[Inject] private IJSRuntime JSRuntime { get; set; } = default!;
|
|
|
|
private PagedResult<QueueJob> jobs = new();
|
|
private bool isLoading = false;
|
|
private int currentPage = 1;
|
|
private int pageSize = 50;
|
|
private JobStatus? selectedStatus = null;
|
|
private JobType? selectedJobType = null;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await LoadJobs();
|
|
}
|
|
|
|
private async Task LoadJobs()
|
|
{
|
|
isLoading = true;
|
|
|
|
try
|
|
{
|
|
jobs = await JobService.GetJobsAsync(currentPage, pageSize, selectedStatus, selectedJobType);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Loading jobs failed: {ex.Message}");
|
|
Snackbar.Add("Failed to load jobs", Severity.Error);
|
|
}
|
|
finally
|
|
{
|
|
isLoading = false;
|
|
}
|
|
}
|
|
|
|
private async Task OnPageChanged(int page)
|
|
{
|
|
currentPage = page;
|
|
await LoadJobs();
|
|
}
|
|
|
|
private async Task ClearFilters()
|
|
{
|
|
selectedStatus = null;
|
|
selectedJobType = null;
|
|
currentPage = 1;
|
|
await LoadJobs();
|
|
}
|
|
|
|
private async Task OnStatusClear()
|
|
{
|
|
selectedStatus = null;
|
|
currentPage = 1;
|
|
await LoadJobs();
|
|
}
|
|
|
|
private async Task OnJobTypeClear()
|
|
{
|
|
selectedJobType = null;
|
|
currentPage = 1;
|
|
await LoadJobs();
|
|
}
|
|
|
|
private void OnRowClick(QueueJob job)
|
|
{
|
|
NavigationManager.NavigateTo($"/jobs/{job.Id}");
|
|
}
|
|
|
|
private async Task OnRowRightClick(MouseEventArgs e, QueueJob job)
|
|
{
|
|
var url = NavigationManager.ToAbsoluteUri($"/jobs/{job.Id}").ToString();
|
|
await JSRuntime.InvokeVoidAsync("open", url, "_blank");
|
|
}
|
|
|
|
private Color GetStatusColor(JobStatus status)
|
|
{
|
|
return status switch
|
|
{
|
|
JobStatus.Pending => Color.Default,
|
|
JobStatus.Running => Color.Info,
|
|
JobStatus.Completed => Color.Success,
|
|
JobStatus.Failed => Color.Error,
|
|
JobStatus.Retrying => Color.Warning,
|
|
_ => Color.Default
|
|
};
|
|
}
|
|
|
|
private Color GetJobTypeColor(JobType jobType)
|
|
{
|
|
return jobType switch
|
|
{
|
|
JobType.Import => Color.Primary,
|
|
JobType.Process => Color.Secondary,
|
|
_ => Color.Default
|
|
};
|
|
}
|
|
}
|