From 7595ccf6c48ec52cb697b22fa3f195070536861e Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Thu, 1 Jun 2017 08:49:14 +0100 Subject: [PATCH] Started the Radarr Settings #865 --- src/Ombi.Api.Radarr/IRadarrApi.cs | 15 +++ src/Ombi.Api.Radarr/Models/Cutoff.cs | 8 ++ src/Ombi.Api.Radarr/Models/Image.cs | 8 ++ src/Ombi.Api.Radarr/Models/Item.cs | 8 ++ src/Ombi.Api.Radarr/Models/MovieResponse.cs | 38 +++++++ src/Ombi.Api.Radarr/Models/Quality.cs | 8 ++ src/Ombi.Api.Radarr/Models/RadarrProfile.cs | 12 ++ .../Models/RadarrRootFolder.cs | 9 ++ src/Ombi.Api.Radarr/Models/Ratings.cs | 8 ++ src/Ombi.Api.Radarr/Models/SystemStatus.cs | 25 +++++ src/Ombi.Api.Radarr/Ombi.Api.Radarr.csproj | 17 +++ src/Ombi.Api.Radarr/RadarrApi.cs | 63 +++++++++++ src/Ombi.Core/Engine/BaseMediaEngine.cs | 1 + .../Engine/Interfaces/IMovieRequestEngine.cs | 1 + src/Ombi.Core/Engine/MovieRequestEngine.cs | 1 + src/Ombi.Core/Engine/MovieSearchEngine.cs | 1 + .../Requests/Movie/MovieRequestModel.cs | 8 +- .../Models/Requests/RequestService.cs | 3 +- src/Ombi.Core/MovieSender.cs | 72 ++++++++++++ src/Ombi.Core/MovieSenderResult.cs | 9 ++ .../Requests/Models/IRequestServiceMain.cs | 3 +- src/Ombi.DependencyInjection/IocExtensions.cs | 2 + .../Ombi.DependencyInjection.csproj | 1 + .../Models/External/RadarrSettings.cs | 13 +++ src/Ombi.sln | 7 ++ src/Ombi/Controllers/RequestController.cs | 1 + src/Ombi/Controllers/SettingsController.cs | 26 +++++ src/Ombi/Ombi.csproj | 18 +++ src/Ombi/wwwroot/app/interfaces/ISettings.ts | 8 ++ .../services/applications/radarr.service.ts | 20 ++++ .../wwwroot/app/services/settings.service.ts | 21 +++- .../app/settings/radarr/radarr.component.html | 104 ++++++++++++++++++ .../app/settings/radarr/radarr.component.ts | 80 ++++++++++++++ .../app/settings/sonarr/sonarr.component.ts | 51 +++++---- 34 files changed, 637 insertions(+), 33 deletions(-) create mode 100644 src/Ombi.Api.Radarr/IRadarrApi.cs create mode 100644 src/Ombi.Api.Radarr/Models/Cutoff.cs create mode 100644 src/Ombi.Api.Radarr/Models/Image.cs create mode 100644 src/Ombi.Api.Radarr/Models/Item.cs create mode 100644 src/Ombi.Api.Radarr/Models/MovieResponse.cs create mode 100644 src/Ombi.Api.Radarr/Models/Quality.cs create mode 100644 src/Ombi.Api.Radarr/Models/RadarrProfile.cs create mode 100644 src/Ombi.Api.Radarr/Models/RadarrRootFolder.cs create mode 100644 src/Ombi.Api.Radarr/Models/Ratings.cs create mode 100644 src/Ombi.Api.Radarr/Models/SystemStatus.cs create mode 100644 src/Ombi.Api.Radarr/Ombi.Api.Radarr.csproj create mode 100644 src/Ombi.Api.Radarr/RadarrApi.cs create mode 100644 src/Ombi.Core/MovieSender.cs create mode 100644 src/Ombi.Core/MovieSenderResult.cs create mode 100644 src/Ombi.Settings/Settings/Models/External/RadarrSettings.cs create mode 100644 src/Ombi/wwwroot/app/services/applications/radarr.service.ts create mode 100644 src/Ombi/wwwroot/app/settings/radarr/radarr.component.html create mode 100644 src/Ombi/wwwroot/app/settings/radarr/radarr.component.ts diff --git a/src/Ombi.Api.Radarr/IRadarrApi.cs b/src/Ombi.Api.Radarr/IRadarrApi.cs new file mode 100644 index 000000000..d3a5c8ed9 --- /dev/null +++ b/src/Ombi.Api.Radarr/IRadarrApi.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Ombi.Api.Radarr.Models; + +namespace Ombi.Api.Radarr +{ + public interface IRadarrApi + { + Task> GetMovies(string apiKey, Uri baseUrl); + Task> GetProfiles(string apiKey, Uri baseUrl); + Task> GetRootFolders(string apiKey, Uri baseUrl); + Task SystemStatus(string apiKey, Uri baseUrl); + } +} \ No newline at end of file diff --git a/src/Ombi.Api.Radarr/Models/Cutoff.cs b/src/Ombi.Api.Radarr/Models/Cutoff.cs new file mode 100644 index 000000000..ea2952bf0 --- /dev/null +++ b/src/Ombi.Api.Radarr/Models/Cutoff.cs @@ -0,0 +1,8 @@ +namespace Ombi.Api.Radarr.Models +{ + public class Cutoff + { + public int id { get; set; } + public string name { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi.Api.Radarr/Models/Image.cs b/src/Ombi.Api.Radarr/Models/Image.cs new file mode 100644 index 000000000..f52aa2b25 --- /dev/null +++ b/src/Ombi.Api.Radarr/Models/Image.cs @@ -0,0 +1,8 @@ +namespace Ombi.Api.Radarr.Models +{ + public class Image + { + public string coverType { get; set; } + public string url { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi.Api.Radarr/Models/Item.cs b/src/Ombi.Api.Radarr/Models/Item.cs new file mode 100644 index 000000000..29aa5c155 --- /dev/null +++ b/src/Ombi.Api.Radarr/Models/Item.cs @@ -0,0 +1,8 @@ +namespace Ombi.Api.Radarr.Models +{ + public class Item + { + public Quality quality { get; set; } + public bool allowed { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi.Api.Radarr/Models/MovieResponse.cs b/src/Ombi.Api.Radarr/Models/MovieResponse.cs new file mode 100644 index 000000000..dcf8a605a --- /dev/null +++ b/src/Ombi.Api.Radarr/Models/MovieResponse.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; + +namespace Ombi.Api.Radarr.Models +{ + public class MovieResponse + { + public string title { get; set; } + public string sortTitle { get; set; } + public double sizeOnDisk { get; set; } + public string status { get; set; } + public string overview { get; set; } + public string inCinemas { get; set; } + public string physicalRelease { get; set; } + public List images { get; set; } + public string website { get; set; } + public bool downloaded { get; set; } + public int year { get; set; } + public bool hasFile { get; set; } + public string youTubeTrailerId { get; set; } + public string studio { get; set; } + public string path { get; set; } + public int profileId { get; set; } + public bool monitored { get; set; } + public int runtime { get; set; } + public string lastInfoSync { get; set; } + public string cleanTitle { get; set; } + public string imdbId { get; set; } + public int tmdbId { get; set; } + public string titleSlug { get; set; } + public List genres { get; set; } + public List tags { get; set; } + public string added { get; set; } + public Ratings ratings { get; set; } + public List alternativeTitles { get; set; } + public int qualityProfileId { get; set; } + public int id { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi.Api.Radarr/Models/Quality.cs b/src/Ombi.Api.Radarr/Models/Quality.cs new file mode 100644 index 000000000..c02090ed4 --- /dev/null +++ b/src/Ombi.Api.Radarr/Models/Quality.cs @@ -0,0 +1,8 @@ +namespace Ombi.Api.Radarr.Models +{ + public class Quality + { + public int id { get; set; } + public string name { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi.Api.Radarr/Models/RadarrProfile.cs b/src/Ombi.Api.Radarr/Models/RadarrProfile.cs new file mode 100644 index 000000000..f9484e9c8 --- /dev/null +++ b/src/Ombi.Api.Radarr/Models/RadarrProfile.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace Ombi.Api.Radarr.Models +{ + public class RadarrProfile + { + public string name { get; set; } + public Cutoff cutoff { get; set; } + public List items { get; set; } + public int id { get; set; } + } +} diff --git a/src/Ombi.Api.Radarr/Models/RadarrRootFolder.cs b/src/Ombi.Api.Radarr/Models/RadarrRootFolder.cs new file mode 100644 index 000000000..127e2be68 --- /dev/null +++ b/src/Ombi.Api.Radarr/Models/RadarrRootFolder.cs @@ -0,0 +1,9 @@ +namespace Ombi.Api.Radarr.Models +{ + public class RadarrRootFolder + { + public int id { get; set; } + public string path { get; set; } + public long freespace { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi.Api.Radarr/Models/Ratings.cs b/src/Ombi.Api.Radarr/Models/Ratings.cs new file mode 100644 index 000000000..f62a7b163 --- /dev/null +++ b/src/Ombi.Api.Radarr/Models/Ratings.cs @@ -0,0 +1,8 @@ +namespace Ombi.Api.Radarr.Models +{ + public class Ratings + { + public int votes { get; set; } + public double value { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi.Api.Radarr/Models/SystemStatus.cs b/src/Ombi.Api.Radarr/Models/SystemStatus.cs new file mode 100644 index 000000000..0232dba24 --- /dev/null +++ b/src/Ombi.Api.Radarr/Models/SystemStatus.cs @@ -0,0 +1,25 @@ +namespace Ombi.Api.Radarr.Models +{ + public class SystemStatus + { + public string version { get; set; } + public string buildTime { get; set; } + public bool isDebug { get; set; } + public bool isProduction { get; set; } + public bool isAdmin { get; set; } + public bool isUserInteractive { get; set; } + public string startupPath { get; set; } + public string appData { get; set; } + public string osVersion { get; set; } + public bool isMonoRuntime { get; set; } + public bool isMono { get; set; } + public bool isLinux { get; set; } + public bool isOsx { get; set; } + public bool isWindows { get; set; } + public string branch { get; set; } + public string authentication { get; set; } + public string sqliteVersion { get; set; } + public string urlBase { get; set; } + public string runtimeVersion { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi.Api.Radarr/Ombi.Api.Radarr.csproj b/src/Ombi.Api.Radarr/Ombi.Api.Radarr.csproj new file mode 100644 index 000000000..4a5d91a95 --- /dev/null +++ b/src/Ombi.Api.Radarr/Ombi.Api.Radarr.csproj @@ -0,0 +1,17 @@ + + + + netstandard1.6 + + + + + + + + + ..\..\..\..\..\.nuget\packages\microsoft.extensions.logging.abstractions\1.1.1\lib\netstandard1.1\Microsoft.Extensions.Logging.Abstractions.dll + + + + \ No newline at end of file diff --git a/src/Ombi.Api.Radarr/RadarrApi.cs b/src/Ombi.Api.Radarr/RadarrApi.cs new file mode 100644 index 000000000..eb543bb41 --- /dev/null +++ b/src/Ombi.Api.Radarr/RadarrApi.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Ombi.Api.Radarr.Models; + +namespace Ombi.Api.Radarr +{ + public class RadarrApi : IRadarrApi + { + public RadarrApi(ILogger logger) + { + Api = new Api(); + Logger = logger; + } + + private Api Api { get; } + private ILogger Logger { get; } + + public async Task> GetProfiles(string apiKey, Uri baseUrl) + { + var request = new Request(baseUrl.ToString(), "/api/profile", HttpMethod.Get); + + AddHeaders(request, apiKey); + return await Api.Request>(request); + } + + public async Task> GetRootFolders(string apiKey, Uri baseUrl) + { + var request = new Request(baseUrl.ToString(), "/api/rootfolder", HttpMethod.Get); + + AddHeaders(request, apiKey); + return await Api.Request>(request); + } + + public async Task SystemStatus(string apiKey, Uri baseUrl) + { + var request = new Request(baseUrl.ToString(), "/api/system/status", HttpMethod.Get); + AddHeaders(request, apiKey); + + return await Api.Request(request); + } + + public async Task> GetMovies(string apiKey, Uri baseUrl) + { + var request = new Request(baseUrl.ToString(), "/api/movie", HttpMethod.Get); + AddHeaders(request, apiKey); + + return await Api.Request>(request); + } + + /// + /// Adds the required headers and also the authorization header + /// + /// + /// + private void AddHeaders(Request request, string key) + { + request.AddHeader("X-Api-Key", key); + } + } +} diff --git a/src/Ombi.Core/Engine/BaseMediaEngine.cs b/src/Ombi.Core/Engine/BaseMediaEngine.cs index e07935c9f..4100ee09d 100644 --- a/src/Ombi.Core/Engine/BaseMediaEngine.cs +++ b/src/Ombi.Core/Engine/BaseMediaEngine.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Ombi.Core.Claims; using Ombi.Core.Engine.Interfaces; using Ombi.Core.Models.Requests; +using Ombi.Core.Models.Requests.Movie; using Ombi.Core.Requests.Models; using Ombi.Helpers; diff --git a/src/Ombi.Core/Engine/Interfaces/IMovieRequestEngine.cs b/src/Ombi.Core/Engine/Interfaces/IMovieRequestEngine.cs index 8649ecfde..f6548a73f 100644 --- a/src/Ombi.Core/Engine/Interfaces/IMovieRequestEngine.cs +++ b/src/Ombi.Core/Engine/Interfaces/IMovieRequestEngine.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Ombi.Core.Models.Requests; +using Ombi.Core.Models.Requests.Movie; using Ombi.Core.Models.Search; using Ombi.Store.Entities; diff --git a/src/Ombi.Core/Engine/MovieRequestEngine.cs b/src/Ombi.Core/Engine/MovieRequestEngine.cs index 09ba73be4..852e15129 100644 --- a/src/Ombi.Core/Engine/MovieRequestEngine.cs +++ b/src/Ombi.Core/Engine/MovieRequestEngine.cs @@ -8,6 +8,7 @@ using Hangfire; using Ombi.Api.TheMovieDb; using Ombi.Api.TvMaze; using Ombi.Core.Models.Requests; +using Ombi.Core.Models.Requests.Movie; using Ombi.Core.Models.Search; using Ombi.Core.Requests.Models; using Ombi.Store.Entities; diff --git a/src/Ombi.Core/Engine/MovieSearchEngine.cs b/src/Ombi.Core/Engine/MovieSearchEngine.cs index 5be8f2ff3..5368a58ee 100644 --- a/src/Ombi.Core/Engine/MovieSearchEngine.cs +++ b/src/Ombi.Core/Engine/MovieSearchEngine.cs @@ -8,6 +8,7 @@ using Ombi.Api.TheMovieDb; using Ombi.Api.TheMovieDb.Models; using Ombi.Core.IdentityResolver; using Ombi.Core.Models.Requests; +using Ombi.Core.Models.Requests.Movie; using Ombi.Core.Models.Search; using Ombi.Core.Requests.Models; using Ombi.Core.Settings; diff --git a/src/Ombi.Core/Models/Requests/Movie/MovieRequestModel.cs b/src/Ombi.Core/Models/Requests/Movie/MovieRequestModel.cs index d88d43953..40a2893fd 100644 --- a/src/Ombi.Core/Models/Requests/Movie/MovieRequestModel.cs +++ b/src/Ombi.Core/Models/Requests/Movie/MovieRequestModel.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Newtonsoft.Json; -using Ombi.Store.Entities; - -namespace Ombi.Core.Models.Requests +namespace Ombi.Core.Models.Requests.Movie { public class MovieRequestModel : BaseRequestModel { diff --git a/src/Ombi.Core/Models/Requests/RequestService.cs b/src/Ombi.Core/Models/Requests/RequestService.cs index 412ebd084..1f1cfd10f 100644 --- a/src/Ombi.Core/Models/Requests/RequestService.cs +++ b/src/Ombi.Core/Models/Requests/RequestService.cs @@ -1,4 +1,5 @@ -using Ombi.Core.Requests.Models; +using Ombi.Core.Models.Requests.Movie; +using Ombi.Core.Requests.Models; namespace Ombi.Core.Models.Requests { diff --git a/src/Ombi.Core/MovieSender.cs b/src/Ombi.Core/MovieSender.cs new file mode 100644 index 000000000..c29191e11 --- /dev/null +++ b/src/Ombi.Core/MovieSender.cs @@ -0,0 +1,72 @@ +using System.Threading.Tasks; +using Ombi.Core.Models.Requests; +using Ombi.Core.Models.Requests.Movie; +using Ombi.Core.Settings; +using Ombi.Settings.Settings.Models.External; + +namespace Ombi.Core +{ + public class MovieSender + { + + public MovieSender(ISettingsService radarrSettings) + { + RadarrSettings = radarrSettings; + } + + private ISettingsService RadarrSettings { get; } + + public async Task Send(MovieRequestModel model, string qualityId = "") + { + //var cpSettings = await CouchPotatoSettings.GetSettingsAsync(); + //var watcherSettings = await WatcherSettings.GetSettingsAsync(); + var radarrSettings = await RadarrSettings.GetSettingsAsync(); + + //if (cpSettings.Enabled) + //{ + // return SendToCp(model, cpSettings, string.IsNullOrEmpty(qualityId) ? cpSettings.ProfileId : qualityId); + //} + + //if (watcherSettings.Enabled) + //{ + // return SendToWatcher(model, watcherSettings); + //} + + if (radarrSettings.Enabled) + { + //return SendToRadarr(model, radarrSettings, qualityId); + } + + return new MovieSenderResult { Success = false, MovieSent = false, Message = "There are no movie providers enabled!"}; + } + + //private MovieSenderResult SendToRadarr(MovieRequestModel model, RadarrSettings settings, string qualityId) + //{ + // var qualityProfile = 0; + // if (!string.IsNullOrEmpty(qualityId)) // try to parse the passed in quality, otherwise use the settings default quality + // { + // int.TryParse(qualityId, out qualityProfile); + // } + + // if (qualityProfile <= 0) + // { + // int.TryParse(settings.QualityProfile, out qualityProfile); + // } + + // var rootFolderPath = model.RootFolderSelected <= 0 ? settings.FullRootPath : GetRootPath(model.RootFolderSelected, settings); + // var result = RadarrApi.AddMovie(model.ProviderId, model.Title, model.ReleaseDate.Year, qualityProfile, rootFolderPath, settings.ApiKey, settings.FullUri, true); + + // if (!string.IsNullOrEmpty(result.Error?.message)) + // { + // Log.Error(result.Error.message); + // return new MovieSenderResult { Result = false, Error = true, MovieSendingEnabled = true }; + // } + // if (!string.IsNullOrEmpty(result.title)) + // { + // return new MovieSenderResult { Result = true, MovieSendingEnabled = true }; + // } + // return new MovieSenderResult { Result = false, MovieSendingEnabled = true }; + //} + + } +} \ No newline at end of file diff --git a/src/Ombi.Core/MovieSenderResult.cs b/src/Ombi.Core/MovieSenderResult.cs new file mode 100644 index 000000000..83de6a2db --- /dev/null +++ b/src/Ombi.Core/MovieSenderResult.cs @@ -0,0 +1,9 @@ +namespace Ombi.Core +{ + public class MovieSenderResult + { + public bool Success { get; set; } + public string Message { get; set; } + public bool MovieSent { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi.Core/Requests/Models/IRequestServiceMain.cs b/src/Ombi.Core/Requests/Models/IRequestServiceMain.cs index c07b05039..d23078e61 100644 --- a/src/Ombi.Core/Requests/Models/IRequestServiceMain.cs +++ b/src/Ombi.Core/Requests/Models/IRequestServiceMain.cs @@ -1,4 +1,5 @@ -using Ombi.Core.Requests.Models; +using Ombi.Core.Models.Requests.Movie; +using Ombi.Core.Requests.Models; namespace Ombi.Core.Models.Requests { diff --git a/src/Ombi.DependencyInjection/IocExtensions.cs b/src/Ombi.DependencyInjection/IocExtensions.cs index 08128e8a6..9183c86c5 100644 --- a/src/Ombi.DependencyInjection/IocExtensions.cs +++ b/src/Ombi.DependencyInjection/IocExtensions.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.DependencyInjection; using Ombi.Api.Emby; using Ombi.Api.Plex; +using Ombi.Api.Radarr; using Ombi.Api.Sonarr; using Ombi.Api.TheMovieDb; using Ombi.Api.Trakt; @@ -55,6 +56,7 @@ namespace Ombi.DependencyInjection services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } public static void RegisterStore(this IServiceCollection services) diff --git a/src/Ombi.DependencyInjection/Ombi.DependencyInjection.csproj b/src/Ombi.DependencyInjection/Ombi.DependencyInjection.csproj index f89680a1b..213245732 100644 --- a/src/Ombi.DependencyInjection/Ombi.DependencyInjection.csproj +++ b/src/Ombi.DependencyInjection/Ombi.DependencyInjection.csproj @@ -13,6 +13,7 @@ + diff --git a/src/Ombi.Settings/Settings/Models/External/RadarrSettings.cs b/src/Ombi.Settings/Settings/Models/External/RadarrSettings.cs new file mode 100644 index 000000000..b76e56f6e --- /dev/null +++ b/src/Ombi.Settings/Settings/Models/External/RadarrSettings.cs @@ -0,0 +1,13 @@ +using Ombi.Core.Settings.Models.External; + +namespace Ombi.Settings.Settings.Models.External +{ + public class RadarrSettings : ExternalSettings + { + public bool Enabled { get; set; } + public string ApiKey { get; set; } + public string DefaultQualityProfile { get; set; } + public string DefaultRootPath { get; set; } + public string FullRootPath { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi.sln b/src/Ombi.sln index 5602d63f3..8b7c88743 100644 --- a/src/Ombi.sln +++ b/src/Ombi.sln @@ -59,6 +59,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.Trakt", "Ombi.Api. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Core.Tests", "Ombi.Core.Tests\Ombi.Core.Tests.csproj", "{FC6A8F7C-9722-4AE4-960D-277ACB0E81CB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.Radarr", "Ombi.Api.Radarr\Ombi.Api.Radarr.csproj", "{94D04C1F-E35A-499C-B0A0-9FADEBDF8336}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -141,6 +143,10 @@ Global {FC6A8F7C-9722-4AE4-960D-277ACB0E81CB}.Debug|Any CPU.Build.0 = Debug|Any CPU {FC6A8F7C-9722-4AE4-960D-277ACB0E81CB}.Release|Any CPU.ActiveCfg = Release|Any CPU {FC6A8F7C-9722-4AE4-960D-277ACB0E81CB}.Release|Any CPU.Build.0 = Release|Any CPU + {94D04C1F-E35A-499C-B0A0-9FADEBDF8336}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {94D04C1F-E35A-499C-B0A0-9FADEBDF8336}.Debug|Any CPU.Build.0 = Debug|Any CPU + {94D04C1F-E35A-499C-B0A0-9FADEBDF8336}.Release|Any CPU.ActiveCfg = Release|Any CPU + {94D04C1F-E35A-499C-B0A0-9FADEBDF8336}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -159,5 +165,6 @@ Global {6EE01B17-0966-4E11-8BC1-A5318A92AB1D} = {EA30DD15-6280-4687-B370-2956EC2E54E5} {3880375C-1A7E-4D75-96EC-63B954C42FEA} = {9293CA11-360A-4C20-A674-B9E794431BF5} {FC6A8F7C-9722-4AE4-960D-277ACB0E81CB} = {6F42AB98-9196-44C4-B888-D5E409F415A1} + {94D04C1F-E35A-499C-B0A0-9FADEBDF8336} = {9293CA11-360A-4C20-A674-B9E794431BF5} EndGlobalSection EndGlobal diff --git a/src/Ombi/Controllers/RequestController.cs b/src/Ombi/Controllers/RequestController.cs index 2b460dc0c..56e612366 100644 --- a/src/Ombi/Controllers/RequestController.cs +++ b/src/Ombi/Controllers/RequestController.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Ombi.Core.Engine; using Ombi.Core.Models.Requests; +using Ombi.Core.Models.Requests.Movie; using Ombi.Core.Models.Search; namespace Ombi.Controllers diff --git a/src/Ombi/Controllers/SettingsController.cs b/src/Ombi/Controllers/SettingsController.cs index b64235a6e..371a6c9ea 100644 --- a/src/Ombi/Controllers/SettingsController.cs +++ b/src/Ombi/Controllers/SettingsController.cs @@ -6,6 +6,7 @@ using Ombi.Core.Settings; using Ombi.Core.Settings.Models; using Ombi.Core.Settings.Models.External; using Ombi.Settings.Settings.Models; +using Ombi.Settings.Settings.Models.External; namespace Ombi.Controllers { @@ -81,6 +82,31 @@ namespace Ombi.Controllers return await Save(settings); } + [HttpGet("sonarr")] + [AllowAnonymous] + public async Task SonarrSettings() + { + return await Get(); + } + + [HttpPost("sonarr")] + public async Task SonarrSettings([FromBody]SonarrSettings settings) + { + return await Save(settings); + } + + [HttpGet("radarr")] + [AllowAnonymous] + public async Task RadarrSettings() + { + return await Get(); + } + + [HttpPost("radarr")] + public async Task RadarrSettings([FromBody]RadarrSettings settings) + { + return await Save(settings); + } private async Task Get() { diff --git a/src/Ombi/Ombi.csproj b/src/Ombi/Ombi.csproj index 5f2fa24ea..bd7ee7ca9 100644 --- a/src/Ombi/Ombi.csproj +++ b/src/Ombi/Ombi.csproj @@ -54,5 +54,23 @@ + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + diff --git a/src/Ombi/wwwroot/app/interfaces/ISettings.ts b/src/Ombi/wwwroot/app/interfaces/ISettings.ts index 395e1c3da..e24b61508 100644 --- a/src/Ombi/wwwroot/app/interfaces/ISettings.ts +++ b/src/Ombi/wwwroot/app/interfaces/ISettings.ts @@ -53,6 +53,14 @@ export interface ISonarrSettings extends IExternalSettings { fullRootPath:string, } +export interface IRadarrSettings extends IExternalSettings { + enabled: boolean, + apiKey: string, + defaultQualityProfile: string, + defaultRootPath: string, + fullRootPath:string, +} + export interface ILandingPageSettings extends ISettings { enabled: boolean, beforeLogin: boolean, diff --git a/src/Ombi/wwwroot/app/services/applications/radarr.service.ts b/src/Ombi/wwwroot/app/services/applications/radarr.service.ts new file mode 100644 index 000000000..21696c46f --- /dev/null +++ b/src/Ombi/wwwroot/app/services/applications/radarr.service.ts @@ -0,0 +1,20 @@ +import { Injectable } from '@angular/core'; +import { AuthHttp } from 'angular2-jwt'; +//import { Observable } from 'rxjs/Rx'; + +import { ServiceAuthHelpers } from '../service.helpers'; +//import { IRadarrSettings } from '../../interfaces/ISettings'; + +@Injectable() +export class RadarrService extends ServiceAuthHelpers { + constructor(http: AuthHttp) { + super(http, '/api/v1/Radarr'); + } + + // getRootFolders(settings: IRadarrSettings): Observable { + // return this.http.post(`${this.url}/RootFolders/`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData); + // } + // getQualityProfiles(settings: IRadarrSettings): Observable { + // return this.http.post(`${this.url}/Profiles/`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData); + // } +} \ No newline at end of file diff --git a/src/Ombi/wwwroot/app/services/settings.service.ts b/src/Ombi/wwwroot/app/services/settings.service.ts index 4eaa8ee25..5e5fffa93 100644 --- a/src/Ombi/wwwroot/app/services/settings.service.ts +++ b/src/Ombi/wwwroot/app/services/settings.service.ts @@ -4,14 +4,22 @@ import { Http } from '@angular/http'; import { Observable } from 'rxjs/Rx'; import { ServiceAuthHelpers } from './service.helpers'; -import { IOmbiSettings, IEmbySettings, IPlexSettings, ISonarrSettings,ILandingPageSettings, ICustomizationSettings } from '../interfaces/ISettings'; +import { + IOmbiSettings, + IEmbySettings, + IPlexSettings, + ISonarrSettings, + ILandingPageSettings, + ICustomizationSettings, + IRadarrSettings +} from '../interfaces/ISettings'; @Injectable() export class SettingsService extends ServiceAuthHelpers { constructor(public httpAuth: AuthHttp, private nonAuthHttp: Http) { super(httpAuth, '/api/v1/Settings'); } - + getOmbi(): Observable { return this.httpAuth.get(`${this.url}/Ombi/`).map(this.extractData).catch(this.handleError) } @@ -45,6 +53,15 @@ export class SettingsService extends ServiceAuthHelpers { return this.httpAuth.post(`${this.url}/Sonarr`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData).catch(this.handleError) } + getRadarr(): Observable { + return this.httpAuth.get(`${this.url}/Radarr`).map(this.extractData) + .catch(this.handleError); + } + + saveRadarr(settings: IRadarrSettings): Observable { + return this.httpAuth.post(`${this.url}/Radarr`, JSON.stringify(settings), { headers: this.headers }).map(this.extractData).catch(this.handleError) + } + // Using http since we need it not to be authenticated to get the landing page settings getLandingPage(): Observable { return this.nonAuthHttp.get(`${this.url}/LandingPage`).map(this.extractData).catch(this.handleError) diff --git a/src/Ombi/wwwroot/app/settings/radarr/radarr.component.html b/src/Ombi/wwwroot/app/settings/radarr/radarr.component.html new file mode 100644 index 000000000..9c6df9826 --- /dev/null +++ b/src/Ombi/wwwroot/app/settings/radarr/radarr.component.html @@ -0,0 +1,104 @@ + + +
+
+
+ Sonarr Settings + +
+
+ + +
+
+ + + +
+ +
+ +
+
+ +
+ + +
+ +
+
+ + +
+ +
+ +
+
+
+
+ + + +
+
+
+ +
+ +
+
+
+
+ +
+
+
+ +
+ +
+
+ +
+
+ + +
+ +
+
+ +
+ +
+
+ + +
+
+ + +
+ +
+
+
+ +
+
+ + +
+
+ +
+
+
+
+
diff --git a/src/Ombi/wwwroot/app/settings/radarr/radarr.component.ts b/src/Ombi/wwwroot/app/settings/radarr/radarr.component.ts new file mode 100644 index 000000000..34dbc7920 --- /dev/null +++ b/src/Ombi/wwwroot/app/settings/radarr/radarr.component.ts @@ -0,0 +1,80 @@ +import { Component, OnInit } from '@angular/core'; +import { Subject } from 'rxjs/Subject'; +import "rxjs/add/operator/takeUntil"; + +import { IRadarrSettings } from '../../interfaces/ISettings' +import { ISonarrProfile, ISonarrRootFolder } from '../../interfaces/ISonarr' +import { SettingsService } from '../../services/settings.service'; +// import { RadarrService } from '../../services/applications/radarr.service'; +import { NotificationService } from "../../services/notification.service"; + +@Component({ + selector: 'ombi', + moduleId: module.id, + templateUrl: './radarr.component.html', +}) +export class RadarrComponent implements OnInit { + + constructor(private settingsService: SettingsService, /*private radarrService: RadarrService,*/ private notificationService: NotificationService) { } + + settings: IRadarrSettings; + + qualities: ISonarrProfile[]; + rootFolders: ISonarrRootFolder[]; + + selectedRootFolder:ISonarrRootFolder; + selectedQuality: ISonarrProfile; + + profilesRunning: boolean; + rootFoldersRunning: boolean; + private subscriptions = new Subject(); + + ngOnInit(): void { + + this.settingsService.getRadarr() + .takeUntil(this.subscriptions) + .subscribe(x => { + this.settings = x; + }); + } + + + getProfiles() { + // this.profilesRunning = true; + // this.sonarrService.getQualityProfiles(this.settings).subscribe(x => { + // this.qualities = x; + // + // this.profilesRunning = false; + // this.notificationService.success("Quality Profiles", "Successfully retrevied the Quality Profiles"); + // }); + } + + getRootFolders() { + // this.rootFoldersRunning = true; + // this.sonarrService.getRootFolders(this.settings).subscribe(x => { + // this.rootFolders = x; + // + // this.rootFoldersRunning = false; + // this.notificationService.success("Settings Saved", "Successfully retrevied the Root Folders"); + // }); + } + + test() { + // TODO + } + + save() { + this.settingsService.saveRadarr(this.settings).subscribe(x => { + if (x) { + this.notificationService.success("Settings Saved", "Successfully saved Radarr settings"); + } else { + this.notificationService.success("Settings Saved", "There was an error when saving the Radarr settings"); + } + }); + } + + ngOnDestroy(): void { + this.subscriptions.next(); + this.subscriptions.complete(); + } +} \ No newline at end of file diff --git a/src/Ombi/wwwroot/app/settings/sonarr/sonarr.component.ts b/src/Ombi/wwwroot/app/settings/sonarr/sonarr.component.ts index ee82a4244..34053f34f 100644 --- a/src/Ombi/wwwroot/app/settings/sonarr/sonarr.component.ts +++ b/src/Ombi/wwwroot/app/settings/sonarr/sonarr.component.ts @@ -1,4 +1,6 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { Subject } from 'rxjs/Subject'; +import "rxjs/add/operator/takeUntil"; import { ISonarrSettings } from '../../interfaces/ISettings' import { ISonarrProfile, ISonarrRootFolder } from '../../interfaces/ISonarr' @@ -11,7 +13,7 @@ import { NotificationService } from "../../services/notification.service"; moduleId: module.id, templateUrl: './sonarr.component.html', }) -export class SonarrComponent implements OnInit { +export class SonarrComponent implements OnInit, OnDestroy { constructor(private settingsService: SettingsService, private sonarrService: SonarrService, private notificationService: NotificationService) { } @@ -20,32 +22,28 @@ export class SonarrComponent implements OnInit { qualities: ISonarrProfile[]; rootFolders: ISonarrRootFolder[]; - selectedRootFolder:ISonarrRootFolder; + selectedRootFolder: ISonarrRootFolder; selectedQuality: ISonarrProfile; profilesRunning: boolean; - rootFoldersRunning:boolean; + rootFoldersRunning: boolean; + private subscriptions = new Subject(); ngOnInit(): void { - this.settings = { - apiKey: "", - port: 8081, - fullRootPath: "", - rootPath: "", - subDir: "", - ssl: false, - seasonFolders: false, - qualityProfile: "", - ip: "", - enable: false, - id: 0 - }; + + this.settingsService.getSonarr() + .takeUntil(this.subscriptions) + .subscribe(x => { + this.settings = x; + }); } getProfiles() { this.profilesRunning = true; - this.sonarrService.getQualityProfiles(this.settings).subscribe(x => { + this.sonarrService.getQualityProfiles(this.settings) + .takeUntil(this.subscriptions) + .subscribe(x => { this.qualities = x; this.profilesRunning = false; @@ -55,7 +53,9 @@ export class SonarrComponent implements OnInit { getRootFolders() { this.rootFoldersRunning = true; - this.sonarrService.getRootFolders(this.settings).subscribe(x => { + this.sonarrService.getRootFolders(this.settings) + .takeUntil(this.subscriptions) + .subscribe(x => { this.rootFolders = x; this.rootFoldersRunning = false; @@ -68,12 +68,19 @@ export class SonarrComponent implements OnInit { } save() { - this.settingsService.saveSonarr(this.settings).subscribe(x => { + this.settingsService.saveSonarr(this.settings) + .takeUntil(this.subscriptions) + .subscribe(x => { if (x) { - this.notificationService.success("Settings Saved", "Successfully saved Ombi settings"); + this.notificationService.success("Settings Saved", "Successfully saved Sonarr settings"); } else { - this.notificationService.success("Settings Saved", "There was an error when saving the Ombi settings"); + this.notificationService.success("Settings Saved", "There was an error when saving the Sonarr settings"); } }); } + + ngOnDestroy(): void { + this.subscriptions.next(); + this.subscriptions.complete(); + } } \ No newline at end of file