mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
parent
9121af0042
commit
7fc26df599
19 changed files with 262 additions and 128 deletions
|
@ -36,12 +36,11 @@ namespace Ombi.Api.Interfaces
|
||||||
List<SonarrProfile> GetProfiles(string apiKey, Uri baseUrl);
|
List<SonarrProfile> GetProfiles(string apiKey, Uri baseUrl);
|
||||||
|
|
||||||
SonarrAddSeries AddSeries(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath,
|
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,
|
int seasonCount, int[] seasons, string apiKey, Uri baseUrl, bool monitor = true,
|
||||||
bool searchForMissingEpisodes = false);
|
bool searchForMissingEpisodes = false);
|
||||||
|
|
||||||
SonarrAddSeries AddSeriesNew(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath,
|
SonarrAddSeries AddSeriesNew(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath,
|
||||||
int rootFolderId, int[] seasons, string apiKey, Uri baseUrl, bool monitor = true,
|
int[] seasons, string apiKey, Uri baseUrl, bool monitor = true,
|
||||||
bool searchForMissingEpisodes = false);
|
bool searchForMissingEpisodes = false);
|
||||||
|
|
||||||
SystemStatus SystemStatus(string apiKey, Uri baseUrl);
|
SystemStatus SystemStatus(string apiKey, Uri baseUrl);
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace Ombi.Api
|
||||||
return obj;
|
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)
|
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)
|
||||||
{
|
{
|
||||||
Log.Debug("Adding series {0}", title);
|
Log.Debug("Adding series {0}", title);
|
||||||
Log.Debug("Seasons = {0}, out of {1} seasons", seasons.DumpJson(), seasonCount);
|
Log.Debug("Seasons = {0}, out of {1} seasons", seasons.DumpJson(), seasonCount);
|
||||||
|
@ -148,7 +148,7 @@ namespace Ombi.Api
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
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)
|
||||||
{
|
{
|
||||||
var request = new RestRequest
|
var request = new RestRequest
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,5 @@ namespace Ombi.Core.SettingModels
|
||||||
public string QualityProfile { get; set; }
|
public string QualityProfile { get; set; }
|
||||||
public bool SeasonFolders { get; set; }
|
public bool SeasonFolders { get; set; }
|
||||||
public string RootPath { get; set; }
|
public string RootPath { get; set; }
|
||||||
public string RootFolder { get; set; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,24 +34,27 @@ using Ombi.Api.Interfaces;
|
||||||
using Ombi.Api.Models.SickRage;
|
using Ombi.Api.Models.SickRage;
|
||||||
using Ombi.Api.Models.Sonarr;
|
using Ombi.Api.Models.Sonarr;
|
||||||
using Ombi.Core.SettingModels;
|
using Ombi.Core.SettingModels;
|
||||||
|
using Ombi.Helpers;
|
||||||
using Ombi.Store;
|
using Ombi.Store;
|
||||||
|
|
||||||
namespace Ombi.Core
|
namespace Ombi.Core
|
||||||
{
|
{
|
||||||
public class TvSender
|
public class TvSender
|
||||||
{
|
{
|
||||||
public TvSender(ISonarrApi sonarrApi, ISickRageApi srApi)
|
public TvSender(ISonarrApi sonarrApi, ISickRageApi srApi, ICacheProvider cache)
|
||||||
{
|
{
|
||||||
SonarrApi = sonarrApi;
|
SonarrApi = sonarrApi;
|
||||||
SickrageApi = srApi;
|
SickrageApi = srApi;
|
||||||
|
Cache = cache;
|
||||||
}
|
}
|
||||||
private ISonarrApi SonarrApi { get; }
|
private ISonarrApi SonarrApi { get; }
|
||||||
private ISickRageApi SickrageApi { get; }
|
private ISickRageApi SickrageApi { get; }
|
||||||
|
private ICacheProvider Cache { get; }
|
||||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model)
|
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model)
|
||||||
{
|
{
|
||||||
return await SendToSonarr(sonarrSettings, model, string.Empty, string.Empty);
|
return await SendToSonarr(sonarrSettings, model, string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -61,7 +64,7 @@ namespace Ombi.Core
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
/// <param name="qualityId"></param>
|
/// <param name="qualityId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model, string qualityId, string rootFolderId)
|
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model, string qualityId)
|
||||||
{
|
{
|
||||||
var qualityProfile = 0;
|
var qualityProfile = 0;
|
||||||
var episodeRequest = model.Episodes.Any();
|
var episodeRequest = model.Episodes.Any();
|
||||||
|
@ -82,16 +85,7 @@ namespace Ombi.Core
|
||||||
var latest = model.SeasonsRequested?.Equals("Latest", StringComparison.CurrentCultureIgnoreCase);
|
var latest = model.SeasonsRequested?.Equals("Latest", StringComparison.CurrentCultureIgnoreCase);
|
||||||
var specificSeasonRequest = model.SeasonList?.Any();
|
var specificSeasonRequest = model.SeasonList?.Any();
|
||||||
|
|
||||||
var rootFolder = 0;
|
var rootFolderPath = model.RootFolderSelected <= 0 ? sonarrSettings.RootPath : await GetRootPath(model.RootFolderSelected, sonarrSettings);
|
||||||
if (!string.IsNullOrEmpty(rootFolderId))
|
|
||||||
{
|
|
||||||
int.TryParse(qualityId, out rootFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rootFolder <= 0)
|
|
||||||
{
|
|
||||||
int.TryParse(sonarrSettings.RootFolder, out rootFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (episodeRequest)
|
if (episodeRequest)
|
||||||
{
|
{
|
||||||
|
@ -107,7 +101,7 @@ namespace Ombi.Core
|
||||||
|
|
||||||
// Series doesn't exist, need to add it as unmonitored.
|
// Series doesn't exist, need to add it as unmonitored.
|
||||||
var addResult = await Task.Run(() => SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
var addResult = await Task.Run(() => SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
||||||
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, 0, rootFolder, new int[0], sonarrSettings.ApiKey,
|
sonarrSettings.SeasonFolders, rootFolderPath, 0, new int[0], sonarrSettings.ApiKey,
|
||||||
sonarrSettings.FullUri, false));
|
sonarrSettings.FullUri, false));
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,7 +130,7 @@ namespace Ombi.Core
|
||||||
{
|
{
|
||||||
// Set the series as monitored with a season count as 0 so it doesn't search for anything
|
// 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,
|
SonarrApi.AddSeriesNew(model.ProviderId, model.Title, qualityProfile,
|
||||||
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, rootFolder, new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13}, sonarrSettings.ApiKey,
|
sonarrSettings.SeasonFolders, rootFolderPath, new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13}, sonarrSettings.ApiKey,
|
||||||
sonarrSettings.FullUri);
|
sonarrSettings.FullUri);
|
||||||
|
|
||||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||||
|
@ -383,5 +377,20 @@ namespace Ombi.Core
|
||||||
|
|
||||||
return selectedSeries;
|
return selectedSeries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<string> GetRootPath(int pathId, SonarrSettings sonarrSettings)
|
||||||
|
{
|
||||||
|
var rootFoldersResult = await Cache.GetOrSetAsync(CacheKeys.SonarrRootFolders, async () =>
|
||||||
|
{
|
||||||
|
return await Task.Run(() => SonarrApi.GetRootFolders(sonarrSettings.ApiKey, sonarrSettings.FullUri));
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var r in rootFoldersResult.Where(r => r.id == pathId))
|
||||||
|
{
|
||||||
|
return r.path;
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,27 +34,30 @@ using Ombi.Api.Interfaces;
|
||||||
using Ombi.Api.Models.SickRage;
|
using Ombi.Api.Models.SickRage;
|
||||||
using Ombi.Api.Models.Sonarr;
|
using Ombi.Api.Models.Sonarr;
|
||||||
using Ombi.Core.SettingModels;
|
using Ombi.Core.SettingModels;
|
||||||
|
using Ombi.Helpers;
|
||||||
using Ombi.Store;
|
using Ombi.Store;
|
||||||
|
|
||||||
namespace Ombi.Core
|
namespace Ombi.Core
|
||||||
{
|
{
|
||||||
public class TvSenderOld
|
public class TvSenderOld
|
||||||
{
|
{
|
||||||
public TvSenderOld(ISonarrApi sonarrApi, ISickRageApi srApi)
|
public TvSenderOld(ISonarrApi sonarrApi, ISickRageApi srApi, ICacheProvider cache)
|
||||||
{
|
{
|
||||||
SonarrApi = sonarrApi;
|
SonarrApi = sonarrApi;
|
||||||
SickrageApi = srApi;
|
SickrageApi = srApi;
|
||||||
|
Cache = cache;
|
||||||
}
|
}
|
||||||
private ISonarrApi SonarrApi { get; }
|
private ISonarrApi SonarrApi { get; }
|
||||||
private ISickRageApi SickrageApi { get; }
|
private ISickRageApi SickrageApi { get; }
|
||||||
|
private ICacheProvider Cache { get; }
|
||||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model, string rootFolderId = null)
|
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model)
|
||||||
{
|
{
|
||||||
return await SendToSonarr(sonarrSettings, model, string.Empty, rootFolderId);
|
return await SendToSonarr(sonarrSettings, model, string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model, string qualityId, string rootFolderId)
|
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model, string qualityId)
|
||||||
{
|
{
|
||||||
var qualityProfile = 0;
|
var qualityProfile = 0;
|
||||||
var episodeRequest = model.Episodes.Any();
|
var episodeRequest = model.Episodes.Any();
|
||||||
|
@ -67,16 +70,7 @@ namespace Ombi.Core
|
||||||
{
|
{
|
||||||
int.TryParse(sonarrSettings.QualityProfile, out qualityProfile);
|
int.TryParse(sonarrSettings.QualityProfile, out qualityProfile);
|
||||||
}
|
}
|
||||||
var rootFolder = 0;
|
var rootFolderPath = model.RootFolderSelected <= 0 ? sonarrSettings.RootPath : await GetRootPath(model.RootFolderSelected, sonarrSettings);
|
||||||
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);
|
var series = await GetSonarrSeries(sonarrSettings, model.ProviderId);
|
||||||
|
@ -95,7 +89,7 @@ namespace Ombi.Core
|
||||||
|
|
||||||
// Series doesn't exist, need to add it as unmonitored.
|
// Series doesn't exist, need to add it as unmonitored.
|
||||||
var addResult = await Task.Run(() => SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
var addResult = await Task.Run(() => SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
||||||
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, rootFolder, 0, new int[0], sonarrSettings.ApiKey,
|
sonarrSettings.SeasonFolders, rootFolderPath, 0, new int[0], sonarrSettings.ApiKey,
|
||||||
sonarrSettings.FullUri, false));
|
sonarrSettings.FullUri, false));
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,7 +161,7 @@ namespace Ombi.Core
|
||||||
|
|
||||||
|
|
||||||
var result = SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
var result = SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
||||||
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, rootFolder, model.SeasonCount, model.SeasonList, sonarrSettings.ApiKey,
|
sonarrSettings.SeasonFolders, rootFolderPath, model.SeasonCount, model.SeasonList, sonarrSettings.ApiKey,
|
||||||
sonarrSettings.FullUri, true, true);
|
sonarrSettings.FullUri, true, true);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -309,5 +303,20 @@ namespace Ombi.Core
|
||||||
|
|
||||||
return selectedSeries;
|
return selectedSeries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task<string> GetRootPath(int pathId, SonarrSettings sonarrSettings)
|
||||||
|
{
|
||||||
|
var rootFoldersResult = await Cache.GetOrSetAsync(CacheKeys.SonarrRootFolders, async () =>
|
||||||
|
{
|
||||||
|
return await Task.Run(() => SonarrApi.GetRootFolders(sonarrSettings.ApiKey, sonarrSettings.FullUri));
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var r in rootFoldersResult.Where(r => r.id == pathId))
|
||||||
|
{
|
||||||
|
return r.path;
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -53,7 +53,7 @@ namespace Ombi.Services.Jobs
|
||||||
ISickRageApi srApi, ISettingsService<SonarrSettings> sonarrSettings, ISettingsService<SickRageSettings> srSettings,
|
ISickRageApi srApi, ISettingsService<SonarrSettings> sonarrSettings, ISettingsService<SickRageSettings> srSettings,
|
||||||
ICouchPotatoApi cpApi, ISettingsService<CouchPotatoSettings> cpsettings, IRequestService requestService,
|
ICouchPotatoApi cpApi, ISettingsService<CouchPotatoSettings> cpsettings, IRequestService requestService,
|
||||||
ISettingsService<HeadphonesSettings> hpSettings, IHeadphonesApi headphonesApi, ISettingsService<PlexRequestSettings> prSettings,
|
ISettingsService<HeadphonesSettings> hpSettings, IHeadphonesApi headphonesApi, ISettingsService<PlexRequestSettings> prSettings,
|
||||||
ISecurityExtensions security, IMovieSender movieSender)
|
ISecurityExtensions security, IMovieSender movieSender, ICacheProvider cache)
|
||||||
{
|
{
|
||||||
Record = record;
|
Record = record;
|
||||||
Repo = repo;
|
Repo = repo;
|
||||||
|
@ -71,6 +71,8 @@ namespace Ombi.Services.Jobs
|
||||||
Security = security;
|
Security = security;
|
||||||
PrSettings = prSettings.GetSettings();
|
PrSettings = prSettings.GetSettings();
|
||||||
MovieSender = movieSender;
|
MovieSender = movieSender;
|
||||||
|
|
||||||
|
Cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IMovieSender MovieSender { get; }
|
private IMovieSender MovieSender { get; }
|
||||||
|
@ -78,6 +80,7 @@ namespace Ombi.Services.Jobs
|
||||||
private IJobRecord Record { get; }
|
private IJobRecord Record { get; }
|
||||||
private ISonarrApi SonarrApi { get; }
|
private ISonarrApi SonarrApi { get; }
|
||||||
private ISickRageApi SrApi { get; }
|
private ISickRageApi SrApi { get; }
|
||||||
|
private ICacheProvider Cache { get; }
|
||||||
private ICouchPotatoApi CpApi { get; }
|
private ICouchPotatoApi CpApi { get; }
|
||||||
private IHeadphonesApi HpApi { get; }
|
private IHeadphonesApi HpApi { get; }
|
||||||
private IRequestService RequestService { get; }
|
private IRequestService RequestService { get; }
|
||||||
|
@ -163,7 +166,7 @@ namespace Ombi.Services.Jobs
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
var sender = new TvSenderOld(SonarrApi, SrApi);
|
var sender = new TvSenderOld(SonarrApi, SrApi, Cache);
|
||||||
if (sonarr.Enabled)
|
if (sonarr.Enabled)
|
||||||
{
|
{
|
||||||
var task = sender.SendToSonarr(sonarr, tvModel, sonarr.QualityProfile);
|
var task = sender.SendToSonarr(sonarr, tvModel, sonarr.QualityProfile);
|
||||||
|
|
|
@ -79,6 +79,7 @@ namespace Ombi.Services.Jobs
|
||||||
|
|
||||||
public void CheckAndUpdateAll()
|
public void CheckAndUpdateAll()
|
||||||
{
|
{
|
||||||
|
|
||||||
var plexSettings = Plex.GetSettings();
|
var plexSettings = Plex.GetSettings();
|
||||||
|
|
||||||
if (!ValidateSettings(plexSettings))
|
if (!ValidateSettings(plexSettings))
|
||||||
|
|
|
@ -46,6 +46,13 @@ namespace Ombi.Store
|
||||||
public List<EpisodesModel> Episodes { get; set; }
|
public List<EpisodesModel> Episodes { get; set; }
|
||||||
public bool Denied { get; set; }
|
public bool Denied { get; set; }
|
||||||
public string DeniedReason { get; set; }
|
public string DeniedReason { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// For TV Shows with a custom root folder
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The root folder selected.
|
||||||
|
/// </value>
|
||||||
|
public int RootFolderSelected { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public List<string> AllUsers
|
public List<string> AllUsers
|
||||||
|
|
|
@ -35,6 +35,7 @@ using Ombi.Api.Interfaces;
|
||||||
using Ombi.Api.Models.Sonarr;
|
using Ombi.Api.Models.Sonarr;
|
||||||
using Ombi.Core;
|
using Ombi.Core;
|
||||||
using Ombi.Core.SettingModels;
|
using Ombi.Core.SettingModels;
|
||||||
|
using Ombi.Helpers;
|
||||||
using Ombi.Store;
|
using Ombi.Store;
|
||||||
using Ploeh.AutoFixture;
|
using Ploeh.AutoFixture;
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@ namespace Ombi.UI.Tests
|
||||||
|
|
||||||
private TvSender Sender { get; set; }
|
private TvSender Sender { get; set; }
|
||||||
private Fixture F { get; set; }
|
private Fixture F { get; set; }
|
||||||
|
private Mock<ICacheProvider> Cache { get; set; }
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
|
@ -56,7 +58,8 @@ namespace Ombi.UI.Tests
|
||||||
F = new Fixture();
|
F = new Fixture();
|
||||||
SonarrMock = new Mock<ISonarrApi>();
|
SonarrMock = new Mock<ISonarrApi>();
|
||||||
SickrageMock = new Mock<ISickRageApi>();
|
SickrageMock = new Mock<ISickRageApi>();
|
||||||
Sender = new TvSender(SonarrMock.Object, SickrageMock.Object);
|
Cache = new Mock<ICacheProvider>();
|
||||||
|
Sender = new TvSender(SonarrMock.Object, SickrageMock.Object, Cache.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -66,7 +69,7 @@ namespace Ombi.UI.Tests
|
||||||
var seriesResult = new SonarrAddSeries() { title = "ABC"};
|
var seriesResult = new SonarrAddSeries() { title = "ABC"};
|
||||||
SonarrMock.Setup(x => x.GetSeries(It.IsAny<string>(), It.IsAny<Uri>())).Returns(F.Build<Series>().With(x => x.tvdbId, 1).With(x => x.title, "ABC").CreateMany().ToList());
|
SonarrMock.Setup(x => x.GetSeries(It.IsAny<string>(), It.IsAny<Uri>())).Returns(F.Build<Series>().With(x => x.tvdbId, 1).With(x => x.title, "ABC").CreateMany().ToList());
|
||||||
|
|
||||||
Sender = new TvSender(SonarrMock.Object, SickrageMock.Object);
|
Sender = new TvSender(SonarrMock.Object, SickrageMock.Object, Cache.Object);
|
||||||
|
|
||||||
var request = new RequestedModel {SeasonsRequested = "All", ProviderId = 1, Title = "ABC"};
|
var request = new RequestedModel {SeasonsRequested = "All", ProviderId = 1, Title = "ABC"};
|
||||||
|
|
||||||
|
@ -79,7 +82,6 @@ namespace Ombi.UI.Tests
|
||||||
It.IsAny<bool>(),
|
It.IsAny<bool>(),
|
||||||
It.IsAny<string>(),
|
It.IsAny<string>(),
|
||||||
It.IsAny<int>(),
|
It.IsAny<int>(),
|
||||||
It.IsAny<int>(),
|
|
||||||
It.IsAny<int[]>(),
|
It.IsAny<int[]>(),
|
||||||
It.IsAny<string>(),
|
It.IsAny<string>(),
|
||||||
It.IsAny<Uri>(),
|
It.IsAny<Uri>(),
|
||||||
|
@ -100,7 +102,6 @@ namespace Ombi.UI.Tests
|
||||||
It.IsAny<bool>(),
|
It.IsAny<bool>(),
|
||||||
It.IsAny<string>(),
|
It.IsAny<string>(),
|
||||||
It.IsAny<int>(),
|
It.IsAny<int>(),
|
||||||
It.IsAny<int>(),
|
|
||||||
It.IsAny<int[]>(),
|
It.IsAny<int[]>(),
|
||||||
It.IsAny<string>(),
|
It.IsAny<string>(),
|
||||||
It.IsAny<Uri>(),
|
It.IsAny<Uri>(),
|
||||||
|
@ -118,7 +119,7 @@ namespace Ombi.UI.Tests
|
||||||
SonarrMock.Setup(x => x.GetEpisodes(It.IsAny<string>(), It.IsAny<string>(),
|
SonarrMock.Setup(x => x.GetEpisodes(It.IsAny<string>(), It.IsAny<string>(),
|
||||||
It.IsAny<Uri>())).Returns(F.CreateMany<SonarrEpisodes>());
|
It.IsAny<Uri>())).Returns(F.CreateMany<SonarrEpisodes>());
|
||||||
|
|
||||||
Sender = new TvSender(SonarrMock.Object, SickrageMock.Object);
|
Sender = new TvSender(SonarrMock.Object, SickrageMock.Object, Cache.Object);
|
||||||
var episodes = new List<EpisodesModel>
|
var episodes = new List<EpisodesModel>
|
||||||
{
|
{
|
||||||
new EpisodesModel
|
new EpisodesModel
|
||||||
|
@ -130,7 +131,7 @@ namespace Ombi.UI.Tests
|
||||||
var model = F.Build<RequestedModel>().With(x => x.ProviderId, 1)
|
var model = F.Build<RequestedModel>().With(x => x.ProviderId, 1)
|
||||||
.With(x => x.Episodes, episodes).Create();
|
.With(x => x.Episodes, episodes).Create();
|
||||||
|
|
||||||
var result = await Sender.SendToSonarr(GetSonarrSettings(), model, "2", string.Empty);
|
var result = await Sender.SendToSonarr(GetSonarrSettings(), model, "2");
|
||||||
|
|
||||||
Assert.That(result, Is.EqualTo(seriesResult));
|
Assert.That(result, Is.EqualTo(seriesResult));
|
||||||
SonarrMock.Verify(x => x.AddSeries(It.IsAny<int>(),
|
SonarrMock.Verify(x => x.AddSeries(It.IsAny<int>(),
|
||||||
|
@ -139,7 +140,6 @@ namespace Ombi.UI.Tests
|
||||||
It.IsAny<bool>(),
|
It.IsAny<bool>(),
|
||||||
It.IsAny<string>(),
|
It.IsAny<string>(),
|
||||||
It.IsAny<int>(),
|
It.IsAny<int>(),
|
||||||
It.IsAny<int>(),
|
|
||||||
It.IsAny<int[]>(),
|
It.IsAny<int[]>(),
|
||||||
It.IsAny<string>(),
|
It.IsAny<string>(),
|
||||||
It.IsAny<Uri>(),
|
It.IsAny<Uri>(),
|
||||||
|
|
|
@ -559,6 +559,25 @@ $(document).on("click", ".approve-with-quality", function (e) {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Change root folder
|
||||||
|
$(document).on("click", ".change-root-folder", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var $this = $(this);
|
||||||
|
var $button = $this.parents('.btn-split').children('.change').first();
|
||||||
|
var rootFolderId = e.target.id
|
||||||
|
var $form = $this.parents('form').first();
|
||||||
|
|
||||||
|
if ($button.text() === " Loading...") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadingButton($button.attr('id'), "success");
|
||||||
|
|
||||||
|
changeRootFolder($form, rootFolderId, function () {
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Change Availability
|
// Change Availability
|
||||||
$(document).on("click", ".change", function (e) {
|
$(document).on("click", ".change", function (e) {
|
||||||
|
@ -638,6 +657,37 @@ function approveRequest($form, qualityId, successCallback) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeRootFolder($form, rootFolderId, successCallback) {
|
||||||
|
|
||||||
|
var formData = $form.serialize();
|
||||||
|
if (rootFolderId) formData += ("&rootFolderId=" + rootFolderId);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: $form.prop('method'),
|
||||||
|
url: $form.prop('action'),
|
||||||
|
data: formData,
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
|
||||||
|
if (checkJsonResponse(response)) {
|
||||||
|
if (response.message) {
|
||||||
|
generateNotify(response.message, "success");
|
||||||
|
} else {
|
||||||
|
generateNotify("Success! Changed Root Path.", "success");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (successCallback) {
|
||||||
|
successCallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function denyRequest($form, successCallback) {
|
function denyRequest($form, successCallback) {
|
||||||
|
|
||||||
var formData = $form.serialize();
|
var formData = $form.serialize();
|
||||||
|
@ -808,6 +858,9 @@ function buildRequestContext(result, type) {
|
||||||
musicBrainzId: result.musicBrainzId,
|
musicBrainzId: result.musicBrainzId,
|
||||||
denied: result.denied,
|
denied: result.denied,
|
||||||
deniedReason: result.deniedReason,
|
deniedReason: result.deniedReason,
|
||||||
|
hasRootFolders: result.hasRootFolders,
|
||||||
|
rootFolders: result.rootFolders,
|
||||||
|
currentRootPath : result.currentRootPath
|
||||||
};
|
};
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
|
|
|
@ -52,8 +52,7 @@ namespace Ombi.UI.ModelDataProviders
|
||||||
with.Property(x => x.QualityProfile).Description("Sonarr's quality profile").Required(true);
|
with.Property(x => x.QualityProfile).Description("Sonarr's quality profile").Required(true);
|
||||||
|
|
||||||
with.Property(x => x.SeasonFolders).Description("Sonarr's season folders").Required(false);
|
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);
|
with.Property(x => x.RootPath).Description("Sonarr's root path").Required(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,5 +59,7 @@ namespace Ombi.UI.Models
|
||||||
public bool Denied { get; set; }
|
public bool Denied { get; set; }
|
||||||
public string DeniedReason { get; set; }
|
public string DeniedReason { get; set; }
|
||||||
public RootFolderModel[] RootFolders { get; set; }
|
public RootFolderModel[] RootFolders { get; set; }
|
||||||
|
public bool HasRootFolders { get; set; }
|
||||||
|
public string CurrentRootPath { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace Ombi.UI.Modules
|
||||||
public ApprovalModule(IRequestService service, ISonarrApi sonarrApi,
|
public ApprovalModule(IRequestService service, ISonarrApi sonarrApi,
|
||||||
ISettingsService<SonarrSettings> sonarrSettings, ISickRageApi srApi, ISettingsService<SickRageSettings> srSettings,
|
ISettingsService<SonarrSettings> sonarrSettings, ISickRageApi srApi, ISettingsService<SickRageSettings> srSettings,
|
||||||
ISettingsService<HeadphonesSettings> hpSettings, IHeadphonesApi hpApi, ISettingsService<PlexRequestSettings> pr, ITransientFaultQueue faultQueue
|
ISettingsService<HeadphonesSettings> hpSettings, IHeadphonesApi hpApi, ISettingsService<PlexRequestSettings> pr, ITransientFaultQueue faultQueue
|
||||||
, ISecurityExtensions security, IMovieSender movieSender) : base("approval", pr, security)
|
, ISecurityExtensions security, IMovieSender movieSender, ICacheProvider cache) : base("approval", pr, security)
|
||||||
{
|
{
|
||||||
|
|
||||||
Before += (ctx) => Security.AdminLoginRedirect(ctx, Permissions.Administrator,Permissions.ManageRequests);
|
Before += (ctx) => Security.AdminLoginRedirect(ctx, Permissions.Administrator,Permissions.ManageRequests);
|
||||||
|
@ -64,8 +64,9 @@ namespace Ombi.UI.Modules
|
||||||
HeadphoneApi = hpApi;
|
HeadphoneApi = hpApi;
|
||||||
FaultQueue = faultQueue;
|
FaultQueue = faultQueue;
|
||||||
MovieSender = movieSender;
|
MovieSender = movieSender;
|
||||||
|
Cache = cache;
|
||||||
|
|
||||||
Post["/approve", true] = async (x, ct) => await Approve((int)Request.Form.requestid, (string)Request.Form.qualityId, (string)Request.Form.rootFolderId ?? null);
|
Post["/approve", true] = async (x, ct) => await Approve((int)Request.Form.requestid, (string)Request.Form.qualityId);
|
||||||
Post["/deny", true] = async (x, ct) => await DenyRequest((int)Request.Form.requestid, (string)Request.Form.reason);
|
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["/approveall", true] = async (x, ct) => await ApproveAll();
|
||||||
Post["/approveallmovies", true] = async (x, ct) => await ApproveAllMovies();
|
Post["/approveallmovies", true] = async (x, ct) => await ApproveAllMovies();
|
||||||
|
@ -86,13 +87,14 @@ namespace Ombi.UI.Modules
|
||||||
private ISickRageApi SickRageApi { get; }
|
private ISickRageApi SickRageApi { get; }
|
||||||
private IHeadphonesApi HeadphoneApi { get; }
|
private IHeadphonesApi HeadphoneApi { get; }
|
||||||
private ITransientFaultQueue FaultQueue { get; }
|
private ITransientFaultQueue FaultQueue { get; }
|
||||||
|
private ICacheProvider Cache { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Approves the specified request identifier.
|
/// Approves the specified request identifier.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="requestId">The request identifier.</param>
|
/// <param name="requestId">The request identifier.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task<Response> Approve(int requestId, string qualityId, string rootFolderId = null)
|
private async Task<Response> Approve(int requestId, string qualityId)
|
||||||
{
|
{
|
||||||
Log.Info("approving request {0}", requestId);
|
Log.Info("approving request {0}", requestId);
|
||||||
|
|
||||||
|
@ -110,7 +112,7 @@ namespace Ombi.UI.Modules
|
||||||
case RequestType.Movie:
|
case RequestType.Movie:
|
||||||
return await RequestMovieAndUpdateStatus(request, qualityId);
|
return await RequestMovieAndUpdateStatus(request, qualityId);
|
||||||
case RequestType.TvShow:
|
case RequestType.TvShow:
|
||||||
return await RequestTvAndUpdateStatus(request, qualityId, rootFolderId);
|
return await RequestTvAndUpdateStatus(request, qualityId);
|
||||||
case RequestType.Album:
|
case RequestType.Album:
|
||||||
return await RequestAlbumAndUpdateStatus(request);
|
return await RequestAlbumAndUpdateStatus(request);
|
||||||
default:
|
default:
|
||||||
|
@ -118,9 +120,9 @@ namespace Ombi.UI.Modules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Response> RequestTvAndUpdateStatus(RequestedModel request, string qualityId, string rootFolderId)
|
private async Task<Response> RequestTvAndUpdateStatus(RequestedModel request, string qualityId)
|
||||||
{
|
{
|
||||||
var sender = new TvSenderOld(SonarrApi, SickRageApi); // TODO put back
|
var sender = new TvSenderOld(SonarrApi, SickRageApi, Cache); // TODO put back
|
||||||
|
|
||||||
var sonarrSettings = await SonarrSettings.GetSettingsAsync();
|
var sonarrSettings = await SonarrSettings.GetSettingsAsync();
|
||||||
if (sonarrSettings.Enabled)
|
if (sonarrSettings.Enabled)
|
||||||
|
@ -435,7 +437,7 @@ namespace Ombi.UI.Modules
|
||||||
}
|
}
|
||||||
if (r.Type == RequestType.TvShow)
|
if (r.Type == RequestType.TvShow)
|
||||||
{
|
{
|
||||||
var sender = new TvSenderOld(SonarrApi, SickRageApi); // TODO put back
|
var sender = new TvSenderOld(SonarrApi, SickRageApi, Cache); // TODO put back
|
||||||
var sr = await SickRageSettings.GetSettingsAsync();
|
var sr = await SickRageSettings.GetSettingsAsync();
|
||||||
var sonarr = await SonarrSettings.GetSettingsAsync();
|
var sonarr = await SonarrSettings.GetSettingsAsync();
|
||||||
if (sr.Enabled)
|
if (sr.Enabled)
|
||||||
|
|
|
@ -96,6 +96,8 @@ namespace Ombi.UI.Modules
|
||||||
|
|
||||||
Post["/changeavailability", true] = async (x, ct) => await ChangeRequestAvailability((int)Request.Form.Id, (bool)Request.Form.Available);
|
Post["/changeavailability", true] = async (x, ct) => await ChangeRequestAvailability((int)Request.Form.Id, (bool)Request.Form.Available);
|
||||||
|
|
||||||
|
Post["/changeRootFolder", true] = async (x, ct) => await ChangeRootFolder((int) Request.Form.requestId, (int) Request.Form.rootFolderId);
|
||||||
|
|
||||||
Get["/UpdateFilters", true] = async (x, ct) => await GetFilterAndSortSettings();
|
Get["/UpdateFilters", true] = async (x, ct) => await GetFilterAndSortSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,38 +162,7 @@ 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 canManageRequest = Security.HasAnyPermissions(User, Permissions.Administrator, Permissions.ManageRequests);
|
||||||
var viewModel = dbMovies.Select(movie => new RequestViewModel
|
var viewModel = dbMovies.Select(movie => new RequestViewModel
|
||||||
{
|
{
|
||||||
|
@ -217,7 +188,6 @@ namespace Ombi.UI.Modules
|
||||||
Denied = movie.Denied,
|
Denied = movie.Denied,
|
||||||
DeniedReason = movie.DeniedReason,
|
DeniedReason = movie.DeniedReason,
|
||||||
Qualities = qualities.ToArray(),
|
Qualities = qualities.ToArray(),
|
||||||
RootFolders = rootFolders.ToArray(),
|
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
return Response.AsJson(viewModel);
|
return Response.AsJson(viewModel);
|
||||||
|
@ -225,32 +195,39 @@ namespace Ombi.UI.Modules
|
||||||
|
|
||||||
private async Task<Response> GetTvShows()
|
private async Task<Response> GetTvShows()
|
||||||
{
|
{
|
||||||
var settingsTask = PrSettings.GetSettingsAsync();
|
|
||||||
|
|
||||||
var requests = await Service.GetAllAsync();
|
var requests = await Service.GetAllAsync();
|
||||||
requests = requests.Where(x => x.Type == RequestType.TvShow);
|
requests = requests.Where(x => x.Type == RequestType.TvShow);
|
||||||
|
|
||||||
var dbTv = requests;
|
var dbTv = requests;
|
||||||
var settings = await settingsTask;
|
|
||||||
if (Security.HasPermissions(User, Permissions.UsersCanViewOnlyOwnRequests) && !IsAdmin)
|
if (Security.HasPermissions(User, Permissions.UsersCanViewOnlyOwnRequests) && !IsAdmin)
|
||||||
{
|
{
|
||||||
dbTv = dbTv.Where(x => x.UserHasRequested(Username)).ToList();
|
dbTv = dbTv.Where(x => x.UserHasRequested(Username)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<QualityModel> qualities = new List<QualityModel>();
|
IEnumerable<QualityModel> qualities = new List<QualityModel>();
|
||||||
|
IEnumerable<RootFolderModel> rootFolders = new List<RootFolderModel>();
|
||||||
|
|
||||||
|
var sonarrSettings = await SonarrSettings.GetSettingsAsync();
|
||||||
if (IsAdmin)
|
if (IsAdmin)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sonarrSettings = await SonarrSettings.GetSettingsAsync();
|
|
||||||
if (sonarrSettings.Enabled)
|
if (sonarrSettings.Enabled)
|
||||||
{
|
{
|
||||||
var result = Cache.GetOrSetAsync(CacheKeys.SonarrQualityProfiles, async () =>
|
var result = await Cache.GetOrSetAsync(CacheKeys.SonarrQualityProfiles, async () =>
|
||||||
{
|
{
|
||||||
return await Task.Run(() => SonarrApi.GetProfiles(sonarrSettings.ApiKey, sonarrSettings.FullUri));
|
return await Task.Run(() => SonarrApi.GetProfiles(sonarrSettings.ApiKey, sonarrSettings.FullUri));
|
||||||
});
|
});
|
||||||
qualities = result.Result.Select(x => new QualityModel { Id = x.id.ToString(), Name = x.name }).ToList();
|
qualities = result.Select(x => new QualityModel { Id = x.id.ToString(), Name = x.name }).ToList();
|
||||||
}
|
|
||||||
|
|
||||||
|
var rootFoldersResult =await Cache.GetOrSetAsync(CacheKeys.SonarrRootFolders, async () =>
|
||||||
|
{
|
||||||
|
return await Task.Run(() => SonarrApi.GetRootFolders(sonarrSettings.ApiKey, sonarrSettings.FullUri));
|
||||||
|
});
|
||||||
|
|
||||||
|
rootFolders = rootFoldersResult.Select(x => new RootFolderModel { Id = x.id.ToString(), Path = x.path, FreeSpace = x.freespace}).ToList();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var sickRageSettings = await SickRageSettings.GetSettingsAsync();
|
var sickRageSettings = await SickRageSettings.GetSettingsAsync();
|
||||||
|
@ -296,11 +273,28 @@ namespace Ombi.UI.Modules
|
||||||
TvSeriesRequestType = tv.SeasonsRequested,
|
TvSeriesRequestType = tv.SeasonsRequested,
|
||||||
Qualities = qualities.ToArray(),
|
Qualities = qualities.ToArray(),
|
||||||
Episodes = tv.Episodes.ToArray(),
|
Episodes = tv.Episodes.ToArray(),
|
||||||
|
RootFolders = rootFolders.ToArray(),
|
||||||
|
HasRootFolders = rootFolders.Any(),
|
||||||
|
CurrentRootPath = GetRootPath(tv.RootFolderSelected, sonarrSettings).Result
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
return Response.AsJson(viewModel);
|
return Response.AsJson(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<string> GetRootPath(int pathId, SonarrSettings sonarrSettings)
|
||||||
|
{
|
||||||
|
var rootFoldersResult = await Cache.GetOrSetAsync(CacheKeys.SonarrRootFolders, async () =>
|
||||||
|
{
|
||||||
|
return await Task.Run(() => SonarrApi.GetRootFolders(sonarrSettings.ApiKey, sonarrSettings.FullUri));
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var r in rootFoldersResult.Where(r => r.id == pathId))
|
||||||
|
{
|
||||||
|
return r.path;
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<Response> GetAlbumRequests()
|
private async Task<Response> GetAlbumRequests()
|
||||||
{
|
{
|
||||||
var settings = PrSettings.GetSettings();
|
var settings = PrSettings.GetSettings();
|
||||||
|
@ -464,5 +458,34 @@ namespace Ombi.UI.Modules
|
||||||
|
|
||||||
return Response.AsJson(vm);
|
return Response.AsJson(vm);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private async Task<Response> ChangeRootFolder(int id, int rootFolderId)
|
||||||
|
{
|
||||||
|
// Get all root folders
|
||||||
|
var settings = await SonarrSettings.GetSettingsAsync();
|
||||||
|
var rootFolders = SonarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);
|
||||||
|
|
||||||
|
// Get Request
|
||||||
|
var allRequests = await Service.GetAllAsync();
|
||||||
|
var request = allRequests.FirstOrDefault(x => x.Id == id);
|
||||||
|
|
||||||
|
if (request == null)
|
||||||
|
{
|
||||||
|
return Response.AsJson(new JsonResponseModel {Result = false});
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var folder in rootFolders)
|
||||||
|
{
|
||||||
|
if (folder.id.Equals(rootFolderId))
|
||||||
|
{
|
||||||
|
request.RootFolderSelected = folder.id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await Service.UpdateRequestAsync(request);
|
||||||
|
|
||||||
|
return Response.AsJson(new JsonResponseModel {Result = true});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1107,7 +1107,7 @@ namespace Ombi.UI.Modules
|
||||||
{
|
{
|
||||||
model.Approved = true;
|
model.Approved = true;
|
||||||
var s = await sonarrSettings;
|
var s = await sonarrSettings;
|
||||||
var sender = new TvSenderOld(SonarrApi, SickrageApi); // TODO put back
|
var sender = new TvSenderOld(SonarrApi, SickrageApi, Cache); // TODO put back
|
||||||
if (s.Enabled)
|
if (s.Enabled)
|
||||||
{
|
{
|
||||||
var result = await sender.SendToSonarr(s, model);
|
var result = await sender.SendToSonarr(s, model);
|
||||||
|
|
|
@ -798,7 +798,7 @@
|
||||||
<Content Include="Views\Admin\DiscordNotification.cshtml">
|
<Content Include="Views\Admin\DiscordNotification.cshtml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Views\Admin\Radarr.cshtml">
|
<Content Include="Views\Integration\Radarr.cshtml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<None Include="Web.Debug.config">
|
<None Include="Web.Debug.config">
|
||||||
|
|
|
@ -81,13 +81,13 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button type="submit" id="getRootFolders" class="btn btn-primary-outline">Get RootFolders <div id="getRootFolderSpinner" /></button>
|
<button type="submit" id="getRootFolders" class="btn btn-primary-outline">Get Root Folders <div id="getRootFolderSpinner" /></button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="selectRootFolder" class="control-label">Root Folders</label>
|
<label for="selectRootFolder" class="control-label">Default Root Folders</label>
|
||||||
<div id="rootFolders">
|
<div id="rootFolders">
|
||||||
<select class="form-control form-control-custom" id="selectRootFolder"></select>
|
<select class="form-control form-control-custom" id="selectRootFolder"></select>
|
||||||
|
|
||||||
|
@ -176,37 +176,38 @@
|
||||||
</text>
|
</text>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (!string.IsNullOrEmpty(Model.RootFolder))
|
@if (!string.IsNullOrEmpty(Model.RootPath))
|
||||||
{
|
{
|
||||||
<text>
|
<text>
|
||||||
|
|
||||||
console.log('Hit root folders..');
|
console.log('Hit root folders..');
|
||||||
|
|
||||||
var rootFolderSelected = @Model.RootFolder;
|
var rootFolderSelected = @Model.RootPath;
|
||||||
if (!rootFolderSelected) {
|
if (!rootFolderSelected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var $form = $("#mainForm");
|
var $form = $("#mainForm");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: $form.prop("method"),
|
type: $form.prop("method"),
|
||||||
data: $form.serialize(),
|
data: $form.serialize(),
|
||||||
url: "sonarrrootfolders",
|
url: "sonarrrootfolders",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
response.forEach(function(result) {
|
response.forEach(function(result) {
|
||||||
if (result.id == rootFolderSelected) {
|
$('#selectedRootFolder').html("");
|
||||||
$("#selectRootFolder").append("<option selected='selected' value='" + result.id + "'>" + result.path + "</option>");
|
if (result.id == rootFolderSelected) {
|
||||||
} else {
|
$("#selectRootFolder").append("<option selected='selected' value='" + result.id + "'>" + result.path + "</option>");
|
||||||
$("#selectRootFolder").append("<option value='" + result.id + "'>" + result.path + "</option>");
|
} else {
|
||||||
}
|
$("#selectRootFolder").append("<option value='" + result.id + "'>" + result.path + "</option>");
|
||||||
});
|
}
|
||||||
},
|
});
|
||||||
error: function(e) {
|
},
|
||||||
console.log(e);
|
error: function(e) {
|
||||||
generateNotify("Something went wrong!", "danger");
|
console.log(e);
|
||||||
}
|
generateNotify("Something went wrong!", "danger");
|
||||||
});
|
}
|
||||||
</text>
|
});
|
||||||
|
</text>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,11 +219,12 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var qualityProfile = $("#profiles option:selected").val();
|
var qualityProfile = $("#profiles option:selected").val();
|
||||||
|
var rootFolder = $("#rootFolders option:selected").val();
|
||||||
|
|
||||||
var $form = $("#mainForm");
|
var $form = $("#mainForm");
|
||||||
|
|
||||||
var data = $form.serialize();
|
var data = $form.serialize();
|
||||||
data = data + "&qualityProfile=" + qualityProfile;
|
data = data + "&qualityProfile=" + qualityProfile + "&rootPath=" + rootFolder;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: $form.prop("method"),
|
type: $form.prop("method"),
|
||||||
|
|
|
@ -244,6 +244,11 @@
|
||||||
<div>@UI.Requests_RequestedBy: {{requestedUsers}}</div>
|
<div>@UI.Requests_RequestedBy: {{requestedUsers}}</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div>@UI.Requests_RequestedDate: {{requestedDate}}</div>
|
<div>@UI.Requests_RequestedDate: {{requestedDate}}</div>
|
||||||
|
{{#if admin}}
|
||||||
|
{{#if currentRootPath}}
|
||||||
|
<div>Root Path: {{currentRootPath}}</div>
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
<div>
|
<div>
|
||||||
{{#if_eq issueId 0}}
|
{{#if_eq issueId 0}}
|
||||||
@*Nothing*@
|
@*Nothing*@
|
||||||
|
@ -275,6 +280,28 @@
|
||||||
<button id="{{requestId}}" custom-button="{{requestId}}" style="text-align: right" class="btn btn-sm btn-success-outline approve" type="submit"><i class="fa fa-plus"></i> @UI.Common_Approve</button>
|
<button id="{{requestId}}" custom-button="{{requestId}}" style="text-align: right" class="btn btn-sm btn-success-outline approve" type="submit"><i class="fa fa-plus"></i> @UI.Common_Approve</button>
|
||||||
{{/if_eq}}
|
{{/if_eq}}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<form method="POST" action="@formAction/requests/changeRootFolder" id="changeFolder{{requestId}}">
|
||||||
|
<input name="requestId" type="text" value="{{requestId}}" hidden="hidden" />
|
||||||
|
{{#if_eq hasRootFolders true}}
|
||||||
|
<div class="btn-group btn-split">
|
||||||
|
<button type="button" class="btn btn-sm btn-success-outline approve" id="{{requestId}}" custom-button="{{requestId}}">@*<i class="fa fa-plus"></i>*@ Change Root Folder</button>
|
||||||
|
<button type="button" class="btn btn-success-outline dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
<span class="caret"></span>
|
||||||
|
<span class="sr-only">@UI.Requests_ToggleDropdown</span>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
{{#each rootFolders}}
|
||||||
|
<li><a href="#" class="change-root-folder" id="{{id}}">{{path}}</a></li>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{{/if_eq}}
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{{#unless denied}}
|
{{#unless denied}}
|
||||||
<form method="POST" action="@formAction/approval/deny" id="deny{{requestId}}">
|
<form method="POST" action="@formAction/approval/deny" id="deny{{requestId}}">
|
||||||
<input name="requestId" type="text" value="{{requestId}}" hidden="hidden" />
|
<input name="requestId" type="text" value="{{requestId}}" hidden="hidden" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue