mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-15 01:32:55 -07:00
Added the api and settings page for Sickrage. Just need to do the tester and hook it up #40
This commit is contained in:
parent
1ebf80d1d1
commit
803b12da0f
12 changed files with 399 additions and 5 deletions
|
@ -73,6 +73,7 @@
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Mocks\MockSonarrApi.cs" />
|
<Compile Include="Mocks\MockSonarrApi.cs" />
|
||||||
<Compile Include="PushbulletApi.cs" />
|
<Compile Include="PushbulletApi.cs" />
|
||||||
|
<Compile Include="SickrageApi.cs" />
|
||||||
<Compile Include="SonarrApi.cs" />
|
<Compile Include="SonarrApi.cs" />
|
||||||
<Compile Include="CouchPotatoApi.cs" />
|
<Compile Include="CouchPotatoApi.cs" />
|
||||||
<Compile Include="MovieBase.cs" />
|
<Compile Include="MovieBase.cs" />
|
||||||
|
|
68
PlexRequests.Api/SickrageApi.cs
Normal file
68
PlexRequests.Api/SickrageApi.cs
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: CouchPotatoApi.cs
|
||||||
|
// Created By: Jamie Rees
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
// a copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
// the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
// ************************************************************************/
|
||||||
|
#endregion
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using NLog;
|
||||||
|
using PlexRequests.Api.Interfaces;
|
||||||
|
using PlexRequests.Api.Models.Sonarr;
|
||||||
|
using RestSharp;
|
||||||
|
|
||||||
|
namespace PlexRequests.Api
|
||||||
|
{
|
||||||
|
public class SickrageApi
|
||||||
|
{
|
||||||
|
public SickrageApi()
|
||||||
|
{
|
||||||
|
Api = new ApiRequest();
|
||||||
|
}
|
||||||
|
private ApiRequest Api { get; set; }
|
||||||
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
|
||||||
|
public SonarrAddSeries AddSeries(int tvdbId, string status, string futureStatus, string quality, string apiKey, Uri baseUrl)
|
||||||
|
{
|
||||||
|
//localhost:8081/api/e738882774aeb0b2210f4bc578cbb584/?cmd=show.addnew&tvdbid=101501&status=skipped&future_status=wanted&initial=fullhdbluray&sdtv
|
||||||
|
|
||||||
|
var request = new RestRequest
|
||||||
|
{
|
||||||
|
Resource = "/api/{apiKey}/?cmd=show.addnew",
|
||||||
|
Method = Method.GET
|
||||||
|
};
|
||||||
|
|
||||||
|
request.AddQueryParameter("tvdbid", tvdbId.ToString());
|
||||||
|
request.AddQueryParameter("status", status);
|
||||||
|
request.AddQueryParameter("future_status", futureStatus);
|
||||||
|
request.AddQueryParameter("initial", quality);
|
||||||
|
|
||||||
|
var obj = Api.ExecuteJson<SonarrAddSeries>(request, baseUrl);
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,13 +24,30 @@
|
||||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// ************************************************************************/
|
// ************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using PlexRequests.Helpers;
|
||||||
|
|
||||||
namespace PlexRequests.Core.SettingModels
|
namespace PlexRequests.Core.SettingModels
|
||||||
{
|
{
|
||||||
public class SickRageSettings : Settings
|
public class SickRageSettings : Settings
|
||||||
{
|
{
|
||||||
|
public bool Enabled { get; set; }
|
||||||
public string Ip { get; set; }
|
public string Ip { get; set; }
|
||||||
public int Port { get; set; }
|
public int Port { get; set; }
|
||||||
public string ApiKey { get; set; }
|
public string ApiKey { get; set; }
|
||||||
public bool Enabled { get; set; }
|
public string QualityProfile { get; set; }
|
||||||
|
public bool Ssl { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public Uri FullUri
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var formatted = Ip.ReturnUri(Port, Ssl);
|
||||||
|
return formatted;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -33,6 +33,7 @@ namespace PlexRequests.Core.SettingModels
|
||||||
{
|
{
|
||||||
public class SonarrSettings : Settings
|
public class SonarrSettings : Settings
|
||||||
{
|
{
|
||||||
|
public bool Enabled { get; set; }
|
||||||
public string Ip { get; set; }
|
public string Ip { get; set; }
|
||||||
public int Port { get; set; }
|
public int Port { get; set; }
|
||||||
public string ApiKey { get; set; }
|
public string ApiKey { get; set; }
|
||||||
|
|
|
@ -52,6 +52,7 @@ namespace PlexRequests.UI.Tests
|
||||||
private Mock<ISettingsService<AuthenticationSettings>> AuthMock { get; set; }
|
private Mock<ISettingsService<AuthenticationSettings>> AuthMock { get; set; }
|
||||||
private Mock<ISettingsService<PlexSettings>> PlexSettingsMock { get; set; }
|
private Mock<ISettingsService<PlexSettings>> PlexSettingsMock { get; set; }
|
||||||
private Mock<ISettingsService<SonarrSettings>> SonarrSettingsMock { get; set; }
|
private Mock<ISettingsService<SonarrSettings>> SonarrSettingsMock { get; set; }
|
||||||
|
private Mock<ISettingsService<SickRageSettings>> SickRageSettingsMock { get; set; }
|
||||||
private Mock<ISettingsService<EmailNotificationSettings>> EmailMock { get; set; }
|
private Mock<ISettingsService<EmailNotificationSettings>> EmailMock { get; set; }
|
||||||
private Mock<ISettingsService<PushbulletNotificationSettings>> PushbulletSettings { get; set; }
|
private Mock<ISettingsService<PushbulletNotificationSettings>> PushbulletSettings { get; set; }
|
||||||
private Mock<IPlexApi> PlexMock { get; set; }
|
private Mock<IPlexApi> PlexMock { get; set; }
|
||||||
|
@ -81,6 +82,7 @@ namespace PlexRequests.UI.Tests
|
||||||
PushbulletApi = new Mock<IPushbulletApi>();
|
PushbulletApi = new Mock<IPushbulletApi>();
|
||||||
PushbulletSettings = new Mock<ISettingsService<PushbulletNotificationSettings>>();
|
PushbulletSettings = new Mock<ISettingsService<PushbulletNotificationSettings>>();
|
||||||
CpApi = new Mock<ICouchPotatoApi>();
|
CpApi = new Mock<ICouchPotatoApi>();
|
||||||
|
SickRageSettingsMock = new Mock<ISettingsService<SickRageSettings>>();
|
||||||
|
|
||||||
Bootstrapper = new ConfigurableBootstrapper(with =>
|
Bootstrapper = new ConfigurableBootstrapper(with =>
|
||||||
{
|
{
|
||||||
|
@ -96,6 +98,7 @@ namespace PlexRequests.UI.Tests
|
||||||
with.Dependency(PushbulletApi.Object);
|
with.Dependency(PushbulletApi.Object);
|
||||||
with.Dependency(PushbulletSettings.Object);
|
with.Dependency(PushbulletSettings.Object);
|
||||||
with.Dependency(CpApi.Object);
|
with.Dependency(CpApi.Object);
|
||||||
|
with.Dependency(SickRageSettingsMock.Object);
|
||||||
with.RootPathProvider<TestRootPathProvider>();
|
with.RootPathProvider<TestRootPathProvider>();
|
||||||
with.RequestStartup((container, pipelines, context) =>
|
with.RequestStartup((container, pipelines, context) =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,6 +73,7 @@ namespace PlexRequests.UI
|
||||||
container.Register<ISettingsService<AuthenticationSettings>, SettingsServiceV2<AuthenticationSettings>>();
|
container.Register<ISettingsService<AuthenticationSettings>, SettingsServiceV2<AuthenticationSettings>>();
|
||||||
container.Register<ISettingsService<PlexSettings>, SettingsServiceV2<PlexSettings>>();
|
container.Register<ISettingsService<PlexSettings>, SettingsServiceV2<PlexSettings>>();
|
||||||
container.Register<ISettingsService<SonarrSettings>, SettingsServiceV2<SonarrSettings>>();
|
container.Register<ISettingsService<SonarrSettings>, SettingsServiceV2<SonarrSettings>>();
|
||||||
|
container.Register<ISettingsService<SickRageSettings>, SettingsServiceV2<SickRageSettings>>();
|
||||||
container.Register<ISettingsService<EmailNotificationSettings>, SettingsServiceV2<EmailNotificationSettings>>();
|
container.Register<ISettingsService<EmailNotificationSettings>, SettingsServiceV2<EmailNotificationSettings>>();
|
||||||
container.Register<ISettingsService<PushbulletNotificationSettings>, SettingsServiceV2<PushbulletNotificationSettings>>();
|
container.Register<ISettingsService<PushbulletNotificationSettings>, SettingsServiceV2<PushbulletNotificationSettings>>();
|
||||||
container.Register<IRepository<RequestedModel>, GenericRepository<RequestedModel>>();
|
container.Register<IRepository<RequestedModel>, GenericRepository<RequestedModel>>();
|
||||||
|
|
|
@ -54,6 +54,7 @@ namespace PlexRequests.UI.Modules
|
||||||
private ISettingsService<AuthenticationSettings> AuthService { get; }
|
private ISettingsService<AuthenticationSettings> AuthService { get; }
|
||||||
private ISettingsService<PlexSettings> PlexService { get; }
|
private ISettingsService<PlexSettings> PlexService { get; }
|
||||||
private ISettingsService<SonarrSettings> SonarrService { get; }
|
private ISettingsService<SonarrSettings> SonarrService { get; }
|
||||||
|
private ISettingsService<SickRageSettings> SickRageService { get; }
|
||||||
private ISettingsService<EmailNotificationSettings> EmailService { get; }
|
private ISettingsService<EmailNotificationSettings> EmailService { get; }
|
||||||
private ISettingsService<PushbulletNotificationSettings> PushbulletService { get; }
|
private ISettingsService<PushbulletNotificationSettings> PushbulletService { get; }
|
||||||
private IPlexApi PlexApi { get; }
|
private IPlexApi PlexApi { get; }
|
||||||
|
@ -67,6 +68,7 @@ namespace PlexRequests.UI.Modules
|
||||||
ISettingsService<AuthenticationSettings> auth,
|
ISettingsService<AuthenticationSettings> auth,
|
||||||
ISettingsService<PlexSettings> plex,
|
ISettingsService<PlexSettings> plex,
|
||||||
ISettingsService<SonarrSettings> sonarr,
|
ISettingsService<SonarrSettings> sonarr,
|
||||||
|
ISettingsService<SickRageSettings> sickrage,
|
||||||
ISonarrApi sonarrApi,
|
ISonarrApi sonarrApi,
|
||||||
ISettingsService<EmailNotificationSettings> email,
|
ISettingsService<EmailNotificationSettings> email,
|
||||||
IPlexApi plexApi,
|
IPlexApi plexApi,
|
||||||
|
@ -85,6 +87,7 @@ namespace PlexRequests.UI.Modules
|
||||||
PushbulletService = pbSettings;
|
PushbulletService = pbSettings;
|
||||||
PushbulletApi = pbApi;
|
PushbulletApi = pbApi;
|
||||||
CpApi = cpApi;
|
CpApi = cpApi;
|
||||||
|
SickRageService = sickrage;
|
||||||
|
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
this.RequiresAuthentication();
|
this.RequiresAuthentication();
|
||||||
|
@ -109,6 +112,9 @@ namespace PlexRequests.UI.Modules
|
||||||
Get["/sonarr"] = _ => Sonarr();
|
Get["/sonarr"] = _ => Sonarr();
|
||||||
Post["/sonarr"] = _ => SaveSonarr();
|
Post["/sonarr"] = _ => SaveSonarr();
|
||||||
|
|
||||||
|
Get["/sickrage"] = _ => Sickrage();
|
||||||
|
Post["/sickrage"] = _ => SaveSickrage();
|
||||||
|
|
||||||
Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
|
Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
|
||||||
Post["/cpprofiles"] = _ => GetCpProfiles();
|
Post["/cpprofiles"] = _ => GetCpProfiles();
|
||||||
|
|
||||||
|
@ -283,7 +289,11 @@ namespace PlexRequests.UI.Modules
|
||||||
{
|
{
|
||||||
return Response.AsJson(valid.SendJsonError());
|
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" });
|
||||||
|
}
|
||||||
var result = SonarrService.SaveSettings(sonarrSettings);
|
var result = SonarrService.SaveSettings(sonarrSettings);
|
||||||
|
|
||||||
return Response.AsJson(result
|
return Response.AsJson(result
|
||||||
|
@ -291,6 +301,35 @@ namespace PlexRequests.UI.Modules
|
||||||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Negotiator Sickrage()
|
||||||
|
{
|
||||||
|
var settings = SickRageService.GetSettings();
|
||||||
|
|
||||||
|
return View["Sickrage", settings];
|
||||||
|
}
|
||||||
|
|
||||||
|
private Response SaveSickrage()
|
||||||
|
{
|
||||||
|
var sickRageSettings = this.Bind<SickRageSettings>();
|
||||||
|
|
||||||
|
var valid = this.Validate(sickRageSettings);
|
||||||
|
if (!valid.IsValid)
|
||||||
|
{
|
||||||
|
return Response.AsJson(valid.SendJsonError());
|
||||||
|
}
|
||||||
|
|
||||||
|
var sonarrEnabled = SonarrService.GetSettings().Enabled;
|
||||||
|
if (sonarrEnabled)
|
||||||
|
{
|
||||||
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Sonarr is enabled, we cannot enable Sonarr and SickRage" });
|
||||||
|
}
|
||||||
|
var result = SickRageService.SaveSettings(sickRageSettings);
|
||||||
|
|
||||||
|
return Response.AsJson(result
|
||||||
|
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for SickRage!" }
|
||||||
|
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||||
|
}
|
||||||
|
|
||||||
private Response GetSonarrQualityProfiles()
|
private Response GetSonarrQualityProfiles()
|
||||||
{
|
{
|
||||||
var settings = this.Bind<SonarrSettings>();
|
var settings = this.Bind<SonarrSettings>();
|
||||||
|
|
|
@ -165,6 +165,7 @@
|
||||||
<Compile Include="Validators\EmailNotificationSettingsValidator.cs" />
|
<Compile Include="Validators\EmailNotificationSettingsValidator.cs" />
|
||||||
<Compile Include="Validators\CouchPotatoValidator.cs" />
|
<Compile Include="Validators\CouchPotatoValidator.cs" />
|
||||||
<Compile Include="Validators\PlexValidator.cs" />
|
<Compile Include="Validators\PlexValidator.cs" />
|
||||||
|
<Compile Include="Validators\SickRageValidator.cs" />
|
||||||
<Compile Include="Validators\SonarrValidator.cs" />
|
<Compile Include="Validators\SonarrValidator.cs" />
|
||||||
<Content Include="Content\bootstrap-notify.min.js">
|
<Content Include="Content\bootstrap-notify.min.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
@ -320,6 +321,9 @@
|
||||||
<Content Include="Views\Admin\PushbulletNotifications.cshtml">
|
<Content Include="Views\Admin\PushbulletNotifications.cshtml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Views\Admin\Sickrage.cshtml">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<None Include="Web.Debug.config">
|
<None Include="Web.Debug.config">
|
||||||
<DependentUpon>web.config</DependentUpon>
|
<DependentUpon>web.config</DependentUpon>
|
||||||
</None>
|
</None>
|
||||||
|
|
43
PlexRequests.UI/Validators/SickRageValidator.cs
Normal file
43
PlexRequests.UI/Validators/SickRageValidator.cs
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: SonarrValidator.cs
|
||||||
|
// Created By: Jamie Rees
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
// a copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
// the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
// ************************************************************************/
|
||||||
|
#endregion
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
using PlexRequests.Core.SettingModels;
|
||||||
|
|
||||||
|
namespace PlexRequests.UI.Validators
|
||||||
|
{
|
||||||
|
public class SickRageValidator : AbstractValidator<SickRageSettings>
|
||||||
|
{
|
||||||
|
public SickRageValidator()
|
||||||
|
{
|
||||||
|
RuleFor(request => request.ApiKey).NotEmpty().WithMessage("You must specify a Api Key.");
|
||||||
|
RuleFor(request => request.Ip).NotEmpty().WithMessage("You must specify a IP/Host name.");
|
||||||
|
RuleFor(request => request.Port).NotEmpty().WithMessage("You must specify a Port.");
|
||||||
|
RuleFor(request => request.QualityProfile).NotEmpty().WithMessage("You must specify a Quality Profile.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
197
PlexRequests.UI/Views/Admin/Sickrage.cshtml
Normal file
197
PlexRequests.UI/Views/Admin/Sickrage.cshtml
Normal file
|
@ -0,0 +1,197 @@
|
||||||
|
@Html.Partial("_Sidebar")
|
||||||
|
@{
|
||||||
|
int port;
|
||||||
|
if (Model.Port == 0)
|
||||||
|
{
|
||||||
|
port = 8081;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
port = Model.Port;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<div class="col-sm-8 col-sm-push-1">
|
||||||
|
<form class="form-horizontal" method="POST" id="mainForm">
|
||||||
|
<fieldset>
|
||||||
|
<legend>SickRage Settings</legend>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
@if (Model.Enabled)
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="Enabled" name="Enabled" checked="checked"><text>Enabled</text>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="Enabled" name="Enabled"><text>Enabled</text>
|
||||||
|
}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="Ip" class="control-label">SickRage Hostname or IP</label>
|
||||||
|
<div class="">
|
||||||
|
<input type="text" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="localhost" value="@Model.Ip">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="portNumber" class="control-label">Port</label>
|
||||||
|
|
||||||
|
<div class="">
|
||||||
|
<input type="text" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="@port">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="ApiKey" class="control-label">SickRage API Key</label>
|
||||||
|
<div>
|
||||||
|
<input type="text" class="form-control form-control-custom " id="ApiKey" name="ApiKey" value="@Model.ApiKey">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
@if (Model.Ssl)
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="Ssl" name="Ssl" checked="checked"><text>SSL</text>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="Ssl" name="Ssl"><text>SSL</text>
|
||||||
|
}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="profiles" class="control-label">Quality Profiles</label>
|
||||||
|
<div id="profiles">
|
||||||
|
<select class="form-control" value="selected">
|
||||||
|
<option selected="selected" value="default">Use Deafult</option>
|
||||||
|
<option value="sdtv">SD TV</option>
|
||||||
|
<option value="sddvd">SD DVD</option>
|
||||||
|
<option value="hdtv">HD TV</option>
|
||||||
|
<option value="rawhdtv">Raw HD TV</option>
|
||||||
|
<option value="hdwebdl">HD Web DL</option>
|
||||||
|
<option value="fullhdwebdl">Full HD Web DL</option>
|
||||||
|
<option value="hdbluray">HD Bluray</option>
|
||||||
|
<option value="fullhdbluray">Full HD Bluray</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div>
|
||||||
|
<button id="testSickRage" type="submit" class="btn btn-primary-outline">Test Connectivity</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div>
|
||||||
|
<button id="save" type="submit" class="btn btn-primary-outline ">Submit</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
|
||||||
|
|
||||||
|
$('#save').click(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var port = $('#portNumber').val();
|
||||||
|
if (isNaN(port)) {
|
||||||
|
generateNotify("You must specify a Port.", "warning");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var qualityProfile = $("#profiles option:selected").val();
|
||||||
|
|
||||||
|
var $form = $("#mainForm");
|
||||||
|
|
||||||
|
var data = $form.serialize();
|
||||||
|
data = data + "&qualityProfile=" + qualityProfile;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: $form.prop("method"),
|
||||||
|
data: data,
|
||||||
|
url: $form.prop("action"),
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
if (response.result === true) {
|
||||||
|
generateNotify("Success!", "success");
|
||||||
|
} else {
|
||||||
|
generateNotify(response.message, "warning");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#getProfiles').click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (!$('#Ip').val()) {
|
||||||
|
generateNotify("Please enter a valid IP/Hostname.", "warning");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!$('#portNumber').val()) {
|
||||||
|
generateNotify("Please enter a valid Port Number.", "warning");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!$('#ApiKey').val()) {
|
||||||
|
generateNotify("Please enter a valid ApiKey.", "warning");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var $form = $("#mainForm");
|
||||||
|
$.ajax({
|
||||||
|
type: $form.prop("method"),
|
||||||
|
data: $form.serialize(),
|
||||||
|
url: "sonarrprofiles",
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
response.forEach(function (result) {
|
||||||
|
$("#select").append("<option value='" + result.id + "'>" + result.name + "</option>");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#testSonarr').click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var $form = $("#mainForm");
|
||||||
|
$.ajax({
|
||||||
|
type: $form.prop("method"),
|
||||||
|
url: "/test/sonarr",
|
||||||
|
data: $form.serialize(),
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
console.log(response);
|
||||||
|
if (response.result === true) {
|
||||||
|
generateNotify(response.message, "success");
|
||||||
|
} else {
|
||||||
|
generateNotify(response.message, "warning");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
</script>
|
|
@ -14,7 +14,20 @@
|
||||||
<form class="form-horizontal" method="POST" id="mainForm">
|
<form class="form-horizontal" method="POST" id="mainForm">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Sonarr Settings</legend>
|
<legend>Sonarr Settings</legend>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
@if (Model.Enabled)
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="Enabled" name="Enabled" checked="checked"><text>Enabled</text>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<input type="checkbox" id="Enabled" name="Enabled"><text>Enabled</text>
|
||||||
|
}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="Ip" class="control-label">Sonarr Hostname or IP</label>
|
<label for="Ip" class="control-label">Sonarr Hostname or IP</label>
|
||||||
<div class="">
|
<div class="">
|
||||||
|
@ -121,7 +134,7 @@
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
response.forEach(function(result) {
|
response.forEach(function(result) {
|
||||||
if (result.id == qualitySelected) {
|
if (result.id == qualitySelected) {
|
||||||
|
|
||||||
$("#select").append("<option selected='selected' value='" + result.id + "'>" + result.name + "</option>");
|
$("#select").append("<option selected='selected' value='" + result.id + "'>" + result.name + "</option>");
|
||||||
} else {
|
} else {
|
||||||
$("#select").append("<option value='" + result.id + "'>" + result.name + "</option>");
|
$("#select").append("<option value='" + result.id + "'>" + result.name + "</option>");
|
||||||
|
|
|
@ -44,7 +44,14 @@
|
||||||
{
|
{
|
||||||
<a class="list-group-item" href="/admin/sonarr">Sonarr</a>
|
<a class="list-group-item" href="/admin/sonarr">Sonarr</a>
|
||||||
}
|
}
|
||||||
@*<a class="list-group-item" href="/admin/sickbeard">Sickbeard Settings</a>*@
|
@if (Context.Request.Path == "/admin/sickrage")
|
||||||
|
{
|
||||||
|
<a class="list-group-item active" href="/admin/sickrage">SickRage</a>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<a class="list-group-item" href="/admin/sickrage">SickRage</a>
|
||||||
|
}
|
||||||
|
|
||||||
@if (Context.Request.Path == "/admin/emailnotification")
|
@if (Context.Request.Path == "/admin/emailnotification")
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue