mirror of https://github.com/Radarr/Radarr
New: Rename all selected series from the series editor
This commit is contained in:
parent
98858bd237
commit
33ebf1bf78
|
@ -0,0 +1,22 @@
|
|||
using System.Collections.Generic;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.Commands
|
||||
{
|
||||
public class RenameSeriesCommand : Command
|
||||
{
|
||||
public List<int> SeriesIds { get; set; }
|
||||
|
||||
public override bool SendUpdatesToClient
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public RenameSeriesCommand()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,7 +21,8 @@ namespace NzbDrone.Core.MediaFiles
|
|||
}
|
||||
|
||||
public class RenameEpisodeFileService : IRenameEpisodeFileService,
|
||||
IExecute<RenameFilesCommand>
|
||||
IExecute<RenameFilesCommand>,
|
||||
IExecute<RenameSeriesCommand>
|
||||
{
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly IMediaFileService _mediaFileService;
|
||||
|
@ -145,7 +146,21 @@ namespace NzbDrone.Core.MediaFiles
|
|||
|
||||
_logger.ProgressInfo("Renaming {0} files for {1}", episodeFiles.Count, series.Title);
|
||||
RenameFiles(episodeFiles, series);
|
||||
_logger.ProgressInfo("Selected Episode Files renamed for {0}", series.Title);
|
||||
_logger.ProgressInfo("Selected episode files renamed for {0}", series.Title);
|
||||
}
|
||||
|
||||
public void Execute(RenameSeriesCommand message)
|
||||
{
|
||||
_logger.Trace("Renaming all files for selected series");
|
||||
var seriesToRename = _seriesService.GetSeries(message.SeriesIds);
|
||||
|
||||
foreach (var series in seriesToRename)
|
||||
{
|
||||
var episodeFiles = _mediaFileService.GetFilesBySeries(series.Id);
|
||||
_logger.ProgressInfo("Renaming all files in series: {0}", series.Title);
|
||||
RenameFiles(episodeFiles, series);
|
||||
_logger.ProgressInfo("All episode files renamed for {0}", series.Title);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -308,6 +308,7 @@
|
|||
<Compile Include="Instrumentation\Commands\DeleteLogFilesCommand.cs" />
|
||||
<Compile Include="Instrumentation\Commands\TrimLogCommand.cs" />
|
||||
<Compile Include="Instrumentation\DeleteLogFilesService.cs" />
|
||||
<Compile Include="MediaFiles\Commands\RenameSeriesCommand.cs" />
|
||||
<Compile Include="MediaFiles\Commands\RescanSeriesCommand.cs" />
|
||||
<Compile Include="Lifecycle\Commands\ShutdownCommand.cs" />
|
||||
<Compile Include="Lifecycle\Commands\RestartCommand.cs" />
|
||||
|
|
|
@ -4,7 +4,6 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.DataAugmentation.Scene;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Organizer;
|
||||
|
@ -15,6 +14,7 @@ namespace NzbDrone.Core.Tv
|
|||
public interface ISeriesService
|
||||
{
|
||||
Series GetSeries(int seriesId);
|
||||
List<Series> GetSeries(IEnumerable<int> seriesIds);
|
||||
Series AddSeries(Series newSeries);
|
||||
Series FindByTvdbId(int tvdbId);
|
||||
Series FindByTvRageId(int tvRageId);
|
||||
|
@ -58,6 +58,11 @@ namespace NzbDrone.Core.Tv
|
|||
return _seriesRepository.Get(seriesId);
|
||||
}
|
||||
|
||||
public List<Series> GetSeries(IEnumerable<int> seriesIds)
|
||||
{
|
||||
return _seriesRepository.Get(seriesIds).ToList();
|
||||
}
|
||||
|
||||
public Series AddSeries(Series newSeries)
|
||||
{
|
||||
Ensure.That(newSeries, () => newSeries).IsNotNull();
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'underscore',
|
||||
'vent',
|
||||
'backbone',
|
||||
'marionette',
|
||||
'Commands/CommandController'
|
||||
], function (_, vent, Backbone, Marionette, CommandController) {
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Series/Editor/Rename/RenameSeriesViewTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-confirm-rename': '_rename'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.series = options.series;
|
||||
|
||||
this.templateHelpers = { numberOfSeries: this.series.length, series: new Backbone.Collection(this.series).toJSON() };
|
||||
},
|
||||
|
||||
_rename: function () {
|
||||
var seriesIds = _.pluck(this.series, 'id');
|
||||
|
||||
CommandController.Execute('renameSeries', {
|
||||
name : 'renameSeries',
|
||||
seriesIds : seriesIds
|
||||
});
|
||||
|
||||
this.trigger('seriesRenamed');
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
});
|
||||
});
|
|
@ -0,0 +1,23 @@
|
|||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>Rename Selected Series</h3>
|
||||
</div>
|
||||
<div class="modal-body rename-series-modal">
|
||||
<div class="alert alert-info">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
You can use the rename function for an individual series to preview the rename
|
||||
</div>
|
||||
|
||||
Are you sure you want to rename all files in the {{numberOfSeries}} selected series?
|
||||
|
||||
{{debug}}
|
||||
<ul class="selected-series">
|
||||
{{#each series}}
|
||||
<li>{{title}}</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal">cancel</button>
|
||||
<button class="btn btn-danger x-confirm-rename">rename</button>
|
||||
</div>
|
|
@ -10,6 +10,7 @@ define(
|
|||
'AddSeries/RootFolders/RootFolderCollection',
|
||||
'Shared/Toolbar/ToolbarLayout',
|
||||
'AddSeries/RootFolders/RootFolderLayout',
|
||||
'Series/Editor/Rename/RenameSeriesView',
|
||||
'Config'
|
||||
], function (_,
|
||||
Marionette,
|
||||
|
@ -20,6 +21,7 @@ define(
|
|||
RootFolders,
|
||||
ToolbarLayout,
|
||||
RootFolderLayout,
|
||||
RenameSeriesView,
|
||||
Config) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Series/Editor/SeriesEditorFooterViewTemplate',
|
||||
|
@ -31,12 +33,14 @@ define(
|
|||
rootFolder : '.x-root-folder',
|
||||
selectedCount : '.x-selected-count',
|
||||
saveButton : '.x-save',
|
||||
renameButton : '.x-rename',
|
||||
container : '.series-editor-footer'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .x-save' : '_updateAndSave',
|
||||
'change .x-root-folder': '_rootFolderChanged'
|
||||
'change .x-root-folder': '_rootFolderChanged',
|
||||
'click .x-rename' : '_rename'
|
||||
},
|
||||
|
||||
templateHelpers: function () {
|
||||
|
@ -115,6 +119,7 @@ define(
|
|||
this.ui.seasonFolder.attr('disabled', '');
|
||||
this.ui.rootFolder.attr('disabled', '');
|
||||
this.ui.saveButton.attr('disabled', '');
|
||||
this.ui.renameButton.attr('disabled', '');
|
||||
}
|
||||
|
||||
else {
|
||||
|
@ -123,6 +128,7 @@ define(
|
|||
this.ui.seasonFolder.removeAttr('disabled', '');
|
||||
this.ui.rootFolder.removeAttr('disabled', '');
|
||||
this.ui.saveButton.removeAttr('disabled', '');
|
||||
this.ui.renameButton.removeAttr('disabled', '');
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -154,6 +160,14 @@ define(
|
|||
model.trigger('backgrid:select', model, false);
|
||||
model.edited = false;
|
||||
});
|
||||
},
|
||||
|
||||
_rename: function () {
|
||||
var selected = this.editorGrid.getSelectedModels();
|
||||
var renameSeriesView = new RenameSeriesView({ series: selected });
|
||||
this.listenToOnce(renameSeriesView, 'seriesRenamed', this._afterSave);
|
||||
|
||||
vent.trigger(vent.Commands.OpenModalCommand, renameSeriesView);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
<span class="pull-right">
|
||||
<span class="selected-count x-selected-count">0 series selected</span>
|
||||
<button class="btn btn-primary x-save">Save</button>
|
||||
<button class="btn btn-danger x-rename">Rename</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
|
@ -302,7 +302,7 @@
|
|||
//Editor
|
||||
|
||||
.series-editor-footer {
|
||||
width: 1100px;
|
||||
width: 1160px;
|
||||
color: #f5f5f5;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
|
@ -310,6 +310,16 @@
|
|||
.selected-count {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.row {
|
||||
margin-left: -40px;
|
||||
}
|
||||
}
|
||||
|
||||
.rename-series-modal {
|
||||
.selected-series {
|
||||
margin-top: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
//Series Details
|
||||
|
|
Loading…
Reference in New Issue