Made the test button actually work on the Lidarr settings page !wip

pull/2478/head
Jamie 6 years ago
parent b9c37309fc
commit 28a1886767

@ -21,5 +21,6 @@ namespace Ombi.Api.Lidarr
Task<List<AlbumResponse>> GetAllAlbumsByArtistId(int artistId, string apiKey, string baseUrl);
Task<List<MetadataProfile>> GetMetadataProfile(string apiKey, string baseUrl);
Task<List<LanguageProfiles>> GetLanguageProfile(string apiKey, string baseUrl);
Task<LidarrStatus> Status(string apiKey, string baseUrl);
}
}

@ -147,6 +147,13 @@ namespace Ombi.Api.Lidarr
return Api.Request<List<MetadataProfile>>(request);
}
public Task<LidarrStatus> Status(string apiKey, string baseUrl)
{
var request = new Request($"{ApiVersion}/system/status", baseUrl, HttpMethod.Get);
AddHeaders(request, apiKey);
return Api.Request<LidarrStatus>(request);
}
private void AddHeaders(Request request, string key)
{
request.AddHeader("X-Api-Key", key);

@ -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; }
}
}

@ -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<boolean>(`${this.url}radarr`, JSON.stringify(settings), {headers: this.headers});
}
public lidarrTest(settings: ILidarrSettings): Observable<boolean> {
return this.http.post<boolean>(`${this.url}lidarr`, JSON.stringify(settings), {headers: this.headers});
}
public sonarrTest(settings: ISonarrSettings): Observable<boolean> {
return this.http.post<boolean>(`${this.url}sonarr`, JSON.stringify(settings), {headers: this.headers});
}

@ -124,8 +124,8 @@ export class LidarrComponent implements OnInit {
this.notificationService.error("Please check your entered values");
return;
}
const settings = <IRadarrSettings>form.value;
this.testerService.radarrTest(settings).subscribe(x => {
const settings = <ILidarrSettings>form.value;
this.testerService.lidarrTest(settings).subscribe(x => {
if (x === true) {
this.notificationService.success("Successfully connected to Lidarr!");
} else {

@ -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<TesterController> 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; }
/// <summary>
@ -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<bool> 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;
}
}
}
}
Loading…
Cancel
Save