Real-time Indexer status changes via SignalR

pull/8/head
Qstick 3 years ago
parent ed0e11847a
commit dd1ced2d5e

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

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

Loading…
Cancel
Save