New: NetImport Lists Grouped by Type

Co-Authored-By: ta264 <ta264@users.noreply.github.com>
pull/4072/head
Qstick 5 years ago
parent d76423a305
commit ba83c01b6c

@ -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,22 +54,28 @@ 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> {
<div className={styles.netImports}> Object.keys(listGroups).map((key) => {
{ return (
netImports.map((netImport) => { <FieldSet legend={`${titleCase(key)} List`} key={key}>
return ( <div className={styles.netImports}>
<AddNetImportItem {
key={netImport.implementation} listGroups[key].map((netImport) => {
implementation={netImport.implementation} return (
{...netImport} <AddNetImportItem
onNetImportSelect={onNetImportSelect} key={netImport.implementation}
/> implementation={netImport.implementation}
); {...netImport}
}) onNetImportSelect={onNetImportSelect}
} />
</div> );
</FieldSet> })
}
</div>
</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
}; };

@ -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
}; };
} }
); );

@ -72,6 +72,7 @@ namespace NzbDrone.Core.Datastore
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()

@ -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;

@ -7,6 +7,7 @@ namespace NzbDrone.Core.NetImport
bool Enabled { get; } bool Enabled { get; }
bool EnableAuto { get; } bool EnableAuto { get; }
NetImportType ListType { get; }
NetImportFetchResult Fetch(); NetImportFetchResult Fetch();
} }
} }

@ -23,6 +23,8 @@ namespace NzbDrone.Core.NetImport
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; }

@ -18,5 +18,7 @@ namespace NzbDrone.Core.NetImport
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; }
} }
} }

@ -39,6 +39,8 @@ namespace NzbDrone.Core.NetImport
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()

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

@ -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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -11,6 +11,8 @@ namespace Radarr.Api.V3.NetImport
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 @@ namespace Radarr.Api.V3.NetImport
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 @@ namespace Radarr.Api.V3.NetImport
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;
} }

Loading…
Cancel
Save