mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 07:46:05 -07:00
Added the option to run the content cacher from the settings page, it will no longer get triggered when we press save.
This commit is contained in:
parent
03f7aba47e
commit
2f8e96ed87
8 changed files with 112 additions and 76 deletions
|
@ -29,4 +29,12 @@ export class JobService extends ServiceAuthHelpers {
|
|||
public runEmbyImporter(): Observable<boolean> {
|
||||
return this.http.post(`${this.url}embyUserImporter/`, { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
|
||||
public runPlexCacher(): Observable<boolean> {
|
||||
return this.http.post(`${this.url}plexcontentcacher/`, { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
|
||||
public runEmbyCacher(): Observable<boolean> {
|
||||
return this.http.post(`${this.url}embycontentcacher/`, { headers: this.headers }).map(this.extractData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="col-md-2 col-md-push-7">
|
||||
<button type="submit" (click)="addTab()" class="btn btn-success-outline">Add Server</button>
|
||||
<button type="button" (click)="addTab()" class="btn btn-success-outline">Add Server</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
|||
<br />
|
||||
<br />
|
||||
<div class="col-md-2" style="float: right;">
|
||||
<button type="submit" (click)="removeServer(server)" class="btn btn-danger-outline">Remove Server</button>
|
||||
<button type="button" (click)="removeServer(server)" class="btn btn-danger-outline">Remove Server</button>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
|
@ -57,17 +57,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!--<div class="form-group">
|
||||
<div class="checkbox">
|
||||
|
||||
|
||||
<input type="checkbox" id="EnableTvEpisodeSearching" [(ngModel)]="server.enableEpisodeSearching" ng-checked="server.enableEpisodeSearching">
|
||||
<label for="EnableTvEpisodeSearching">Enable Episode Searching</label>
|
||||
|
||||
</div>
|
||||
</div>-->
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label for="authToken" class="control-label">Emby Api Key</label>
|
||||
<div class="">
|
||||
|
@ -76,7 +65,7 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<button id="testEmby" type="submit" (click)="test(server)" class="btn btn-primary-outline">Test Connectivity <div id="spinner"></div></button>
|
||||
<button id="testEmby" type="button" (click)="test(server)" class="btn btn-primary-outline">Test Connectivity <div id="spinner"></div></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -84,12 +73,19 @@
|
|||
</ngb-tab>
|
||||
</div>
|
||||
</ngb-tabset>
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<button (click)="save()" type="submit" id="save" class="btn btn-primary-outline">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<button (click)="runCacher()" type="button" id="save" class="btn btn-primary-outline">Manually Run Cacher</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
|
@ -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");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="col-md-2 col-md-push-7">
|
||||
<button type="submit" (click)="addTab()" class="btn btn-success-outline">Add Server</button>
|
||||
<button type="button" (click)="addTab()" class="btn btn-success-outline">Add Server</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
|||
<br />
|
||||
<br />
|
||||
<div class="col-md-2 " style="float: right;">
|
||||
<button type="submit" (click)="removeServer(server)" class="btn btn-danger-outline">Remove Server</button>
|
||||
<button type="button" (click)="removeServer(server)" class="btn btn-danger-outline">Remove Server</button>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
|
@ -158,7 +158,7 @@
|
|||
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<button id="testPlex" type="submit" (click)="testPlex(server)" class="btn btn-primary-outline">
|
||||
<button id="testPlex" type="button" (click)="testPlex(server)" class="btn btn-primary-outline">
|
||||
Test Connectivity
|
||||
<div id="spinner"></div>
|
||||
</button>
|
||||
|
@ -171,12 +171,19 @@
|
|||
</ngb-tab>
|
||||
</div>
|
||||
</ngb-tabset>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<button (click)="save()" type="submit" id="save" class="btn btn-primary-outline">Submit</button>
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<button (click)="save()" type="submit" id="save" class="btn btn-primary-outline">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<button (click)="runCacher()" type="button" id="save" class="btn btn-primary-outline">Manually Run Cacher</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
|
@ -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<void>();
|
||||
|
||||
public advanced = false;
|
||||
|
||||
private subscriptions = new Subject<void>();
|
||||
|
||||
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();
|
||||
|
|
18
src/Ombi/Controllers/External/PlexController.cs
vendored
18
src/Ombi/Controllers/External/PlexController.cs
vendored
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Runs the update job
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("update")]
|
||||
public bool ForceUpdate()
|
||||
{
|
||||
|
@ -38,26 +48,29 @@ namespace Ombi.Controllers
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks for an update
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("update")]
|
||||
public async Task<bool> 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<bool> CheckForUpdateCached()
|
||||
{
|
||||
|
@ -74,6 +87,10 @@ namespace Ombi.Controllers
|
|||
return val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the Plex User importer
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("plexuserimporter")]
|
||||
public bool PlexUserImporter()
|
||||
{
|
||||
|
@ -81,11 +98,37 @@ namespace Ombi.Controllers
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the Emby User importer
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("embyuserimporter")]
|
||||
public bool EmbyUserImporter()
|
||||
{
|
||||
BackgroundJob.Enqueue(() => _embyUserImporter.Start());
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the Plex Content Cacher
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("plexcontentcacher")]
|
||||
public bool StartPlexContentCacher()
|
||||
{
|
||||
BackgroundJob.Enqueue(() => _plexContentCacher.CacheContent());
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the Emby Content Cacher
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("embycontentcacher")]
|
||||
public bool StartEmbyContentCacher()
|
||||
{
|
||||
BackgroundJob.Enqueue(() => _embyContentCacher.Start());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
|||
/// <param name="mapper">The mapper.</param>
|
||||
/// <param name="templateRepo">The templateRepo.</param>
|
||||
/// <param name="embyApi">The embyApi.</param>
|
||||
/// <param name="cacher">The cacher.</param>
|
||||
/// <param name="embyCacher">The embyCacher.</param>
|
||||
/// <param name="radarrCacher">The radarrCacher.</param>
|
||||
/// <param name="memCache">The memory cache.</param>
|
||||
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<bool> 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue