Series Grid AJAX'd.

Edit in popup for Series Grid using custom editing template.
pull/4/head
Mark McDowall 14 years ago
parent 5c1c8466c1
commit 70bfc49b4e

@ -66,14 +66,30 @@ namespace NzbDrone.Core.Test
public void AddByUrlError()
{
//Setup
string sabHost = "192.168.5.55";
string sabPort = "2222";
string apikey = "5c770e3197e4fe763423ee7c392c25d1";
string username = "admin";
string password = "pass";
string priority = "Normal";
string category = "tv";
var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>();
fakeConfig.SetupGet(c => c.SabHost)
.Returns(sabHost);
fakeConfig.SetupGet(c => c.SabPort)
.Returns(sabPort);
fakeConfig.SetupGet(c => c.SabApiKey)
.Returns(apikey);
fakeConfig.SetupGet(c => c.SabUsername)
.Returns(username);
fakeConfig.Setup(c => c.SabPassword)
fakeConfig.SetupGet(c => c.SabPassword)
.Returns(password);
fakeConfig.Setup(c => c.SabTvPriority)
fakeConfig.SetupGet(c => c.SabTvPriority)
.Returns(priority);
fakeConfig.Setup(c => c.SabTvCategory)
fakeConfig.SetupGet(c => c.SabTvCategory)
.Returns(category);
mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadString(It.IsAny<String>()))

@ -168,6 +168,7 @@
<Compile Include="Instrumentation\NlogWriter.cs" />
<Compile Include="Model\ExternalNotificationType.cs" />
<Compile Include="Model\IndexerType.cs" />
<Compile Include="Model\LanguageType.cs" />
<Compile Include="Model\SabnzbdInfoModel.cs" />
<Compile Include="Providers\ExternalNotification\ExternalNotificationProviderBase.cs" />
<Compile Include="Providers\ExternalNotification\XbmcNotificationProvider.cs" />

@ -33,7 +33,7 @@ namespace NzbDrone.Core.Providers
string name = url.Replace("&", "%26");
string nzbName = HttpUtility.UrlEncode(title);
string action = string.Format("mode=addurl&name={0}&priority={1}&cat={2}&nzbname={3}",
string action = string.Format("mode=addurl&name={0}&priority={1}&pp=3&cat={2}&nzbname={3}",
name, priority, cat, nzbName);
string request = GetSabRequest(action);

@ -294,4 +294,11 @@ button, input[type="button"], input[type="submit"], input[type="reset"]
.Grid
{
font-size: 13px;
}
.edit-group
{
width: 435px;
display: block;
height: 25px;
}

@ -43,11 +43,12 @@ namespace NzbDrone.Web.Controllers
public ActionResult Index()
{
ViewData.Model = _seriesProvider.GetAllSeries().ToList();
var profiles = _qualityProvider.GetAllProfiles();
ViewData["SelectList"] = new SelectList(profiles, "QualityProfileId", "Name");
return View();
}
public ActionResult RssSync()
{
_jobProvider.BeginExecute(typeof(RssSyncJob));
@ -63,6 +64,63 @@ namespace NzbDrone.Web.Controllers
});
}
[GridAction]
public ActionResult _AjaxSeriesGrid()
{
var series = new List<SeriesModel>();
var seriesInDb = _seriesProvider.GetAllSeries().ToList();
seriesInDb.ForEach(s => series.Add(new SeriesModel
{
SeriesId = s.SeriesId,
Title = s.Title,
AirsDayOfWeek = s.AirsDayOfWeek.ToString(),
Monitored = s.Monitored,
Overview = s.Overview,
Path = s.Path,
QualityProfileId = s.QualityProfileId,
QualityProfileName = s.QualityProfile.Name,
SeasonsCount = s.Seasons.Count,
SeasonFolder = s.SeasonFolder,
Status = s.Status
}));
return View(new GridModel(series));
}
[AcceptVerbs(HttpVerbs.Post)]
[GridAction]
public ActionResult _SaveAjaxSeriesEditing(int id, string path, bool monitored, bool seasonFolder, int qualityProfileId)
{
var oldSeries = _seriesProvider.GetSeries(id);
oldSeries.Path = path;
oldSeries.Monitored = monitored;
oldSeries.SeasonFolder = monitored;
oldSeries.QualityProfileId = qualityProfileId;
_seriesProvider.UpdateSeries(oldSeries);
var series = new List<SeriesModel>();
var seriesInDb = _seriesProvider.GetAllSeries().ToList();
seriesInDb.ForEach(s => series.Add(new SeriesModel
{
SeriesId = s.SeriesId,
Title = s.Title,
AirsDayOfWeek = s.AirsDayOfWeek.ToString(),
Monitored = s.Monitored,
Overview = s.Overview,
Path = s.Path,
QualityProfileId = s.QualityProfileId,
QualityProfileName = s.QualityProfile.Name,
SeasonsCount = s.Seasons.Count,
SeasonFolder = s.SeasonFolder,
Status = s.Status
}));
return View(new GridModel(series));
}
[GridAction]
public ActionResult _AjaxSeasonGrid(int seasonId)
{

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository;
namespace NzbDrone.Web.Models
{
public class SeriesModel
{
public int SeriesId { get; set; }
//View Only
public string Title { get; set; }
public int SeasonsCount { get; set; }
public string Status { get; set; }
public string AirsDayOfWeek { get; set; }
public string QualityProfileName { get; set; }
public string Overview { get; set; }
//View & Edit
[DisplayName("Path")]
public string Path { get; set; }
[DisplayName("Quality Profile")]
public virtual int QualityProfileId { get; set; }
//Editing Only
[DisplayName("Use Season Folder")]
public bool SeasonFolder { get; set; }
[DisplayName("Monitored")]
public bool Monitored { get; set; }
}
}

@ -240,6 +240,7 @@
<Compile Include="Models\MissingEpisodeModel.cs" />
<Compile Include="Models\NotificationSettingsModel.cs" />
<Compile Include="Models\QualityModel.cs" />
<Compile Include="Models\SeriesModel.cs" />
<Compile Include="Models\SeriesSearchResultModel.cs" />
<Compile Include="Models\SettingsModels.cs" />
<Compile Include="Models\TestModel.cs" />
@ -598,6 +599,7 @@
<Content Include="Content\jquery.jgrowl.css" />
<Content Include="Content\notibar.css" />
<Content Include="Content\style.css" />
<Content Include="Content\thickbox.css" />
<Content Include="Content\XbmcNotification.png" />
<Content Include="favicon.ico" />
<Content Include="Global.asax" />
@ -641,6 +643,7 @@
<Content Include="Scripts\jquery-tgc-countdown-1.0.js" />
<Content Include="Scripts\jquery.simpledropdown.js" />
<Content Include="Scripts\Notification.js" />
<Content Include="Scripts\thickbox-compressed.js" />
<Content Include="Views\AddSeries\AddExisting.cshtml" />
<Content Include="Views\AddSeries\AddNew.cshtml" />
<Content Include="Views\AddSeries\AddSeriesItem.cshtml" />
@ -835,6 +838,9 @@
<ItemGroup>
<Content Include="Views\Missing\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Series\EditorTemplates\SeriesModel.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

@ -0,0 +1,29 @@
@using NzbDrone.Web.Helpers;
@model NzbDrone.Web.Models.SeriesModel
@{
Layout = null;
}
<div style="width: 435px; margin: 10px;">
<div class="edit-group">
<div class="config-title">@Html.LabelFor(m => m.Path)</div>
<div class="config-value">@Html.TextBoxFor(m => m.Path, new { style = "width: 300" })</div>
</div>
<div class="edit-group">
<div class="config-title">@Html.LabelFor(m => m.Monitored)</div>
<div class="config-value">@Html.CheckBoxFor(m => m.Monitored, new { style = "margin-right:287px" })</div>
</div>
<div class="edit-group">
<div class="config-title">@Html.LabelFor(m => m.SeasonFolder)</div>
<div class="config-value">@Html.CheckBoxFor(m => m.SeasonFolder, new { style = "margin-right:287px" })</div>
</div>
<div class="edit-group">
<div class="config-title">@Html.LabelFor(m => m.QualityProfileId)</div>
<div class="config-value">@Html.DropDownListFor(model => model.QualityProfileId, (SelectList)ViewData["SelectList"], new { style = "margin-right:216px" })</div>
</div>
</div>

@ -1,4 +1,6 @@
@model IEnumerable<NzbDrone.Core.Repository.Series>
@using NzbDrone.Core.Repository;
@using NzbDrone.Web.Models;
@model IEnumerable<NzbDrone.Core.Repository.Series>
@section TitleContent{
Series
@ -9,19 +11,31 @@
}
@section MainContent{
@{Html.Telerik().Grid(Model).Name("Grid")
@{Html.Telerik().Grid<SeriesModel>().Name("Grid")
.TableHtmlAttributes(new { @class = "Grid" })
.DataKeys(keys =>
{
keys.Add(p => p.SeriesId);
})
.DataBinding(data => data.Ajax()
.Select("_AjaxSeriesGrid", "Series")
.Update("_SaveAjaxSeriesEditing", "Series"))
.Columns(columns =>
{
columns.Template(c => @Html.ActionLink(c.Title ?? "New Series", "Details",
new {seriesId = c.SeriesId})
).Title("Title");
columns.Bound(o => o.Seasons.Count).Title("Seasons");
columns.Bound(o => o.QualityProfile.Name).Title("Quality");
columns.Bound(o => o.Title)
.ClientTemplate("<a href=" +
Url.Action("Details", "Series", new {seriesId = "<#= SeriesId #>"}) +
"><#= Title #></a>");
columns.Bound(o => o.SeasonsCount).Title("Seasons");
columns.Bound(o => o.QualityProfileName).Title("Quality");
columns.Bound(o => o.Status);
columns.Bound(o => o.AirsDayOfWeek);
columns.Bound(o => o.Path);
columns.Command(commands => commands.Edit().ButtonType(GridButtonType.Image)).Title("Edit").Width(50);
})
.Sortable(sort => sort.OrderBy(order => order.Add(o => o.Title).Ascending()).Enabled(false))
.Editable(editor => editor.Mode(GridEditMode.PopUp))
.Sortable(sort => sort.OrderBy(order => order.Add(o => o.Title).Ascending()).Enabled(true))
.DetailView(detailView => detailView.ClientTemplate("<div style=\"width:95%\"><#= Overview #></div>"))
.Render();}
}

Loading…
Cancel
Save