Added ImageLink helpers for Ajax and Html links.

Added run button to System/Jobs.
pull/4/head
Mark McDowall 13 years ago
parent ed566e6e9a
commit 9264dcdf88

@ -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() private void ProcessQueue()
{ {
try try

@ -35,7 +35,7 @@ namespace NzbDrone.Core.Jobs
public int DefaultInterval public int DefaultInterval
{ {
get { return 720; } //Daily get { return 720; } //12-hours
} }
public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId) public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -20,5 +20,8 @@ namespace NzbDrone.Core.Repository
public DateTime LastExecution { get; set; } public DateTime LastExecution { get; set; }
public Boolean Success { get; set; } public Boolean Success { get; set; }
[Ignore]
public string Command { get; set; }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

@ -35,7 +35,14 @@ namespace NzbDrone.Web.Controllers
TargetId = c.TargetId, TargetId = c.TargetId,
SecondaryTargetId = c.SecondaryTargetId SecondaryTargetId = c.SecondaryTargetId
}); });
return View(_jobProvider.All()); var jobs = _jobProvider.All();
foreach(var jobDefinition in jobs)
{
jobDefinition.Command = "<a href=\"http://www.google.ca\"></a>";
}
return View(jobs);
} }
public ActionResult Indexers() public ActionResult Indexers()
@ -131,5 +138,13 @@ namespace NzbDrone.Web.Controllers
return new JsonResult { Data = "ok" }; 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" });
}
} }
} }

@ -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)));
}
}
}

@ -142,6 +142,7 @@
<Content Include="Content\2011.3.1115\telerik.sitefinity.min.css" /> <Content Include="Content\2011.3.1115\telerik.sitefinity.min.css" />
<Content Include="Content\Images\background.jpg" /> <Content Include="Content\Images\background.jpg" />
<Content Include="Content\Images\blue.png" /> <Content Include="Content\Images\blue.png" />
<Content Include="Content\Images\Gear.png" />
<Content Include="Content\Images\green.png" /> <Content Include="Content\Images\green.png" />
<Content Include="Content\Images\header.jpg" /> <Content Include="Content\Images\header.jpg" />
<Content Include="Content\Images\Indexers\Newznab.png" /> <Content Include="Content\Images\Indexers\Newznab.png" />
@ -219,6 +220,7 @@
<DependentUpon>Global.asax</DependentUpon> <DependentUpon>Global.asax</DependentUpon>
</Compile> </Compile>
<Compile Include="Helpers\HtmlIncludeExtentions.cs" /> <Compile Include="Helpers\HtmlIncludeExtentions.cs" />
<Compile Include="Helpers\LinkHelper.cs" />
<Compile Include="Helpers\ProfilerHelper.cs" /> <Compile Include="Helpers\ProfilerHelper.cs" />
<Compile Include="Helpers\ValueExtension.cs" /> <Compile Include="Helpers\ValueExtension.cs" />
<Compile Include="Helpers\DescriptionExtension.cs" /> <Compile Include="Helpers\DescriptionExtension.cs" />

@ -1,9 +1,24 @@
@using NzbDrone.Web.Models @using NzbDrone.Web.Models
@using NzbDrone.Web.Helpers
@model IEnumerable<NzbDrone.Core.Repository.JobDefinition> @model IEnumerable<NzbDrone.Core.Repository.JobDefinition>
@{ViewBag.Title = "Jobs";} @{ViewBag.Title = "Jobs";}
@{Html.Telerik().Grid(Model).Name("Grid") @{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(@<text> @{ 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)
}
}
</text>))
.Render();}
Items currently in queue Items currently in queue
@ -13,3 +28,9 @@
.Columns(c => c.Bound(g => g.SecondaryTargetId).Title("Secondary Target")) .Columns(c => c.Bound(g => g.SecondaryTargetId).Title("Secondary Target"))
.Render();} .Render();}
@section Scripts{
<script>
function
</script>
}
Loading…
Cancel
Save