mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 16:22:55 -07:00
Started to add the specify Sonarr root folders.
This commit is contained in:
parent
ee66cd66e9
commit
1c6e75a413
16 changed files with 316 additions and 59 deletions
|
@ -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" />
|
||||
|
|
35
Ombi.Api.Models/Sonarr/SonarrRootFolder.cs
Normal file
35
Ombi.Api.Models/Sonarr/SonarrRootFolder.cs
Normal file
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
|
36
Ombi.UI/Models/RootFolderModel.cs
Normal file
36
Ombi.UI/Models/RootFolderModel.cs
Normal file
|
@ -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" />
|
||||
|
|
|
@ -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,12 +80,27 @@
|
|||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<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>*@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
|
@ -105,7 +120,7 @@
|
|||
</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();
|
||||
|
@ -234,6 +282,46 @@
|
|||
});
|
||||
});
|
||||
|
||||
$('#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) {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue