diff --git a/NzbDrone.Core/Jobs/JobProvider.cs b/NzbDrone.Core/Jobs/JobProvider.cs
index ec6a10689..dfa2ae8f9 100644
--- a/NzbDrone.Core/Jobs/JobProvider.cs
+++ b/NzbDrone.Core/Jobs/JobProvider.cs
@@ -184,6 +184,17 @@ namespace NzbDrone.Core.Jobs
}
+ public virtual bool QueueJob(string jobTypeString)
+ {
+ var type = Type.GetType(jobTypeString);
+
+ if (type == null)
+ return false;
+
+ QueueJob(type);
+ return true;
+ }
+
private void ProcessQueue()
{
try
diff --git a/NzbDrone.Core/Jobs/UpdateInfoJob.cs b/NzbDrone.Core/Jobs/UpdateInfoJob.cs
index 135676a10..5b3a7de6a 100644
--- a/NzbDrone.Core/Jobs/UpdateInfoJob.cs
+++ b/NzbDrone.Core/Jobs/UpdateInfoJob.cs
@@ -35,7 +35,7 @@ namespace NzbDrone.Core.Jobs
public int DefaultInterval
{
- get { return 720; } //Daily
+ get { return 720; } //12-hours
}
public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
diff --git a/NzbDrone.Core/Repository/JobDefinition.cs b/NzbDrone.Core/Repository/JobDefinition.cs
index 3eb1dcec9..3bbac9bf6 100644
--- a/NzbDrone.Core/Repository/JobDefinition.cs
+++ b/NzbDrone.Core/Repository/JobDefinition.cs
@@ -20,5 +20,8 @@ namespace NzbDrone.Core.Repository
public DateTime LastExecution { get; set; }
public Boolean Success { get; set; }
+
+ [Ignore]
+ public string Command { get; set; }
}
}
\ No newline at end of file
diff --git a/NzbDrone.Web/Content/Images/Gear.png b/NzbDrone.Web/Content/Images/Gear.png
new file mode 100644
index 000000000..2e4fedcaa
Binary files /dev/null and b/NzbDrone.Web/Content/Images/Gear.png differ
diff --git a/NzbDrone.Web/Controllers/SystemController.cs b/NzbDrone.Web/Controllers/SystemController.cs
index 99f259903..4e42e9f96 100644
--- a/NzbDrone.Web/Controllers/SystemController.cs
+++ b/NzbDrone.Web/Controllers/SystemController.cs
@@ -35,7 +35,14 @@ namespace NzbDrone.Web.Controllers
TargetId = c.TargetId,
SecondaryTargetId = c.SecondaryTargetId
});
- return View(_jobProvider.All());
+ var jobs = _jobProvider.All();
+
+ foreach(var jobDefinition in jobs)
+ {
+ jobDefinition.Command = "";
+ }
+
+ return View(jobs);
}
public ActionResult Indexers()
@@ -131,5 +138,13 @@ namespace NzbDrone.Web.Controllers
return new JsonResult { Data = "ok" };
}
+
+ public JsonResult RunJob(string typeName)
+ {
+ if (!_jobProvider.QueueJob(typeName))
+ return Json(new NotificationResult { Title = "Failed to Start Job", Text = "Invalid job name", NotificationType = NotificationType.Error });
+
+ return Json(new NotificationResult { Title = "Job Queued" });
+ }
}
}
diff --git a/NzbDrone.Web/Helpers/LinkHelper.cs b/NzbDrone.Web/Helpers/LinkHelper.cs
new file mode 100644
index 000000000..af1438715
--- /dev/null
+++ b/NzbDrone.Web/Helpers/LinkHelper.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using System.Web.Mvc.Ajax;
+using System.Web.Mvc.Html;
+using System.Web.Routing;
+
+namespace NzbDrone.Web.Helpers
+{
+ public static class LinkHelper
+ {
+ public static MvcHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, object imgAttributes, string actionName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes)
+ {
+ return ImageActionLink(helper, imageUrl, imgAttributes, actionName, null, routeValues, ajaxOptions, htmlAttributes);
+ }
+
+ public static MvcHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, object imgAttributes, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes)
+ {
+ var builder = new TagBuilder("img");
+ builder.MergeAttribute("src", imageUrl);
+ var imgAttributesDictionary = new RouteValueDictionary(imgAttributes);
+ builder.MergeAttributes(imgAttributesDictionary);
+ var link = helper.ActionLink("[replaceme]", actionName, controllerName, routeValues, ajaxOptions, htmlAttributes).ToHtmlString();
+ return new MvcHtmlString(link.Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing)));
+ }
+
+ public static MvcHtmlString ImageActionLink(this HtmlHelper helper, string imageUrl, object imgAttributes, string actionName, object routeValues, object htmlAttributes)
+ {
+ return ImageActionLink(helper, imageUrl, imgAttributes, actionName, null, routeValues, htmlAttributes);
+ }
+
+ public static MvcHtmlString ImageActionLink(this HtmlHelper helper, string imageUrl, object imgAttributes, string actionName, string controllerName, object routeValues, object htmlAttributes)
+ {
+ var builder = new TagBuilder("img");
+ builder.MergeAttribute("src", imageUrl);
+ var imgAttributesDictionary = new RouteValueDictionary(imgAttributes);
+ builder.MergeAttributes(imgAttributesDictionary);
+ var link = helper.ActionLink("[replaceme]", actionName, controllerName, routeValues, htmlAttributes).ToHtmlString();
+ return new MvcHtmlString(link.Replace("[replaceme]", builder.ToString(TagRenderMode.SelfClosing)));
+ }
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj
index e5013ac09..28c065394 100644
--- a/NzbDrone.Web/NzbDrone.Web.csproj
+++ b/NzbDrone.Web/NzbDrone.Web.csproj
@@ -142,6 +142,7 @@
+
@@ -219,6 +220,7 @@
Global.asax
+
diff --git a/NzbDrone.Web/Views/System/Jobs.cshtml b/NzbDrone.Web/Views/System/Jobs.cshtml
index e2020c286..385b5a715 100644
--- a/NzbDrone.Web/Views/System/Jobs.cshtml
+++ b/NzbDrone.Web/Views/System/Jobs.cshtml
@@ -1,9 +1,24 @@
@using NzbDrone.Web.Models
+@using NzbDrone.Web.Helpers
@model IEnumerable
@{ViewBag.Title = "Jobs";}
@{Html.Telerik().Grid(Model).Name("Grid")
- .Render();}
+ .Columns(c => c.Bound(g => g.Id))
+ .Columns(c => c.Bound(g => g.Enable))
+ .Columns(c => c.Bound(g => g.TypeName))
+ .Columns(c => c.Bound(g => g.Name))
+ .Columns(c => c.Bound(g => g.Interval))
+ .Columns(c => c.Bound(g => g.LastExecution))
+ .Columns(c => c.Bound(g => g.Success))
+ .Columns(c => c.Bound(g => g.Command)
+ .Template(@ @{ if(item.Enable)
+ {
+ @Ajax.ImageActionLink("../../Content/Images/Gear.png", new { Alt = "Run", Width = 18, Height = 18, Title = "Run Job" }, "RunJob", new { TypeName = item.TypeName }, null, null)
+ }
+ }
+ ))
+ .Render();}
Items currently in queue
@@ -13,3 +28,9 @@
.Columns(c => c.Bound(g => g.SecondaryTargetId).Title("Secondary Target"))
.Render();}
+
+@section Scripts{
+
+}
\ No newline at end of file