1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-17 15:02:34 +02:00

New: NetImport Lists Grouped by Type

Co-Authored-By: ta264 <ta264@users.noreply.github.com>
This commit is contained in:
Qstick 2019-11-02 15:43:45 -04:00
parent d76423a305
commit ba83c01b6c
15 changed files with 65 additions and 19 deletions

View File

@ -10,6 +10,7 @@ import ModalHeader from 'Components/Modal/ModalHeader';
import ModalBody from 'Components/Modal/ModalBody'; import ModalBody from 'Components/Modal/ModalBody';
import ModalFooter from 'Components/Modal/ModalFooter'; import ModalFooter from 'Components/Modal/ModalFooter';
import AddNetImportItem from './AddNetImportItem'; import AddNetImportItem from './AddNetImportItem';
import titleCase from 'Utilities/String/titleCase';
import styles from './AddNetImportModalContent.css'; import styles from './AddNetImportModalContent.css';
class AddNetImportModalContent extends Component { class AddNetImportModalContent extends Component {
@ -22,7 +23,7 @@ class AddNetImportModalContent extends Component {
isSchemaFetching, isSchemaFetching,
isSchemaPopulated, isSchemaPopulated,
schemaError, schemaError,
netImports, listGroups,
onNetImportSelect, onNetImportSelect,
onModalClose onModalClose
} = this.props; } = this.props;
@ -53,10 +54,13 @@ class AddNetImportModalContent extends Component {
<div>For more information on the individual netImports, clink on the info buttons.</div> <div>For more information on the individual netImports, clink on the info buttons.</div>
</Alert> </Alert>
<FieldSet> {
Object.keys(listGroups).map((key) => {
return (
<FieldSet legend={`${titleCase(key)} List`} key={key}>
<div className={styles.netImports}> <div className={styles.netImports}>
{ {
netImports.map((netImport) => { listGroups[key].map((netImport) => {
return ( return (
<AddNetImportItem <AddNetImportItem
key={netImport.implementation} key={netImport.implementation}
@ -69,6 +73,9 @@ class AddNetImportModalContent extends Component {
} }
</div> </div>
</FieldSet> </FieldSet>
);
})
}
</div> </div>
} }
</ModalBody> </ModalBody>
@ -88,7 +95,7 @@ AddNetImportModalContent.propTypes = {
isSchemaFetching: PropTypes.bool.isRequired, isSchemaFetching: PropTypes.bool.isRequired,
isSchemaPopulated: PropTypes.bool.isRequired, isSchemaPopulated: PropTypes.bool.isRequired,
schemaError: PropTypes.object, schemaError: PropTypes.object,
netImports: PropTypes.arrayOf(PropTypes.object).isRequired, listGroups: PropTypes.object.isRequired,
onNetImportSelect: PropTypes.func.isRequired, onNetImportSelect: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired onModalClose: PropTypes.func.isRequired
}; };

View File

@ -1,3 +1,4 @@
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';
@ -16,11 +17,16 @@ function createMapStateToProps() {
schema schema
} = netImports; } = netImports;
const listGroups = _.chain(schema)
.sortBy((o) => o.listOrder)
.groupBy('listType')
.value();
return { return {
isSchemaFetching, isSchemaFetching,
isSchemaPopulated, isSchemaPopulated,
schemaError, schemaError,
netImports: schema listGroups
}; };
} }
); );

View File

@ -72,6 +72,7 @@ public static void Map()
Mapper.Entity<NetImportDefinition>("NetImport").RegisterModel() Mapper.Entity<NetImportDefinition>("NetImport").RegisterModel()
.Ignore(x => x.ImplementationName) .Ignore(x => x.ImplementationName)
.Ignore(i => i.ListType)
.Ignore(i => i.Enable); .Ignore(i => i.Enable);
Mapper.Entity<NotificationDefinition>("Notifications").RegisterModel() Mapper.Entity<NotificationDefinition>("Notifications").RegisterModel()

View File

@ -8,6 +8,8 @@ namespace NzbDrone.Core.NetImport.CouchPotato
public class CouchPotatoImport : HttpNetImportBase<CouchPotatoSettings> public class CouchPotatoImport : HttpNetImportBase<CouchPotatoSettings>
{ {
public override string Name => "CouchPotato"; public override string Name => "CouchPotato";
public override NetImportType ListType => NetImportType.Other;
public override bool Enabled => true; public override bool Enabled => true;
public override bool EnableAuto => false; public override bool EnableAuto => false;

View File

@ -7,6 +7,7 @@ public interface INetImport : IProvider
bool Enabled { get; } bool Enabled { get; }
bool EnableAuto { get; } bool EnableAuto { get; }
NetImportType ListType { get; }
NetImportFetchResult Fetch(); NetImportFetchResult Fetch();
} }
} }

View File

@ -23,6 +23,8 @@ public abstract class NetImportBase<TSettings> : INetImport
protected readonly Logger _logger; protected readonly Logger _logger;
public abstract string Name { get; } public abstract string Name { get; }
public abstract NetImportType ListType { get; }
public abstract bool Enabled { get; } public abstract bool Enabled { get; }
public abstract bool EnableAuto { get; } public abstract bool EnableAuto { get; }

View File

@ -18,5 +18,7 @@ public NetImportDefinition()
public int ProfileId { get; set; } public int ProfileId { get; set; }
public string RootFolderPath { get; set; } public string RootFolderPath { get; set; }
public override bool Enable => Enabled; public override bool Enable => Enabled;
public NetImportType ListType { get; set; }
} }
} }

View File

@ -39,6 +39,8 @@ protected override List<NetImportDefinition> Active()
public override void SetProviderCharacteristics(INetImport provider, NetImportDefinition definition) public override void SetProviderCharacteristics(INetImport provider, NetImportDefinition definition)
{ {
base.SetProviderCharacteristics(provider, definition); base.SetProviderCharacteristics(provider, definition);
definition.ListType = provider.ListType;
} }
public List<INetImport> Enabled() public List<INetImport> Enabled()

View File

@ -0,0 +1,8 @@
namespace NzbDrone.Core.NetImport
{
public enum NetImportType
{
TMDB,
Other
}
}

View File

@ -10,6 +10,8 @@ namespace NzbDrone.Core.NetImport.RSSImport
public class RSSImport : HttpNetImportBase<RSSImportSettings> public class RSSImport : HttpNetImportBase<RSSImportSettings>
{ {
public override string Name => "RSSList"; public override string Name => "RSSList";
public override NetImportType ListType => NetImportType.Other;
public override bool Enabled => true; public override bool Enabled => true;
public override bool EnableAuto => false; public override bool EnableAuto => false;

View File

@ -11,6 +11,8 @@ namespace NzbDrone.Core.NetImport.Radarr
public class RadarrLists : HttpNetImportBase<RadarrSettings> public class RadarrLists : HttpNetImportBase<RadarrSettings>
{ {
public override string Name => "Radarr Lists"; public override string Name => "Radarr Lists";
public override NetImportType ListType => NetImportType.Other;
public override bool Enabled => true; public override bool Enabled => true;
public override bool EnableAuto => false; public override bool EnableAuto => false;

View File

@ -8,6 +8,8 @@ namespace NzbDrone.Core.NetImport.StevenLu
public class StevenLuImport : HttpNetImportBase<StevenLuSettings> public class StevenLuImport : HttpNetImportBase<StevenLuSettings>
{ {
public override string Name => "StevenLu"; public override string Name => "StevenLu";
public override NetImportType ListType => NetImportType.Other;
public override bool Enabled => true; public override bool Enabled => true;
public override bool EnableAuto => false; public override bool EnableAuto => false;

View File

@ -9,6 +9,8 @@ namespace NzbDrone.Core.NetImport.TMDb
public class TMDbImport : HttpNetImportBase<TMDbSettings> public class TMDbImport : HttpNetImportBase<TMDbSettings>
{ {
public override string Name => "TMDb Lists"; public override string Name => "TMDb Lists";
public override NetImportType ListType => NetImportType.TMDB;
public override bool Enabled => true; public override bool Enabled => true;
public override bool EnableAuto => false; public override bool EnableAuto => false;

View File

@ -11,6 +11,8 @@ namespace NzbDrone.Core.NetImport.Trakt
public class TraktImport : HttpNetImportBase<TraktSettings> public class TraktImport : HttpNetImportBase<TraktSettings>
{ {
public override string Name => "Trakt List"; public override string Name => "Trakt List";
public override NetImportType ListType => NetImportType.Other;
public override bool Enabled => true; public override bool Enabled => true;
public override bool EnableAuto => false; public override bool EnableAuto => false;

View File

@ -11,6 +11,8 @@ public class NetImportResource : ProviderResource
public string RootFolderPath { get; set; } public string RootFolderPath { get; set; }
public int QualityProfileId { get; set; } public int QualityProfileId { get; set; }
public MovieStatusType MinimumAvailability { get; set; } public MovieStatusType MinimumAvailability { get; set; }
public NetImportType ListType { get; set; }
public int ListOrder { get; set; }
} }
public class NetImportResourceMapper : ProviderResourceMapper<NetImportResource, NetImportDefinition> public class NetImportResourceMapper : ProviderResourceMapper<NetImportResource, NetImportDefinition>
@ -30,6 +32,8 @@ public override NetImportResource ToResource(NetImportDefinition definition)
resource.RootFolderPath = definition.RootFolderPath; resource.RootFolderPath = definition.RootFolderPath;
resource.QualityProfileId = definition.ProfileId; resource.QualityProfileId = definition.ProfileId;
resource.MinimumAvailability = definition.MinimumAvailability; resource.MinimumAvailability = definition.MinimumAvailability;
resource.ListType = definition.ListType;
resource.ListOrder = (int)definition.ListType;
return resource; return resource;
} }
@ -49,6 +53,7 @@ public override NetImportDefinition ToModel(NetImportResource resource)
definition.RootFolderPath = resource.RootFolderPath; definition.RootFolderPath = resource.RootFolderPath;
definition.ProfileId = resource.QualityProfileId; definition.ProfileId = resource.QualityProfileId;
definition.MinimumAvailability = resource.MinimumAvailability; definition.MinimumAvailability = resource.MinimumAvailability;
definition.ListType = resource.ListType;
return definition; return definition;
} }