Started to add the specify Sonarr root folders.

pull/982/head
Jamie.Rees 8 years ago
parent ee66cd66e9
commit 1c6e75a413

@ -36,14 +36,16 @@ namespace Ombi.Api.Interfaces
List<SonarrProfile> GetProfiles(string apiKey, Uri baseUrl);
SonarrAddSeries AddSeries(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath,
int rootFolderId,
int seasonCount, int[] seasons, string apiKey, Uri baseUrl, bool monitor = true,
bool searchForMissingEpisodes = false);
SonarrAddSeries AddSeriesNew(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath,
int[] seasons, string apiKey, Uri baseUrl, bool monitor = true,
int rootFolderId, int[] seasons, string apiKey, Uri baseUrl, bool monitor = true,
bool searchForMissingEpisodes = false);
SystemStatus SystemStatus(string apiKey, Uri baseUrl);
List<SonarrRootFolder> GetRootFolders(string apiKey, Uri baseUrl);
List<Series> GetSeries(string apiKey, Uri baseUrl);
Series GetSeries(string seriesId, string apiKey, Uri baseUrl);

@ -101,6 +101,7 @@
<Compile Include="Sonarr\SonarrEpisodes.cs" />
<Compile Include="Sonarr\SonarrError.cs" />
<Compile Include="Sonarr\SonarrProfile.cs" />
<Compile Include="Sonarr\SonarrRootFolder.cs" />
<Compile Include="Sonarr\SonarrSearchCommand.cs" />
<Compile Include="Sonarr\SonarrSeasonSearchResult.cs" />
<Compile Include="Sonarr\SonarrSeriesSearchResult.cs" />

@ -0,0 +1,35 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2017 Jamie Rees
// File: SonarrRootFolder.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
namespace Ombi.Api.Models.Sonarr
{
public class SonarrRootFolder
{
public int id { get; set; }
public string path { get; set; }
public long freespace { get; set; }
}
}

@ -62,7 +62,23 @@ namespace Ombi.Api
return obj;
}
public SonarrAddSeries AddSeries(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath, int seasonCount, int[] seasons, string apiKey, Uri baseUrl, bool monitor = true, bool searchForMissingEpisodes = false)
public List<SonarrRootFolder> GetRootFolders(string apiKey, Uri baseUrl)
{
var request = new RestRequest { Resource = "/api/rootfolder", Method = Method.GET };
request.AddHeader("X-Api-Key", apiKey);
var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling GetRootFolders for Sonarr, Retrying {0}", timespan), new TimeSpan[] {
TimeSpan.FromSeconds (2),
TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(10)
});
var obj = policy.Execute(() => Api.ExecuteJson<List<SonarrRootFolder>>(request, baseUrl));
return obj;
}
public SonarrAddSeries AddSeries(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath, int rootFolderId, int seasonCount, int[] seasons, string apiKey, Uri baseUrl, bool monitor = true, bool searchForMissingEpisodes = false)
{
Log.Debug("Adding series {0}", title);
Log.Debug("Seasons = {0}, out of {1} seasons", seasons.DumpJson(), seasonCount);
@ -132,7 +148,7 @@ namespace Ombi.Api
return result;
}
public SonarrAddSeries AddSeriesNew(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath, int[] seasons, string apiKey, Uri baseUrl, bool monitor = true, bool searchForMissingEpisodes = false)
public SonarrAddSeries AddSeriesNew(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath, int rootFolderId, int[] seasons, string apiKey, Uri baseUrl, bool monitor = true, bool searchForMissingEpisodes = false)
{
var request = new RestRequest
{

@ -47,5 +47,6 @@ namespace Ombi.Core
public const string WatcherQueued = nameof(WatcherQueued);
public const string GetPlexRequestSettings = nameof(GetPlexRequestSettings);
public const string LastestProductVersion = nameof(LastestProductVersion);
public const string SonarrRootFolders = nameof(SonarrRootFolders);
}
}

@ -33,6 +33,7 @@ namespace Ombi.Core.SettingModels
public string QualityProfile { get; set; }
public bool SeasonFolders { get; set; }
public string RootPath { get; set; }
public string RootFolder { get; set; }
}
}

@ -51,7 +51,7 @@ namespace Ombi.Core
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model)
{
return await SendToSonarr(sonarrSettings, model, string.Empty);
return await SendToSonarr(sonarrSettings, model, string.Empty, string.Empty);
}
/// <summary>
@ -61,7 +61,7 @@ namespace Ombi.Core
/// <param name="model"></param>
/// <param name="qualityId"></param>
/// <returns></returns>
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model, string qualityId)
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model, string qualityId, string rootFolderId)
{
var qualityProfile = 0;
var episodeRequest = model.Episodes.Any();
@ -82,6 +82,17 @@ namespace Ombi.Core
var latest = model.SeasonsRequested?.Equals("Latest", StringComparison.CurrentCultureIgnoreCase);
var specificSeasonRequest = model.SeasonList?.Any();
var rootFolder = 0;
if (!string.IsNullOrEmpty(rootFolderId))
{
int.TryParse(qualityId, out rootFolder);
}
if (rootFolder <= 0)
{
int.TryParse(sonarrSettings.RootFolder, out rootFolder);
}
if (episodeRequest)
{
// Does series exist?
@ -96,7 +107,7 @@ namespace Ombi.Core
// Series doesn't exist, need to add it as unmonitored.
var addResult = await Task.Run(() => SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, 0, new int[0], sonarrSettings.ApiKey,
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, 0, rootFolder, new int[0], sonarrSettings.ApiKey,
sonarrSettings.FullUri, false));
@ -125,7 +136,7 @@ namespace Ombi.Core
{
// Set the series as monitored with a season count as 0 so it doesn't search for anything
SonarrApi.AddSeriesNew(model.ProviderId, model.Title, qualityProfile,
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13}, sonarrSettings.ApiKey,
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, rootFolder, new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13}, sonarrSettings.ApiKey,
sonarrSettings.FullUri);
await Task.Delay(TimeSpan.FromSeconds(1));

@ -49,12 +49,12 @@ namespace Ombi.Core
private ISickRageApi SickrageApi { get; }
private static Logger Log = LogManager.GetCurrentClassLogger();
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model)
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model, string rootFolderId = null)
{
return await SendToSonarr(sonarrSettings, model, string.Empty);
return await SendToSonarr(sonarrSettings, model, string.Empty, rootFolderId);
}
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model, string qualityId)
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model, string qualityId, string rootFolderId)
{
var qualityProfile = 0;
var episodeRequest = model.Episodes.Any();
@ -67,6 +67,17 @@ namespace Ombi.Core
{
int.TryParse(sonarrSettings.QualityProfile, out qualityProfile);
}
var rootFolder = 0;
if (!string.IsNullOrEmpty(rootFolderId))
{
int.TryParse(qualityId, out rootFolder);
}
if (rootFolder <= 0)
{
int.TryParse(sonarrSettings.RootFolder, out rootFolder);
}
var series = await GetSonarrSeries(sonarrSettings, model.ProviderId);
@ -84,7 +95,7 @@ namespace Ombi.Core
// Series doesn't exist, need to add it as unmonitored.
var addResult = await Task.Run(() => SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, 0, new int[0], sonarrSettings.ApiKey,
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, rootFolder, 0, new int[0], sonarrSettings.ApiKey,
sonarrSettings.FullUri, false));
@ -156,7 +167,7 @@ namespace Ombi.Core
var result = SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, model.SeasonCount, model.SeasonList, sonarrSettings.ApiKey,
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, rootFolder, model.SeasonCount, model.SeasonList, sonarrSettings.ApiKey,
sonarrSettings.FullUri, true, true);
return result;

@ -53,6 +53,7 @@ namespace Ombi.UI.ModelDataProviders
with.Property(x => x.SeasonFolders).Description("Sonarr's season folders").Required(false);
with.Property(x => x.RootFolder).Description("Sonarr's root folder").Required(true);
with.Property(x => x.RootPath).Description("Sonarr's root path").Required(false);
});
}

@ -58,5 +58,6 @@ namespace Ombi.UI.Models
public Store.EpisodesModel[] Episodes { get; set; }
public bool Denied { get; set; }
public string DeniedReason { get; set; }
public RootFolderModel[] RootFolders { get; set; }
}
}

@ -0,0 +1,36 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2017 Jamie Rees
// File: RootFolderModel.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
namespace Ombi.UI.Models
{
public class RootFolderModel
{
public string Id { get; set; }
public string Path { get; set; }
public long FreeSpace { get; set; }
}
}

@ -54,7 +54,7 @@ namespace Ombi.UI.Modules.Admin
{
public IntegrationModule(ISettingsService<PlexRequestSettings> settingsService, ISettingsService<WatcherSettings> watcher,
ISettingsService<CouchPotatoSettings> cp,ISecurityExtensions security, IAnalytics a, ISettingsService<RadarrSettings> radarrSettings,
ICacheProvider cache, IRadarrApi radarrApi) : base("admin", settingsService, security)
ICacheProvider cache, IRadarrApi radarrApi, ISonarrApi sonarrApi) : base("admin", settingsService, security)
{
WatcherSettings = watcher;
@ -63,9 +63,13 @@ namespace Ombi.UI.Modules.Admin
Cache = cache;
RadarrApi = radarrApi;
RadarrSettings = radarrSettings;
SonarrApi = sonarrApi;
Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
Post["/sonarrrootfolders"] = _ => GetSonarrRootFolders();
Get["/watcher", true] = async (x, ct) => await Watcher();
Post["/watcher", true] = async (x, ct) => await SaveWatcher();
@ -82,6 +86,7 @@ namespace Ombi.UI.Modules.Admin
private IRadarrApi RadarrApi { get; }
private ICacheProvider Cache { get; }
private IAnalytics Analytics { get; }
private ISonarrApi SonarrApi { get; }
private async Task<Negotiator> Watcher()
{
@ -182,5 +187,20 @@ namespace Ombi.UI.Modules.Admin
return Response.AsJson(profiles);
}
private Response GetSonarrRootFolders()
{
var settings = this.Bind<SonarrSettings>();
var rootFolders = SonarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);
// set the cache
if (rootFolders != null)
{
Cache.Set(CacheKeys.SonarrRootFolders, rootFolders);
}
return Response.AsJson(rootFolders);
}
}
}

@ -65,7 +65,7 @@ namespace Ombi.UI.Modules
FaultQueue = faultQueue;
MovieSender = movieSender;
Post["/approve", true] = async (x, ct) => await Approve((int)Request.Form.requestid, (string)Request.Form.qualityId);
Post["/approve", true] = async (x, ct) => await Approve((int)Request.Form.requestid, (string)Request.Form.qualityId, (string)Request.Form.rootFolderId ?? null);
Post["/deny", true] = async (x, ct) => await DenyRequest((int)Request.Form.requestid, (string)Request.Form.reason);
Post["/approveall", true] = async (x, ct) => await ApproveAll();
Post["/approveallmovies", true] = async (x, ct) => await ApproveAllMovies();
@ -92,7 +92,7 @@ namespace Ombi.UI.Modules
/// </summary>
/// <param name="requestId">The request identifier.</param>
/// <returns></returns>
private async Task<Response> Approve(int requestId, string qualityId)
private async Task<Response> Approve(int requestId, string qualityId, string rootFolderId = null)
{
Log.Info("approving request {0}", requestId);
@ -110,7 +110,7 @@ namespace Ombi.UI.Modules
case RequestType.Movie:
return await RequestMovieAndUpdateStatus(request, qualityId);
case RequestType.TvShow:
return await RequestTvAndUpdateStatus(request, qualityId);
return await RequestTvAndUpdateStatus(request, qualityId, rootFolderId);
case RequestType.Album:
return await RequestAlbumAndUpdateStatus(request);
default:
@ -118,7 +118,7 @@ namespace Ombi.UI.Modules
}
}
private async Task<Response> RequestTvAndUpdateStatus(RequestedModel request, string qualityId)
private async Task<Response> RequestTvAndUpdateStatus(RequestedModel request, string qualityId, string rootFolderId)
{
var sender = new TvSenderOld(SonarrApi, SickRageApi); // TODO put back

@ -160,6 +160,37 @@ namespace Ombi.UI.Modules
}
}
IEnumerable<RootFolderModel> rootFolders = new List<RootFolderModel>();
if (IsAdmin)
{
try
{
var sonarrSettings = await SonarrSettings.GetSettingsAsync();
if (sonarrSettings.Enabled)
{
var result = Cache.GetOrSetAsync(CacheKeys.SonarrRootFolders, async () =>
{
return await Task.Run(() => SonarrApi.GetRootFolders(sonarrSettings.ApiKey, sonarrSettings.FullUri));
});
rootFolders = result.Result.Select(x => new RootFolderModel { Id = x.id.ToString(), Path = x.path }).ToList();
}
// @TODO Sick Rage Root Folders
//else
//{
// var sickRageSettings = await SickRageSettings.GetSettingsAsync();
// if (sickRageSettings.Enabled)
// {
// qualities = sickRageSettings.Qualities.Select(x => new QualityModel { Id = x.Key, Name = x.Value }).ToList();
// }
//}
}
catch (Exception e)
{
Log.Info(e);
}
}
var canManageRequest = Security.HasAnyPermissions(User, Permissions.Administrator, Permissions.ManageRequests);
var viewModel = dbMovies.Select(movie => new RequestViewModel
@ -185,7 +216,8 @@ namespace Ombi.UI.Modules
IssueId = movie.IssueId,
Denied = movie.Denied,
DeniedReason = movie.DeniedReason,
Qualities = qualities.ToArray()
Qualities = qualities.ToArray(),
RootFolders = rootFolders.ToArray(),
}).ToList();
return Response.AsJson(viewModel);

@ -250,6 +250,7 @@
<Compile Include="Models\MovieSearchType.cs" />
<Compile Include="Models\QualityModel.cs" />
<Compile Include="Models\Requests\RequestsIndexViewModel.cs" />
<Compile Include="Models\RootFolderModel.cs" />
<Compile Include="Models\ScheduledJobsViewModel.cs" />
<Compile Include="Models\SearchViewModel.cs" />
<Compile Include="Models\SearchMusicViewModel.cs" />

@ -17,14 +17,14 @@
<legend>Sonarr Settings</legend>
<div class="form-group">
<div class="checkbox">
@if (Model.Enabled)
{
<input type="checkbox" id="Enabled" name="Enabled" checked="checked"><label for="Enabled">Enabled</label>
}
else
{
<input type="checkbox" id="Enabled" name="Enabled"><label for="Enabled">Enabled</label>
}
@if (Model.Enabled)
{
<input type="checkbox" id="Enabled" name="Enabled" checked="checked"><label for="Enabled">Enabled</label>
}
else
{
<input type="checkbox" id="Enabled" name="Enabled"><label for="Enabled">Enabled</label>
}
</div>
</div>
<div class="form-group">
@ -51,14 +51,14 @@
</div>
<div class="form-group">
<div class="checkbox">
@if (Model.Ssl)
{
<input type="checkbox" id="Ssl" name="Ssl" checked="checked"><label for="Ssl">SSL</label>
}
else
{
<input type="checkbox" id="Ssl" name="Ssl"><label for="Ssl">SSL</label>
}
@if (Model.Ssl)
{
<input type="checkbox" id="Ssl" name="Ssl" checked="checked"><label for="Ssl">SSL</label>
}
else
{
<input type="checkbox" id="Ssl" name="Ssl"><label for="Ssl">SSL</label>
}
</div>
</div>
<div class="form-group">
@ -69,7 +69,7 @@
</div>
<div class="form-group">
<div>
<button type="submit" id="getProfiles" class="btn btn-primary-outline">Get Quality Profiles <div id="getSpinner"/></button>
<button type="submit" id="getProfiles" class="btn btn-primary-outline">Get Quality Profiles <div id="getSpinner" /></button>
</div>
</div>
<div class="form-group">
@ -80,32 +80,47 @@
</div>
<div class="form-group">
<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>
<button type="submit" id="getRootFolders" class="btn btn-primary-outline">Get RootFolders <div id="getRootFolderSpinner" /></button>
</div>
</div>
<div class="form-group">
<label for="selectRootFolder" class="control-label">Root Folders</label>
<div id="rootFolders">
<select class="form-control form-control-custom" id="selectRootFolder"></select>
</div>
</div>
@*<div class="form-group">
<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>
</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>
@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>
<button id="testSonarr" type="submit" class="btn btn-primary-outline">Test Connectivity <div id="spinner" /></button>
</div>
</div>
@ -161,6 +176,39 @@
</text>
}
@if (!string.IsNullOrEmpty(Model.RootFolder))
{
<text>
console.log('Hit root folders..');
var rootFolderSelected = @Model.RootFolder;
if (!rootFolderSelected) {
return;
}
var $form = $("#mainForm");
$.ajax({
type: $form.prop("method"),
data: $form.serialize(),
url: "sonarrrootfolders",
dataType: "json",
success: function(response) {
response.forEach(function(result) {
if (result.id == rootFolderSelected) {
$("#selectRootFolder").append("<option selected='selected' value='" + result.id + "'>" + result.path + "</option>");
} else {
$("#selectRootFolder").append("<option value='" + result.id + "'>" + result.path + "</option>");
}
});
},
error: function(e) {
console.log(e);
generateNotify("Something went wrong!", "danger");
}
});
</text>
}
$('#save').click(function(e) {
e.preventDefault();
@ -201,17 +249,17 @@
e.preventDefault();
if (!$('#Ip').val()) {
generateNotify("Please enter a valid IP/Hostname.", "warning");
$('#getSpinner').attr("class", "fa fa-times");
$('#getSpinner').attr("class", "fa fa-times");
return;
}
if (!$('#portNumber').val()) {
generateNotify("Please enter a valid Port Number.", "warning");
$('#getSpinner').attr("class", "fa fa-times");
$('#getSpinner').attr("class", "fa fa-times");
return;
}
if (!$('#ApiKey').val()) {
generateNotify("Please enter a valid ApiKey.", "warning");
$('#getSpinner').attr("class", "fa fa-times");
$('#getSpinner').attr("class", "fa fa-times");
return;
}
var $form = $("#mainForm");
@ -222,18 +270,58 @@
dataType: "json",
success: function (response) {
response.forEach(function (result) {
$('#getSpinner').attr("class", "fa fa-check");
$('#getSpinner').attr("class", "fa fa-check");
$("#select").append("<option value='" + result.id + "'>" + result.name + "</option>");
});
},
error: function (e) {
console.log(e);
$('#getSpinner').attr("class", "fa fa-times");
$('#getSpinner').attr("class", "fa fa-times");
generateNotify("Something went wrong!", "danger");
}
});
});
$('#getRootFolders').click(function (e) {
$('#getRootFolderSpinner').attr("class", "fa fa-spinner fa-spin");
e.preventDefault();
if (!$('#Ip').val()) {
generateNotify("Please enter a valid IP/Hostname.", "warning");
$('#getRootFolderSpinner').attr("class", "fa fa-times");
return;
}
if (!$('#portNumber').val()) {
generateNotify("Please enter a valid Port Number.", "warning");
$('#getRootFolderSpinner').attr("class", "fa fa-times");
return;
}
if (!$('#ApiKey').val()) {
generateNotify("Please enter a valid ApiKey.", "warning");
$('#getRootFolderSpinner').attr("class", "fa fa-times");
return;
}
var $form = $("#mainForm");
$.ajax({
type: $form.prop("method"),
data: $form.serialize(),
url: "sonarrrootfolders",
dataType: "json",
success: function (response) {
response.forEach(function (result) {
$('#getRootFolderSpinner').attr("class", "fa fa-check");
$("#selectRootFolder").append("<option value='" + result.id + "'>" + result.path + "</option>");
});
},
error: function (e) {
console.log(e);
$('#getRootFolderSpinner').attr("class", "fa fa-times");
generateNotify("Something went wrong!", "danger");
}
});
});
var base = '@Html.GetBaseUrl()';
$('#testSonarr').click(function (e) {
@ -256,16 +344,16 @@
console.log(response);
if (response.result === true) {
generateNotify(response.message, "success");
$('#spinner').attr("class", "fa fa-check");
$('#spinner').attr("class", "fa fa-check");
} else {
generateNotify(response.message, "warning");
$('#spinner').attr("class", "fa fa-times");
$('#spinner').attr("class", "fa fa-times");
}
},
error: function (e) {
console.log(e);
generateNotify("Something went wrong!", "danger");
$('#spinner').attr("class", "fa fa-times");
$('#spinner').attr("class", "fa fa-times");
}
});
});

Loading…
Cancel
Save