From bf499ed98ae0d39f2dfbda6048a29c2cd58b0c6a Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Fri, 7 Jun 2013 16:54:46 -0700 Subject: [PATCH] added some custom cells for resources. --- NzbDrone.Api/Indexers/ReleaseModule.cs | 11 +++++++--- NzbDrone.sln | 4 ++++ UI/Release/Layout.js | 29 +++++++++++++------------ UI/Shared/Cells/ApprovalStatusCell.js | 19 ++++++++++++++++ UI/Shared/Cells/EpisodeNumberCell.js | 30 ++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 17 deletions(-) create mode 100644 UI/Shared/Cells/ApprovalStatusCell.js create mode 100644 UI/Shared/Cells/EpisodeNumberCell.js diff --git a/NzbDrone.Api/Indexers/ReleaseModule.cs b/NzbDrone.Api/Indexers/ReleaseModule.cs index be39a303c..6e68124fa 100644 --- a/NzbDrone.Api/Indexers/ReleaseModule.cs +++ b/NzbDrone.Api/Indexers/ReleaseModule.cs @@ -13,6 +13,7 @@ namespace NzbDrone.Api.Indexers private readonly IFetchAndParseRss _rssFetcherAndParser; private readonly ISearchForNzb _nzbSearchService; private readonly IMakeDownloadDecision _downloadDecisionMaker; + private static List results; public ReleaseModule(IFetchAndParseRss rssFetcherAndParser, ISearchForNzb nzbSearchService, IMakeDownloadDecision downloadDecisionMaker) { @@ -41,10 +42,14 @@ namespace NzbDrone.Api.Indexers private List 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 MapDecisions(IEnumerable decisions) diff --git a/NzbDrone.sln b/NzbDrone.sln index f6307d2a9..4ffbf30d7 100644 --- a/NzbDrone.sln +++ b/NzbDrone.sln @@ -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 diff --git a/UI/Release/Layout.js b/UI/Release/Layout.js index d5fa38685..9efb385b9 100644 --- a/UI/Release/Layout.js +++ b/UI/Release/Layout.js @@ -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, diff --git a/UI/Shared/Cells/ApprovalStatusCell.js b/UI/Shared/Cells/ApprovalStatusCell.js new file mode 100644 index 000000000..9062ac52b --- /dev/null +++ b/UI/Shared/Cells/ApprovalStatusCell.js @@ -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; + } +}); diff --git a/UI/Shared/Cells/EpisodeNumberCell.js b/UI/Shared/Cells/EpisodeNumberCell.js new file mode 100644 index 000000000..cca9a5b5c --- /dev/null +++ b/UI/Shared/Cells/EpisodeNumberCell.js @@ -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; + } +});