UI Updates (Cancel Import, Move Artist, Manual Import from Artist)

Ability to cancel an import lookup/search at any point.
Ability to move artist path from Artist Edit or bulk move from Mass Editor.
Trigger manual import for Artist path from Artist Detail page.
Pulled from Sonarr
This commit is contained in:
Qstick 2017-12-29 22:23:04 -05:00
parent 5fae202760
commit d8c89f5bbd
79 changed files with 1075 additions and 376 deletions

View file

@ -1,7 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using Nancy;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Music;
using NzbDrone.Core.Music.Commands;
using Lidarr.Http.Extensions;
namespace Lidarr.Api.V1.Artist
@ -9,11 +12,13 @@ namespace Lidarr.Api.V1.Artist
public class ArtistEditorModule : LidarrV1Module
{
private readonly IArtistService _artistService;
private readonly IManageCommandQueue _commandQueueManager;
public ArtistEditorModule(IArtistService artistService)
public ArtistEditorModule(IArtistService artistService, IManageCommandQueue commandQueueManager)
: base("/artist/editor")
{
_artistService = artistService;
_commandQueueManager = commandQueueManager;
Put["/"] = artist => SaveAll();
Delete["/"] = artist => DeleteArtist();
}
@ -22,6 +27,7 @@ namespace Lidarr.Api.V1.Artist
{
var resource = Request.Body.FromJson<ArtistEditorResource>();
var artistToUpdate = _artistService.GetArtists(resource.ArtistIds);
var artistToMove = new List<BulkMoveArtist>();
foreach (var artist in artistToUpdate)
{
@ -53,6 +59,12 @@ namespace Lidarr.Api.V1.Artist
if (resource.RootFolderPath.IsNotNullOrWhiteSpace())
{
artist.RootFolderPath = resource.RootFolderPath;
artistToMove.Add(new BulkMoveArtist
{
ArtistId = artist.Id,
SourcePath = artist.Path
});
}
if (resource.Tags != null)
@ -75,6 +87,15 @@ namespace Lidarr.Api.V1.Artist
}
}
if (resource.MoveFiles && artistToMove.Any())
{
_commandQueueManager.Push(new BulkMoveArtistCommand
{
DestinationRootFolder = resource.RootFolderPath,
Artist = artistToMove
});
}
return _artistService.UpdateArtists(artistToUpdate)
.ToResource()
.AsResponse(HttpStatusCode.Accepted);