diff --git a/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs b/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs new file mode 100644 index 000000000..40be1ab5e --- /dev/null +++ b/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using NzbDrone.Api.REST; +using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.Tv; +using NzbDrone.Api.Extensions; +using System.Linq; +using Omu.ValueInjecter; + +namespace NzbDrone.Api.EpisodeFiles +{ + public class EpisodeModule : NzbDroneRestModule + { + private readonly IMediaFileService _mediaFileService; + + public EpisodeModule(IMediaFileService mediaFileService) + : base("/episodefile") + { + _mediaFileService = mediaFileService; + + UpdateResource = SetQuality; + } + + private EpisodeFileResource SetQuality(EpisodeFileResource episodeFileResource) + { + var episodeFile = _mediaFileService.Get(episodeFileResource.Id); + episodeFile.Quality = episodeFileResource.Quality; + + _mediaFileService.Update(episodeFile); + episodeFileResource.InjectFrom(episodeFile); + + return episodeFileResource; + } + } +} \ No newline at end of file diff --git a/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs b/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs new file mode 100644 index 000000000..f3bd37368 --- /dev/null +++ b/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs @@ -0,0 +1,17 @@ +using System; +using NzbDrone.Api.REST; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Api.EpisodeFiles +{ + public class EpisodeFileResource : RestResource + { + public Int32 SeriesId { get; set; } + public Int32 SeasonNumber { get; set; } + public String Path { get; set; } + public Int64 Size { get; set; } + public DateTime DateAdded { get; set; } + public String SceneName { get; set; } + public QualityModel Quality { get; set; } + } +} diff --git a/NzbDrone.Api/NzbDrone.Api.csproj b/NzbDrone.Api/NzbDrone.Api.csproj index 58414d8dc..06f3cb936 100644 --- a/NzbDrone.Api/NzbDrone.Api.csproj +++ b/NzbDrone.Api/NzbDrone.Api.csproj @@ -85,6 +85,8 @@ + + diff --git a/NzbDrone.Core/MediaFiles/MediaFileService.cs b/NzbDrone.Core/MediaFiles/MediaFileService.cs index 784a09c02..a2fe8ba22 100644 --- a/NzbDrone.Core/MediaFiles/MediaFileService.cs +++ b/NzbDrone.Core/MediaFiles/MediaFileService.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using NLog; @@ -18,6 +19,7 @@ public interface IMediaFileService List GetFilesBySeries(int seriesId); List GetFilesBySeason(int seriesId, int seasonNumber); List FilterExistingFiles(List files, int seriesId); + EpisodeFile Get(int id); } public class MediaFileService : IMediaFileService, IHandleAsync @@ -81,6 +83,11 @@ public List FilterExistingFiles(List files, int seriesId) return files.Select(f => f.CleanFilePath().ToLower()).Except(seriesFiles).ToList(); } + public EpisodeFile Get(int id) + { + return _mediaFileRepository.Get(id); + } + public void HandleAsync(SeriesDeletedEvent message) { var files = GetFilesBySeries(message.Series.Id); diff --git a/UI/Cells/Edit/QualityCellEditor.js b/UI/Cells/Edit/QualityCellEditor.js index a9bb9c856..d92c9be03 100644 --- a/UI/Cells/Edit/QualityCellEditor.js +++ b/UI/Cells/Edit/QualityCellEditor.js @@ -51,6 +51,7 @@ define( }; model.set(column.get("name"), newQuality); + model.save(); model.trigger("backgrid:edited", model, column, new Backgrid.Command(e)); }, diff --git a/UI/Cells/EpisodeStatusCell.js b/UI/Cells/EpisodeStatusCell.js index bef528f72..3f335cefa 100644 --- a/UI/Cells/EpisodeStatusCell.js +++ b/UI/Cells/EpisodeStatusCell.js @@ -23,8 +23,8 @@ define( if (hasFile) { var episodeFile = this.model.get('episodeFile'); - var quality = episodeFile.quality; - var size = FormatHelpers.bytes(episodeFile.size); + var quality = episodeFile.get('quality'); + var size = FormatHelpers.bytes(episodeFile.get('size')); var title = 'Episode downloaded'; if (quality.proper) { diff --git a/UI/Episode/Layout.js b/UI/Episode/Layout.js index 8634d6b46..bfb75aca9 100644 --- a/UI/Episode/Layout.js +++ b/UI/Episode/Layout.js @@ -36,7 +36,6 @@ define( this._setMonitoredState(); }, - _showSummary: function (e) { if (e) { e.preventDefault(); diff --git a/UI/Series/EpisodeFileModel.js b/UI/Series/EpisodeFileModel.js new file mode 100644 index 000000000..25ece8c7c --- /dev/null +++ b/UI/Series/EpisodeFileModel.js @@ -0,0 +1,9 @@ +'use strict'; +define( + [ + 'backbone' + ], function (Backbone) { + return Backbone.Model.extend({ + url: window.ApiRoot + '/episodefile' + }); + }); diff --git a/UI/Series/EpisodeModel.js b/UI/Series/EpisodeModel.js index bdfaeedab..713ded3ee 100644 --- a/UI/Series/EpisodeModel.js +++ b/UI/Series/EpisodeModel.js @@ -3,8 +3,9 @@ define( [ 'backbone', 'moment', - 'Series/SeriesModel' - ], function (Backbone, Moment, SeriesModel) { + 'Series/SeriesModel', + 'Series/EpisodeFileModel' + ], function (Backbone, Moment, SeriesModel, EpisodeFileModel) { return Backbone.Model.extend({ initialize: function () { @@ -19,6 +20,10 @@ define( parse: function (model) { model.series = new SeriesModel(model.series); + if (model.episodeFile) { + model.episodeFile = new EpisodeFileModel(model.episodeFile); + } + return model; },