mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Trigger manual search from any History Item
This commit is contained in:
@@ -63,6 +63,32 @@ function HistoryDetails(props) {
|
||||
);
|
||||
}
|
||||
|
||||
if (eventType === 'releaseGrabbed') {
|
||||
const {
|
||||
source
|
||||
} = data;
|
||||
|
||||
return (
|
||||
<DescriptionList>
|
||||
{
|
||||
!!indexer &&
|
||||
<DescriptionListItem
|
||||
title={translate('Indexer')}
|
||||
data={indexer.name}
|
||||
/>
|
||||
}
|
||||
|
||||
{
|
||||
!!data &&
|
||||
<DescriptionListItem
|
||||
title={'Source'}
|
||||
data={source}
|
||||
/>
|
||||
}
|
||||
</DescriptionList>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<DescriptionList>
|
||||
<DescriptionListItem
|
||||
|
@@ -9,14 +9,16 @@ function getIconName(eventType) {
|
||||
switch (eventType) {
|
||||
case 'indexerQuery':
|
||||
return icons.SEARCH;
|
||||
case 'releaseGrabbed':
|
||||
return icons.DOWNLOAD;
|
||||
default:
|
||||
return icons.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
function getIconKind(eventType) {
|
||||
switch (eventType) {
|
||||
case 'downloadFailed':
|
||||
function getIconKind(data) {
|
||||
switch (data.successful) {
|
||||
case 'False':
|
||||
return kinds.DANGER;
|
||||
default:
|
||||
return kinds.DEFAULT;
|
||||
@@ -27,6 +29,8 @@ function getTooltip(eventType, data, indexer) {
|
||||
switch (eventType) {
|
||||
case 'indexerQuery':
|
||||
return `Query "${data.query}" sent to ${indexer.name}`;
|
||||
case 'releaseGrabbed':
|
||||
return `Release grabbed from ${indexer.name}`;
|
||||
default:
|
||||
return 'Unknown event';
|
||||
}
|
||||
@@ -34,7 +38,7 @@ function getTooltip(eventType, data, indexer) {
|
||||
|
||||
function HistoryEventTypeCell({ eventType, data, indexer }) {
|
||||
const iconName = getIconName(eventType);
|
||||
const iconKind = getIconKind(eventType);
|
||||
const iconKind = getIconKind(data);
|
||||
const tooltip = getTooltip(eventType, data, indexer);
|
||||
|
||||
return (
|
||||
|
@@ -35,6 +35,25 @@ class HistoryRow extends Component {
|
||||
//
|
||||
// Listeners
|
||||
|
||||
onSearchPress = () => {
|
||||
const {
|
||||
indexer,
|
||||
data
|
||||
} = this.props;
|
||||
|
||||
let categories = [];
|
||||
|
||||
if (data.categories) {
|
||||
categories = data.categories.split(',').map((item) => {
|
||||
return parseInt(item);
|
||||
});
|
||||
}
|
||||
|
||||
console.log(categories);
|
||||
|
||||
this.props.onSearchPress(data.query, indexer.id, categories);
|
||||
}
|
||||
|
||||
onDetailsPress = () => {
|
||||
this.setState({ isDetailsModalOpen: true });
|
||||
}
|
||||
@@ -115,7 +134,11 @@ class HistoryRow extends Component {
|
||||
key={name}
|
||||
className={styles.indexer}
|
||||
>
|
||||
{`${data.elapsedTime}ms`}
|
||||
{
|
||||
data.elapsedTime ?
|
||||
`${data.elapsedTime}ms` :
|
||||
null
|
||||
}
|
||||
</TableRowCell>
|
||||
);
|
||||
}
|
||||
@@ -146,9 +169,19 @@ class HistoryRow extends Component {
|
||||
key={name}
|
||||
className={styles.details}
|
||||
>
|
||||
{
|
||||
eventType === 'indexerQuery' ?
|
||||
<IconButton
|
||||
name={icons.SEARCH}
|
||||
onPress={this.onSearchPress}
|
||||
title='Repeat Search'
|
||||
/> :
|
||||
null
|
||||
}
|
||||
<IconButton
|
||||
name={icons.INFO}
|
||||
onPress={this.onDetailsPress}
|
||||
title='History Details'
|
||||
/>
|
||||
</TableRowCell>
|
||||
);
|
||||
@@ -186,7 +219,8 @@ HistoryRow.propTypes = {
|
||||
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
shortDateFormat: PropTypes.string.isRequired,
|
||||
timeFormat: PropTypes.string.isRequired,
|
||||
onMarkAsFailedPress: PropTypes.func.isRequired
|
||||
onMarkAsFailedPress: PropTypes.func.isRequired,
|
||||
onSearchPress: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default HistoryRow;
|
||||
|
@@ -1,8 +1,10 @@
|
||||
import { push } from 'connected-react-router';
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { fetchHistory, markAsFailed } from 'Store/Actions/historyActions';
|
||||
import { setSearchDefault } from 'Store/Actions/releaseActions';
|
||||
import createIndexerSelector from 'Store/Selectors/createIndexerSelector';
|
||||
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
||||
import HistoryRow from './HistoryRow';
|
||||
@@ -23,7 +25,9 @@ function createMapStateToProps() {
|
||||
|
||||
const mapDispatchToProps = {
|
||||
fetchHistory,
|
||||
markAsFailed
|
||||
markAsFailed,
|
||||
setSearchDefault,
|
||||
push
|
||||
};
|
||||
|
||||
class HistoryRowConnector extends Component {
|
||||
@@ -44,6 +48,11 @@ class HistoryRowConnector extends Component {
|
||||
//
|
||||
// Listeners
|
||||
|
||||
onSearchPress = (term, indexerId, categories) => {
|
||||
this.props.setSearchDefault({ searchQuery: term, searchIndexerIds: [indexerId], searchCategories: categories });
|
||||
this.props.push(`${window.Prowlarr.urlBase}search`);
|
||||
}
|
||||
|
||||
onMarkAsFailedPress = () => {
|
||||
this.props.markAsFailed({ id: this.props.id });
|
||||
}
|
||||
@@ -56,6 +65,7 @@ class HistoryRowConnector extends Component {
|
||||
<HistoryRow
|
||||
{...this.props}
|
||||
onMarkAsFailedPress={this.onMarkAsFailedPress}
|
||||
onSearchPress={this.onSearchPress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -67,7 +77,9 @@ HistoryRowConnector.propTypes = {
|
||||
isMarkingAsFailed: PropTypes.bool,
|
||||
markAsFailedError: PropTypes.object,
|
||||
fetchHistory: PropTypes.func.isRequired,
|
||||
markAsFailed: PropTypes.func.isRequired
|
||||
markAsFailed: PropTypes.func.isRequired,
|
||||
setSearchDefault: PropTypes.func.isRequired,
|
||||
push: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default connect(createMapStateToProps, mapDispatchToProps)(HistoryRowConnector);
|
||||
|
@@ -24,18 +24,10 @@
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.organizeSelectedButton,
|
||||
.tagsButton {
|
||||
.searchButton {
|
||||
composes: button from '~Components/Link/SpinnerButton.css';
|
||||
|
||||
margin-right: 10px;
|
||||
height: 35px;
|
||||
}
|
||||
|
||||
.deleteSelectedButton {
|
||||
composes: button from '~Components/Link/SpinnerButton.css';
|
||||
|
||||
margin-left: 50px;
|
||||
margin-left: 25px;
|
||||
height: 35px;
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import _ from 'lodash';
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import IndexersSelectInputConnector from 'Components/Form/IndexersSelectInputConnector';
|
||||
@@ -16,36 +17,75 @@ class SearchFooter extends Component {
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
|
||||
const {
|
||||
defaultIndexerIds,
|
||||
defaultCategories,
|
||||
defaultSearchQuery
|
||||
} = props;
|
||||
|
||||
this.state = {
|
||||
searchingReleases: false,
|
||||
searchQuery: '',
|
||||
indexerIds: [],
|
||||
categories: []
|
||||
searchQuery: defaultSearchQuery,
|
||||
searchIndexerIds: defaultIndexerIds,
|
||||
searchCategories: defaultCategories
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const {
|
||||
searchIndexerIds,
|
||||
searchCategories,
|
||||
searchQuery
|
||||
} = this.state;
|
||||
|
||||
if (searchQuery !== '' || searchCategories !== [] || searchIndexerIds !== []) {
|
||||
this.onSearchPress();
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const {
|
||||
isFetching,
|
||||
defaultIndexerIds,
|
||||
defaultCategories,
|
||||
defaultSearchQuery,
|
||||
searchError
|
||||
} = this.props;
|
||||
|
||||
const {
|
||||
searchIndexerIds,
|
||||
searchCategories,
|
||||
searchQuery
|
||||
} = this.state;
|
||||
|
||||
const newState = {};
|
||||
|
||||
if (searchIndexerIds !== defaultIndexerIds) {
|
||||
newState.searchIndexerIds = defaultIndexerIds;
|
||||
}
|
||||
|
||||
if (searchCategories !== defaultCategories) {
|
||||
newState.searchCategories = defaultCategories;
|
||||
}
|
||||
|
||||
if (searchQuery !== defaultSearchQuery) {
|
||||
newState.searchQuery = defaultSearchQuery;
|
||||
}
|
||||
|
||||
if (prevProps.isFetching && !isFetching && !searchError) {
|
||||
this.setState({
|
||||
searchingReleases: false
|
||||
});
|
||||
newState.searchingReleases = false;
|
||||
}
|
||||
|
||||
if (!_.isEmpty(newState)) {
|
||||
this.setState(newState);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Listeners
|
||||
|
||||
onInputChange = ({ name, value }) => {
|
||||
this.setState({ [name]: value });
|
||||
}
|
||||
|
||||
onSearchPress = () => {
|
||||
this.props.onSearchPress(this.state.searchQuery, this.state.indexerIds, this.state.categories);
|
||||
this.props.onSearchPress(this.state.searchQuery, this.state.searchIndexerIds, this.state.searchCategories);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -54,13 +94,14 @@ class SearchFooter extends Component {
|
||||
render() {
|
||||
const {
|
||||
isFetching,
|
||||
hasIndexers
|
||||
hasIndexers,
|
||||
onInputChange
|
||||
} = this.props;
|
||||
|
||||
const {
|
||||
searchQuery,
|
||||
indexerIds,
|
||||
categories
|
||||
searchIndexerIds,
|
||||
searchCategories
|
||||
} = this.state;
|
||||
|
||||
return (
|
||||
@@ -75,7 +116,7 @@ class SearchFooter extends Component {
|
||||
name='searchQuery'
|
||||
value={searchQuery}
|
||||
isDisabled={isFetching}
|
||||
onChange={this.onInputChange}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -86,10 +127,10 @@ class SearchFooter extends Component {
|
||||
/>
|
||||
|
||||
<IndexersSelectInputConnector
|
||||
name='indexerIds'
|
||||
value={indexerIds}
|
||||
name='searchIndexerIds'
|
||||
value={searchIndexerIds}
|
||||
isDisabled={isFetching}
|
||||
onChange={this.onInputChange}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -100,19 +141,24 @@ class SearchFooter extends Component {
|
||||
/>
|
||||
|
||||
<NewznabCategorySelectInputConnector
|
||||
name='categories'
|
||||
value={categories}
|
||||
name='searchCategories'
|
||||
value={searchCategories}
|
||||
isDisabled={isFetching}
|
||||
onChange={this.onInputChange}
|
||||
onChange={onInputChange}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={styles.buttonContainer}>
|
||||
<div className={styles.buttonContainerContent}>
|
||||
<SearchFooterLabel
|
||||
label={`Search ${searchIndexerIds.length === 0 ? 'all' : searchIndexerIds.length} Indexers`}
|
||||
isSaving={false}
|
||||
/>
|
||||
|
||||
<div className={styles.buttons}>
|
||||
|
||||
<SpinnerButton
|
||||
className={styles.deleteSelectedButton}
|
||||
className={styles.searchButton}
|
||||
isSpinning={isFetching}
|
||||
isDisabled={isFetching || !hasIndexers}
|
||||
onPress={this.onSearchPress}
|
||||
@@ -128,9 +174,13 @@ class SearchFooter extends Component {
|
||||
}
|
||||
|
||||
SearchFooter.propTypes = {
|
||||
defaultIndexerIds: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||
defaultCategories: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||
defaultSearchQuery: PropTypes.string.isRequired,
|
||||
isFetching: PropTypes.bool.isRequired,
|
||||
onSearchPress: PropTypes.func.isRequired,
|
||||
hasIndexers: PropTypes.bool.isRequired,
|
||||
onInputChange: PropTypes.func.isRequired,
|
||||
searchError: PropTypes.object
|
||||
};
|
||||
|
||||
|
58
frontend/src/Search/SearchFooterConnector.js
Normal file
58
frontend/src/Search/SearchFooterConnector.js
Normal file
@@ -0,0 +1,58 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { setSearchDefault } from 'Store/Actions/releaseActions';
|
||||
import SearchFooter from './SearchFooter';
|
||||
|
||||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
(state) => state.releases,
|
||||
(releases) => {
|
||||
const {
|
||||
searchQuery: defaultSearchQuery,
|
||||
searchIndexerIds: defaultIndexerIds,
|
||||
searchCategories: defaultCategories
|
||||
} = releases.defaults;
|
||||
|
||||
return {
|
||||
defaultSearchQuery,
|
||||
defaultIndexerIds,
|
||||
defaultCategories
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const mapDispatchToProps = {
|
||||
setSearchDefault
|
||||
};
|
||||
|
||||
class SearchFooterConnector extends Component {
|
||||
|
||||
//
|
||||
// Listeners
|
||||
|
||||
onInputChange = ({ name, value }) => {
|
||||
console.log(name, value);
|
||||
this.props.setSearchDefault({ [name]: value });
|
||||
}
|
||||
|
||||
//
|
||||
// Render
|
||||
|
||||
render() {
|
||||
return (
|
||||
<SearchFooter
|
||||
{...this.props}
|
||||
onInputChange={this.onInputChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
SearchFooterConnector.propTypes = {
|
||||
setSearchDefault: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default connect(createMapStateToProps, mapDispatchToProps)(SearchFooterConnector);
|
@@ -21,7 +21,7 @@ import translate from 'Utilities/String/translate';
|
||||
import SearchIndexFilterMenu from './Menus/SearchIndexFilterMenu';
|
||||
import SearchIndexSortMenu from './Menus/SearchIndexSortMenu';
|
||||
import NoSearchResults from './NoSearchResults';
|
||||
import SearchFooter from './SearchFooter.js';
|
||||
import SearchFooterConnector from './SearchFooterConnector';
|
||||
import SearchIndexTableConnector from './Table/SearchIndexTableConnector';
|
||||
import styles from './SearchIndex.css';
|
||||
|
||||
@@ -290,7 +290,7 @@ class SearchIndex extends Component {
|
||||
}
|
||||
</div>
|
||||
|
||||
<SearchFooter
|
||||
<SearchFooterConnector
|
||||
isFetching={isFetching}
|
||||
hasIndexers={hasIndexers}
|
||||
onSearchPress={this.onSearchPress}
|
||||
|
@@ -2,6 +2,8 @@ import { createAction } from 'redux-actions';
|
||||
import { filterBuilderTypes, filterBuilderValueTypes, sortDirections } from 'Helpers/Props';
|
||||
import { createThunk, handleThunks } from 'Store/thunks';
|
||||
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
||||
import getSectionState from 'Utilities/State/getSectionState';
|
||||
import updateSectionState from 'Utilities/State/updateSectionState';
|
||||
import translate from 'Utilities/String/translate';
|
||||
import createFetchHandler from './Creators/createFetchHandler';
|
||||
import createHandleActions from './Creators/createHandleActions';
|
||||
@@ -27,6 +29,12 @@ export const defaultState = {
|
||||
sortKey: 'title',
|
||||
sortDirection: sortDirections.ASCENDING,
|
||||
|
||||
defaults: {
|
||||
searchQuery: '',
|
||||
searchIndexerIds: [],
|
||||
searchCategories: []
|
||||
},
|
||||
|
||||
columns: [
|
||||
{
|
||||
name: 'protocol',
|
||||
@@ -196,6 +204,7 @@ export const GRAB_RELEASE = 'releases/grabRelease';
|
||||
export const UPDATE_RELEASE = 'releases/updateRelease';
|
||||
export const SET_RELEASES_FILTER = 'releases/setReleasesFilter';
|
||||
export const SET_RELEASES_TABLE_OPTION = 'releases/setReleasesTableOption';
|
||||
export const SET_SEARCH_DEFAULT = 'releases/setSearchDefault';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
@@ -208,6 +217,7 @@ export const grabRelease = createThunk(GRAB_RELEASE);
|
||||
export const updateRelease = createAction(UPDATE_RELEASE);
|
||||
export const setReleasesFilter = createAction(SET_RELEASES_FILTER);
|
||||
export const setReleasesTableOption = createAction(SET_RELEASES_TABLE_OPTION);
|
||||
export const setSearchDefault = createAction(SET_SEARCH_DEFAULT);
|
||||
|
||||
//
|
||||
// Helpers
|
||||
@@ -291,6 +301,17 @@ export const reducers = createHandleActions({
|
||||
return newState;
|
||||
},
|
||||
|
||||
[SET_SEARCH_DEFAULT]: function(state, { payload }) {
|
||||
const newState = getSectionState(state, section);
|
||||
|
||||
newState.defaults = {
|
||||
...newState.defaults,
|
||||
...payload
|
||||
};
|
||||
|
||||
return updateSectionState(state, section, newState);
|
||||
},
|
||||
|
||||
[SET_RELEASES_FILTER]: createSetClientSideCollectionFilterReducer(section),
|
||||
[SET_RELEASES_SORT]: createSetClientSideCollectionSortReducer(section),
|
||||
|
||||
|
@@ -77,9 +77,6 @@ namespace NzbDrone.Core.Indexers.Gazelle
|
||||
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
|
||||
|
||||
_logger.Debug("Gazelle authentication succeeded.");
|
||||
|
||||
//Settings.AuthKey = index.Response.Authkey;
|
||||
//Settings.PassKey = index.Response.Passkey;
|
||||
}
|
||||
|
||||
protected override bool CheckIfLoginNeeded(HttpResponse response)
|
||||
|
@@ -5,7 +5,6 @@ using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Common.TPL;
|
||||
using NzbDrone.Core.Exceptions;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Indexers.Events;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
||||
|
Reference in New Issue
Block a user