pull/952/head
Jamie.Rees 8 years ago
parent 5e06d9bd26
commit 02a1770b31

@ -37,6 +37,7 @@ namespace Ombi.Core
public const string PlexEpisodes = nameof(PlexEpisodes);
public const string TvDbToken = nameof(TvDbToken);
public const string SonarrQualityProfiles = nameof(SonarrQualityProfiles);
public const string RadarrQualityProfiles = nameof(RadarrQualityProfiles);
public const string SonarrQueued = nameof(SonarrQueued);
public const string SickRageQualityProfiles = nameof(SickRageQualityProfiles);
public const string SickRageQueued = nameof(SickRageQueued);

@ -95,6 +95,8 @@ namespace Ombi.UI.Modules.Admin
private ISettingsService<NotificationSettingsV2> NotifySettings { get; }
private ISettingsService<DiscordNotificationSettings> DiscordSettings { get; }
private IDiscordApi DiscordApi { get; }
private ISettingsService<RadarrSettings> RadarrSettings { get; }
private IRadarrApi RadarrApi { get; }
private static Logger Log = LogManager.GetCurrentClassLogger();
public AdminModule(ISettingsService<PlexRequestSettings> prService,
@ -122,7 +124,7 @@ namespace Ombi.UI.Modules.Admin
ISettingsService<NotificationSettingsV2> notifyService, IRecentlyAdded recentlyAdded,
ISettingsService<WatcherSettings> watcherSettings ,
ISettingsService<DiscordNotificationSettings> discord,
IDiscordApi discordapi
IDiscordApi discordapi, ISettingsService<RadarrSettings> settings, IRadarrApi radarrApi
, ISecurityExtensions security) : base("admin", prService, security)
{
PrService = prService;
@ -156,6 +158,8 @@ namespace Ombi.UI.Modules.Admin
WatcherSettings = watcherSettings;
DiscordSettings = discord;
DiscordApi = discordapi;
RadarrSettings = settings;
RadarrApi = radarrApi;
Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
@ -178,11 +182,15 @@ namespace Ombi.UI.Modules.Admin
Get["/sonarr"] = _ => Sonarr();
Post["/sonarr"] = _ => SaveSonarr();
Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
Get["/radarr", true] = async (x, ct) => await Radarr();
Post["/radarr"] = _ => SaveRadarr();
Post["/radarrprofiles"] = _ => GetRadarrQualityProfiles();
Get["/sickrage"] = _ => Sickrage();
Post["/sickrage"] = _ => SaveSickrage();
Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
Post["/cpprofiles", true] = async (x, ct) => await GetCpProfiles();
Post["/cpapikey"] = x => GetCpApiKey();
@ -465,6 +473,49 @@ namespace Ombi.UI.Modules.Admin
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
}
private async Task<Negotiator> Radarr()
{
var settings = await RadarrSettings.GetSettingsAsync();
return View["Radarr", settings];
}
private Response SaveRadarr()
{
var sonarrSettings = this.Bind<SonarrSettings>();
var valid = this.Validate(sonarrSettings);
if (!valid.IsValid)
{
return Response.AsJson(valid.SendJsonError());
}
var sickRageEnabled = SickRageService.GetSettings().Enabled;
if (sickRageEnabled)
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = "SickRage is enabled, we cannot enable Sonarr and SickRage" });
}
sonarrSettings.ApiKey = sonarrSettings.ApiKey.Trim();
var result = SonarrService.SaveSettings(sonarrSettings);
return Response.AsJson(result
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for Sonarr!" }
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
}
private Response GetRadarrQualityProfiles()
{
var settings = this.Bind<RadarrSettings>();
var profiles = RadarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
// set the cache
if (profiles != null)
{
Cache.Set(CacheKeys.RadarrQualityProfiles, profiles);
}
return Response.AsJson(profiles);
}
private Negotiator Sickrage()
{
var settings = SickRageService.GetSettings();

@ -46,7 +46,7 @@ namespace Ombi.UI.Modules
public ApplicationTesterModule(ICouchPotatoApi cpApi, ISonarrApi sonarrApi, IPlexApi plexApi,
ISickRageApi srApi, IHeadphonesApi hpApi, ISettingsService<PlexRequestSettings> pr, ISecurityExtensions security,
IWatcherApi watcherApi) : base("test", pr, security)
IWatcherApi watcherApi, IRadarrApi radarrApi) : base("test", pr, security)
{
this.RequiresAuthentication();
@ -56,9 +56,11 @@ namespace Ombi.UI.Modules
SickRageApi = srApi;
HeadphonesApi = hpApi;
WatcherApi = watcherApi;
RadarrApi = radarrApi;
Post["/cp"] = _ => CouchPotatoTest();
Post["/sonarr"] = _ => SonarrTest();
Post["/radarr"] = _ => RadarrTest();
Post["/plex"] = _ => PlexTest();
Post["/sickrage"] = _ => SickRageTest();
Post["/headphones"] = _ => HeadphonesTest();
@ -73,6 +75,7 @@ namespace Ombi.UI.Modules
private ISickRageApi SickRageApi { get; }
private IHeadphonesApi HeadphonesApi { get; }
private IWatcherApi WatcherApi { get; }
private IRadarrApi RadarrApi { get; }
private Response CouchPotatoTest()
{
@ -148,7 +151,7 @@ namespace Ombi.UI.Modules
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Sonarr, please check your settings." });
}
catch (Exception e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
catch (Exception e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
{
Log.Warn("Exception thrown when attempting to get Sonarr's status: ");
Log.Warn(e);
@ -161,6 +164,35 @@ namespace Ombi.UI.Modules
}
}
private Response RadarrTest()
{
var radarrSettings = this.Bind<RadarrSettings>();
var valid = this.Validate(radarrSettings);
if (!valid.IsValid)
{
return Response.AsJson(valid.SendJsonError());
}
try
{
var status = RadarrApi.SystemStatus(radarrSettings.ApiKey, radarrSettings.FullUri);
return status?.version != null
? Response.AsJson(new JsonResponseModel { Result = true, Message = "Connected to Radarr successfully!" })
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Radarr, please check your settings." });
}
catch (Exception e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
{
Log.Warn("Exception thrown when attempting to get Radarr's status: ");
Log.Warn(e);
var message = $"Could not connect to Radarr, please check your settings. <strong>Exception Message:</strong> {e.Message}";
if (e.InnerException != null)
{
message = $"Could not connect to Radarr, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
}
return Response.AsJson(new JsonResponseModel { Result = false, Message = message });
}
}
private Response PlexTest()
{
var plexSettings = this.Bind<PlexSettings>();

@ -48,6 +48,7 @@ namespace Ombi.UI.NinjectModules
Bind<IWatcherApi>().To<WatcherApi>();
Bind<INetflixApi>().To<NetflixRouletteApi>();
Bind<IDiscordApi>().To<DiscordApi>();
Bind<IRadarrApi>().To<RadarrApi>();
}
}
}

@ -124,6 +124,10 @@ namespace Ombi.UI
var slackService = container.Get<ISettingsService<SlackNotificationSettings>>();
var slackSettings = slackService.GetSettings();
SubScribeOvserver(slackSettings, notificationService, new SlackNotification(container.Get<ISlackApi>(), slackService));
var discordSettings = container.Get<ISettingsService<DiscordNotificationSettings>>();
var discordService = discordSettings.GetSettings();
SubScribeOvserver(discordService, notificationService, new DiscordNotification(container.Get<IDiscordApi>(), discordSettings));
}
private void SubScribeOvserver<T>(T settings, INotificationService notificationService, INotification notification)

@ -67,26 +67,10 @@
<label for="RootPath" class="control-label">Root save directory for TV shows</label>
<div>
<input type="text" class="form-control form-control-custom " placeholder="C:\Media\Tv" id="RootPath" name="RootPath" value="@Model.RootPath">
<label>Enter the root folder where tv shows are saved. For example <strong>C:\Media\TV</strong>.</label>
<label>Enter the root folder where movies are saved. For example <strong>C:\Media\TV</strong>.</label>
</div>
</div>
<div class="form-group">
<div class="checkbox">
@if (Model.SeasonFolders)
{
<input type="checkbox" id="SeasonFolders" name="SeasonFolders" checked="checked">
}
else
{
<input type="checkbox" id="SeasonFolders" name="SeasonFolders">
}
<label for="SeasonFolders">Enable season folders</label>
</div>
<label>Enabled Season Folders to organize seasons into individual folders within a show.</label>
</div>
<div class="form-group">
<div>
<button id="testSonarr" type="submit" class="btn btn-primary-outline">Test Connectivity <div id="spinner"/></button>
@ -124,7 +108,7 @@
$.ajax({
type: $form.prop("method"),
data: $form.serialize(),
url: "sonarrprofiles",
url: "radarrprofiles",
dataType: "json",
success: function(response) {
response.forEach(function(result) {
@ -202,7 +186,7 @@
$.ajax({
type: $form.prop("method"),
data: $form.serialize(),
url: "sonarrprofiles",
url: "radarrprofiles",
dataType: "json",
success: function (response) {
response.forEach(function (result) {
@ -219,7 +203,7 @@
});
var base = '@Html.GetBaseUrl()';
$('#testSonarr').click(function (e) {
$('#testRadarr').click(function (e) {
$('#spinner').attr("class", "fa fa-spinner fa-spin");
e.preventDefault();
@ -230,7 +214,7 @@
var data = $form.serialize();
data = data + "&qualityProfile=" + qualityProfile;
var url = createBaseUrl(base, '/test/sonarr');
var url = createBaseUrl(base, '/test/radarr');
$.ajax({
type: $form.prop("method"),
url: url,

@ -11,6 +11,7 @@
@Html.GetSidebarUrl(Context, "/admin/plex", "Plex")
@Html.GetSidebarUrl(Context, "/admin/couchpotato", "CouchPotato")
@Html.GetSidebarUrl(Context, "/admin/watcher", "Watcher (beta)")
@Html.GetSidebarUrl(Context, "/admin/radarr", "Radarr (beta)")
@Html.GetSidebarUrl(Context, "/admin/sonarr", "Sonarr")
@Html.GetSidebarUrl(Context, "/admin/sickrage", "SickRage")
@Html.GetSidebarUrl(Context, "/admin/headphones", "Headphones (beta)")

Loading…
Cancel
Save