-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b4839a
commit 9f761bc
Showing
11 changed files
with
265 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@using Mangarr.Shared.Models | ||
<div class="p-4"> | ||
<p class="lead">Queue</p> | ||
|
||
@if (_isRefreshing) | ||
{ | ||
<Spinner/> | ||
} | ||
else if (_items.Count == 0) | ||
{ | ||
<p class="lead">The queue is empty at the moment</p> | ||
} | ||
else | ||
{ | ||
<div class="table-responsive"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Description</th> | ||
<th>Last run</th> | ||
<th>Next run</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (JobQueueItemModel item in _items) | ||
{ | ||
<QueueItem Item="@item"/> | ||
} | ||
</tbody> | ||
</table> | ||
</div> | ||
} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using FluentResults; | ||
using Mangarr.Frontend.Api; | ||
using Mangarr.Shared.Models; | ||
using Mangarr.Shared.Responses; | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace Mangarr.Frontend.Pages.Settings.Tasks; | ||
|
||
public partial class Queue | ||
{ | ||
private readonly List<JobQueueItemModel> _items = new(); | ||
|
||
private bool _isRefreshing = false; | ||
|
||
[Inject] public BackendApi BackendApi { get; set; } | ||
|
||
protected override void OnInitialized() => RefreshAsync(); | ||
|
||
private async void RefreshAsync() | ||
{ | ||
_isRefreshing = true; | ||
await InvokeAsync(StateHasChanged); | ||
|
||
Result<JobsQueueResponse> result = await BackendApi.GetJobQueue(); | ||
|
||
if (result.IsFailed) | ||
{ | ||
// TODO: Log error | ||
} | ||
else | ||
{ | ||
_items.Clear(); | ||
_items.AddRange(result.Value.Data); | ||
} | ||
|
||
_isRefreshing = false; | ||
await InvokeAsync(StateHasChanged); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@using Humanizer | ||
@using Mangarr.Shared.Models | ||
|
||
@code { | ||
[Parameter] public JobQueueItemModel Item { get; set; } | ||
} | ||
|
||
<tr> | ||
<td> | ||
@Item.Description | ||
</td> | ||
<td> | ||
@if (Item.PreviousFireTime.HasValue) | ||
{ | ||
TimeSpan timeSinceLastRun = DateTimeOffset.UtcNow - Item.PreviousFireTime.Value; | ||
<span>@timeSinceLastRun.Humanize() ago</span> | ||
} | ||
else | ||
{ | ||
<span>-</span> | ||
} | ||
</td> | ||
<td> | ||
@if (Item.NextFireTime.HasValue) | ||
{ | ||
TimeSpan timeUntilNextRun = Item.NextFireTime.Value - DateTimeOffset.UtcNow; | ||
<span>in @timeUntilNextRun.Humanize()</span> | ||
} | ||
else | ||
{ | ||
<span>-</span> | ||
} | ||
</td> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@using Mangarr.Shared.Models | ||
<div class="p-4"> | ||
<p class="lead">Schedule</p> | ||
|
||
@if (_isRefreshing) | ||
{ | ||
<Spinner/> | ||
} | ||
else if (_items.Count == 0) | ||
{ | ||
<p class="lead">The queue is empty at the moment</p> | ||
} | ||
else | ||
{ | ||
<div class="table-responsive"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Description</th> | ||
<th>Last run</th> | ||
<th>Next run</th> | ||
<th>Request run</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (JobScheduleItemModel item in _items) | ||
{ | ||
<ScheduleItem Item="@item"/> | ||
} | ||
</tbody> | ||
</table> | ||
</div> | ||
} | ||
</div> |
37 changes: 37 additions & 0 deletions
37
src/Mangarr.Frontend/Pages/Settings/Tasks/Schedule.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using FluentResults; | ||
using Mangarr.Frontend.Api; | ||
using Mangarr.Shared.Models; | ||
using Mangarr.Shared.Responses; | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace Mangarr.Frontend.Pages.Settings.Tasks; | ||
|
||
public partial class Schedule | ||
{ | ||
private readonly List<JobScheduleItemModel> _items = new(); | ||
private bool _isRefreshing; | ||
[Inject] public BackendApi BackendApi { get; set; } | ||
|
||
protected override void OnInitialized() => RefreshAsync(); | ||
|
||
private async void RefreshAsync() | ||
{ | ||
_isRefreshing = true; | ||
await InvokeAsync(StateHasChanged); | ||
|
||
Result<JobsScheduleResponse> result = await BackendApi.GetJobSchedule(); | ||
|
||
if (result.IsFailed) | ||
{ | ||
// TODO: Log error | ||
} | ||
else | ||
{ | ||
_items.Clear(); | ||
_items.AddRange(result.Value.Data); | ||
} | ||
|
||
_isRefreshing = false; | ||
await InvokeAsync(StateHasChanged); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/Mangarr.Frontend/Pages/Settings/Tasks/ScheduleItem.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@using Humanizer | ||
<tr> | ||
<td> | ||
@Item.Description | ||
</td> | ||
<td> | ||
@if (Item.PreviousFireTime.HasValue) | ||
{ | ||
TimeSpan timeSinceLastRun = DateTimeOffset.UtcNow - Item.PreviousFireTime.Value; | ||
<span>@timeSinceLastRun.Humanize() ago</span> | ||
} | ||
else | ||
{ | ||
<span>-</span> | ||
} | ||
</td> | ||
<td> | ||
@if (Item.NextFireTime.HasValue) | ||
{ | ||
TimeSpan timeUntilNextRun = Item.NextFireTime.Value - DateTimeOffset.UtcNow; | ||
<span>in @timeUntilNextRun.Humanize()</span> | ||
} | ||
else | ||
{ | ||
<span>-</span> | ||
} | ||
</td> | ||
<td> | ||
@if (_isRequesting) | ||
{ | ||
<input type="button" class="btn btn-primary disabled" value="Request" @onclick="RequestClicked"/> | ||
} | ||
else | ||
{ | ||
<input type="button" class="btn btn-primary" value="Request" @onclick="RequestClicked"/> | ||
} | ||
|
||
</td> | ||
</tr> |
24 changes: 24 additions & 0 deletions
24
src/Mangarr.Frontend/Pages/Settings/Tasks/ScheduleItem.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Mangarr.Frontend.Api; | ||
using Mangarr.Shared.Models; | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace Mangarr.Frontend.Pages.Settings.Tasks; | ||
|
||
public partial class ScheduleItem | ||
{ | ||
private bool _isRequesting; | ||
[Parameter] public JobScheduleItemModel Item { get; set; } | ||
|
||
[Inject] public BackendApi BackendApi { get; set; } | ||
|
||
private async void RequestClicked() | ||
{ | ||
_isRequesting = true; | ||
await InvokeAsync(StateHasChanged); | ||
|
||
await BackendApi.TriggerJob(Item.Group, Item.Name); | ||
|
||
_isRequesting = true; | ||
await InvokeAsync(StateHasChanged); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@page "/settings/tasks" | ||
|
||
<div id="wrapper" class="overflow-auto d-flex flex-column"> | ||
<Schedule/> | ||
<Queue/> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters