07-12-2022

This commit is contained in:
Jonathan Jenne
2022-12-07 16:45:31 +01:00
parent 248be23804
commit 7b7147eeee
28 changed files with 781 additions and 385 deletions

View File

@@ -7,7 +7,7 @@
<h3>Jobs</h3>
@if (jobs == null)
@if (filteredJobs == null)
{
<ul class="list-group">
<li class="list-group-item">Loading Jobs..</li>
@@ -15,8 +15,22 @@
}
else
{
<section class="mb-3">
<input class="form-control" placeholder="Enter a filter query and press ENTER" type="text" @bind="FilterQuery" />
</section>
<div class="list-group">
@foreach (var job in jobs)
@if (filteredJobs.Count() == 0)
{
<a class="list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
No Jobs found.
</div>
</a>
}
@foreach (var job in filteredJobs)
{
<a class="list-group-item list-group-item-action d-flex justify-content-between align-items-start" href="/jobs/@job.Id">
<div class="ms-2 me-auto">
@@ -44,7 +58,7 @@ else
@if (job.Active)
{
<span class="badge bg-primary rounded-pill">Running</span>
<span class="badge bg-success rounded-pill">Running</span>
}
else
{
@@ -66,11 +80,36 @@ else
}
@code {
private List<JobDefinition>? jobs;
private IEnumerable<JobDefinition>? jobs;
private IEnumerable<JobDefinition>? filteredJobs;
private string filterQuery = "";
private string FilterQuery {
get { return filterQuery; }
set {
filterQuery = value;
OnFilterChanged();
}
}
protected async override void OnInitialized()
{
jobs = await Jobs.GetJobs();
filteredJobs = jobs;
StateHasChanged();
}
protected void OnFilterChanged()
{
if (jobs != null)
{
filteredJobs = jobs.Where(j => j.Name.Contains(FilterQuery, StringComparison.OrdinalIgnoreCase));
} else
{
filteredJobs = null;
}
}
}

View File

@@ -20,9 +20,20 @@
}
else
{
<h3>@job.Name</h3>
<h3>@job.Name</h3>
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
<div class="fw-bold">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-info-square" viewBox="0 0 16 16">
<path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z" />
<path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z" />
</svg> Active
</div>
@job.Active
</div>
</li>
<li class="list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
<div class="fw-bold">
@@ -102,8 +113,10 @@ else
bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure?");
if (confirmed)
{
await Jobs.DeleteJob(job);
Navigation.NavigateTo($"/jobs");
if (await Jobs.DeleteJob(job) == true)
{
Navigation.NavigateTo($"/jobs");
};
}
}
}

View File

@@ -22,7 +22,7 @@
if (result == true)
{
Navigation.NavigateTo($"/jobs");
Navigation.NavigateTo("/jobs");
}
}
}