mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
Added ImageLink helpers for Ajax and Html links.
Added run button to System/Jobs.
This commit is contained in:
parent
ed566e6e9a
commit
9264dcdf88
@ -184,6 +184,17 @@ public virtual void QueueJob(Type jobType, int targetId = 0, int secondaryTarget
|
||||
|
||||
}
|
||||
|
||||
public virtual bool QueueJob(string jobTypeString)
|
||||
{
|
||||
var type = Type.GetType(jobTypeString);
|
||||
|
||||
if (type == null)
|
||||
return false;
|
||||
|
||||
QueueJob(type);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ProcessQueue()
|
||||
{
|
||||
try
|
||||
|
@ -35,7 +35,7 @@ public string Name
|
||||
|
||||
public int DefaultInterval
|
||||
{
|
||||
get { return 720; } //Daily
|
||||
get { return 720; } //12-hours
|
||||
}
|
||||
|
||||
public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
|
||||
|
@ -20,5 +20,8 @@ public class JobDefinition
|
||||
public DateTime LastExecution { get; set; }
|
||||
|
||||
public Boolean Success { get; set; }
|
||||
|
||||
[Ignore]
|
||||
public string Command { get; set; }
|
||||
}
|
||||
}
|
BIN
NzbDrone.Web/Content/Images/Gear.png
Normal file
BIN
NzbDrone.Web/Content/Images/Gear.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
@ -35,7 +35,14 @@ public ActionResult Jobs()
|
||||
TargetId = c.TargetId,
|
||||
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()
|
||||
@ -131,5 +138,13 @@ public JsonResult RenamePendingProcessing(string path)
|
||||
|
||||
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" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
44
NzbDrone.Web/Helpers/LinkHelper.cs
Normal file
44
NzbDrone.Web/Helpers/LinkHelper.cs
Normal file
@ -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\Images\background.jpg" />
|
||||
<Content Include="Content\Images\blue.png" />
|
||||
<Content Include="Content\Images\Gear.png" />
|
||||
<Content Include="Content\Images\green.png" />
|
||||
<Content Include="Content\Images\header.jpg" />
|
||||
<Content Include="Content\Images\Indexers\Newznab.png" />
|
||||
@ -219,6 +220,7 @@
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Helpers\HtmlIncludeExtentions.cs" />
|
||||
<Compile Include="Helpers\LinkHelper.cs" />
|
||||
<Compile Include="Helpers\ProfilerHelper.cs" />
|
||||
<Compile Include="Helpers\ValueExtension.cs" />
|
||||
<Compile Include="Helpers\DescriptionExtension.cs" />
|
||||
|
@ -1,9 +1,24 @@
|
||||
@using NzbDrone.Web.Models
|
||||
@using NzbDrone.Web.Helpers
|
||||
@model IEnumerable<NzbDrone.Core.Repository.JobDefinition>
|
||||
@{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(@<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
|
||||
|
||||
@ -13,3 +28,9 @@
|
||||
.Columns(c => c.Bound(g => g.SecondaryTargetId).Title("Secondary Target"))
|
||||
.Render();}
|
||||
|
||||
|
||||
@section Scripts{
|
||||
<script>
|
||||
function
|
||||
</script>
|
||||
}
|
Loading…
Reference in New Issue
Block a user