1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00

added some custom cells for resources.

This commit is contained in:
Keivan Beigi 2013-06-07 16:54:46 -07:00
parent c93548c9f6
commit bf499ed98a
5 changed files with 76 additions and 17 deletions

View File

@ -13,6 +13,7 @@ public class ReleaseModule : NzbDroneRestModule<ReleaseResource>
private readonly IFetchAndParseRss _rssFetcherAndParser;
private readonly ISearchForNzb _nzbSearchService;
private readonly IMakeDownloadDecision _downloadDecisionMaker;
private static List<DownloadDecision> results;
public ReleaseModule(IFetchAndParseRss rssFetcherAndParser, ISearchForNzb nzbSearchService, IMakeDownloadDecision downloadDecisionMaker)
{
@ -41,10 +42,14 @@ private List<ReleaseResource> GetEpisodeReleases(int episodeId)
private List<ReleaseResource> GetRss()
{
var reports = _rssFetcherAndParser.Fetch();
var decisions = _downloadDecisionMaker.GetRssDecision(reports);
if (results == null)
{
var reports = _rssFetcherAndParser.Fetch();
var decisions = _downloadDecisionMaker.GetRssDecision(reports);
results = decisions;
}
return MapDecisions(decisions);
return MapDecisions(results);
}
private static List<ReleaseResource> MapDecisions(IEnumerable<DownloadDecision> decisions)

View File

@ -340,6 +340,7 @@ Global
{F6FC6BE7-0847-4817-A1ED-223DC647C3D7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{F6FC6BE7-0847-4817-A1ED-223DC647C3D7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{F6FC6BE7-0847-4817-A1ED-223DC647C3D7}.Debug|x86.ActiveCfg = Debug|Any CPU
{F6FC6BE7-0847-4817-A1ED-223DC647C3D7}.Debug|x86.Build.0 = Debug|Any CPU
{F6FC6BE7-0847-4817-A1ED-223DC647C3D7}.Pilot|Any CPU.ActiveCfg = Release|Any CPU
{F6FC6BE7-0847-4817-A1ED-223DC647C3D7}.Pilot|Any CPU.Build.0 = Release|Any CPU
{F6FC6BE7-0847-4817-A1ED-223DC647C3D7}.Pilot|Mixed Platforms.ActiveCfg = Release|Any CPU
@ -356,6 +357,7 @@ Global
{CBF6B8B0-A015-413A-8C86-01238BB45770}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{CBF6B8B0-A015-413A-8C86-01238BB45770}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{CBF6B8B0-A015-413A-8C86-01238BB45770}.Debug|x86.ActiveCfg = Debug|Any CPU
{CBF6B8B0-A015-413A-8C86-01238BB45770}.Debug|x86.Build.0 = Debug|Any CPU
{CBF6B8B0-A015-413A-8C86-01238BB45770}.Pilot|Any CPU.ActiveCfg = Release|Any CPU
{CBF6B8B0-A015-413A-8C86-01238BB45770}.Pilot|Any CPU.Build.0 = Release|Any CPU
{CBF6B8B0-A015-413A-8C86-01238BB45770}.Pilot|Mixed Platforms.ActiveCfg = Release|Any CPU
@ -372,6 +374,7 @@ Global
{8CEFECD0-A6C2-498F-98B1-3FBE5820F9AB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{8CEFECD0-A6C2-498F-98B1-3FBE5820F9AB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{8CEFECD0-A6C2-498F-98B1-3FBE5820F9AB}.Debug|x86.ActiveCfg = Debug|Any CPU
{8CEFECD0-A6C2-498F-98B1-3FBE5820F9AB}.Debug|x86.Build.0 = Debug|Any CPU
{8CEFECD0-A6C2-498F-98B1-3FBE5820F9AB}.Pilot|Any CPU.ActiveCfg = Release|Any CPU
{8CEFECD0-A6C2-498F-98B1-3FBE5820F9AB}.Pilot|Any CPU.Build.0 = Release|Any CPU
{8CEFECD0-A6C2-498F-98B1-3FBE5820F9AB}.Pilot|Mixed Platforms.ActiveCfg = Release|Any CPU
@ -388,6 +391,7 @@ Global
{B1784698-592E-4132-BDFA-9817409E3A96}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{B1784698-592E-4132-BDFA-9817409E3A96}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{B1784698-592E-4132-BDFA-9817409E3A96}.Debug|x86.ActiveCfg = Debug|Any CPU
{B1784698-592E-4132-BDFA-9817409E3A96}.Debug|x86.Build.0 = Debug|Any CPU
{B1784698-592E-4132-BDFA-9817409E3A96}.Pilot|Any CPU.ActiveCfg = Pilot|Any CPU
{B1784698-592E-4132-BDFA-9817409E3A96}.Pilot|Any CPU.Build.0 = Pilot|Any CPU
{B1784698-592E-4132-BDFA-9817409E3A96}.Pilot|Mixed Platforms.ActiveCfg = Pilot|Any CPU

View File

@ -3,7 +3,10 @@ define([
'app',
'Release/Collection',
'Shared/SpinnerView',
'Shared/Toolbar/ToolbarLayout'
'Shared/Toolbar/ToolbarLayout',
'Shared/Cells/EpisodeNumberCell',
'Shared/Cells/FileSizeCell',
'Shared/Cells/ApprovalStatusCell'
],
function () {
NzbDrone.Release.Layout = Backbone.Marionette.Layout.extend({
@ -25,7 +28,7 @@ define([
name : 'size',
label : 'Size',
sortable: true,
cell : Backgrid.IntegerCell
cell : NzbDrone.Shared.Cells.FileSizeCell
},
{
name : 'title',
@ -34,24 +37,22 @@ define([
cell : Backgrid.StringCell
},
{
name : 'seasonNumber',
label: 'season',
cell : Backgrid.IntegerCell
name : 'episodeNumbers',
season : 'seasonNumber',
airDate : 'airDate',
episodes: 'episodeNumbers',
label : 'season',
cell : NzbDrone.Shared.Cells.EpisodeNumberCell
},
{
name : 'episodeNumber',
label: 'episode',
cell : Backgrid.StringCell
},
{
name : 'approved',
label: 'Approved',
cell : Backgrid.BooleanCell
name : 'rejections',
label: 'decision',
cell : NzbDrone.Shared.Cells.ApprovalStatusCell
}
],
showTable: function () {
if (!this.isClosed) {
if (!this.isClosed) {
this.grid.show(new Backgrid.Grid(
{
row : Backgrid.Row,

View File

@ -0,0 +1,19 @@
"use strict";
NzbDrone.Shared.Cells.ApprovalStatusCell = Backgrid.Cell.extend({
className: "approval-status-cell",
render: function () {
var rejections = this.model.get(this.column.get("name"));
var result = '';
_.each(rejections, function (reason) {
result += reason + ' ';
});
this.$el.html(result);
this.delegateEvents();
return this;
}
});

View File

@ -0,0 +1,30 @@
"use strict";
NzbDrone.Shared.Cells.EpisodeNumberCell = Backgrid.Cell.extend({
className: "episode-number-cell",
render: function () {
var airDate = this.model.get(this.column.get("airDate"));
var result = 'Unknown';
if (airDate) {
result = new Date(airDate).toLocaleDateString();
}
else {
var season = this.model.get(this.column.get("season")).pad(2);
var episodes = _.map(this.model.get(this.column.get("episodes")), function (episodeNumber) {
return episodeNumber.pad(2);
});
result = 'S{0}-E{1}'.format(season, episodes.join());
}
this.$el.html(result);
this.delegateEvents();
return this;
}
});