Jonathan Jenne 1e925242bc 20-12-2022
2022-12-20 15:29:29 +01:00

167 lines
7.5 KiB
Plaintext

@page "/history"
@using ECM.JobRunner.Common.JobRunnerReference;
@using ECM.JobRunner.Web.Data;
@inject DashboardService Api
<PageTitle>History</PageTitle>
<h3>Job History</h3>
<div class="container-fluid">
<div class="row">
<div class="col-2">
<div class="card">
<div class="card-body">
<form>
<legend>Filter</legend>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="showWaiting" checked="@showWaiting" @oninput="CheckboxChanged">
<label class="form-check-label" for="exampleCheck1">Waiting</label>
</div>
</form>
</div>
</div>
</div>
<div class="col-10">
@if (filteredEntries == null)
{
<ul class="list-group">
<li class="list-group-item">Loading Job History..</li>
</ul>
}
else if (filteredEntries.Count == 0)
{
<ul class="list-group">
<li class="list-group-item">No Job History yet.</li>
</ul>
}
else
{
@foreach (var entry in filteredEntries)
{
<ul class="list-group mb-3">
<li class="list-group-item list-group-item-secondary d-flex justify-content-between align-items-start">
<div class="me-auto">
<div class="fw-bold">
<span>@entry.Name</span>
</div>
</div>
<div>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-calendar-check" viewBox="0 0 16 16">
<path d="M10.854 7.146a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 1 1 .708-.708L7.5 9.793l2.646-2.647a.5.5 0 0 1 .708 0z" />
<path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z" />
</svg> @entry.CompleteTime.ToString("HH:mm:ss")
</div>
</li>
@foreach (var step in entry.Steps)
{
<li class="list-group-item">
<strong>@step.Created.ToString("HH:mm:ss")</strong> @step.Message
</li>
}
@if (entry.Successful == false)
{
<li class="list-group-item list-group-item-danger d-flex justify-content-between align-items-start">
<span>@entry.FailureMessage</span>
<span>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-stopwatch" viewBox="0 0 16 16">
<path d="M8.5 5.6a.5.5 0 1 0-1 0v2.9h-3a.5.5 0 0 0 0 1H8a.5.5 0 0 0 .5-.5V5.6z" />
<path d="M6.5 1A.5.5 0 0 1 7 .5h2a.5.5 0 0 1 0 1v.57c1.36.196 2.594.78 3.584 1.64a.715.715 0 0 1 .012-.013l.354-.354-.354-.353a.5.5 0 0 1 .707-.708l1.414 1.415a.5.5 0 1 1-.707.707l-.353-.354-.354.354a.512.512 0 0 1-.013.012A7 7 0 1 1 7 2.071V1.5a.5.5 0 0 1-.5-.5zM8 3a6 6 0 1 0 .001 12A6 6 0 0 0 8 3z" />
</svg> @entry.ExecutionTime.ToString("mm':'ss")
</span>
</li>
}
@if (entry.Successful == true && entry.Waiting == false)
{
<li class="list-group-item list-group-item-success d-flex justify-content-between align-items-start">
<span>@entry.SuccessMessage</span>
<span>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-stopwatch" viewBox="0 0 16 16">
<path d="M8.5 5.6a.5.5 0 1 0-1 0v2.9h-3a.5.5 0 0 0 0 1H8a.5.5 0 0 0 .5-.5V5.6z" />
<path d="M6.5 1A.5.5 0 0 1 7 .5h2a.5.5 0 0 1 0 1v.57c1.36.196 2.594.78 3.584 1.64a.715.715 0 0 1 .012-.013l.354-.354-.354-.353a.5.5 0 0 1 .707-.708l1.414 1.415a.5.5 0 1 1-.707.707l-.353-.354-.354.354a.512.512 0 0 1-.013.012A7 7 0 1 1 7 2.071V1.5a.5.5 0 0 1-.5-.5zM8 3a6 6 0 1 0 .001 12A6 6 0 0 0 8 3z" />
</svg> @entry.ExecutionTime.ToString("mm':'ss")
</span>
</li>
}
@if (entry.Successful == true && entry.Waiting == true)
{
<li class="list-group-item list-group-item-info d-flex justify-content-between align-items-start">
<span>@entry.SuccessMessage</span>
<span>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-stopwatch" viewBox="0 0 16 16">
<path d="M8.5 5.6a.5.5 0 1 0-1 0v2.9h-3a.5.5 0 0 0 0 1H8a.5.5 0 0 0 .5-.5V5.6z" />
<path d="M6.5 1A.5.5 0 0 1 7 .5h2a.5.5 0 0 1 0 1v.57c1.36.196 2.594.78 3.584 1.64a.715.715 0 0 1 .012-.013l.354-.354-.354-.353a.5.5 0 0 1 .707-.708l1.414 1.415a.5.5 0 1 1-.707.707l-.353-.354-.354.354a.512.512 0 0 1-.013.012A7 7 0 1 1 7 2.071V1.5a.5.5 0 0 1-.5-.5zM8 3a6 6 0 1 0 .001 12A6 6 0 0 0 8 3z" />
</svg> @entry.ExecutionTime.ToString("mm':'ss")
</span>
</li>
}
</ul>
}
}
</div>
</div>
</div>
@code {
private DateTime today;
private List<StatusItem>? statusEntries;
private List<StatusItem>? filteredEntries;
private bool showSuccessful = true;
private bool showFailed = true;
private bool showWaiting = true;
protected async override void OnInitialized()
{
DashboardResponse data = await Api.GetData();
UpdateData(data);
Api.DataUpdated += Api_DataUpdated;
}
private void CheckboxChanged(ChangeEventArgs e)
{
showWaiting = (bool)e.Value;
UpdateEntries(statusEntries);
InvokeAsync(StateHasChanged);
}
protected void Api_DataUpdated(object? sender, DashboardResponse e)
{
UpdateData(e);
}
protected void UpdateData(DashboardResponse response)
{
today = response.heartbeat;
statusEntries = response.jobStatus;
UpdateEntries(response.jobStatus);
InvokeAsync(StateHasChanged);
}
protected void UpdateEntries(List<StatusItem>? entries)
{
if (entries == null)
{
return;
}
var filtered = entries.
Where(s => s.Executing == false);
if (!showWaiting)
{
filtered = filtered.
Where(e => e.Waiting == false);
}
filteredEntries = filtered.ToList();
}
}