New: Scheduled tasks shwon in UI under System

This commit is contained in:
Mark McDowall
2014-09-11 23:06:11 -07:00
parent 879035b28a
commit 2b0ddb6131
14 changed files with 310 additions and 8 deletions

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Jobs;
namespace NzbDrone.Api.System.Tasks
{
public class TaskModule : NzbDroneRestModule<TaskResource>
{
private readonly ITaskManager _taskManager;
public TaskModule(ITaskManager taskManager)
: base("system/task")
{
_taskManager = taskManager;
GetResourceAll = GetAll;
}
private List<TaskResource> GetAll()
{
return _taskManager.GetAll().Select(ConvertToResource).ToList();
}
private static TaskResource ConvertToResource(ScheduledTask scheduledTask)
{
return new TaskResource
{
Id = scheduledTask.Id,
Name = scheduledTask.TypeName.Split('.').Last().Replace("Command", ""),
CommandName = scheduledTask.TypeName.Split('.').Last(),
Interval = scheduledTask.Interval,
LastExecution = scheduledTask.LastExecution,
NextExecution = scheduledTask.LastExecution.AddMinutes(scheduledTask.Interval)
};
}
}
}