Real-time Indexer status changes via SignalR

This commit is contained in:
Qstick
2021-02-19 00:17:52 -05:00
parent ed0e11847a
commit dd1ced2d5e
2 changed files with 20 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import { setAppValue, setVersion } from 'Store/Actions/appActions';
import { removeItem, update, updateItem } from 'Store/Actions/baseActions';
import { fetchCommands, finishCommand, updateCommand } from 'Store/Actions/commandActions';
import { fetchIndexers } from 'Store/Actions/indexerActions';
import { fetchIndexerStatus } from 'Store/Actions/indexerStatusActions';
import { fetchHealth } from 'Store/Actions/systemActions';
import { fetchTagDetails, fetchTags } from 'Store/Actions/tagActions';
import { repopulatePage } from 'Utilities/pagePopulator';
@@ -43,6 +44,7 @@ const mapDispatchToProps = {
dispatchRemoveItem: removeItem,
dispatchFetchHealth: fetchHealth,
dispatchFetchIndexers: fetchIndexers,
dispatchFetchIndexerStatus: fetchIndexerStatus,
dispatchFetchTags: fetchTags,
dispatchFetchTagDetails: fetchTagDetails
};
@@ -162,6 +164,10 @@ class SignalRConnector extends Component {
this.props.dispatchFetchHealth();
}
handleIndexerstatus = () => {
this.props.dispatchFetchIndexerStatus();
}
handleMovie = (body) => {
const action = body.action;
const section = 'movies';
@@ -274,6 +280,7 @@ SignalRConnector.propTypes = {
dispatchRemoveItem: PropTypes.func.isRequired,
dispatchFetchHealth: PropTypes.func.isRequired,
dispatchFetchIndexers: PropTypes.func.isRequired,
dispatchFetchIndexerStatus: PropTypes.func.isRequired,
dispatchFetchTags: PropTypes.func.isRequired,
dispatchFetchTagDetails: PropTypes.func.isRequired
};

View File

@@ -1,14 +1,20 @@
using System.Collections.Generic;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.ThingiProvider.Events;
using NzbDrone.SignalR;
using Prowlarr.Http;
namespace Prowlarr.Api.V1.Indexers
{
public class IndexerStatusModule : ProwlarrRestModule<IndexerStatusResource>
public class IndexerStatusModule : ProwlarrRestModuleWithSignalR<IndexerStatusResource, IndexerStatus>,
IHandle<ProviderStatusChangedEvent<IIndexer>>
{
private readonly IIndexerStatusService _indexerStatusService;
public IndexerStatusModule(IIndexerStatusService indexerStatusService)
public IndexerStatusModule(IBroadcastSignalRMessage signalRBroadcaster, IIndexerStatusService indexerStatusService)
: base(signalRBroadcaster)
{
_indexerStatusService = indexerStatusService;
@@ -19,5 +25,10 @@ namespace Prowlarr.Api.V1.Indexers
{
return _indexerStatusService.GetBlockedProviders().ToResource();
}
public void Handle(ProviderStatusChangedEvent<IIndexer> message)
{
BroadcastResourceChange(ModelAction.Sync);
}
}
}