Fancy grid, well getting there anyways.

Cell colour only in the "Command" column.
Cell colour toggles when ignored is toggled.
pull/4/head
Mark McDowall 13 years ago committed by kay.one
parent f065d345a5
commit d7bc3a3734

@ -185,10 +185,17 @@ namespace NzbDrone.Web.Controllers
foreach (var season in episodes.Select(s => s.SeasonNumber).Distinct())
{
var episodesInSeason = episodes.Where(e => e.SeasonNumber == season).ToList();
var commonStatusList = episodes.Select(s => s.Status).Distinct().ToList();
var commonStatus = commonStatusList.Count > 1 ? "Missing" : commonStatusList.First().ToString();
seasons.Add(new SeasonModel
{
SeriesId = seriesId,
SeasonNumber = season,
Episodes = GetEpisodeModels(episodes.Where(e => e.SeasonNumber == season).ToList()).OrderByDescending(e=> e.EpisodeNumber).ToList()
Episodes = GetEpisodeModels(episodesInSeason).OrderByDescending(e=> e.EpisodeNumber).ToList(),
AnyWanted = episodesInSeason.Any(e => !e.Ignored),
CommonStatus = commonStatus
});
}

@ -9,7 +9,10 @@ namespace NzbDrone.Web.Models
{
public class SeasonModel
{
public int SeriesId { get; set; }
public int SeasonNumber { get; set; }
public List<EpisodeModel> Episodes { get; set; }
public bool AnyWanted { get; set; }
public string CommonStatus { get; set; }
}
}

@ -16,11 +16,13 @@ $(".ignoreEpisode").live("click", function () {
if (ignored) {
toggle.removeClass('ignored');
toggle.attr('src', notIgnoredImage);
toggleCellColour(toggle, false);
}
else {
toggle.addClass('ignored');
toggle.attr('src', ignoredImage);
toggleCellColour(toggle, true);
}
var seasonNumber = 0;
@ -29,7 +31,6 @@ $(".ignoreEpisode").live("click", function () {
ignored = !ignored;
if (toggle.hasClass('ignoredEpisodesMaster')) {
//seasonNumber = toggle.attr('id').replace('master_', '');
seasonNumber = toggle.attr('class').split(/\s+/)[2].replace('ignoreSeason_', '');
toggleChildren(seasonNumber, ignored);
@ -53,6 +54,7 @@ function toggleChildren(seasonNumber, ignored) {
ignoreEpisodes.each(function (index) {
$(this).addClass('ignored');
$(this).attr('src', ignoredImage);
toggleCellColour($(this), true);
});
}
@ -60,12 +62,14 @@ function toggleChildren(seasonNumber, ignored) {
ignoreEpisodes.each(function (index) {
$(this).removeClass('ignored');
$(this).attr('src', notIgnoredImage);
toggleCellColour($(this), false);
});
}
}
function toggleMaster(seasonNumber) {
//Toggles all master toggles when the childen changes or the grid is loaded
//Toggles all master toggles when the childen changes
var ignoreEpisodes = $('.ignoreEpisode_' + seasonNumber);
var ignoredCount = ignoreEpisodes.filter('.ignored').length;
@ -103,36 +107,19 @@ function toggleMasters(seasonNumber, ignored) {
}
}
//Functions called by the Telerik Season Grid
function grid_rowBound(e) {
var dataItem = e.dataItem;
var row = e.row;
var ignored = dataItem.Ignored;
var episodeId = dataItem.EpisodeId;
var ignoredIcon = $('#' + episodeId);
function toggleCellColour(toggle, ignored) {
if (ignored) {
ignoredIcon.attr('src', ignoredImage);
toggle.parent('td').addClass('episodeIgnored');
toggle.parent('td').removeClass('episodeMissing');
}
else {
ignoredIcon.attr('src', notIgnoredImage);
ignoredIcon.removeClass('ignored');
}
if (seriesId == 0)
seriesId = dataItem.SeriesId;
toggle.parent('td').removeClass('episodeIgnored');
highlightRow(e);
}
function grid_dataBound(e) {
var id = $(this).attr('id');
var seasonNumber = id.replace('seasons_', '');
toggleMaster(seasonNumber);
setMasterStatus(this);
//check to see if episode is missing
if (toggle.parent('td').children('.statusImage').hasClass('status-Missing'))
toggle.parent('td').addClass('episodeMissing');
}
}
//Episode Ignore Saving
@ -157,32 +144,3 @@ function saveEpisodeIgnore(episodeId, ignored) {
}
});
}
//Set master status to match children
function setMasterStatus(grid) {
//Get children of this grid
var masterStatus = $(grid).find('.statusImageMaster');
var statuses = $(grid).find('.statusImage').filter(':not(.statusImageMaster)');
var episodeCount = statuses.length;
//Get missing count
if (statuses.filter('.status-Missing').length == episodeCount) {
//Leave as is (default is missing)
return;
}
if (statuses.filter('.status-NotAired').length == episodeCount) {
masterStatus.attr('src', notAiredImage);
return;
}
if (statuses.filter('.status-Ready').length == episodeCount) {
masterStatus.attr('src', readyImage);
return;
}
if (statuses.filter('.status-Downloading').length == episodeCount) {
masterStatus.attr('src', downloadingImage);
return;
}
}

@ -68,7 +68,6 @@
border-style: none;
border-color: white;
border-collapse: collapse;
background-color: white;
}
.seriesTable th {
@ -86,7 +85,6 @@
padding: 0 0.6em;
border-style: inset;
border-color: #EEEEEE;
background-color: white;
padding-left: 7px;
}
</style>
@ -110,12 +108,14 @@
<img src="@bannerUrl" alt="Banner"/>
</div>
<div class="seasonToggleTopGroup">
@foreach (var season in Model.Seasons.Select(s => s.SeasonNumber))
@foreach (var season in Model.Seasons.OrderBy(s => s.SeasonNumber))
{
var ignoreSeason = "ignoreSeason_" + season;
var ignoreSeason = "ignoreSeason_" + season.SeasonNumber;
<div class="seasonToggleTop">
<img src='../../Content/Images/ignoredNeutral.png' class='ignoredEpisodesMaster ignoreEpisode @ignoreSeason' title='Click to toggle season ignore status' />
<span class="seasonToggleLabel">@(season == 0 ? "Specials" : "Season " + season)</span>
<img src='../../Content/Images/@(season.AnyWanted ? "notIgnored" : "ignored").png'
class='ignoredEpisodesMaster ignoreEpisode @ignoreSeason @(season.AnyWanted ? "" : "ignored")'
title='Click to toggle season ignore status' />
<span class="seasonToggleLabel">@(season.SeasonNumber == 0 ? "Specials" : "Season " + season.SeasonNumber)</span>
</div>
}
</div>

@ -7,9 +7,23 @@
<td>@Model.AirDate</td>
<td>@Model.Quality</td>
@{
string cellColourClass = String.Empty;
if (Model.Status == "Missing")
{
cellColourClass = "episodeMissing";
}
if (Model.Ignored)
{
cellColourClass = "episodeIgnored";
}
}
@*Commands Column*@
<td>
<img src='../../Content/Images/@(Model.Ignored ? "ignored" : "notIgnored").png' class='ignoreEpisode ignoreEpisode_" + @Model.SeasonNumber + " ignored' id='@Model.EpisodeId' title='Click to toggle episode ignore status' />
<td class="@cellColourClass">
<img src='../../Content/Images/@(Model.Ignored ? "ignored" : "notIgnored").png' class='ignoreEpisode ignoreEpisode_@(Model.SeasonNumber) @(Model.Ignored ? "ignored" : "")' id='@Model.EpisodeId' title='Click to toggle episode ignore status' />
<img src='../../Content/Images/@(Model.Status).png' alt='@Model.Status' title='@Model.Status' class='statusImage status-@Model.Status' />
@Ajax.ImageActionLink("../../Content/Images/Search.png", new { Alt = "Search", Title = "Search for episode", @class = "searchImage" }, "Search", "Episode", new { EpisodeId = Model.EpisodeId }, null, null)
@Ajax.ImageActionLink("../../Content/Images/Rename.png", new { Alt = "Rename", Title = "Rename episode", @class = "renameImage" }, "Rename", "Episode", new { EpisodeFileId = Model.EpisodeFileId }, null, null)

@ -6,19 +6,25 @@
</h2>
<table class="seriesTable">
<colgroup>
<col style="width:100px" />
<col>
<col style="width:100px" />
<col style="width:100px" />
<col style="width:110px" />
</colgroup>
<tr>
<th width="100px">Episode #</th>
<th>Episode #</th>
<th>Title</th>
<th width="100px">Air Date</th>
<th width="100px">Quality</th>
<th>Air Date</th>
<th>Quality</th>
@*Commands Column*@
<th width="110px">
Commands
@* <img src='../../Content/Images/ignoredNeutral.png' class='ignoredEpisodesMaster ignoreEpisode ignoreSeason_" + season + "' title='Click to toggle season ignore status' />
<img src='../../Content/Images/Missing.png' alt='Status' title='Season Status' class='statusImage statusImageMaster' />
Ajax.ImageActionLink("../../Content/Images/Search.png", new { Alt = "Search", Title = "Search for all episodes in this season", @class = "searchImage searchImageMaster" }, "SearchSeason", "Episode", new { SeriesId = seriesId, SeasonNumber = season }, null, null)
Ajax.ImageActionLink("../../Content/Images/Rename.png", new { Alt = "Rename", Title = "Rename all episodes in this season", @class = "renameImage renameImageMaster" }, "RenameSeason", "Episode", new { SeriesId = seriesId, SeasonNumber = season }, null, null))*@
<th>
<img src='../../Content/Images/@(Model.AnyWanted ? "notIgnored" : "ignored").png' class='ignoredEpisodesMaster ignoreEpisode ignoreSeason_@(Model.SeasonNumber) @(Model.AnyWanted ? "" : "ignored")' title='Click to toggle season ignore status' />
<img src='../../Content/Images/@(Model.CommonStatus).png' alt='Status' title='Season Status' class='statusImage statusImageMaster' />
@Ajax.ImageActionLink("../../Content/Images/Search.png", new { Alt = "Search", Title = "Search for all episodes in this season", @class = "searchImage searchImageMaster" }, "SearchSeason", "Episode", new { SeriesId = Model.SeriesId, SeasonNumber = Model.SeasonNumber }, null, null)
@Ajax.ImageActionLink("../../Content/Images/Rename.png", new { Alt = "Rename", Title = "Rename all episodes in this season", @class = "renameImage renameImageMaster" }, "RenameSeason", "Episode", new { SeriesId = Model.SeriesId, SeasonNumber = Model.SeasonNumber }, null, null)
</th>
</tr>

Loading…
Cancel
Save