From b9c37309fc09083acb6bf7fae0367806c7d5adfd Mon Sep 17 00:00:00 2001 From: Jamie Date: Tue, 28 Aug 2018 19:59:42 +0100 Subject: [PATCH 1/2] Added the album folder option to the lidarr settings !wip --- .../ClientApp/app/settings/lidarr/lidarr.component.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.html b/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.html index aa3dbaa66..11d9baf2d 100644 --- a/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.html +++ b/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.html @@ -103,6 +103,13 @@ A Metadata profile is required +
+
+ + +
+
+
From 28a1886767eab052eb6a71359b61aa214a3e0e5d Mon Sep 17 00:00:00 2001 From: Jamie Date: Tue, 28 Aug 2018 20:09:54 +0100 Subject: [PATCH 2/2] Made the test button actually work on the Lidarr settings page !wip --- src/Ombi.Api.Lidarr/ILidarrApi.cs | 1 + src/Ombi.Api.Lidarr/LidarrApi.cs | 7 +++++ src/Ombi.Api.Lidarr/Models/LidarrStatus.cs | 31 +++++++++++++++++++ .../services/applications/tester.service.ts | 5 +++ .../app/settings/lidarr/lidarr.component.ts | 4 +-- .../Controllers/External/TesterController.cs | 30 ++++++++++++++++-- 6 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 src/Ombi.Api.Lidarr/Models/LidarrStatus.cs diff --git a/src/Ombi.Api.Lidarr/ILidarrApi.cs b/src/Ombi.Api.Lidarr/ILidarrApi.cs index 38724f668..15d20fd28 100644 --- a/src/Ombi.Api.Lidarr/ILidarrApi.cs +++ b/src/Ombi.Api.Lidarr/ILidarrApi.cs @@ -21,5 +21,6 @@ namespace Ombi.Api.Lidarr Task> GetAllAlbumsByArtistId(int artistId, string apiKey, string baseUrl); Task> GetMetadataProfile(string apiKey, string baseUrl); Task> GetLanguageProfile(string apiKey, string baseUrl); + Task Status(string apiKey, string baseUrl); } } \ No newline at end of file diff --git a/src/Ombi.Api.Lidarr/LidarrApi.cs b/src/Ombi.Api.Lidarr/LidarrApi.cs index cf358699c..2aded7e1a 100644 --- a/src/Ombi.Api.Lidarr/LidarrApi.cs +++ b/src/Ombi.Api.Lidarr/LidarrApi.cs @@ -147,6 +147,13 @@ namespace Ombi.Api.Lidarr return Api.Request>(request); } + public Task Status(string apiKey, string baseUrl) + { + var request = new Request($"{ApiVersion}/system/status", baseUrl, HttpMethod.Get); + AddHeaders(request, apiKey); + return Api.Request(request); + } + private void AddHeaders(Request request, string key) { request.AddHeader("X-Api-Key", key); diff --git a/src/Ombi.Api.Lidarr/Models/LidarrStatus.cs b/src/Ombi.Api.Lidarr/Models/LidarrStatus.cs new file mode 100644 index 000000000..27f6c1820 --- /dev/null +++ b/src/Ombi.Api.Lidarr/Models/LidarrStatus.cs @@ -0,0 +1,31 @@ +using System; + +namespace Ombi.Api.Lidarr.Models +{ + public class LidarrStatus + { + public string version { get; set; } + public DateTime 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 osName { 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 mode { get; set; } + public string branch { get; set; } + public string authentication { get; set; } + public string sqliteVersion { get; set; } + public int migrationVersion { get; set; } + public string urlBase { get; set; } + public string runtimeVersion { get; set; } + public string runtimeName { get; set; } + } +} \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/services/applications/tester.service.ts b/src/Ombi/ClientApp/app/services/applications/tester.service.ts index 3fa038888..e692b9196 100644 --- a/src/Ombi/ClientApp/app/services/applications/tester.service.ts +++ b/src/Ombi/ClientApp/app/services/applications/tester.service.ts @@ -11,6 +11,7 @@ import { IDiscordNotifcationSettings, IEmailNotificationSettings, IEmbyServer, + ILidarrSettings, IMattermostNotifcationSettings, IMobileNotificationTestSettings, INewsletterNotificationSettings, @@ -66,6 +67,10 @@ export class TesterService extends ServiceHelpers { return this.http.post(`${this.url}radarr`, JSON.stringify(settings), {headers: this.headers}); } + public lidarrTest(settings: ILidarrSettings): Observable { + return this.http.post(`${this.url}lidarr`, JSON.stringify(settings), {headers: this.headers}); + } + public sonarrTest(settings: ISonarrSettings): Observable { return this.http.post(`${this.url}sonarr`, JSON.stringify(settings), {headers: this.headers}); } diff --git a/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.ts b/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.ts index 8100c0194..b124f9d47 100644 --- a/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.ts +++ b/src/Ombi/ClientApp/app/settings/lidarr/lidarr.component.ts @@ -124,8 +124,8 @@ export class LidarrComponent implements OnInit { this.notificationService.error("Please check your entered values"); return; } - const settings = form.value; - this.testerService.radarrTest(settings).subscribe(x => { + const settings = form.value; + this.testerService.lidarrTest(settings).subscribe(x => { if (x === true) { this.notificationService.success("Successfully connected to Lidarr!"); } else { diff --git a/src/Ombi/Controllers/External/TesterController.cs b/src/Ombi/Controllers/External/TesterController.cs index fca42bb63..5e3156bde 100644 --- a/src/Ombi/Controllers/External/TesterController.cs +++ b/src/Ombi/Controllers/External/TesterController.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Ombi.Api.CouchPotato; using Ombi.Api.Emby; +using Ombi.Api.Lidarr; using Ombi.Api.Plex; using Ombi.Api.Radarr; using Ombi.Api.SickRage; @@ -38,7 +39,8 @@ namespace Ombi.Controllers.External public TesterController(INotificationService service, IDiscordNotification notification, IEmailNotification emailN, IPushbulletNotification pushbullet, ISlackNotification slack, IPushoverNotification po, IMattermostNotification mm, IPlexApi plex, IEmbyApi emby, IRadarrApi radarr, ISonarrApi sonarr, ILogger log, IEmailProvider provider, - ICouchPotatoApi cpApi, ITelegramNotification telegram, ISickRageApi srApi, INewsletterJob newsletter, IMobileNotification mobileNotification) + ICouchPotatoApi cpApi, ITelegramNotification telegram, ISickRageApi srApi, INewsletterJob newsletter, IMobileNotification mobileNotification, + ILidarrApi lidarrApi) { Service = service; DiscordNotification = notification; @@ -58,6 +60,7 @@ namespace Ombi.Controllers.External SickRageApi = srApi; Newsletter = newsletter; MobileNotification = mobileNotification; + LidarrApi = lidarrApi; } private INotificationService Service { get; } @@ -78,6 +81,7 @@ namespace Ombi.Controllers.External private ISickRageApi SickRageApi { get; } private INewsletterJob Newsletter { get; } private IMobileNotification MobileNotification { get; } + private ILidarrApi LidarrApi { get; } /// @@ -397,7 +401,7 @@ namespace Ombi.Controllers.External { try { - await MobileNotification.NotifyAsync(new NotificationOptions { NotificationType = NotificationType.Test, RequestId = -1, UserId = settings.UserId}, settings.Settings); + await MobileNotification.NotifyAsync(new NotificationOptions { NotificationType = NotificationType.Test, RequestId = -1, UserId = settings.UserId }, settings.Settings); return true; } @@ -407,5 +411,27 @@ namespace Ombi.Controllers.External return false; } } + + [HttpPost("lidarr")] + public async Task LidarrTest([FromBody] LidarrSettings settings) + { + try + { + var status = await LidarrApi.Status(settings.ApiKey, settings.FullUri); + if (status != null & status?.version.HasValue() ?? false) + { + return true; + } + else + { + return false; + } + } + catch (Exception e) + { + Log.LogError(LoggingEvents.Api, e, "Could not test Mobile Notifications"); + return false; + } + } } } \ No newline at end of file