mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Allow group select Indexers by protocol in Search view
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
|
import _ from 'lodash';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import titleCase from 'Utilities/String/titleCase';
|
||||||
import EnhancedSelectInput from './EnhancedSelectInput';
|
import EnhancedSelectInput from './EnhancedSelectInput';
|
||||||
|
|
||||||
function createMapStateToProps() {
|
function createMapStateToProps() {
|
||||||
@@ -9,11 +11,24 @@ function createMapStateToProps() {
|
|||||||
(state, { value }) => value,
|
(state, { value }) => value,
|
||||||
(state) => state.indexers,
|
(state) => state.indexers,
|
||||||
(value, indexers) => {
|
(value, indexers) => {
|
||||||
const values = indexers.items.map(({ id, name }) => {
|
const values = [];
|
||||||
return {
|
const groupedIndexers = _(indexers.items).groupBy((x) => x.protocol).map((val, key) => ({ protocol: key, indexers: val })).value();
|
||||||
key: id,
|
|
||||||
value: name
|
groupedIndexers.forEach((element) => {
|
||||||
};
|
values.push({
|
||||||
|
key: element.protocol === 'usenet' ? -1 : -2,
|
||||||
|
value: titleCase(element.protocol)
|
||||||
|
});
|
||||||
|
|
||||||
|
if (element.indexers && element.indexers.length > 0) {
|
||||||
|
element.indexers.forEach((subCat) => {
|
||||||
|
values.push({
|
||||||
|
key: subCat.id,
|
||||||
|
value: subCat.name,
|
||||||
|
parentKey: element.protocol === 'usenet' ? -1 : -2
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -27,6 +42,7 @@ function createMapStateToProps() {
|
|||||||
class IndexersSelectInputConnector extends Component {
|
class IndexersSelectInputConnector extends Component {
|
||||||
|
|
||||||
onChange = ({ name, value }) => {
|
onChange = ({ name, value }) => {
|
||||||
|
console.log(name, value);
|
||||||
this.props.onChange({ name, value });
|
this.props.onChange({ name, value });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +63,7 @@ class IndexersSelectInputConnector extends Component {
|
|||||||
IndexersSelectInputConnector.propTypes = {
|
IndexersSelectInputConnector.propTypes = {
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
indexerIds: PropTypes.number,
|
indexerIds: PropTypes.number,
|
||||||
value: PropTypes.arrayOf(PropTypes.number).isRequired,
|
value: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])).isRequired,
|
||||||
values: PropTypes.arrayOf(PropTypes.object).isRequired,
|
values: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
onChange: PropTypes.func.isRequired
|
onChange: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
@@ -135,7 +135,10 @@ namespace NzbDrone.Core.IndexerSearch
|
|||||||
|
|
||||||
if (criteriaBase.IndexerIds != null && criteriaBase.IndexerIds.Count > 0)
|
if (criteriaBase.IndexerIds != null && criteriaBase.IndexerIds.Count > 0)
|
||||||
{
|
{
|
||||||
indexers = indexers.Where(i => criteriaBase.IndexerIds.Contains(i.Definition.Id)).ToList();
|
indexers = indexers.Where(i => criteriaBase.IndexerIds.Contains(i.Definition.Id) ||
|
||||||
|
(criteriaBase.IndexerIds.Contains(-1) && i.Protocol == DownloadProtocol.Usenet) ||
|
||||||
|
(criteriaBase.IndexerIds.Contains(-2) && i.Protocol == DownloadProtocol.Torrent))
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
var reports = new List<ReleaseInfo>();
|
var reports = new List<ReleaseInfo>();
|
||||||
|
Reference in New Issue
Block a user