Jonathan Jenne 45f8dd2aad 16-12-2022
2022-12-16 15:59:26 +01:00

118 lines
4.1 KiB
Plaintext

@page "/profiles/import"
@using ECM.JobRunner.Common.JobRunnerReference;
@using ECM.JobRunner.Web.Data;
@inject HelperService Jobs
@inject ImportProfileService Import;
<PageTitle>Import Profiles</PageTitle>
<h3>Import Profiles</h3>
@if (filteredProfiles == null)
{
<ul class="list-group">
<li class="list-group-item">Loading Profiles..</li>
</ul>
}
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">
@if (filteredProfiles.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 profile in filteredProfiles)
{
<a href="/profiles/import/@profile.Id" class="list-group-item list-group-item-action d-flex justify-content-between align-items-start">
<div class="me-auto">
<div class="fw-bold">
<span>
@if (profile.Active)
{
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-play-circle text-success" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
<path d="M6.271 5.055a.5.5 0 0 1 .52.038l3.5 2.5a.5.5 0 0 1 0 .814l-3.5 2.5A.5.5 0 0 1 6 10.5v-5a.5.5 0 0 1 .271-.445z" />
</svg>
}
else
{
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-stop-circle text-danger" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
<path d="M5 6.5A1.5 1.5 0 0 1 6.5 5h3A1.5 1.5 0 0 1 11 6.5v3A1.5 1.5 0 0 1 9.5 11h-3A1.5 1.5 0 0 1 5 9.5v-3z" />
</svg>
}
</span>
<span>@profile.Job.Name</span>
</div>
@profile.Job.Name
</div>
@if (profile.Active)
{
<span class="badge bg-success rounded-pill">Running</span>
}
else
{
<span class="badge bg-danger rounded-pill">Stopped</span>
}
</a>
}
</div>
<div class="btn-group mt-3" role="group" aria-label="Basic example">
<a class="btn btn-primary" href="/profiles/import/new">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-circle" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z" />
</svg> New
</a>
</div>
}
@code {
private List<ImportProfile>? profiles;
private List<ImportProfile>? filteredProfiles;
private string filterQuery = "";
private string FilterQuery {
get { return filterQuery; }
set {
filterQuery = value;
OnFilterChanged();
}
}
protected async override void OnInitialized()
{
profiles = await Import.GetProfiles();
filteredProfiles = profiles;
StateHasChanged();
}
protected void OnFilterChanged()
{
if (profiles != null)
{
filteredProfiles = profiles.
Where(j => j.Job.Name.Contains(FilterQuery, StringComparison.OrdinalIgnoreCase)).
ToList();
} else
{
filteredProfiles = null;
}
}
}