mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
New: Sync UI updates for providers
This commit is contained in:
@@ -141,6 +141,16 @@ class SignalRConnector extends Component {
|
|||||||
console.error(`signalR: Unable to find handler for ${name}`);
|
console.error(`signalR: Unable to find handler for ${name}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleApplications = ({ action, resource }) => {
|
||||||
|
const section = 'settings.applications';
|
||||||
|
|
||||||
|
if (action === 'created' || action === 'updated') {
|
||||||
|
this.props.dispatchUpdateItem({ section, ...resource });
|
||||||
|
} else if (action === 'deleted') {
|
||||||
|
this.props.dispatchRemoveItem({ section, id: resource.id });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
handleCommand = (body) => {
|
handleCommand = (body) => {
|
||||||
if (body.action === 'sync') {
|
if (body.action === 'sync') {
|
||||||
this.props.dispatchFetchCommands();
|
this.props.dispatchFetchCommands();
|
||||||
@@ -150,8 +160,8 @@ class SignalRConnector extends Component {
|
|||||||
const resource = body.resource;
|
const resource = body.resource;
|
||||||
const status = resource.status;
|
const status = resource.status;
|
||||||
|
|
||||||
// Both sucessful and failed commands need to be
|
// Both successful and failed commands need to be
|
||||||
// completed, otherwise they spin until they timeout.
|
// completed, otherwise they spin until they time out.
|
||||||
|
|
||||||
if (status === 'completed' || status === 'failed') {
|
if (status === 'completed' || status === 'failed') {
|
||||||
this.props.dispatchFinishCommand(resource);
|
this.props.dispatchFinishCommand(resource);
|
||||||
@@ -160,6 +170,16 @@ class SignalRConnector extends Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleDownloadclient = ({ action, resource }) => {
|
||||||
|
const section = 'settings.downloadClients';
|
||||||
|
|
||||||
|
if (action === 'created' || action === 'updated') {
|
||||||
|
this.props.dispatchUpdateItem({ section, ...resource });
|
||||||
|
} else if (action === 'deleted') {
|
||||||
|
this.props.dispatchRemoveItem({ section, id: resource.id });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
handleHealth = () => {
|
handleHealth = () => {
|
||||||
this.props.dispatchFetchHealth();
|
this.props.dispatchFetchHealth();
|
||||||
};
|
};
|
||||||
@@ -168,14 +188,33 @@ class SignalRConnector extends Component {
|
|||||||
this.props.dispatchFetchIndexerStatus();
|
this.props.dispatchFetchIndexerStatus();
|
||||||
};
|
};
|
||||||
|
|
||||||
handleIndexer = (body) => {
|
handleIndexer = ({ action, resource }) => {
|
||||||
const action = body.action;
|
|
||||||
const section = 'indexers';
|
const section = 'indexers';
|
||||||
|
|
||||||
if (action === 'updated') {
|
if (action === 'created' || action === 'updated') {
|
||||||
this.props.dispatchUpdateItem({ section, ...body.resource });
|
this.props.dispatchUpdateItem({ section, ...resource });
|
||||||
} else if (action === 'deleted') {
|
} else if (action === 'deleted') {
|
||||||
this.props.dispatchRemoveItem({ section, id: body.resource.id });
|
this.props.dispatchRemoveItem({ section, id: resource.id });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handleIndexerproxy = ({ action, resource }) => {
|
||||||
|
const section = 'settings.indexerProxies';
|
||||||
|
|
||||||
|
if (action === 'created' || action === 'updated') {
|
||||||
|
this.props.dispatchUpdateItem({ section, ...resource });
|
||||||
|
} else if (action === 'deleted') {
|
||||||
|
this.props.dispatchRemoveItem({ section, id: resource.id });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handleNotification = ({ action, resource }) => {
|
||||||
|
const section = 'settings.notifications';
|
||||||
|
|
||||||
|
if (action === 'created' || action === 'updated') {
|
||||||
|
this.props.dispatchUpdateItem({ section, ...resource });
|
||||||
|
} else if (action === 'deleted') {
|
||||||
|
this.props.dispatchRemoveItem({ section, id: resource.id });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using NzbDrone.Core.Applications;
|
using NzbDrone.Core.Applications;
|
||||||
|
using NzbDrone.SignalR;
|
||||||
using Prowlarr.Http;
|
using Prowlarr.Http;
|
||||||
|
|
||||||
namespace Prowlarr.Api.V1.Applications
|
namespace Prowlarr.Api.V1.Applications
|
||||||
@@ -9,8 +10,8 @@ namespace Prowlarr.Api.V1.Applications
|
|||||||
public static readonly ApplicationResourceMapper ResourceMapper = new ();
|
public static readonly ApplicationResourceMapper ResourceMapper = new ();
|
||||||
public static readonly ApplicationBulkResourceMapper BulkResourceMapper = new ();
|
public static readonly ApplicationBulkResourceMapper BulkResourceMapper = new ();
|
||||||
|
|
||||||
public ApplicationController(ApplicationFactory applicationsFactory)
|
public ApplicationController(IBroadcastSignalRMessage signalRBroadcaster, ApplicationFactory applicationsFactory)
|
||||||
: base(applicationsFactory, "applications", ResourceMapper, BulkResourceMapper)
|
: base(signalRBroadcaster, applicationsFactory, "applications", ResourceMapper, BulkResourceMapper)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
|
using NzbDrone.SignalR;
|
||||||
using Prowlarr.Http;
|
using Prowlarr.Http;
|
||||||
|
|
||||||
namespace Prowlarr.Api.V1.DownloadClient
|
namespace Prowlarr.Api.V1.DownloadClient
|
||||||
@@ -9,8 +10,8 @@ namespace Prowlarr.Api.V1.DownloadClient
|
|||||||
public static readonly DownloadClientResourceMapper ResourceMapper = new ();
|
public static readonly DownloadClientResourceMapper ResourceMapper = new ();
|
||||||
public static readonly DownloadClientBulkResourceMapper BulkResourceMapper = new ();
|
public static readonly DownloadClientBulkResourceMapper BulkResourceMapper = new ();
|
||||||
|
|
||||||
public DownloadClientController(IDownloadClientFactory downloadClientFactory)
|
public DownloadClientController(IBroadcastSignalRMessage signalRBroadcaster, IDownloadClientFactory downloadClientFactory)
|
||||||
: base(downloadClientFactory, "downloadclient", ResourceMapper, BulkResourceMapper)
|
: base(signalRBroadcaster, downloadClientFactory, "downloadclient", ResourceMapper, BulkResourceMapper)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NzbDrone.Core.IndexerProxies;
|
using NzbDrone.Core.IndexerProxies;
|
||||||
|
using NzbDrone.SignalR;
|
||||||
using Prowlarr.Http;
|
using Prowlarr.Http;
|
||||||
|
|
||||||
namespace Prowlarr.Api.V1.IndexerProxies
|
namespace Prowlarr.Api.V1.IndexerProxies
|
||||||
@@ -11,8 +12,8 @@ namespace Prowlarr.Api.V1.IndexerProxies
|
|||||||
public static readonly IndexerProxyResourceMapper ResourceMapper = new ();
|
public static readonly IndexerProxyResourceMapper ResourceMapper = new ();
|
||||||
public static readonly IndexerProxyBulkResourceMapper BulkResourceMapper = new ();
|
public static readonly IndexerProxyBulkResourceMapper BulkResourceMapper = new ();
|
||||||
|
|
||||||
public IndexerProxyController(IndexerProxyFactory notificationFactory)
|
public IndexerProxyController(IBroadcastSignalRMessage signalRBroadcaster, IndexerProxyFactory notificationFactory)
|
||||||
: base(notificationFactory, "indexerProxy", ResourceMapper, BulkResourceMapper)
|
: base(signalRBroadcaster, notificationFactory, "indexerProxy", ResourceMapper, BulkResourceMapper)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Core.Indexers;
|
using NzbDrone.Core.Indexers;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
|
using NzbDrone.SignalR;
|
||||||
using Prowlarr.Http;
|
using Prowlarr.Http;
|
||||||
|
|
||||||
namespace Prowlarr.Api.V1.Indexers
|
namespace Prowlarr.Api.V1.Indexers
|
||||||
@@ -8,12 +9,13 @@ namespace Prowlarr.Api.V1.Indexers
|
|||||||
[V1ApiController]
|
[V1ApiController]
|
||||||
public class IndexerController : ProviderControllerBase<IndexerResource, IndexerBulkResource, IIndexer, IndexerDefinition>
|
public class IndexerController : ProviderControllerBase<IndexerResource, IndexerBulkResource, IIndexer, IndexerDefinition>
|
||||||
{
|
{
|
||||||
public IndexerController(IndexerFactory indexerFactory,
|
public IndexerController(IBroadcastSignalRMessage signalRBroadcaster,
|
||||||
|
IndexerFactory indexerFactory,
|
||||||
IndexerResourceMapper resourceMapper,
|
IndexerResourceMapper resourceMapper,
|
||||||
IndexerBulkResourceMapper bulkResourceMapper,
|
IndexerBulkResourceMapper bulkResourceMapper,
|
||||||
AppProfileExistsValidator appProfileExistsValidator,
|
AppProfileExistsValidator appProfileExistsValidator,
|
||||||
DownloadClientExistsValidator downloadClientExistsValidator)
|
DownloadClientExistsValidator downloadClientExistsValidator)
|
||||||
: base(indexerFactory, "indexer", resourceMapper, bulkResourceMapper)
|
: base(signalRBroadcaster, indexerFactory, "indexer", resourceMapper, bulkResourceMapper)
|
||||||
{
|
{
|
||||||
SharedValidator.RuleFor(c => c.AppProfileId).Cascade(CascadeMode.Stop)
|
SharedValidator.RuleFor(c => c.AppProfileId).Cascade(CascadeMode.Stop)
|
||||||
.ValidId()
|
.ValidId()
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NzbDrone.Core.Notifications;
|
using NzbDrone.Core.Notifications;
|
||||||
|
using NzbDrone.SignalR;
|
||||||
using Prowlarr.Http;
|
using Prowlarr.Http;
|
||||||
|
|
||||||
namespace Prowlarr.Api.V1.Notifications
|
namespace Prowlarr.Api.V1.Notifications
|
||||||
@@ -11,8 +12,8 @@ namespace Prowlarr.Api.V1.Notifications
|
|||||||
public static readonly NotificationResourceMapper ResourceMapper = new ();
|
public static readonly NotificationResourceMapper ResourceMapper = new ();
|
||||||
public static readonly NotificationBulkResourceMapper BulkResourceMapper = new ();
|
public static readonly NotificationBulkResourceMapper BulkResourceMapper = new ();
|
||||||
|
|
||||||
public NotificationController(NotificationFactory notificationFactory)
|
public NotificationController(IBroadcastSignalRMessage signalRBroadcaster, NotificationFactory notificationFactory)
|
||||||
: base(notificationFactory, "notification", ResourceMapper, BulkResourceMapper)
|
: base(signalRBroadcaster, notificationFactory, "notification", ResourceMapper, BulkResourceMapper)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,14 +4,21 @@ using FluentValidation;
|
|||||||
using FluentValidation.Results;
|
using FluentValidation.Results;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.Datastore.Events;
|
||||||
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Core.ThingiProvider;
|
using NzbDrone.Core.ThingiProvider;
|
||||||
|
using NzbDrone.Core.ThingiProvider.Events;
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
using NzbDrone.Http.REST.Attributes;
|
using NzbDrone.Http.REST.Attributes;
|
||||||
|
using NzbDrone.SignalR;
|
||||||
using Prowlarr.Http.REST;
|
using Prowlarr.Http.REST;
|
||||||
|
|
||||||
namespace Prowlarr.Api.V1
|
namespace Prowlarr.Api.V1
|
||||||
{
|
{
|
||||||
public abstract class ProviderControllerBase<TProviderResource, TBulkProviderResource, TProvider, TProviderDefinition> : RestController<TProviderResource>
|
public abstract class ProviderControllerBase<TProviderResource, TBulkProviderResource, TProvider, TProviderDefinition> : RestControllerWithSignalR<TProviderResource, TProviderDefinition>,
|
||||||
|
IHandle<ProviderAddedEvent<TProvider>>,
|
||||||
|
IHandle<ProviderUpdatedEvent<TProvider>>,
|
||||||
|
IHandle<ProviderDeletedEvent<TProvider>>
|
||||||
where TProviderDefinition : ProviderDefinition, new()
|
where TProviderDefinition : ProviderDefinition, new()
|
||||||
where TBulkProviderResource : ProviderBulkResource<TBulkProviderResource>, new()
|
where TBulkProviderResource : ProviderBulkResource<TBulkProviderResource>, new()
|
||||||
where TProvider : IProvider
|
where TProvider : IProvider
|
||||||
@@ -21,11 +28,13 @@ namespace Prowlarr.Api.V1
|
|||||||
protected readonly ProviderResourceMapper<TProviderResource, TProviderDefinition> _resourceMapper;
|
protected readonly ProviderResourceMapper<TProviderResource, TProviderDefinition> _resourceMapper;
|
||||||
private readonly ProviderBulkResourceMapper<TBulkProviderResource, TProviderDefinition> _bulkResourceMapper;
|
private readonly ProviderBulkResourceMapper<TBulkProviderResource, TProviderDefinition> _bulkResourceMapper;
|
||||||
|
|
||||||
protected ProviderControllerBase(IProviderFactory<TProvider,
|
protected ProviderControllerBase(IBroadcastSignalRMessage signalRBroadcaster,
|
||||||
|
IProviderFactory<TProvider,
|
||||||
TProviderDefinition> providerFactory,
|
TProviderDefinition> providerFactory,
|
||||||
string resource,
|
string resource,
|
||||||
ProviderResourceMapper<TProviderResource, TProviderDefinition> resourceMapper,
|
ProviderResourceMapper<TProviderResource, TProviderDefinition> resourceMapper,
|
||||||
ProviderBulkResourceMapper<TBulkProviderResource, TProviderDefinition> bulkResourceMapper)
|
ProviderBulkResourceMapper<TBulkProviderResource, TProviderDefinition> bulkResourceMapper)
|
||||||
|
: base(signalRBroadcaster)
|
||||||
{
|
{
|
||||||
_providerFactory = providerFactory;
|
_providerFactory = providerFactory;
|
||||||
_resourceMapper = resourceMapper;
|
_resourceMapper = resourceMapper;
|
||||||
@@ -244,6 +253,24 @@ namespace Prowlarr.Api.V1
|
|||||||
return Json(data);
|
return Json(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public void Handle(ProviderAddedEvent<TProvider> message)
|
||||||
|
{
|
||||||
|
BroadcastResourceChange(ModelAction.Created, message.Definition.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public void Handle(ProviderUpdatedEvent<TProvider> message)
|
||||||
|
{
|
||||||
|
BroadcastResourceChange(ModelAction.Updated, message.Definition.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public void Handle(ProviderDeletedEvent<TProvider> message)
|
||||||
|
{
|
||||||
|
BroadcastResourceChange(ModelAction.Deleted, message.ProviderId);
|
||||||
|
}
|
||||||
|
|
||||||
private void Validate(TProviderDefinition definition, bool includeWarnings)
|
private void Validate(TProviderDefinition definition, bool includeWarnings)
|
||||||
{
|
{
|
||||||
var validationResult = definition.Settings.Validate();
|
var validationResult = definition.Settings.Validate();
|
||||||
|
Reference in New Issue
Block a user