diff --git a/src/Ombi/ClientApp/app/services/job.service.ts b/src/Ombi/ClientApp/app/services/job.service.ts index 687cbe1b1..1be356f39 100644 --- a/src/Ombi/ClientApp/app/services/job.service.ts +++ b/src/Ombi/ClientApp/app/services/job.service.ts @@ -29,4 +29,12 @@ export class JobService extends ServiceAuthHelpers { public runEmbyImporter(): Observable { return this.http.post(`${this.url}embyUserImporter/`, { headers: this.headers }).map(this.extractData); } + + public runPlexCacher(): Observable { + return this.http.post(`${this.url}plexcontentcacher/`, { headers: this.headers }).map(this.extractData); + } + + public runEmbyCacher(): Observable { + return this.http.post(`${this.url}embycontentcacher/`, { headers: this.headers }).map(this.extractData); + } } diff --git a/src/Ombi/ClientApp/app/settings/emby/emby.component.html b/src/Ombi/ClientApp/app/settings/emby/emby.component.html index 00c641fd1..ec966acf5 100644 --- a/src/Ombi/ClientApp/app/settings/emby/emby.component.html +++ b/src/Ombi/ClientApp/app/settings/emby/emby.component.html @@ -14,7 +14,7 @@
- +
@@ -25,7 +25,7 @@

- +


@@ -57,17 +57,6 @@ - - -
@@ -76,7 +65,7 @@
- +
@@ -84,12 +73,19 @@ -
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/src/Ombi/ClientApp/app/settings/emby/emby.component.ts b/src/Ombi/ClientApp/app/settings/emby/emby.component.ts index 522490e0c..29b229831 100644 --- a/src/Ombi/ClientApp/app/settings/emby/emby.component.ts +++ b/src/Ombi/ClientApp/app/settings/emby/emby.component.ts @@ -1,9 +1,7 @@ import { Component, OnInit } from "@angular/core"; import { IEmbyServer, IEmbySettings } from "../../interfaces"; -import { TesterService } from "../../services"; -import { NotificationService } from "../../services"; -import { SettingsService } from "../../services"; +import { JobService, NotificationService, SettingsService, TesterService } from "../../services"; @Component({ templateUrl: "./emby.component.html", @@ -14,7 +12,8 @@ export class EmbyComponent implements OnInit { constructor(private settingsService: SettingsService, private notificationService: NotificationService, - private testerService: TesterService) { } + private testerService: TesterService, + private jobService: JobService) { } public ngOnInit() { this.settingsService.getEmby().subscribe(x => this.settings = x); @@ -63,4 +62,12 @@ export class EmbyComponent implements OnInit { } }); } + + public runCacher(): void { + this.jobService.runEmbyCacher().subscribe(x => { + if(x) { + this.notificationService.success("Running","Triggered the Emby Content Cacher"); + } + }); + } } diff --git a/src/Ombi/ClientApp/app/settings/plex/plex.component.html b/src/Ombi/ClientApp/app/settings/plex/plex.component.html index e90948635..9f433601e 100644 --- a/src/Ombi/ClientApp/app/settings/plex/plex.component.html +++ b/src/Ombi/ClientApp/app/settings/plex/plex.component.html @@ -18,7 +18,7 @@
- +
@@ -30,7 +30,7 @@

- +


@@ -158,7 +158,7 @@
- @@ -171,12 +171,19 @@
-
-
-
- +
+
+
+ +
-
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/src/Ombi/ClientApp/app/settings/plex/plex.component.ts b/src/Ombi/ClientApp/app/settings/plex/plex.component.ts index 761a07a12..c9dd370fe 100644 --- a/src/Ombi/ClientApp/app/settings/plex/plex.component.ts +++ b/src/Ombi/ClientApp/app/settings/plex/plex.component.ts @@ -5,10 +5,7 @@ import { Subject } from "rxjs/Subject"; import { IPlexServerResponse, IPlexServerViewModel } from "../../interfaces"; import { IPlexLibrariesSettings, IPlexServer, IPlexSettings } from "../../interfaces"; -import { PlexService } from "../../services"; -import { TesterService } from "../../services"; -import { NotificationService } from "../../services"; -import { SettingsService } from "../../services"; +import { JobService, NotificationService, PlexService, SettingsService, TesterService } from "../../services"; @Component({ templateUrl: "./plex.component.html", @@ -20,14 +17,15 @@ export class PlexComponent implements OnInit, OnDestroy { public password: string; public serversButton = false; - private subscriptions = new Subject(); - public advanced = false; + private subscriptions = new Subject(); + constructor(private settingsService: SettingsService, private notificationService: NotificationService, private plexService: PlexService, - private testerService: TesterService) { } + private testerService: TesterService, + private jobService: JobService) { } public ngOnInit() { this.settingsService.getPlex().subscribe(x => { @@ -40,7 +38,6 @@ export class PlexComponent implements OnInit, OnDestroy { .takeUntil(this.subscriptions) .subscribe(x => { if (x.success) { - debugger; this.loadedServers = x; this.serversButton = true; this.notificationService.success("Loaded", "Found the servers! Please select one!"); @@ -121,6 +118,14 @@ export class PlexComponent implements OnInit, OnDestroy { }); } + public runCacher(): void { + this.jobService.runPlexCacher().subscribe(x => { + if(x) { + this.notificationService.success("Running","Triggered the Plex Content Cacher"); + } + }); + } + public ngOnDestroy() { this.subscriptions.next(); this.subscriptions.complete(); diff --git a/src/Ombi/Controllers/External/PlexController.cs b/src/Ombi/Controllers/External/PlexController.cs index f79fb81ab..cbb366955 100644 --- a/src/Ombi/Controllers/External/PlexController.cs +++ b/src/Ombi/Controllers/External/PlexController.cs @@ -68,24 +68,6 @@ namespace Ombi.Controllers.External Name = "Server 1", } }; - //var serverNumber = 0; - //foreach (var s in servers) - //{ - // if (string.IsNullOrEmpty(s.LocalAddresses) || string.IsNullOrEmpty(s.Port)) - // { - // continue; - // } - // settings.Servers.Add(new PlexServers - // { - // PlexAuthToken = result.user.authentication_token, - // Id = new Random().Next(), - // Ip = s.LocalAddresses.Split(new []{','}, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(), - // MachineIdentifier = s.MachineIdentifier, - // Port = int.Parse(s.Port), - // Ssl = s.Scheme != "http", - // Name = $"Server{serverNumber++}" - // }); - //} await PlexSettings.SaveSettingsAsync(settings); } diff --git a/src/Ombi/Controllers/JobController.cs b/src/Ombi/Controllers/JobController.cs index fc25a0ae2..458ccc8b2 100644 --- a/src/Ombi/Controllers/JobController.cs +++ b/src/Ombi/Controllers/JobController.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.Caching.Memory; using Ombi.Api.Service; using Ombi.Attributes; using Ombi.Helpers; +using Ombi.Schedule.Jobs; using Ombi.Schedule.Jobs.Emby; using Ombi.Schedule.Jobs.Ombi; using Ombi.Schedule.Jobs.Plex; @@ -18,19 +19,28 @@ namespace Ombi.Controllers public class JobController : Controller { public JobController(IOmbiAutomaticUpdater updater, IPlexUserImporter userImporter, - IMemoryCache mem, IEmbyUserImporter embyImporter) + IMemoryCache mem, IEmbyUserImporter embyImporter, IPlexContentCacher plexContentCacher, + IEmbyContentCacher embyContentCacher) { _updater = updater; _plexUserImporter = userImporter; _embyUserImporter = embyImporter; _memCache = mem; + _plexContentCacher = plexContentCacher; + _embyContentCacher = embyContentCacher; } private readonly IOmbiAutomaticUpdater _updater; private readonly IPlexUserImporter _plexUserImporter; private readonly IEmbyUserImporter _embyUserImporter; private readonly IMemoryCache _memCache; + private readonly IPlexContentCacher _plexContentCacher; + private readonly IEmbyContentCacher _embyContentCacher; + /// + /// Runs the update job + /// + /// [HttpPost("update")] public bool ForceUpdate() { @@ -38,26 +48,29 @@ namespace Ombi.Controllers return true; } + /// + /// Checks for an update + /// + /// [HttpGet("update")] public async Task CheckForUpdate() { try { + var productArray = _updater.GetVersion(); + var version = productArray[0]; + var branch = productArray[1]; + var updateAvailable = await _updater.UpdateAvailable(branch, version); - - var productArray = _updater.GetVersion(); - var version = productArray[0]; - var branch = productArray[1]; - var updateAvailable = await _updater.UpdateAvailable(branch, version); - - return updateAvailable; + return updateAvailable; } - catch (Exception e) + catch (Exception) { return false; } } - + + [ApiExplorerSettings(IgnoreApi = true)] [HttpGet("updateCached")] public async Task CheckForUpdateCached() { @@ -74,6 +87,10 @@ namespace Ombi.Controllers return val; } + /// + /// Runs the Plex User importer + /// + /// [HttpPost("plexuserimporter")] public bool PlexUserImporter() { @@ -81,11 +98,37 @@ namespace Ombi.Controllers return true; } + /// + /// Runs the Emby User importer + /// + /// [HttpPost("embyuserimporter")] public bool EmbyUserImporter() { BackgroundJob.Enqueue(() => _embyUserImporter.Start()); return true; } + + /// + /// Runs the Plex Content Cacher + /// + /// + [HttpPost("plexcontentcacher")] + public bool StartPlexContentCacher() + { + BackgroundJob.Enqueue(() => _plexContentCacher.CacheContent()); + return true; + } + + /// + /// Runs the Emby Content Cacher + /// + /// + [HttpPost("embycontentcacher")] + public bool StartEmbyContentCacher() + { + BackgroundJob.Enqueue(() => _embyContentCacher.Start()); + return true; + } } } \ No newline at end of file diff --git a/src/Ombi/Controllers/SettingsController.cs b/src/Ombi/Controllers/SettingsController.cs index 607c15041..94c35a4de 100644 --- a/src/Ombi/Controllers/SettingsController.cs +++ b/src/Ombi/Controllers/SettingsController.cs @@ -17,7 +17,6 @@ using Ombi.Core.Settings.Models; using Ombi.Core.Settings.Models.External; using Ombi.Helpers; using Ombi.Models; -using Ombi.Schedule.Jobs; using Ombi.Schedule.Jobs.Emby; using Ombi.Schedule.Jobs.Radarr; using Ombi.Settings.Settings.Models; @@ -44,14 +43,13 @@ namespace Ombi.Controllers /// The mapper. /// The templateRepo. /// The embyApi. - /// The cacher. /// The embyCacher. /// The radarrCacher. + /// The memory cache. public SettingsController(ISettingsResolver resolver, IMapper mapper, INotificationTemplatesRepository templateRepo, IEmbyApi embyApi, - IPlexContentCacher cacher, IEmbyContentCacher embyCacher, IRadarrCacher radarrCacher, IMemoryCache memCache) @@ -60,7 +58,6 @@ namespace Ombi.Controllers Mapper = mapper; TemplateRepository = templateRepo; _embyApi = embyApi; - _plexContentCacher = cacher; _embyContentCacher = embyCacher; _radarrCacher = radarrCacher; _cache = memCache; @@ -70,7 +67,6 @@ namespace Ombi.Controllers private IMapper Mapper { get; } private INotificationTemplatesRepository TemplateRepository { get; } private readonly IEmbyApi _embyApi; - private readonly IPlexContentCacher _plexContentCacher; private readonly IEmbyContentCacher _embyContentCacher; private readonly IRadarrCacher _radarrCacher; private readonly IMemoryCache _cache; @@ -145,10 +141,6 @@ namespace Ombi.Controllers public async Task PlexSettings([FromBody]PlexSettings plex) { var result = await Save(plex); - if (result && plex.Enable) - { - BackgroundJob.Enqueue(() => _plexContentCacher.CacheContent()); - } return result; } @@ -180,10 +172,6 @@ namespace Ombi.Controllers } } var result = await Save(emby); - if (result && emby.Enable) - { - BackgroundJob.Enqueue(() => _embyContentCacher.Start()); - } return result; }