From 1c4a687854ca61c677f6261e79d91cd3e98d7a7c Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 25 Aug 2013 22:31:58 -0700 Subject: [PATCH] Added history details modal --- NzbDrone.Core/History/HistoryService.cs | 6 +- .../MediaFiles/Events/EpisodeImportedEvent.cs | 2 +- UI/Cells/cells.less | 9 +++ UI/History/Details/HistoryDetailsView.js | 10 ++++ .../Details/HistoryDetailsViewTemplate.html | 58 +++++++++++++++++++ UI/History/HistoryDetailsCell.js | 27 +++++++++ UI/History/HistoryLayout.js | 20 ++++++- UI/Shared/Modal/Controller.js | 12 +++- UI/app.js | 1 + 9 files changed, 139 insertions(+), 6 deletions(-) create mode 100644 UI/History/Details/HistoryDetailsView.js create mode 100644 UI/History/Details/HistoryDetailsViewTemplate.html create mode 100644 UI/History/HistoryDetailsCell.js diff --git a/NzbDrone.Core/History/HistoryService.cs b/NzbDrone.Core/History/HistoryService.cs index 48f7ebbf8..40f637fcf 100644 --- a/NzbDrone.Core/History/HistoryService.cs +++ b/NzbDrone.Core/History/HistoryService.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using NLog; using NzbDrone.Common.Messaging; @@ -89,9 +90,12 @@ namespace NzbDrone.Core.History Quality = message.EpisodeFile.Quality, SourceTitle = message.EpisodeFile.Path, SeriesId = message.EpisodeFile.SeriesId, - EpisodeId = episode.Id, + EpisodeId = episode.Id }; + history.Data.Add("Path", message.EpisodeFile.Path); + history.Data.Add("Filename", Path.GetFileNameWithoutExtension(message.EpisodeFile.Path)); + _historyRepository.Insert(history); } } diff --git a/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs b/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs index e9d0eb458..9c8e59cdc 100644 --- a/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs +++ b/NzbDrone.Core/MediaFiles/Events/EpisodeImportedEvent.cs @@ -2,7 +2,7 @@ namespace NzbDrone.Core.MediaFiles.Events { - public class EpisodeImportedEvent:IEvent + public class EpisodeImportedEvent : IEvent { public EpisodeFile EpisodeFile { get; private set; } diff --git a/UI/Cells/cells.less b/UI/Cells/cells.less index fb55fb928..0bf8a9097 100644 --- a/UI/Cells/cells.less +++ b/UI/Cells/cells.less @@ -47,4 +47,13 @@ td.episode-status-cell, td.quality-cell { .badge { font-size: 9px; } +} + +.history-details-cell { + .clickable(); + width: 10px; + + i { + .clickable(); + } } \ No newline at end of file diff --git a/UI/History/Details/HistoryDetailsView.js b/UI/History/Details/HistoryDetailsView.js new file mode 100644 index 000000000..b7c8e1a9d --- /dev/null +++ b/UI/History/Details/HistoryDetailsView.js @@ -0,0 +1,10 @@ +'use strict'; +define( + [ + 'marionette' + ], function (Marionette) { + + return Marionette.ItemView.extend({ + template: 'History/Details/HistoryDetailsViewTemplate' + }); + }); diff --git a/UI/History/Details/HistoryDetailsViewTemplate.html b/UI/History/Details/HistoryDetailsViewTemplate.html new file mode 100644 index 000000000..832573e9e --- /dev/null +++ b/UI/History/Details/HistoryDetailsViewTemplate.html @@ -0,0 +1,58 @@ +
+ + + +
+ diff --git a/UI/History/HistoryDetailsCell.js b/UI/History/HistoryDetailsCell.js new file mode 100644 index 000000000..33ba3d609 --- /dev/null +++ b/UI/History/HistoryDetailsCell.js @@ -0,0 +1,27 @@ +'use strict'; + +define( + [ + 'app', + 'Cells/NzbDroneCell' + ], function (App, NzbDroneCell) { + return NzbDroneCell.extend({ + + className: 'history-details-cell', + + events: { + 'click': '_showDetails' + }, + + render: function () { + this.$el.empty(); + this.$el.html(''); + + return this; + }, + + _showDetails: function () { + App.vent.trigger(App.Commands.ShowHistoryDetails, { history: this.model }); + } + }); + }); diff --git a/UI/History/HistoryLayout.js b/UI/History/HistoryLayout.js index ca4580c98..146361aef 100644 --- a/UI/History/HistoryLayout.js +++ b/UI/History/HistoryLayout.js @@ -10,9 +10,21 @@ define( 'Cells/EpisodeTitleCell', 'Cells/QualityCell', 'Cells/RelativeDateCell', + 'History/HistoryDetailsCell', 'Shared/Grid/Pager', 'Shared/LoadingView' - ], function (Marionette, Backgrid, HistoryCollection, EventTypeCell, SeriesTitleCell, EpisodeNumberCell, EpisodeTitleCell, QualityCell, RelativeDateCell, GridPager, LoadingView) { + ], function (Marionette, + Backgrid, + HistoryCollection, + EventTypeCell, + SeriesTitleCell, + EpisodeNumberCell, + EpisodeTitleCell, + QualityCell, + RelativeDateCell, + HistoryDetailsCell, + GridPager, + LoadingView) { return Marionette.Layout.extend({ template: 'History/HistoryLayoutTemplate', @@ -56,6 +68,12 @@ define( name : 'date', label: 'Date', cell : RelativeDateCell + }, + { + name : 'this', + label : '', + cell : HistoryDetailsCell, + sortable: false } ], diff --git a/UI/Shared/Modal/Controller.js b/UI/Shared/Modal/Controller.js index eaa475b1a..a1303a453 100644 --- a/UI/Shared/Modal/Controller.js +++ b/UI/Shared/Modal/Controller.js @@ -5,9 +5,9 @@ define( 'marionette', 'Series/Edit/EditSeriesView', 'Series/Delete/DeleteSeriesView', - 'Episode/Layout' - - ], function (App, Marionette, EditSeriesView, DeleteSeriesView, EpisodeLayout) { + 'Episode/Layout', + 'History/Details/HistoryDetailsView' + ], function (App, Marionette, EditSeriesView, DeleteSeriesView, EpisodeLayout, HistoryDetailsView) { var router = Marionette.AppRouter.extend({ @@ -16,6 +16,7 @@ define( App.vent.on(App.Commands.EditSeriesCommand, this._editSeries, this); App.vent.on(App.Commands.DeleteSeriesCommand, this._deleteSeries, this); App.vent.on(App.Commands.ShowEpisodeDetails, this._showEpisode, this); + App.vent.on(App.Commands.ShowHistoryDetails, this._showHistory, this); }, _closeModal: function () { @@ -35,6 +36,11 @@ define( _showEpisode: function (options) { var view = new EpisodeLayout({ model: options.episode, hideSeriesLink: options.hideSeriesLink }); App.modalRegion.show(view); + }, + + _showHistory: function (options) { + var view = new HistoryDetailsView({ model: options.history }); + App.modalRegion.show(view); } }); diff --git a/UI/app.js b/UI/app.js index 4f0406162..c3ba25d6f 100644 --- a/UI/app.js +++ b/UI/app.js @@ -196,6 +196,7 @@ define( DeleteSeriesCommand: 'DeleteSeriesCommand', CloseModalCommand : 'CloseModalCommand', ShowEpisodeDetails : 'ShowEpisodeDetails', + ShowHistoryDetails : 'ShowHistryDetails', SaveSettings : 'saveSettings', ShowLogFile : 'showLogFile' };