diff --git a/NzbDrone.Api/History/HistoryResource.cs b/NzbDrone.Api/History/HistoryResource.cs index 447484c5d..0251e9354 100644 --- a/NzbDrone.Api/History/HistoryResource.cs +++ b/NzbDrone.Api/History/HistoryResource.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using NzbDrone.Api.REST; +using NzbDrone.Core.History; using NzbDrone.Core.Tv; namespace NzbDrone.Api.History @@ -15,7 +17,11 @@ public class HistoryResource : RestResource public string NzbInfoUrl { get; set; } public string ReleaseGroup { get; set; } + public HistoryEventType EventType { get; set; } + + public Dictionary Data { get; set; } + public Episode Episode { get; set; } - public Core.Tv.Series Series { get; set; } + public Core.Tv.Series Series { get; set; } } } diff --git a/NzbDrone.Core/Datastore/Migration/005_added_eventtype_to_history.cs b/NzbDrone.Core/Datastore/Migration/005_added_eventtype_to_history.cs new file mode 100644 index 000000000..566acfff0 --- /dev/null +++ b/NzbDrone.Core/Datastore/Migration/005_added_eventtype_to_history.cs @@ -0,0 +1,18 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Tags("")] + [Migration(5)] + public class added_eventtype_to_history : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("History") + .AddColumn("EventType") + .AsInt32() + .Nullable(); + } + } +} diff --git a/NzbDrone.Core/History/History.cs b/NzbDrone.Core/History/History.cs index 76d2ed379..886ae9c4e 100644 --- a/NzbDrone.Core/History/History.cs +++ b/NzbDrone.Core/History/History.cs @@ -21,7 +21,18 @@ public History() public Episode Episode { get; set; } public Series Series { get; set; } + public HistoryEventType EventType { get; set; } + public Dictionary Data { get; set; } } + + public enum HistoryEventType + { + Unknown = 0, + Grabbed = 1, + SeriesFolderImported = 2, + DownloadFolderImported = 3 + } + } \ No newline at end of file diff --git a/NzbDrone.Core/History/HistoryService.cs b/NzbDrone.Core/History/HistoryService.cs index 6a334cfe2..48f7ebbf8 100644 --- a/NzbDrone.Core/History/HistoryService.cs +++ b/NzbDrone.Core/History/HistoryService.cs @@ -61,6 +61,7 @@ public void Handle(EpisodeGrabbedEvent message) { var history = new History { + EventType = HistoryEventType.Grabbed, Date = DateTime.UtcNow, Quality = message.Episode.ParsedEpisodeInfo.Quality, SourceTitle = message.Episode.Report.Title, @@ -83,6 +84,7 @@ public void Handle(EpisodeImportedEvent message) { var history = new History { + EventType = HistoryEventType.DownloadFolderImported, Date = DateTime.UtcNow, Quality = message.EpisodeFile.Quality, SourceTitle = message.EpisodeFile.Path, diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index d4a6484f4..8596816b0 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -211,6 +211,7 @@ + diff --git a/UI/Cells/NzbDroneCell.js b/UI/Cells/NzbDroneCell.js index 9d4e619f0..580ba0273 100644 --- a/UI/Cells/NzbDroneCell.js +++ b/UI/Cells/NzbDroneCell.js @@ -22,18 +22,18 @@ define(['app'], function () { var name = this.column.get('name'); - if(name === 'this'){ + if (name === 'this') { return this.model; } var value = this.model.get(name); - if(!value){ + if (!value) { return undefined; } //if not a model - if (!value.get) { + if (!value.get && typeof value === 'object') { value = new Backbone.Model(value); } diff --git a/UI/Cells/cells.less b/UI/Cells/cells.less index f4efe0cc4..a58aeceeb 100644 --- a/UI/Cells/cells.less +++ b/UI/Cells/cells.less @@ -17,3 +17,7 @@ .quality-cell{ width: 130px; } + +.history-event-type-cell{ + width : 10px; +} diff --git a/UI/History/EventTypeCell.js b/UI/History/EventTypeCell.js new file mode 100644 index 000000000..c6871e330 --- /dev/null +++ b/UI/History/EventTypeCell.js @@ -0,0 +1,37 @@ +"use strict"; + +define(['app', 'Cells/NzbDroneCell' ], function () { + NzbDrone.History.EventTypeCell = NzbDrone.Cells.NzbDroneCell.extend({ + + className: 'history-event-type-cell', + + render: function () { + this.$el.empty(); + + if (this.cellValue) { + + var icon = 'icon-question'; + var toolTip = 'unknow event'; + + switch (this.cellValue) { + case 'grabbed': + icon = 'icon-cloud-download'; + toolTip = 'Episode grabbed from indexer and sent to download client'; + break; + case 'seriesFolderImported': + icon = 'icon-hdd'; + toolTip = 'Existing episode file added to library'; + break; + case 'DownloadFolderImported': + icon = 'icon-download-alt'; + toolTip = 'Episode downloaded succesfully and picked up from download client'; + break; + } + + this.$el.html(''.format(icon, toolTip)); + } + + return this; + } + }); +}); diff --git a/UI/History/HistoryLayout.js b/UI/History/HistoryLayout.js index 2610a2b06..079b04367 100644 --- a/UI/History/HistoryLayout.js +++ b/UI/History/HistoryLayout.js @@ -2,8 +2,8 @@ define([ 'app', 'History/Collection', + 'History/EventTypeCell', 'Cells/RelativeDateCell', - 'Cells/IndexerCell', 'Cells/TemplatedCell', 'Cells/SeriesTitleCell', 'Cells/EpisodeNumberCell', @@ -24,9 +24,9 @@ define([ columns: [ { - name : 'indexer', - label: '', - cell : NzbDrone.Cells.IndexerCell + name: 'eventType', + label:'', + cell : NzbDrone.History.EventTypeCell }, { name : 'series',