Quality of an existing movie file can now be edited.

pull/2/head
Leonardo Galli 8 years ago
parent c6912a193c
commit 5e9a79afe8

@ -35,21 +35,21 @@ namespace NzbDrone.Api.EpisodeFiles
_seriesService = seriesService;
_qualityUpgradableSpecification = qualityUpgradableSpecification;
_logger = logger;
/*GetResourceById = GetEpisodeFile;
GetResourceAll = GetEpisodeFiles;
GetResourceById = GetMovieFile;
/*GetResourceAll = GetEpisodeFiles;
UpdateResource = SetQuality;*/
UpdateResource = SetQuality;
DeleteResource = DeleteEpisodeFile;
}
/*private EpisodeFileResource GetEpisodeFile(int id)
private MovieFileResource GetMovieFile(int id)
{
var episodeFile = _mediaFileService.Get(id);
var series = _seriesService.GetSeries(episodeFile.SeriesId);
var episodeFile = _mediaFileService.GetMovie(id);
return episodeFile.ToResource(series, _qualityUpgradableSpecification);
return episodeFile.ToResource();
}
private List<EpisodeFileResource> GetEpisodeFiles()
/*private List<EpisodeFileResource> GetEpisodeFiles()
{
if (!Request.Query.SeriesId.HasValue)
{
@ -62,13 +62,13 @@ namespace NzbDrone.Api.EpisodeFiles
return _mediaFileService.GetFilesBySeries(seriesId).ConvertAll(f => f.ToResource(series, _qualityUpgradableSpecification));
}
private void SetQuality(EpisodeFileResource episodeFileResource)
*/
private void SetQuality(MovieFileResource episodeFileResource)
{
var episodeFile = _mediaFileService.Get(episodeFileResource.Id);
var episodeFile = _mediaFileService.GetMovie(episodeFileResource.Id);
episodeFile.Quality = episodeFileResource.Quality;
_mediaFileService.Update(episodeFile);
}*/
}
private void DeleteEpisodeFile(int id)
{

@ -61,6 +61,8 @@ module.exports = Marionette.Layout.extend({
this.listenTo(this.model, 'change:monitored', this._setMonitoredState);
this.listenTo(this.model, 'remove', this._moviesRemoved);
this.listenTo(this.model, "change:movieFile", this._refreshFiles);
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
this.listenTo(this.model, 'change', function(model, options) {
@ -268,7 +270,6 @@ module.exports = Marionette.Layout.extend({
//this.seasonCollection.add(this.model.get('seasons'), { merge : true });
//this.episodeCollection.fetch();
//this.episodeFileCollection.fetch();
this._setMonitoredState();
this._showInfo();
},

@ -0,0 +1,32 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{{relativePath}}</h3>
</div>
<div class="modal-body edit-series-modal">
<div class="row">
<div class="col-sm-12">
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-4 control-label">Quality</label>
<div class="col-sm-4">
<select class="form-control x-quality" id="inputProfile" name="qualityId">
{{#each qualities}}
<option value="{{quality.id}}">{{quality.name}}</option>
{{/each}}
</select>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<span class="indicator x-indicator"><i class="icon-sonarr-spinner fa-spin"></i></span>
<button class="btn" data-dismiss="modal">Cancel</button>
<button class="btn btn-primary x-save">Save</button>
</div>
</div>

@ -0,0 +1,60 @@
var vent = require('vent');
var Marionette = require('marionette');
var Qualities = require('../../../Quality/QualityDefinitionCollection');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var AsEditModalView = require('../../../Mixins/AsEditModalView');
require('../../../Mixins/TagInput');
require('../../../Mixins/FileBrowser');
var view = Marionette.ItemView.extend({
template : 'Movies/Files/Edit/EditFileTemplate',
ui : {
quality : '.x-quality',
path : '.x-path',
tags : '.x-tags'
},
events : {
},
initialize : function() {
this.qualities = new Qualities();
var self = this;
this.listenTo(this.qualities, 'all', this._qualitiesUpdated);
this.qualities.fetch()
},
onRender : function() {
this.ui.quality.val(this.model.get("quality").quality.id)
},
_onBeforeSave : function() {
var qualityId = this.ui.quality.val();
var quality = this.qualities.find(function(m){return m.get("quality").id == qualityId}).get("quality");
var mQuality = this.model.get("quality");
mQuality.quality = quality;
this.model.set({ quality : mQuality });
},
_qualitiesUpdated : function() {
this.templateHelpers = {};
this.templateHelpers.qualities = this.qualities.toJSON();
this.render();
},
_onAfterSave : function() {
this.trigger('saved');
vent.trigger(vent.Commands.CloseModalCommand);
},
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
module.exports = view;

@ -0,0 +1,22 @@
var vent = require('vent');
var Backgrid = require('backgrid');
module.exports = Backgrid.Cell.extend({
className : 'edit-episode-file-cell',
events : {
'click' : '_onClick'
},
render : function() {
this.$el.empty();
this.$el.html('<i class="icon-sonarr-edit" title="Edit information about this file."></i>');
return this;
},
_onClick : function() {
var self = this;
vent.trigger(vent.Commands.EditFileCommand, { file : this.model });
}
});

@ -19,6 +19,7 @@ var ProtocolCell = require('../../Release/ProtocolCell');
var PeersCell = require('../../Release/PeersCell');
var EditionCell = require('../../Cells/EditionCell');
var DeleteFileCell = require("./DeleteFileCell");
var EditFileCell = require("./EditFileCell");
module.exports = Marionette.Layout.extend({
template : 'Movies/Files/FilesLayoutTemplate',
@ -65,6 +66,11 @@ module.exports = Marionette.Layout.extend({
name : "delete",
label : "",
cell : DeleteFileCell,
},
{
name : "edit",
label : "",
cell : EditFileCell,
}
],
@ -72,8 +78,30 @@ module.exports = Marionette.Layout.extend({
initialize : function(movie) {
this.filesCollection = new FilesCollection();
var file = movie.model.get("movieFile");
this.movie = movie;
this.filesCollection.add(file);
//this.listenTo(this.releaseCollection, 'sync', this._showSearchResults);
this.listenTo(this.model, 'change', function(model, options) {
if (options && options.changeSource === 'signalr') {
this._refresh(movie);
}
});
vent.on(vent.Commands.CloseModalCommand, this._refreshClose, this);
},
_refresh : function(movie) {
this.filesCollection = new FilesCollection();
var file = movie.model.get("movieFile");
this.filesCollection.add(file);
this.onShow();
},
_refreshClose : function(options) {
this.filesCollection = new FilesCollection();
var file = this.movie.model.get("movieFile");
this.filesCollection.add(file);
this.onShow();
},
onShow : function() {

@ -11,6 +11,7 @@ var RenamePreviewLayout = require('../../Rename/RenamePreviewLayout');
var ManualImportLayout = require('../../ManualImport/ManualImportLayout');
var FileBrowserLayout = require('../FileBrowser/FileBrowserLayout');
var MoviesDetailsLayout = require('../../Movies/Details/MoviesDetailsLayout');
var EditFileView = require("../../Movies/Files/Edit/EditFileView");
module.exports = Marionette.AppRouter.extend({
initialize : function() {
@ -20,6 +21,7 @@ module.exports = Marionette.AppRouter.extend({
vent.on(vent.Commands.CloseModal2Command, this._closeModal2, this);
vent.on(vent.Commands.EditSeriesCommand, this._editSeries, this);
vent.on(vent.Commands.EditMovieCommand, this._editMovie, this);
vent.on(vent.Commands.EditFileCommand, this._editFile, this);
vent.on(vent.Commands.DeleteSeriesCommand, this._deleteSeries, this);
vent.on(vent.Commands.ShowEpisodeDetails, this._showEpisode, this);
vent.on(vent.Commands.ShowMovieDetails, this._showMovie, this);
@ -57,6 +59,11 @@ module.exports = Marionette.AppRouter.extend({
AppLayout.modalRegion.show(view);
},
_editFile : function(options) {
var view = new EditFileView({ model : options.file });
AppLayout.modalRegion.show(view);
},
_deleteSeries : function(options) {
var view = new DeleteSeriesView({ model : options.series });
AppLayout.modalRegion.show(view);

@ -13,6 +13,7 @@ vent.Events = {
vent.Commands = {
EditSeriesCommand : 'EditSeriesCommand',
EditMovieCommand : 'EditMovieCommand',
EditFileCommand : "EditFileCommand",
DeleteSeriesCommand : 'DeleteSeriesCommand',
OpenModalCommand : 'OpenModalCommand',
CloseModalCommand : 'CloseModalCommand',

Loading…
Cancel
Save