From d4b79b9c41ba141a85312883dace78cff3ab5c01 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 8 Jul 2017 08:13:16 -0400 Subject: [PATCH] Fixed: Artist Editor View and API Backend (#29) Fixed: Artist Editor View and API Backend --- src/NzbDrone.Api/Music/ArtistEditorModule.cs | 31 +++++++++++++++++++ src/NzbDrone.Api/NzbDrone.Api.csproj | 1 + .../Editor/ArtistEditorFooterViewTemplate.hbs | 4 +-- src/UI/Artist/Editor/ArtistEditorLayout.js | 8 ++--- ...ArtistFolderCell.js => AlbumFolderCell.js} | 5 ++- 5 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 src/NzbDrone.Api/Music/ArtistEditorModule.cs rename src/UI/Cells/{ArtistFolderCell.js => AlbumFolderCell.js} (62%) diff --git a/src/NzbDrone.Api/Music/ArtistEditorModule.cs b/src/NzbDrone.Api/Music/ArtistEditorModule.cs new file mode 100644 index 000000000..ca8ec3598 --- /dev/null +++ b/src/NzbDrone.Api/Music/ArtistEditorModule.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using System.Linq; +using Nancy; +using NzbDrone.Api.Extensions; +using NzbDrone.Core.Music; + +namespace NzbDrone.Api.Music +{ + public class ArtistEditorModule : NzbDroneApiModule + { + private readonly IArtistService _artistService; + + public ArtistEditorModule(IArtistService seriesService) + : base("/artist/editor") + { + _artistService = seriesService; + Put["/"] = artist => SaveAll(); + } + + private Response SaveAll() + { + var resources = Request.Body.FromJson>(); + + var artist = resources.Select(artistResource => artistResource.ToModel(_artistService.GetArtist(artistResource.Id))).ToList(); + + return _artistService.UpdateArtists(artist) + .ToResource() + .AsResponse(HttpStatusCode.Accepted); + } + } +} diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj index 166066512..3c8875fcd 100644 --- a/src/NzbDrone.Api/NzbDrone.Api.csproj +++ b/src/NzbDrone.Api/NzbDrone.Api.csproj @@ -108,6 +108,7 @@ + diff --git a/src/UI/Artist/Editor/ArtistEditorFooterViewTemplate.hbs b/src/UI/Artist/Editor/ArtistEditorFooterViewTemplate.hbs index 91a9aaea7..6f92ca1a4 100644 --- a/src/UI/Artist/Editor/ArtistEditorFooterViewTemplate.hbs +++ b/src/UI/Artist/Editor/ArtistEditorFooterViewTemplate.hbs @@ -22,9 +22,9 @@
- + - diff --git a/src/UI/Artist/Editor/ArtistEditorLayout.js b/src/UI/Artist/Editor/ArtistEditorLayout.js index 822d8e4b2..7325e82a4 100644 --- a/src/UI/Artist/Editor/ArtistEditorLayout.js +++ b/src/UI/Artist/Editor/ArtistEditorLayout.js @@ -6,7 +6,7 @@ var ArtistCollection = require('../ArtistCollection'); var ArtistTitleCell = require('../../Cells/ArtistTitleCell'); var ProfileCell = require('../../Cells/ProfileCell'); var ArtistStatusCell = require('../../Cells/ArtistStatusCell'); -var ArtistFolderCell = require('../../Cells/ArtistFolderCell'); +var AlbumFolderCell = require('../../Cells/AlbumFolderCell'); var SelectAllCell = require('../../Cells/SelectAllCell'); var ToolbarLayout = require('../../Shared/Toolbar/ToolbarLayout'); var FooterView = require('./ArtistEditorFooterView'); @@ -56,9 +56,9 @@ module.exports = Marionette.Layout.extend({ cell : ProfileCell }, { - name : 'artistFolder', - label : 'Artist Folder', - cell : ArtistFolderCell + name : 'albumFolder', + label : 'Album Folder', + cell : AlbumFolderCell }, { name : 'path', diff --git a/src/UI/Cells/ArtistFolderCell.js b/src/UI/Cells/AlbumFolderCell.js similarity index 62% rename from src/UI/Cells/ArtistFolderCell.js rename to src/UI/Cells/AlbumFolderCell.js index 8e1052fe9..bb5173a5c 100644 --- a/src/UI/Cells/ArtistFolderCell.js +++ b/src/UI/Cells/AlbumFolderCell.js @@ -5,9 +5,8 @@ module.exports = Backgrid.Cell.extend({ render : function() { this.$el.empty(); - - var artistFolder = this.model.get(this.column.get('name')); - this.$el.html(artistFolder.toString()); + var albumFolder = this.model.get(this.column.get('name')); + this.$el.html(albumFolder.toString()); return this; }