Skip to content

Commit

Permalink
Tasklist
Browse files Browse the repository at this point in the history
  • Loading branch information
Webreaper committed Nov 8, 2021
1 parent d6999da commit 982ebba
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions Damselfly.Web/Shared/TaskList.razor
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
{
<tr>
<td>@task.Type.ToString()</td>
<td>@task.LastStarted.ToHumanReadableString(now) ago</td>
<td>@task.LastCompleted.ToHumanReadableString(now) ago</td>
<td>@ElapsedString( task.LastStarted )</td>
<td>@ElapsedString( task.LastCompleted )</td>
<td>@GetTimeTaken(task)</td>
<td>In @now.ToHumanReadableString(task.NextRun)</td>
<td align="center"><button class="btn btn-primary" type="submit" @onclick="@(() => RunTask(task))">Run</button></td>
Expand All @@ -40,12 +40,24 @@
ScheduledTask[] tasks;
private DateTime now = DateTime.UtcNow;

private string ElapsedString( DateTime dateTime )
{
if (dateTime < new DateTime(1990, 1, 1))
return "Never";

var diff = (dateTime - now);

return dateTime.ToHumanReadableString(now) + " ago";
}

private string GetTimeTaken(ScheduledTask task)
{
if (task.LastCompleted < new DateTime(1990, 1, 1))
return "N/A";

if (task.LastStarted > task.LastCompleted)
{
var running = DateTime.UtcNow.ToHumanReadableString(task.LastStarted);
return $"Running for {running}";
return DateTime.UtcNow.ToHumanReadableString(task.LastStarted);
}
else
{
Expand Down

0 comments on commit 982ebba

Please sign in to comment.