mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 00:53:57 -07:00
parent
dd11f74073
commit
5b7339cd73
92 changed files with 2611 additions and 145 deletions
|
@ -58,7 +58,8 @@
|
||||||
composes: button from 'Components/Link/SpinnerButton.css';
|
composes: button from 'Components/Link/SpinnerButton.css';
|
||||||
}
|
}
|
||||||
|
|
||||||
.hideLanguageProfile {
|
.hideLanguageProfile,
|
||||||
|
.hideMetadataProfile {
|
||||||
composes: group from 'Components/Form/FormGroup.css';
|
composes: group from 'Components/Form/FormGroup.css';
|
||||||
|
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
@ -46,6 +46,10 @@ class AddNewArtistModalContent extends Component {
|
||||||
this.props.onInputChange({ name: 'languageProfileId', value: parseInt(value) });
|
this.props.onInputChange({ name: 'languageProfileId', value: parseInt(value) });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMetadataProfileIdChange = ({ value }) => {
|
||||||
|
this.props.onInputChange({ name: 'metadataProfileId', value: parseInt(value) });
|
||||||
|
}
|
||||||
|
|
||||||
onAddArtistPress = () => {
|
onAddArtistPress = () => {
|
||||||
this.props.onAddArtistPress(this.state.searchForMissingAlbums);
|
this.props.onAddArtistPress(this.state.searchForMissingAlbums);
|
||||||
}
|
}
|
||||||
|
@ -63,11 +67,11 @@ class AddNewArtistModalContent extends Component {
|
||||||
monitor,
|
monitor,
|
||||||
qualityProfileId,
|
qualityProfileId,
|
||||||
languageProfileId,
|
languageProfileId,
|
||||||
|
metadataProfileId,
|
||||||
albumFolder,
|
albumFolder,
|
||||||
primaryAlbumTypes,
|
|
||||||
secondaryAlbumTypes,
|
|
||||||
tags,
|
tags,
|
||||||
showLanguageProfile,
|
showLanguageProfile,
|
||||||
|
showMetadataProfile,
|
||||||
isSmallScreen,
|
isSmallScreen,
|
||||||
onModalClose,
|
onModalClose,
|
||||||
onInputChange
|
onInputChange
|
||||||
|
@ -149,7 +153,9 @@ class AddNewArtistModalContent extends Component {
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|
||||||
<FormGroup className={showLanguageProfile ? null : styles.hideLanguageProfile}>
|
{
|
||||||
|
showLanguageProfile &&
|
||||||
|
<FormGroup>
|
||||||
<FormLabel>Language Profile</FormLabel>
|
<FormLabel>Language Profile</FormLabel>
|
||||||
|
|
||||||
<FormInputGroup
|
<FormInputGroup
|
||||||
|
@ -159,6 +165,21 @@ class AddNewArtistModalContent extends Component {
|
||||||
{...languageProfileId}
|
{...languageProfileId}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
showMetadataProfile &&
|
||||||
|
<FormGroup>
|
||||||
|
<FormLabel>Metadata Profile</FormLabel>
|
||||||
|
|
||||||
|
<FormInputGroup
|
||||||
|
type={inputTypes.METADATA_PROFILE_SELECT}
|
||||||
|
name="metadataProfileId"
|
||||||
|
onChange={this.onMetadataProfileIdChange}
|
||||||
|
{...metadataProfileId}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
}
|
||||||
|
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<FormLabel>Album Folder</FormLabel>
|
<FormLabel>Album Folder</FormLabel>
|
||||||
|
@ -225,11 +246,11 @@ AddNewArtistModalContent.propTypes = {
|
||||||
monitor: PropTypes.object.isRequired,
|
monitor: PropTypes.object.isRequired,
|
||||||
qualityProfileId: PropTypes.object,
|
qualityProfileId: PropTypes.object,
|
||||||
languageProfileId: PropTypes.object,
|
languageProfileId: PropTypes.object,
|
||||||
|
metadataProfileId: PropTypes.object,
|
||||||
albumFolder: PropTypes.object.isRequired,
|
albumFolder: PropTypes.object.isRequired,
|
||||||
primaryAlbumTypes: PropTypes.object.isRequired,
|
|
||||||
secondaryAlbumTypes: PropTypes.object.isRequired,
|
|
||||||
tags: PropTypes.object.isRequired,
|
tags: PropTypes.object.isRequired,
|
||||||
showLanguageProfile: PropTypes.bool.isRequired,
|
showLanguageProfile: PropTypes.bool.isRequired,
|
||||||
|
showMetadataProfile: PropTypes.bool.isRequired,
|
||||||
isSmallScreen: PropTypes.bool.isRequired,
|
isSmallScreen: PropTypes.bool.isRequired,
|
||||||
onModalClose: PropTypes.func.isRequired,
|
onModalClose: PropTypes.func.isRequired,
|
||||||
onInputChange: PropTypes.func.isRequired,
|
onInputChange: PropTypes.func.isRequired,
|
||||||
|
|
|
@ -11,8 +11,9 @@ function createMapStateToProps() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.addArtist,
|
(state) => state.addArtist,
|
||||||
(state) => state.settings.languageProfiles,
|
(state) => state.settings.languageProfiles,
|
||||||
|
(state) => state.settings.metadataProfiles,
|
||||||
createDimensionsSelector(),
|
createDimensionsSelector(),
|
||||||
(addArtistState, languageProfiles, dimensions) => {
|
(addArtistState, languageProfiles, metadataProfiles, dimensions) => {
|
||||||
const {
|
const {
|
||||||
isAdding,
|
isAdding,
|
||||||
addError,
|
addError,
|
||||||
|
@ -28,7 +29,8 @@ function createMapStateToProps() {
|
||||||
return {
|
return {
|
||||||
isAdding,
|
isAdding,
|
||||||
addError,
|
addError,
|
||||||
showLanguageProfile: languageProfiles.length > 1,
|
showLanguageProfile: languageProfiles.items.length > 1,
|
||||||
|
showMetadataProfile: metadataProfiles.items.length > 1,
|
||||||
isSmallScreen: dimensions.isSmallScreen,
|
isSmallScreen: dimensions.isSmallScreen,
|
||||||
validationErrors,
|
validationErrors,
|
||||||
validationWarnings,
|
validationWarnings,
|
||||||
|
@ -59,9 +61,8 @@ class AddNewArtistModalContentConnector extends Component {
|
||||||
monitor,
|
monitor,
|
||||||
qualityProfileId,
|
qualityProfileId,
|
||||||
languageProfileId,
|
languageProfileId,
|
||||||
|
metadataProfileId,
|
||||||
albumFolder,
|
albumFolder,
|
||||||
primaryAlbumTypes,
|
|
||||||
secondaryAlbumTypes,
|
|
||||||
tags
|
tags
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
@ -71,9 +72,8 @@ class AddNewArtistModalContentConnector extends Component {
|
||||||
monitor: monitor.value,
|
monitor: monitor.value,
|
||||||
qualityProfileId: qualityProfileId.value,
|
qualityProfileId: qualityProfileId.value,
|
||||||
languageProfileId: languageProfileId.value,
|
languageProfileId: languageProfileId.value,
|
||||||
|
metadataProfileId: metadataProfileId.value,
|
||||||
albumFolder: albumFolder.value,
|
albumFolder: albumFolder.value,
|
||||||
primaryAlbumTypes: primaryAlbumTypes.value,
|
|
||||||
secondaryAlbumTypes: secondaryAlbumTypes.value,
|
|
||||||
tags: tags.value,
|
tags: tags.value,
|
||||||
searchForMissingAlbums
|
searchForMissingAlbums
|
||||||
});
|
});
|
||||||
|
@ -99,9 +99,8 @@ AddNewArtistModalContentConnector.propTypes = {
|
||||||
monitor: PropTypes.object.isRequired,
|
monitor: PropTypes.object.isRequired,
|
||||||
qualityProfileId: PropTypes.object,
|
qualityProfileId: PropTypes.object,
|
||||||
languageProfileId: PropTypes.object,
|
languageProfileId: PropTypes.object,
|
||||||
|
metadataProfileId: PropTypes.object,
|
||||||
albumFolder: PropTypes.object.isRequired,
|
albumFolder: PropTypes.object.isRequired,
|
||||||
primaryAlbumTypes: PropTypes.object.isRequired,
|
|
||||||
secondaryAlbumTypes: PropTypes.object.isRequired,
|
|
||||||
tags: PropTypes.object.isRequired,
|
tags: PropTypes.object.isRequired,
|
||||||
onModalClose: PropTypes.func.isRequired,
|
onModalClose: PropTypes.func.isRequired,
|
||||||
setAddArtistDefault: PropTypes.func.isRequired,
|
setAddArtistDefault: PropTypes.func.isRequired,
|
||||||
|
|
|
@ -87,7 +87,8 @@ class ImportArtist extends Component {
|
||||||
rootFoldersPopulated,
|
rootFoldersPopulated,
|
||||||
rootFoldersError,
|
rootFoldersError,
|
||||||
unmappedFolders,
|
unmappedFolders,
|
||||||
showLanguageProfile
|
showLanguageProfile,
|
||||||
|
showMetadataProfile
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -130,6 +131,7 @@ class ImportArtist extends Component {
|
||||||
selectedState={selectedState}
|
selectedState={selectedState}
|
||||||
contentBody={contentBody}
|
contentBody={contentBody}
|
||||||
showLanguageProfile={showLanguageProfile}
|
showLanguageProfile={showLanguageProfile}
|
||||||
|
showMetadataProfile={showMetadataProfile}
|
||||||
scrollTop={this.state.scrollTop}
|
scrollTop={this.state.scrollTop}
|
||||||
onSelectAllChange={this.onSelectAllChange}
|
onSelectAllChange={this.onSelectAllChange}
|
||||||
onSelectedChange={this.onSelectedChange}
|
onSelectedChange={this.onSelectedChange}
|
||||||
|
@ -144,6 +146,7 @@ class ImportArtist extends Component {
|
||||||
<ImportArtistFooterConnector
|
<ImportArtistFooterConnector
|
||||||
selectedIds={this.getSelectedIds()}
|
selectedIds={this.getSelectedIds()}
|
||||||
showLanguageProfile={showLanguageProfile}
|
showLanguageProfile={showLanguageProfile}
|
||||||
|
showMetadataProfile={showMetadataProfile}
|
||||||
onInputChange={this.onInputChange}
|
onInputChange={this.onInputChange}
|
||||||
onImportPress={this.onImportPress}
|
onImportPress={this.onImportPress}
|
||||||
/>
|
/>
|
||||||
|
@ -162,6 +165,7 @@ ImportArtist.propTypes = {
|
||||||
unmappedFolders: PropTypes.arrayOf(PropTypes.object),
|
unmappedFolders: PropTypes.arrayOf(PropTypes.object),
|
||||||
items: PropTypes.arrayOf(PropTypes.object),
|
items: PropTypes.arrayOf(PropTypes.object),
|
||||||
showLanguageProfile: PropTypes.bool.isRequired,
|
showLanguageProfile: PropTypes.bool.isRequired,
|
||||||
|
showMetadataProfile: PropTypes.bool.isRequired,
|
||||||
onInputChange: PropTypes.func.isRequired,
|
onInputChange: PropTypes.func.isRequired,
|
||||||
onImportPress: PropTypes.func.isRequired
|
onImportPress: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,8 @@ function createMapStateToProps() {
|
||||||
(state) => state.addArtist,
|
(state) => state.addArtist,
|
||||||
(state) => state.importArtist,
|
(state) => state.importArtist,
|
||||||
(state) => state.settings.languageProfiles,
|
(state) => state.settings.languageProfiles,
|
||||||
(match, rootFolders, addArtist, importArtistState, languageProfiles) => {
|
(state) => state.settings.metadataProfiles,
|
||||||
|
(match, rootFolders, addArtist, importArtistState, languageProfiles, metadataProfiles) => {
|
||||||
const {
|
const {
|
||||||
isFetching: rootFoldersFetching,
|
isFetching: rootFoldersFetching,
|
||||||
isPopulated: rootFoldersPopulated,
|
isPopulated: rootFoldersPopulated,
|
||||||
|
@ -31,7 +32,8 @@ function createMapStateToProps() {
|
||||||
rootFoldersFetching,
|
rootFoldersFetching,
|
||||||
rootFoldersPopulated,
|
rootFoldersPopulated,
|
||||||
rootFoldersError,
|
rootFoldersError,
|
||||||
showLanguageProfile: languageProfiles.items.length > 1
|
showLanguageProfile: languageProfiles.items.length > 1,
|
||||||
|
showMetadataProfile: metadataProfiles.items.length > 1
|
||||||
};
|
};
|
||||||
|
|
||||||
if (items.length) {
|
if (items.length) {
|
||||||
|
|
|
@ -23,18 +23,16 @@ class ImportArtistFooter extends Component {
|
||||||
defaultMonitor,
|
defaultMonitor,
|
||||||
defaultQualityProfileId,
|
defaultQualityProfileId,
|
||||||
defaultLanguageProfileId,
|
defaultLanguageProfileId,
|
||||||
defaultAlbumFolder,
|
defaultMetadataProfileId,
|
||||||
defaultPrimaryAlbumTypes,
|
defaultAlbumFolder
|
||||||
defaultSecondaryAlbumTypes
|
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
monitor: defaultMonitor,
|
monitor: defaultMonitor,
|
||||||
qualityProfileId: defaultQualityProfileId,
|
qualityProfileId: defaultQualityProfileId,
|
||||||
languageProfileId: defaultLanguageProfileId,
|
languageProfileId: defaultLanguageProfileId,
|
||||||
albumFolder: defaultAlbumFolder,
|
metadataProfileId: defaultMetadataProfileId,
|
||||||
primaryAlbumTypes: defaultPrimaryAlbumTypes,
|
albumFolder: defaultAlbumFolder
|
||||||
secondaryAlbumTypes: defaultSecondaryAlbumTypes
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,24 +41,21 @@ class ImportArtistFooter extends Component {
|
||||||
defaultMonitor,
|
defaultMonitor,
|
||||||
defaultQualityProfileId,
|
defaultQualityProfileId,
|
||||||
defaultLanguageProfileId,
|
defaultLanguageProfileId,
|
||||||
|
defaultMetadataProfileId,
|
||||||
defaultAlbumFolder,
|
defaultAlbumFolder,
|
||||||
defaultPrimaryAlbumTypes,
|
|
||||||
defaultSecondaryAlbumTypes,
|
|
||||||
isMonitorMixed,
|
isMonitorMixed,
|
||||||
isQualityProfileIdMixed,
|
isQualityProfileIdMixed,
|
||||||
isLanguageProfileIdMixed,
|
isLanguageProfileIdMixed,
|
||||||
isAlbumFolderMixed,
|
isMetadataProfileIdMixed,
|
||||||
isPrimaryAlbumTypesMixed,
|
isAlbumFolderMixed
|
||||||
isSecondaryAlbumTypesMixed
|
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
monitor,
|
monitor,
|
||||||
qualityProfileId,
|
qualityProfileId,
|
||||||
languageProfileId,
|
languageProfileId,
|
||||||
albumFolder,
|
metadataProfileId,
|
||||||
primaryAlbumTypes,
|
albumFolder
|
||||||
secondaryAlbumTypes
|
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
const newState = {};
|
const newState = {};
|
||||||
|
@ -83,24 +78,18 @@ class ImportArtistFooter extends Component {
|
||||||
newState.languageProfileId = defaultLanguageProfileId;
|
newState.languageProfileId = defaultLanguageProfileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isMetadataProfileIdMixed && metadataProfileId !== MIXED) {
|
||||||
|
newState.metadataProfileId = MIXED;
|
||||||
|
} else if (!isMetadataProfileIdMixed && metadataProfileId !== defaultMetadataProfileId) {
|
||||||
|
newState.metadataProfileId = defaultMetadataProfileId;
|
||||||
|
}
|
||||||
|
|
||||||
if (isAlbumFolderMixed && albumFolder != null) {
|
if (isAlbumFolderMixed && albumFolder != null) {
|
||||||
newState.albumFolder = null;
|
newState.albumFolder = null;
|
||||||
} else if (!isAlbumFolderMixed && albumFolder !== defaultAlbumFolder) {
|
} else if (!isAlbumFolderMixed && albumFolder !== defaultAlbumFolder) {
|
||||||
newState.albumFolder = defaultAlbumFolder;
|
newState.albumFolder = defaultAlbumFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPrimaryAlbumTypesMixed && primaryAlbumTypes != null) {
|
|
||||||
newState.primaryAlbumTypes = null;
|
|
||||||
} else if (!isPrimaryAlbumTypesMixed && primaryAlbumTypes !== defaultPrimaryAlbumTypes) {
|
|
||||||
newState.primaryAlbumTypes = defaultPrimaryAlbumTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSecondaryAlbumTypesMixed && secondaryAlbumTypes != null) {
|
|
||||||
newState.secondaryAlbumTypes = null;
|
|
||||||
} else if (!isSecondaryAlbumTypesMixed && secondaryAlbumTypes !== defaultSecondaryAlbumTypes) {
|
|
||||||
newState.secondaryAlbumTypes = defaultSecondaryAlbumTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_.isEmpty(newState)) {
|
if (!_.isEmpty(newState)) {
|
||||||
this.setState(newState);
|
this.setState(newState);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +114,9 @@ class ImportArtistFooter extends Component {
|
||||||
isMonitorMixed,
|
isMonitorMixed,
|
||||||
isQualityProfileIdMixed,
|
isQualityProfileIdMixed,
|
||||||
isLanguageProfileIdMixed,
|
isLanguageProfileIdMixed,
|
||||||
|
isMetadataProfileIdMixed,
|
||||||
showLanguageProfile,
|
showLanguageProfile,
|
||||||
|
showMetadataProfile,
|
||||||
onImportPress
|
onImportPress
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
@ -133,9 +124,8 @@ class ImportArtistFooter extends Component {
|
||||||
monitor,
|
monitor,
|
||||||
qualityProfileId,
|
qualityProfileId,
|
||||||
languageProfileId,
|
languageProfileId,
|
||||||
albumFolder,
|
metadataProfileId,
|
||||||
primaryAlbumTypes,
|
albumFolder
|
||||||
secondaryAlbumTypes
|
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -189,6 +179,25 @@ class ImportArtistFooter extends Component {
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
showMetadataProfile &&
|
||||||
|
|
||||||
|
<div className={styles.inputContainer}>
|
||||||
|
<div className={styles.label}>
|
||||||
|
Metadata Profile
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<FormInputGroup
|
||||||
|
type={inputTypes.METADATA_PROFILE_SELECT}
|
||||||
|
name="metadataProfileId"
|
||||||
|
value={metadataProfileId}
|
||||||
|
isDisabled={!selectedCount}
|
||||||
|
includeMixed={isMetadataProfileIdMixed}
|
||||||
|
onChange={this.onInputChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
<div className={styles.inputContainer}>
|
<div className={styles.inputContainer}>
|
||||||
<div className={styles.label}>
|
<div className={styles.label}>
|
||||||
Album Folder
|
Album Folder
|
||||||
|
@ -244,16 +253,15 @@ ImportArtistFooter.propTypes = {
|
||||||
defaultMonitor: PropTypes.string.isRequired,
|
defaultMonitor: PropTypes.string.isRequired,
|
||||||
defaultQualityProfileId: PropTypes.number,
|
defaultQualityProfileId: PropTypes.number,
|
||||||
defaultLanguageProfileId: PropTypes.number,
|
defaultLanguageProfileId: PropTypes.number,
|
||||||
|
defaultMetadataProfileId: PropTypes.number,
|
||||||
defaultAlbumFolder: PropTypes.bool.isRequired,
|
defaultAlbumFolder: PropTypes.bool.isRequired,
|
||||||
defaultPrimaryAlbumTypes: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
||||||
defaultSecondaryAlbumTypes: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
||||||
isMonitorMixed: PropTypes.bool.isRequired,
|
isMonitorMixed: PropTypes.bool.isRequired,
|
||||||
isQualityProfileIdMixed: PropTypes.bool.isRequired,
|
isQualityProfileIdMixed: PropTypes.bool.isRequired,
|
||||||
isLanguageProfileIdMixed: PropTypes.bool.isRequired,
|
isLanguageProfileIdMixed: PropTypes.bool.isRequired,
|
||||||
|
isMetadataProfileIdMixed: PropTypes.bool.isRequired,
|
||||||
isAlbumFolderMixed: PropTypes.bool.isRequired,
|
isAlbumFolderMixed: PropTypes.bool.isRequired,
|
||||||
isPrimaryAlbumTypesMixed: PropTypes.bool.isRequired,
|
|
||||||
isSecondaryAlbumTypesMixed: PropTypes.bool.isRequired,
|
|
||||||
showLanguageProfile: PropTypes.bool.isRequired,
|
showLanguageProfile: PropTypes.bool.isRequired,
|
||||||
|
showMetadataProfile: PropTypes.bool.isRequired,
|
||||||
onInputChange: PropTypes.func.isRequired,
|
onInputChange: PropTypes.func.isRequired,
|
||||||
onImportPress: PropTypes.func.isRequired
|
onImportPress: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,9 +19,8 @@ function createMapStateToProps() {
|
||||||
monitor: defaultMonitor,
|
monitor: defaultMonitor,
|
||||||
qualityProfileId: defaultQualityProfileId,
|
qualityProfileId: defaultQualityProfileId,
|
||||||
languageProfileId: defaultLanguageProfileId,
|
languageProfileId: defaultLanguageProfileId,
|
||||||
albumFolder: defaultAlbumFolder,
|
metadataProfileId: defaultMetadataProfileId,
|
||||||
primaryAlbumTypes: defaultPrimaryAlbumTypes,
|
albumFolder: defaultAlbumFolder
|
||||||
secondaryAlbumTypes: defaultSecondaryAlbumTypes
|
|
||||||
} = addArtist.defaults;
|
} = addArtist.defaults;
|
||||||
|
|
||||||
const items = importArtist.items;
|
const items = importArtist.items;
|
||||||
|
@ -33,9 +32,8 @@ function createMapStateToProps() {
|
||||||
const isMonitorMixed = isMixed(items, selectedIds, defaultMonitor, 'monitor');
|
const isMonitorMixed = isMixed(items, selectedIds, defaultMonitor, 'monitor');
|
||||||
const isQualityProfileIdMixed = isMixed(items, selectedIds, defaultQualityProfileId, 'qualityProfileId');
|
const isQualityProfileIdMixed = isMixed(items, selectedIds, defaultQualityProfileId, 'qualityProfileId');
|
||||||
const isLanguageProfileIdMixed = isMixed(items, selectedIds, defaultLanguageProfileId, 'languageProfileId');
|
const isLanguageProfileIdMixed = isMixed(items, selectedIds, defaultLanguageProfileId, 'languageProfileId');
|
||||||
|
const isMetadataProfileIdMixed = isMixed(items, selectedIds, defaultMetadataProfileId, 'metadataProfileId');
|
||||||
const isAlbumFolderMixed = isMixed(items, selectedIds, defaultAlbumFolder, 'albumFolder');
|
const isAlbumFolderMixed = isMixed(items, selectedIds, defaultAlbumFolder, 'albumFolder');
|
||||||
const isPrimaryAlbumTypesMixed = isMixed(items, selectedIds, defaultPrimaryAlbumTypes, 'primaryAlbumTypes');
|
|
||||||
const isSecondaryAlbumTypesMixed = isMixed(items, selectedIds, defaultSecondaryAlbumTypes, 'secondaryAlbumTypes');
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
selectedCount: selectedIds.length,
|
selectedCount: selectedIds.length,
|
||||||
|
@ -44,15 +42,13 @@ function createMapStateToProps() {
|
||||||
defaultMonitor,
|
defaultMonitor,
|
||||||
defaultQualityProfileId,
|
defaultQualityProfileId,
|
||||||
defaultLanguageProfileId,
|
defaultLanguageProfileId,
|
||||||
|
defaultMetadataProfileId,
|
||||||
defaultAlbumFolder,
|
defaultAlbumFolder,
|
||||||
defaultPrimaryAlbumTypes,
|
|
||||||
defaultSecondaryAlbumTypes,
|
|
||||||
isMonitorMixed,
|
isMonitorMixed,
|
||||||
isQualityProfileIdMixed,
|
isQualityProfileIdMixed,
|
||||||
isLanguageProfileIdMixed,
|
isLanguageProfileIdMixed,
|
||||||
isAlbumFolderMixed,
|
isMetadataProfileIdMixed,
|
||||||
isPrimaryAlbumTypesMixed,
|
isAlbumFolderMixed
|
||||||
isSecondaryAlbumTypesMixed
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.qualityProfile,
|
.qualityProfile,
|
||||||
.languageProfile {
|
.languageProfile,
|
||||||
|
.metadataProfile {
|
||||||
composes: headerCell from 'Components/Table/VirtualTableHeaderCell.css';
|
composes: headerCell from 'Components/Table/VirtualTableHeaderCell.css';
|
||||||
|
|
||||||
flex: 0 1 250px;
|
flex: 0 1 250px;
|
||||||
|
|
|
@ -13,6 +13,7 @@ import styles from './ImportArtistHeader.css';
|
||||||
function ImportArtistHeader(props) {
|
function ImportArtistHeader(props) {
|
||||||
const {
|
const {
|
||||||
showLanguageProfile,
|
showLanguageProfile,
|
||||||
|
showMetadataProfile,
|
||||||
allSelected,
|
allSelected,
|
||||||
allUnselected,
|
allUnselected,
|
||||||
onSelectAllChange
|
onSelectAllChange
|
||||||
|
@ -69,6 +70,16 @@ function ImportArtistHeader(props) {
|
||||||
</VirtualTableHeaderCell>
|
</VirtualTableHeaderCell>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
showMetadataProfile &&
|
||||||
|
<VirtualTableHeaderCell
|
||||||
|
className={styles.metadataProfile}
|
||||||
|
name="metadataProfileId"
|
||||||
|
>
|
||||||
|
Metadata Profile
|
||||||
|
</VirtualTableHeaderCell>
|
||||||
|
}
|
||||||
|
|
||||||
<VirtualTableHeaderCell
|
<VirtualTableHeaderCell
|
||||||
className={styles.albumFolder}
|
className={styles.albumFolder}
|
||||||
name="albumFolder"
|
name="albumFolder"
|
||||||
|
@ -88,6 +99,7 @@ function ImportArtistHeader(props) {
|
||||||
|
|
||||||
ImportArtistHeader.propTypes = {
|
ImportArtistHeader.propTypes = {
|
||||||
showLanguageProfile: PropTypes.bool.isRequired,
|
showLanguageProfile: PropTypes.bool.isRequired,
|
||||||
|
showMetadataProfile: PropTypes.bool.isRequired,
|
||||||
allSelected: PropTypes.bool.isRequired,
|
allSelected: PropTypes.bool.isRequired,
|
||||||
allUnselected: PropTypes.bool.isRequired,
|
allUnselected: PropTypes.bool.isRequired,
|
||||||
onSelectAllChange: PropTypes.func.isRequired
|
onSelectAllChange: PropTypes.func.isRequired
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.qualityProfile,
|
.qualityProfile,
|
||||||
.languageProfile {
|
.languageProfile,
|
||||||
|
.metadataProfile {
|
||||||
composes: cell from 'Components/Table/Cells/VirtualTableRowCell.css';
|
composes: cell from 'Components/Table/Cells/VirtualTableRowCell.css';
|
||||||
|
|
||||||
flex: 0 1 250px;
|
flex: 0 1 250px;
|
||||||
|
@ -38,7 +39,8 @@
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hideLanguageProfile {
|
.hideLanguageProfile,
|
||||||
|
.hideMetadataProfile {
|
||||||
composes: cell from 'Components/Table/Cells/VirtualTableRowCell.css';
|
composes: cell from 'Components/Table/Cells/VirtualTableRowCell.css';
|
||||||
|
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
@ -15,10 +15,12 @@ function ImportArtistRow(props) {
|
||||||
monitor,
|
monitor,
|
||||||
qualityProfileId,
|
qualityProfileId,
|
||||||
languageProfileId,
|
languageProfileId,
|
||||||
|
metadataProfileId,
|
||||||
albumFolder,
|
albumFolder,
|
||||||
selectedArtist,
|
selectedArtist,
|
||||||
isExistingArtist,
|
isExistingArtist,
|
||||||
showLanguageProfile,
|
showLanguageProfile,
|
||||||
|
showMetadataProfile,
|
||||||
isSelected,
|
isSelected,
|
||||||
onSelectedChange,
|
onSelectedChange,
|
||||||
onInputChange
|
onInputChange
|
||||||
|
@ -67,6 +69,17 @@ function ImportArtistRow(props) {
|
||||||
/>
|
/>
|
||||||
</VirtualTableRowCell>
|
</VirtualTableRowCell>
|
||||||
|
|
||||||
|
<VirtualTableRowCell
|
||||||
|
className={showMetadataProfile ? styles.metadataProfile : styles.hideMetadataProfile}
|
||||||
|
>
|
||||||
|
<FormInputGroup
|
||||||
|
type={inputTypes.METADATA_PROFILE_SELECT}
|
||||||
|
name="metadataProfileId"
|
||||||
|
value={metadataProfileId}
|
||||||
|
onChange={onInputChange}
|
||||||
|
/>
|
||||||
|
</VirtualTableRowCell>
|
||||||
|
|
||||||
<VirtualTableRowCell className={styles.albumFolder}>
|
<VirtualTableRowCell className={styles.albumFolder}>
|
||||||
<FormInputGroup
|
<FormInputGroup
|
||||||
type={inputTypes.CHECK}
|
type={inputTypes.CHECK}
|
||||||
|
@ -92,12 +105,14 @@ ImportArtistRow.propTypes = {
|
||||||
monitor: PropTypes.string.isRequired,
|
monitor: PropTypes.string.isRequired,
|
||||||
qualityProfileId: PropTypes.number.isRequired,
|
qualityProfileId: PropTypes.number.isRequired,
|
||||||
languageProfileId: PropTypes.number.isRequired,
|
languageProfileId: PropTypes.number.isRequired,
|
||||||
|
metadataProfileId: PropTypes.number.isRequired,
|
||||||
albumFolder: PropTypes.bool.isRequired,
|
albumFolder: PropTypes.bool.isRequired,
|
||||||
selectedArtist: PropTypes.object,
|
selectedArtist: PropTypes.object,
|
||||||
isExistingArtist: PropTypes.bool.isRequired,
|
isExistingArtist: PropTypes.bool.isRequired,
|
||||||
items: PropTypes.arrayOf(PropTypes.object).isRequired,
|
items: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
queued: PropTypes.bool.isRequired,
|
queued: PropTypes.bool.isRequired,
|
||||||
showLanguageProfile: PropTypes.bool.isRequired,
|
showLanguageProfile: PropTypes.bool.isRequired,
|
||||||
|
showMetadataProfile: PropTypes.bool.isRequired,
|
||||||
isSelected: PropTypes.bool,
|
isSelected: PropTypes.bool,
|
||||||
onSelectedChange: PropTypes.func.isRequired,
|
onSelectedChange: PropTypes.func.isRequired,
|
||||||
onInputChange: PropTypes.func.isRequired
|
onInputChange: PropTypes.func.isRequired
|
||||||
|
|
|
@ -22,9 +22,8 @@ class ImportArtistTable extends Component {
|
||||||
defaultMonitor,
|
defaultMonitor,
|
||||||
defaultQualityProfileId,
|
defaultQualityProfileId,
|
||||||
defaultLanguageProfileId,
|
defaultLanguageProfileId,
|
||||||
|
defaultMetadataProfileId,
|
||||||
defaultAlbumFolder,
|
defaultAlbumFolder,
|
||||||
defaultPrimaryAlbumTypes,
|
|
||||||
defaultSecondaryAlbumTypes,
|
|
||||||
onArtistLookup,
|
onArtistLookup,
|
||||||
onSetImportArtistValue
|
onSetImportArtistValue
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
@ -33,9 +32,8 @@ class ImportArtistTable extends Component {
|
||||||
monitor: defaultMonitor,
|
monitor: defaultMonitor,
|
||||||
qualityProfileId: defaultQualityProfileId,
|
qualityProfileId: defaultQualityProfileId,
|
||||||
languageProfileId: defaultLanguageProfileId,
|
languageProfileId: defaultLanguageProfileId,
|
||||||
albumFolder: defaultAlbumFolder,
|
metadataProfileId: defaultMetadataProfileId,
|
||||||
primaryAlbumTypes: defaultPrimaryAlbumTypes,
|
albumFolder: defaultAlbumFolder
|
||||||
secondaryAlbumTypes: defaultSecondaryAlbumTypes
|
|
||||||
};
|
};
|
||||||
|
|
||||||
unmappedFolders.forEach((unmappedFolder) => {
|
unmappedFolders.forEach((unmappedFolder) => {
|
||||||
|
@ -125,6 +123,7 @@ class ImportArtistTable extends Component {
|
||||||
items,
|
items,
|
||||||
selectedState,
|
selectedState,
|
||||||
showLanguageProfile,
|
showLanguageProfile,
|
||||||
|
showMetadataProfile,
|
||||||
onSelectedChange
|
onSelectedChange
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
@ -136,6 +135,7 @@ class ImportArtistTable extends Component {
|
||||||
style={style}
|
style={style}
|
||||||
rootFolderId={rootFolderId}
|
rootFolderId={rootFolderId}
|
||||||
showLanguageProfile={showLanguageProfile}
|
showLanguageProfile={showLanguageProfile}
|
||||||
|
showMetadataProfile={showMetadataProfile}
|
||||||
isSelected={selectedState[item.id]}
|
isSelected={selectedState[item.id]}
|
||||||
onSelectedChange={onSelectedChange}
|
onSelectedChange={onSelectedChange}
|
||||||
id={item.id}
|
id={item.id}
|
||||||
|
@ -154,6 +154,7 @@ class ImportArtistTable extends Component {
|
||||||
isSmallScreen,
|
isSmallScreen,
|
||||||
contentBody,
|
contentBody,
|
||||||
showLanguageProfile,
|
showLanguageProfile,
|
||||||
|
showMetadataProfile,
|
||||||
scrollTop,
|
scrollTop,
|
||||||
onSelectAllChange,
|
onSelectAllChange,
|
||||||
onScroll
|
onScroll
|
||||||
|
@ -176,6 +177,7 @@ class ImportArtistTable extends Component {
|
||||||
header={
|
header={
|
||||||
<ImportArtistHeader
|
<ImportArtistHeader
|
||||||
showLanguageProfile={showLanguageProfile}
|
showLanguageProfile={showLanguageProfile}
|
||||||
|
showMetadataProfile={showMetadataProfile}
|
||||||
allSelected={allSelected}
|
allSelected={allSelected}
|
||||||
allUnselected={allUnselected}
|
allUnselected={allUnselected}
|
||||||
onSelectAllChange={onSelectAllChange}
|
onSelectAllChange={onSelectAllChange}
|
||||||
|
@ -194,9 +196,8 @@ ImportArtistTable.propTypes = {
|
||||||
defaultMonitor: PropTypes.string.isRequired,
|
defaultMonitor: PropTypes.string.isRequired,
|
||||||
defaultQualityProfileId: PropTypes.number,
|
defaultQualityProfileId: PropTypes.number,
|
||||||
defaultLanguageProfileId: PropTypes.number,
|
defaultLanguageProfileId: PropTypes.number,
|
||||||
|
defaultMetadataProfileId: PropTypes.number,
|
||||||
defaultAlbumFolder: PropTypes.bool.isRequired,
|
defaultAlbumFolder: PropTypes.bool.isRequired,
|
||||||
defaultPrimaryAlbumTypes: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
||||||
defaultSecondaryAlbumTypes: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
||||||
allSelected: PropTypes.bool.isRequired,
|
allSelected: PropTypes.bool.isRequired,
|
||||||
allUnselected: PropTypes.bool.isRequired,
|
allUnselected: PropTypes.bool.isRequired,
|
||||||
selectedState: PropTypes.object.isRequired,
|
selectedState: PropTypes.object.isRequired,
|
||||||
|
@ -204,6 +205,7 @@ ImportArtistTable.propTypes = {
|
||||||
allArtists: PropTypes.arrayOf(PropTypes.object),
|
allArtists: PropTypes.arrayOf(PropTypes.object),
|
||||||
contentBody: PropTypes.object.isRequired,
|
contentBody: PropTypes.object.isRequired,
|
||||||
showLanguageProfile: PropTypes.bool.isRequired,
|
showLanguageProfile: PropTypes.bool.isRequired,
|
||||||
|
showMetadataProfile: PropTypes.bool.isRequired,
|
||||||
scrollTop: PropTypes.number.isRequired,
|
scrollTop: PropTypes.number.isRequired,
|
||||||
onSelectAllChange: PropTypes.func.isRequired,
|
onSelectAllChange: PropTypes.func.isRequired,
|
||||||
onSelectedChange: PropTypes.func.isRequired,
|
onSelectedChange: PropTypes.func.isRequired,
|
||||||
|
|
|
@ -15,9 +15,8 @@ function createMapStateToProps() {
|
||||||
defaultMonitor: addArtist.defaults.monitor,
|
defaultMonitor: addArtist.defaults.monitor,
|
||||||
defaultQualityProfileId: addArtist.defaults.qualityProfileId,
|
defaultQualityProfileId: addArtist.defaults.qualityProfileId,
|
||||||
defaultLanguageProfileId: addArtist.defaults.languageProfileId,
|
defaultLanguageProfileId: addArtist.defaults.languageProfileId,
|
||||||
|
defaultMetadataProfileId: addArtist.defaults.metadataProfileId,
|
||||||
defaultAlbumFolder: addArtist.defaults.albumFolder,
|
defaultAlbumFolder: addArtist.defaults.albumFolder,
|
||||||
defaultPrimaryAlbumTypes: addArtist.defaults.primaryAlbumTypes,
|
|
||||||
defaultSecondaryAlbumTypes: addArtist.defaults.secondaryAlbumTypes,
|
|
||||||
items: importArtist.items,
|
items: importArtist.items,
|
||||||
isSmallScreen: dimensions.isSmallScreen,
|
isSmallScreen: dimensions.isSmallScreen,
|
||||||
allArtists
|
allArtists
|
||||||
|
|
|
@ -32,6 +32,34 @@ import ArtistTagsConnector from './ArtistTagsConnector';
|
||||||
import ArtistDetailsLinks from './ArtistDetailsLinks';
|
import ArtistDetailsLinks from './ArtistDetailsLinks';
|
||||||
import styles from './ArtistDetails.css';
|
import styles from './ArtistDetails.css';
|
||||||
|
|
||||||
|
const albumTypes = [
|
||||||
|
{
|
||||||
|
name: 'album',
|
||||||
|
label: 'Album',
|
||||||
|
isVisible: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ep',
|
||||||
|
label: 'EP',
|
||||||
|
isVisible: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'single',
|
||||||
|
label: 'Single',
|
||||||
|
isVisible: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'broadcast',
|
||||||
|
label: 'Broadcast',
|
||||||
|
isVisible: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'other',
|
||||||
|
label: 'Other',
|
||||||
|
isVisible: true
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
const defaultFontSize = parseInt(fonts.defaultFontSize);
|
const defaultFontSize = parseInt(fonts.defaultFontSize);
|
||||||
const lineHeight = parseFloat(fonts.lineHeight);
|
const lineHeight = parseFloat(fonts.lineHeight);
|
||||||
|
|
||||||
|
@ -150,7 +178,6 @@ class ArtistDetails extends Component {
|
||||||
links,
|
links,
|
||||||
images,
|
images,
|
||||||
albums,
|
albums,
|
||||||
primaryAlbumTypes,
|
|
||||||
alternateTitles,
|
alternateTitles,
|
||||||
tags,
|
tags,
|
||||||
isRefreshing,
|
isRefreshing,
|
||||||
|
@ -479,18 +506,18 @@ class ArtistDetails extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
isPopulated && !!primaryAlbumTypes.length &&
|
isPopulated && !!albumTypes.length &&
|
||||||
<div>
|
<div>
|
||||||
{
|
{
|
||||||
primaryAlbumTypes.slice(0).map((albumType) => {
|
albumTypes.slice(0).map((albumType) => {
|
||||||
return (
|
return (
|
||||||
<ArtistDetailsSeasonConnector
|
<ArtistDetailsSeasonConnector
|
||||||
key={albumType}
|
key={albumType.name}
|
||||||
artistId={id}
|
artistId={id}
|
||||||
name={albumType}
|
name={albumType.name}
|
||||||
label={albumType}
|
label={albumType.label}
|
||||||
{...albumType}
|
{...albumType}
|
||||||
isExpanded={expandedState[albumType]}
|
isExpanded={expandedState[albumType.name]}
|
||||||
onExpandPress={this.onExpandPress}
|
onExpandPress={this.onExpandPress}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -546,7 +573,6 @@ ArtistDetails.propTypes = {
|
||||||
links: PropTypes.arrayOf(PropTypes.object).isRequired,
|
links: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
images: PropTypes.arrayOf(PropTypes.object).isRequired,
|
images: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
albums: PropTypes.arrayOf(PropTypes.object).isRequired,
|
albums: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
primaryAlbumTypes: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
||||||
alternateTitles: PropTypes.arrayOf(PropTypes.string).isRequired,
|
alternateTitles: PropTypes.arrayOf(PropTypes.string).isRequired,
|
||||||
tags: PropTypes.arrayOf(PropTypes.number).isRequired,
|
tags: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||||
isRefreshing: PropTypes.bool.isRequired,
|
isRefreshing: PropTypes.bool.isRequired,
|
||||||
|
|
|
@ -24,6 +24,7 @@ class EditArtistModalContent extends Component {
|
||||||
item,
|
item,
|
||||||
isSaving,
|
isSaving,
|
||||||
showLanguageProfile,
|
showLanguageProfile,
|
||||||
|
showMetadataProfile,
|
||||||
onInputChange,
|
onInputChange,
|
||||||
onSavePress,
|
onSavePress,
|
||||||
onModalClose,
|
onModalClose,
|
||||||
|
@ -36,6 +37,7 @@ class EditArtistModalContent extends Component {
|
||||||
albumFolder,
|
albumFolder,
|
||||||
qualityProfileId,
|
qualityProfileId,
|
||||||
languageProfileId,
|
languageProfileId,
|
||||||
|
metadataProfileId,
|
||||||
path,
|
path,
|
||||||
tags
|
tags
|
||||||
} = item;
|
} = item;
|
||||||
|
@ -99,6 +101,21 @@ class EditArtistModalContent extends Component {
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
showMetadataProfile &&
|
||||||
|
<FormGroup>
|
||||||
|
<FormLabel>Metadata Profile</FormLabel>
|
||||||
|
|
||||||
|
<FormInputGroup
|
||||||
|
type={inputTypes.METADATA_PROFILE_SELECT}
|
||||||
|
name="metadataProfileId"
|
||||||
|
helpText="Changes will take place on next artist refresh"
|
||||||
|
{...metadataProfileId}
|
||||||
|
onChange={onInputChange}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
}
|
||||||
|
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<FormLabel>Path</FormLabel>
|
<FormLabel>Path</FormLabel>
|
||||||
|
|
||||||
|
@ -155,6 +172,7 @@ EditArtistModalContent.propTypes = {
|
||||||
item: PropTypes.object.isRequired,
|
item: PropTypes.object.isRequired,
|
||||||
isSaving: PropTypes.bool.isRequired,
|
isSaving: PropTypes.bool.isRequired,
|
||||||
showLanguageProfile: PropTypes.bool.isRequired,
|
showLanguageProfile: PropTypes.bool.isRequired,
|
||||||
|
showMetadataProfile: PropTypes.bool.isRequired,
|
||||||
onInputChange: PropTypes.func.isRequired,
|
onInputChange: PropTypes.func.isRequired,
|
||||||
onSavePress: PropTypes.func.isRequired,
|
onSavePress: PropTypes.func.isRequired,
|
||||||
onModalClose: PropTypes.func.isRequired,
|
onModalClose: PropTypes.func.isRequired,
|
||||||
|
|
|
@ -12,8 +12,9 @@ function createMapStateToProps() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.artist,
|
(state) => state.artist,
|
||||||
(state) => state.settings.languageProfiles,
|
(state) => state.settings.languageProfiles,
|
||||||
|
(state) => state.settings.metadataProfiles,
|
||||||
createArtistSelector(),
|
createArtistSelector(),
|
||||||
(artistState, languageProfiles, artist) => {
|
(artistState, languageProfiles, metadataProfiles, artist) => {
|
||||||
const {
|
const {
|
||||||
isSaving,
|
isSaving,
|
||||||
saveError,
|
saveError,
|
||||||
|
@ -25,6 +26,7 @@ function createMapStateToProps() {
|
||||||
'albumFolder',
|
'albumFolder',
|
||||||
'qualityProfileId',
|
'qualityProfileId',
|
||||||
'languageProfileId',
|
'languageProfileId',
|
||||||
|
'metadataProfileId',
|
||||||
'path',
|
'path',
|
||||||
'tags'
|
'tags'
|
||||||
]);
|
]);
|
||||||
|
@ -38,6 +40,7 @@ function createMapStateToProps() {
|
||||||
pendingChanges,
|
pendingChanges,
|
||||||
item: settings.settings,
|
item: settings.settings,
|
||||||
showLanguageProfile: languageProfiles.items.length > 1,
|
showLanguageProfile: languageProfiles.items.length > 1,
|
||||||
|
showMetadataProfile: metadataProfiles.items.length > 1,
|
||||||
...settings
|
...settings
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import ArtistEditorRowConnector from './ArtistEditorRowConnector';
|
||||||
import ArtistEditorFooter from './ArtistEditorFooter';
|
import ArtistEditorFooter from './ArtistEditorFooter';
|
||||||
import OrganizeArtistModal from './Organize/OrganizeArtistModal';
|
import OrganizeArtistModal from './Organize/OrganizeArtistModal';
|
||||||
|
|
||||||
function getColumns(showLanguageProfile) {
|
function getColumns(showLanguageProfile, showMetadataProfile) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: 'status',
|
name: 'status',
|
||||||
|
@ -43,6 +43,12 @@ function getColumns(showLanguageProfile) {
|
||||||
isSortable: true,
|
isSortable: true,
|
||||||
isVisible: showLanguageProfile
|
isVisible: showLanguageProfile
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'metadataProfileId',
|
||||||
|
label: 'Metadata Profile',
|
||||||
|
isSortable: true,
|
||||||
|
isVisible: showMetadataProfile
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'albumFolder',
|
name: 'albumFolder',
|
||||||
label: 'Album Folder',
|
label: 'Album Folder',
|
||||||
|
@ -78,7 +84,7 @@ class ArtistEditor extends Component {
|
||||||
lastToggled: null,
|
lastToggled: null,
|
||||||
selectedState: {},
|
selectedState: {},
|
||||||
isOrganizingArtistModalOpen: false,
|
isOrganizingArtistModalOpen: false,
|
||||||
columns: getColumns(props.showLanguageProfile)
|
columns: getColumns(props.showLanguageProfile, props.showMetadataProfile)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +161,7 @@ class ArtistEditor extends Component {
|
||||||
deleteError,
|
deleteError,
|
||||||
isOrganizingArtist,
|
isOrganizingArtist,
|
||||||
showLanguageProfile,
|
showLanguageProfile,
|
||||||
|
showMetadataProfile,
|
||||||
onSortPress,
|
onSortPress,
|
||||||
onFilterSelect
|
onFilterSelect
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
@ -285,6 +292,7 @@ class ArtistEditor extends Component {
|
||||||
deleteError={deleteError}
|
deleteError={deleteError}
|
||||||
isOrganizingArtist={isOrganizingArtist}
|
isOrganizingArtist={isOrganizingArtist}
|
||||||
showLanguageProfile={showLanguageProfile}
|
showLanguageProfile={showLanguageProfile}
|
||||||
|
showMetadataProfile={showMetadataProfile}
|
||||||
onSaveSelected={this.onSaveSelected}
|
onSaveSelected={this.onSaveSelected}
|
||||||
onOrganizeArtistPress={this.onOrganizeArtistPress}
|
onOrganizeArtistPress={this.onOrganizeArtistPress}
|
||||||
/>
|
/>
|
||||||
|
@ -314,6 +322,7 @@ ArtistEditor.propTypes = {
|
||||||
deleteError: PropTypes.object,
|
deleteError: PropTypes.object,
|
||||||
isOrganizingArtist: PropTypes.bool.isRequired,
|
isOrganizingArtist: PropTypes.bool.isRequired,
|
||||||
showLanguageProfile: PropTypes.bool.isRequired,
|
showLanguageProfile: PropTypes.bool.isRequired,
|
||||||
|
showMetadataProfile: PropTypes.bool.isRequired,
|
||||||
onSortPress: PropTypes.func.isRequired,
|
onSortPress: PropTypes.func.isRequired,
|
||||||
onFilterSelect: PropTypes.func.isRequired,
|
onFilterSelect: PropTypes.func.isRequired,
|
||||||
onSaveSelected: PropTypes.func.isRequired
|
onSaveSelected: PropTypes.func.isRequired
|
||||||
|
|
|
@ -12,12 +12,14 @@ import ArtistEditor from './ArtistEditor';
|
||||||
function createMapStateToProps() {
|
function createMapStateToProps() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.settings.languageProfiles,
|
(state) => state.settings.languageProfiles,
|
||||||
|
(state) => state.settings.metadataProfiles,
|
||||||
createClientSideCollectionSelector(),
|
createClientSideCollectionSelector(),
|
||||||
createCommandSelector(commandNames.RENAME_ARTIST),
|
createCommandSelector(commandNames.RENAME_ARTIST),
|
||||||
(languageProfiles, artist, isOrganizingArtist) => {
|
(languageProfiles, metadataProfiles, artist, isOrganizingArtist) => {
|
||||||
return {
|
return {
|
||||||
isOrganizingArtist,
|
isOrganizingArtist,
|
||||||
showLanguageProfile: languageProfiles.items.length > 1,
|
showLanguageProfile: languageProfiles.items.length > 1,
|
||||||
|
showMetadataProfile: metadataProfiles.items.length > 1,
|
||||||
...artist
|
...artist
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import React, { Component } from 'react';
|
||||||
import { kinds } from 'Helpers/Props';
|
import { kinds } from 'Helpers/Props';
|
||||||
import SelectInput from 'Components/Form/SelectInput';
|
import SelectInput from 'Components/Form/SelectInput';
|
||||||
import LanguageProfileSelectInputConnector from 'Components/Form/LanguageProfileSelectInputConnector';
|
import LanguageProfileSelectInputConnector from 'Components/Form/LanguageProfileSelectInputConnector';
|
||||||
|
import MetadataProfileSelectInputConnector from 'Components/Form/MetadataProfileSelectInputConnector';
|
||||||
import QualityProfileSelectInputConnector from 'Components/Form/QualityProfileSelectInputConnector';
|
import QualityProfileSelectInputConnector from 'Components/Form/QualityProfileSelectInputConnector';
|
||||||
import RootFolderSelectInputConnector from 'Components/Form/RootFolderSelectInputConnector';
|
import RootFolderSelectInputConnector from 'Components/Form/RootFolderSelectInputConnector';
|
||||||
import SpinnerButton from 'Components/Link/SpinnerButton';
|
import SpinnerButton from 'Components/Link/SpinnerButton';
|
||||||
|
@ -26,6 +27,7 @@ class ArtistEditorFooter extends Component {
|
||||||
monitored: NO_CHANGE,
|
monitored: NO_CHANGE,
|
||||||
qualityProfileId: NO_CHANGE,
|
qualityProfileId: NO_CHANGE,
|
||||||
languageProfileId: NO_CHANGE,
|
languageProfileId: NO_CHANGE,
|
||||||
|
metadataProfileId: NO_CHANGE,
|
||||||
albumFolder: NO_CHANGE,
|
albumFolder: NO_CHANGE,
|
||||||
rootFolderPath: NO_CHANGE,
|
rootFolderPath: NO_CHANGE,
|
||||||
savingTags: false,
|
savingTags: false,
|
||||||
|
@ -45,6 +47,7 @@ class ArtistEditorFooter extends Component {
|
||||||
monitored: NO_CHANGE,
|
monitored: NO_CHANGE,
|
||||||
qualityProfileId: NO_CHANGE,
|
qualityProfileId: NO_CHANGE,
|
||||||
languageProfileId: NO_CHANGE,
|
languageProfileId: NO_CHANGE,
|
||||||
|
metadataProfileId: NO_CHANGE,
|
||||||
albumFolder: NO_CHANGE,
|
albumFolder: NO_CHANGE,
|
||||||
rootFolderPath: NO_CHANGE,
|
rootFolderPath: NO_CHANGE,
|
||||||
savingTags: false
|
savingTags: false
|
||||||
|
@ -113,6 +116,7 @@ class ArtistEditorFooter extends Component {
|
||||||
isDeleting,
|
isDeleting,
|
||||||
isOrganizingArtist,
|
isOrganizingArtist,
|
||||||
showLanguageProfile,
|
showLanguageProfile,
|
||||||
|
showMetadataProfile,
|
||||||
onOrganizeArtistPress
|
onOrganizeArtistPress
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
@ -120,6 +124,7 @@ class ArtistEditorFooter extends Component {
|
||||||
monitored,
|
monitored,
|
||||||
qualityProfileId,
|
qualityProfileId,
|
||||||
languageProfileId,
|
languageProfileId,
|
||||||
|
metadataProfileId,
|
||||||
albumFolder,
|
albumFolder,
|
||||||
rootFolderPath,
|
rootFolderPath,
|
||||||
savingTags,
|
savingTags,
|
||||||
|
@ -189,6 +194,24 @@ class ArtistEditorFooter extends Component {
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
showMetadataProfile &&
|
||||||
|
<div className={styles.inputContainer}>
|
||||||
|
<ArtistEditorFooterLabel
|
||||||
|
label="Metadata Profile"
|
||||||
|
isSaving={isSaving && metadataProfileId !== NO_CHANGE}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<MetadataProfileSelectInputConnector
|
||||||
|
name="metadataProfileId"
|
||||||
|
value={metadataProfileId}
|
||||||
|
includeNoChange={true}
|
||||||
|
isDisabled={!selectedCount}
|
||||||
|
onChange={this.onInputChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
<div className={styles.inputContainer}>
|
<div className={styles.inputContainer}>
|
||||||
<ArtistEditorFooterLabel
|
<ArtistEditorFooterLabel
|
||||||
label="Album Folder"
|
label="Album Folder"
|
||||||
|
@ -288,6 +311,7 @@ ArtistEditorFooter.propTypes = {
|
||||||
deleteError: PropTypes.object,
|
deleteError: PropTypes.object,
|
||||||
isOrganizingArtist: PropTypes.bool.isRequired,
|
isOrganizingArtist: PropTypes.bool.isRequired,
|
||||||
showLanguageProfile: PropTypes.bool.isRequired,
|
showLanguageProfile: PropTypes.bool.isRequired,
|
||||||
|
showMetadataProfile: PropTypes.bool.isRequired,
|
||||||
onSaveSelected: PropTypes.func.isRequired,
|
onSaveSelected: PropTypes.func.isRequired,
|
||||||
onOrganizeArtistPress: PropTypes.func.isRequired
|
onOrganizeArtistPress: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,6 +32,7 @@ class ArtistEditorRow extends Component {
|
||||||
artistName,
|
artistName,
|
||||||
monitored,
|
monitored,
|
||||||
languageProfile,
|
languageProfile,
|
||||||
|
metadataProfile,
|
||||||
qualityProfile,
|
qualityProfile,
|
||||||
albumFolder,
|
albumFolder,
|
||||||
path,
|
path,
|
||||||
|
@ -72,6 +73,13 @@ class ArtistEditorRow extends Component {
|
||||||
</TableRowCell>
|
</TableRowCell>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
_.find(columns, { name: 'metadataProfileId' }).isVisible &&
|
||||||
|
<TableRowCell>
|
||||||
|
{metadataProfile.name}
|
||||||
|
</TableRowCell>
|
||||||
|
}
|
||||||
|
|
||||||
<TableRowCell className={styles.albumFolder}>
|
<TableRowCell className={styles.albumFolder}>
|
||||||
<CheckInput
|
<CheckInput
|
||||||
name="albumFolder"
|
name="albumFolder"
|
||||||
|
@ -102,6 +110,7 @@ ArtistEditorRow.propTypes = {
|
||||||
artistName: PropTypes.string.isRequired,
|
artistName: PropTypes.string.isRequired,
|
||||||
monitored: PropTypes.bool.isRequired,
|
monitored: PropTypes.bool.isRequired,
|
||||||
languageProfile: PropTypes.object.isRequired,
|
languageProfile: PropTypes.object.isRequired,
|
||||||
|
metadataProfile: PropTypes.object.isRequired,
|
||||||
qualityProfile: PropTypes.object.isRequired,
|
qualityProfile: PropTypes.object.isRequired,
|
||||||
albumFolder: PropTypes.bool.isRequired,
|
albumFolder: PropTypes.bool.isRequired,
|
||||||
path: PropTypes.string.isRequired,
|
path: PropTypes.string.isRequired,
|
||||||
|
|
|
@ -3,16 +3,19 @@ import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import createLanguageProfileSelector from 'Store/Selectors/createLanguageProfileSelector';
|
import createLanguageProfileSelector from 'Store/Selectors/createLanguageProfileSelector';
|
||||||
|
import createMetadataProfileSelector from 'Store/Selectors/createMetadataProfileSelector';
|
||||||
import createQualityProfileSelector from 'Store/Selectors/createQualityProfileSelector';
|
import createQualityProfileSelector from 'Store/Selectors/createQualityProfileSelector';
|
||||||
import ArtistEditorRow from './ArtistEditorRow';
|
import ArtistEditorRow from './ArtistEditorRow';
|
||||||
|
|
||||||
function createMapStateToProps() {
|
function createMapStateToProps() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
createLanguageProfileSelector(),
|
createLanguageProfileSelector(),
|
||||||
|
createMetadataProfileSelector(),
|
||||||
createQualityProfileSelector(),
|
createQualityProfileSelector(),
|
||||||
(languageProfile, qualityProfile) => {
|
(languageProfile, metadataProfile, qualityProfile) => {
|
||||||
return {
|
return {
|
||||||
languageProfile,
|
languageProfile,
|
||||||
|
metadataProfile,
|
||||||
qualityProfile
|
qualityProfile
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { createSelector } from 'reselect';
|
||||||
import createCommandsSelector from 'Store/Selectors/createCommandsSelector';
|
import createCommandsSelector from 'Store/Selectors/createCommandsSelector';
|
||||||
import createQualityProfileSelector from 'Store/Selectors/createQualityProfileSelector';
|
import createQualityProfileSelector from 'Store/Selectors/createQualityProfileSelector';
|
||||||
import createLanguageProfileSelector from 'Store/Selectors/createLanguageProfileSelector';
|
import createLanguageProfileSelector from 'Store/Selectors/createLanguageProfileSelector';
|
||||||
|
import createMetadataProfileSelector from 'Store/Selectors/createMetadataProfileSelector';
|
||||||
import { executeCommand } from 'Store/Actions/commandActions';
|
import { executeCommand } from 'Store/Actions/commandActions';
|
||||||
import * as commandNames from 'Commands/commandNames';
|
import * as commandNames from 'Commands/commandNames';
|
||||||
|
|
||||||
|
@ -15,8 +16,9 @@ function createMapStateToProps() {
|
||||||
(state, { albums }) => albums,
|
(state, { albums }) => albums,
|
||||||
createQualityProfileSelector(),
|
createQualityProfileSelector(),
|
||||||
createLanguageProfileSelector(),
|
createLanguageProfileSelector(),
|
||||||
|
createMetadataProfileSelector(),
|
||||||
createCommandsSelector(),
|
createCommandsSelector(),
|
||||||
(artistId, albums, qualityProfile, languageProfile, commands) => {
|
(artistId, albums, qualityProfile, languageProfile, metadataProfile, commands) => {
|
||||||
const isRefreshingArtist = _.some(commands, (command) => {
|
const isRefreshingArtist = _.some(commands, (command) => {
|
||||||
return command.name === commandNames.REFRESH_ARTIST &&
|
return command.name === commandNames.REFRESH_ARTIST &&
|
||||||
command.body.artistId === artistId;
|
command.body.artistId === artistId;
|
||||||
|
@ -27,6 +29,7 @@ function createMapStateToProps() {
|
||||||
return {
|
return {
|
||||||
qualityProfile,
|
qualityProfile,
|
||||||
languageProfile,
|
languageProfile,
|
||||||
|
metadataProfile,
|
||||||
latestAlbum,
|
latestAlbum,
|
||||||
isRefreshingArtist
|
isRefreshingArtist
|
||||||
};
|
};
|
||||||
|
|
|
@ -51,6 +51,15 @@ function ArtistIndexSortMenu(props) {
|
||||||
Language Profile
|
Language Profile
|
||||||
</SortMenuItem>
|
</SortMenuItem>
|
||||||
|
|
||||||
|
<SortMenuItem
|
||||||
|
name="metadataProfileId"
|
||||||
|
sortKey={sortKey}
|
||||||
|
sortDirection={sortDirection}
|
||||||
|
onPress={onSortSelect}
|
||||||
|
>
|
||||||
|
Metadata Profile
|
||||||
|
</SortMenuItem>
|
||||||
|
|
||||||
<SortMenuItem
|
<SortMenuItem
|
||||||
name="nextAiring"
|
name="nextAiring"
|
||||||
sortKey={sortKey}
|
sortKey={sortKey}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.qualityProfileId,
|
.qualityProfileId,
|
||||||
.languageProfileId {
|
.languageProfileId,
|
||||||
|
.metadataProfileId {
|
||||||
composes: headerCell from 'Components/Table/VirtualTableHeaderCell.css';
|
composes: headerCell from 'Components/Table/VirtualTableHeaderCell.css';
|
||||||
|
|
||||||
flex: 1 0 125px;
|
flex: 1 0 125px;
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.qualityProfileId,
|
.qualityProfileId,
|
||||||
.languageProfileId {
|
.languageProfileId,
|
||||||
|
.metadataProfileId {
|
||||||
composes: cell from 'Components/Table/Cells/VirtualTableRowCell.css';
|
composes: cell from 'Components/Table/Cells/VirtualTableRowCell.css';
|
||||||
|
|
||||||
flex: 1 0 125px;
|
flex: 1 0 125px;
|
||||||
|
|
|
@ -69,6 +69,7 @@ class ArtistIndexRow extends Component {
|
||||||
artistType,
|
artistType,
|
||||||
qualityProfile,
|
qualityProfile,
|
||||||
languageProfile,
|
languageProfile,
|
||||||
|
metadataProfile,
|
||||||
nextAiring,
|
nextAiring,
|
||||||
previousAiring,
|
previousAiring,
|
||||||
added,
|
added,
|
||||||
|
@ -163,6 +164,17 @@ class ArtistIndexRow extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (name === 'metadataProfileId') {
|
||||||
|
return (
|
||||||
|
<VirtualTableRowCell
|
||||||
|
key={name}
|
||||||
|
className={styles[name]}
|
||||||
|
>
|
||||||
|
{metadataProfile.name}
|
||||||
|
</VirtualTableRowCell>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (name === 'nextAiring') {
|
if (name === 'nextAiring') {
|
||||||
return (
|
return (
|
||||||
<RelativeDateCellConnector
|
<RelativeDateCellConnector
|
||||||
|
@ -347,6 +359,7 @@ ArtistIndexRow.propTypes = {
|
||||||
artistType: PropTypes.string,
|
artistType: PropTypes.string,
|
||||||
qualityProfile: PropTypes.object.isRequired,
|
qualityProfile: PropTypes.object.isRequired,
|
||||||
languageProfile: PropTypes.object.isRequired,
|
languageProfile: PropTypes.object.isRequired,
|
||||||
|
metadataProfile: PropTypes.object.isRequired,
|
||||||
nextAiring: PropTypes.string,
|
nextAiring: PropTypes.string,
|
||||||
previousAiring: PropTypes.string,
|
previousAiring: PropTypes.string,
|
||||||
added: PropTypes.string,
|
added: PropTypes.string,
|
||||||
|
@ -358,7 +371,6 @@ ArtistIndexRow.propTypes = {
|
||||||
path: PropTypes.string.isRequired,
|
path: PropTypes.string.isRequired,
|
||||||
sizeOnDisk: PropTypes.number,
|
sizeOnDisk: PropTypes.number,
|
||||||
tags: PropTypes.arrayOf(PropTypes.number).isRequired,
|
tags: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||||
// useSceneNumbering: PropTypes.bool.isRequired,
|
|
||||||
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
|
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
isRefreshingArtist: PropTypes.bool.isRequired,
|
isRefreshingArtist: PropTypes.bool.isRequired,
|
||||||
onRefreshArtistPress: PropTypes.func.isRequired
|
onRefreshArtistPress: PropTypes.func.isRequired
|
||||||
|
|
|
@ -11,6 +11,7 @@ import PasswordInput from './PasswordInput';
|
||||||
import PathInputConnector from './PathInputConnector';
|
import PathInputConnector from './PathInputConnector';
|
||||||
import QualityProfileSelectInputConnector from './QualityProfileSelectInputConnector';
|
import QualityProfileSelectInputConnector from './QualityProfileSelectInputConnector';
|
||||||
import LanguageProfileSelectInputConnector from './LanguageProfileSelectInputConnector';
|
import LanguageProfileSelectInputConnector from './LanguageProfileSelectInputConnector';
|
||||||
|
import MetadataProfileSelectInputConnector from './MetadataProfileSelectInputConnector';
|
||||||
import RootFolderSelectInputConnector from './RootFolderSelectInputConnector';
|
import RootFolderSelectInputConnector from './RootFolderSelectInputConnector';
|
||||||
import SeriesTypeSelectInput from './SeriesTypeSelectInput';
|
import SeriesTypeSelectInput from './SeriesTypeSelectInput';
|
||||||
import SelectInput from './SelectInput';
|
import SelectInput from './SelectInput';
|
||||||
|
@ -49,6 +50,9 @@ function getComponent(type) {
|
||||||
case inputTypes.LANGUAGE_PROFILE_SELECT:
|
case inputTypes.LANGUAGE_PROFILE_SELECT:
|
||||||
return LanguageProfileSelectInputConnector;
|
return LanguageProfileSelectInputConnector;
|
||||||
|
|
||||||
|
case inputTypes.METADATA_PROFILE_SELECT:
|
||||||
|
return MetadataProfileSelectInputConnector;
|
||||||
|
|
||||||
case inputTypes.ROOT_FOLDER_SELECT:
|
case inputTypes.ROOT_FOLDER_SELECT:
|
||||||
return RootFolderSelectInputConnector;
|
return RootFolderSelectInputConnector;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
import _ from 'lodash';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
import sortByName from 'Utilities/Array/sortByName';
|
||||||
|
import SelectInput from './SelectInput';
|
||||||
|
|
||||||
|
function createMapStateToProps() {
|
||||||
|
return createSelector(
|
||||||
|
(state) => state.settings.metadataProfiles,
|
||||||
|
(state, { includeNoChange }) => includeNoChange,
|
||||||
|
(state, { includeMixed }) => includeMixed,
|
||||||
|
(metadataProfiles, includeNoChange, includeMixed) => {
|
||||||
|
const values = _.map(metadataProfiles.items.sort(sortByName), (metadataProfile) => {
|
||||||
|
return {
|
||||||
|
key: metadataProfile.id,
|
||||||
|
value: metadataProfile.name
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
if (includeNoChange) {
|
||||||
|
values.unshift({
|
||||||
|
key: 'noChange',
|
||||||
|
value: 'No Change',
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeMixed) {
|
||||||
|
values.unshift({
|
||||||
|
key: 'mixed',
|
||||||
|
value: '(Mixed)',
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
values
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class MetadataProfileSelectInputConnector extends Component {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lifecycle
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
const {
|
||||||
|
name,
|
||||||
|
value,
|
||||||
|
values
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
if (!value || !_.some(values, (option) => parseInt(option.key) === value)) {
|
||||||
|
const firstValue = _.find(values, (option) => !isNaN(parseInt(option.key)));
|
||||||
|
|
||||||
|
if (firstValue) {
|
||||||
|
this.onChange({ name, value: firstValue.key });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Listeners
|
||||||
|
|
||||||
|
onChange = ({ name, value }) => {
|
||||||
|
this.props.onChange({ name, value: parseInt(value) });
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<SelectInput
|
||||||
|
{...this.props}
|
||||||
|
onChange={this.onChange}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MetadataProfileSelectInputConnector.propTypes = {
|
||||||
|
name: PropTypes.string.isRequired,
|
||||||
|
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||||
|
values: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
|
includeNoChange: PropTypes.bool.isRequired,
|
||||||
|
onChange: PropTypes.func.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
MetadataProfileSelectInputConnector.defaultProps = {
|
||||||
|
includeNoChange: false
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(createMapStateToProps)(MetadataProfileSelectInputConnector);
|
|
@ -7,7 +7,7 @@ import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
|
||||||
import { saveDimensions, setIsSidebarVisible } from 'Store/Actions/appActions';
|
import { saveDimensions, setIsSidebarVisible } from 'Store/Actions/appActions';
|
||||||
import { fetchArtist } from 'Store/Actions/artistActions';
|
import { fetchArtist } from 'Store/Actions/artistActions';
|
||||||
import { fetchTags } from 'Store/Actions/tagActions';
|
import { fetchTags } from 'Store/Actions/tagActions';
|
||||||
import { fetchQualityProfiles, fetchLanguageProfiles, fetchUISettings } from 'Store/Actions/settingsActions';
|
import { fetchQualityProfiles, fetchLanguageProfiles, fetchMetadataProfiles, fetchUISettings } from 'Store/Actions/settingsActions';
|
||||||
import { fetchStatus } from 'Store/Actions/systemActions';
|
import { fetchStatus } from 'Store/Actions/systemActions';
|
||||||
import ErrorPage from './ErrorPage';
|
import ErrorPage from './ErrorPage';
|
||||||
import LoadingPage from './LoadingPage';
|
import LoadingPage from './LoadingPage';
|
||||||
|
@ -75,6 +75,9 @@ function createMapDispatchToProps(dispatch, props) {
|
||||||
dispatchFetchLanguageProfiles() {
|
dispatchFetchLanguageProfiles() {
|
||||||
dispatch(fetchLanguageProfiles());
|
dispatch(fetchLanguageProfiles());
|
||||||
},
|
},
|
||||||
|
dispatchFetchMetadataProfiles() {
|
||||||
|
dispatch(fetchMetadataProfiles());
|
||||||
|
},
|
||||||
dispatchFetchUISettings() {
|
dispatchFetchUISettings() {
|
||||||
dispatch(fetchUISettings());
|
dispatch(fetchUISettings());
|
||||||
},
|
},
|
||||||
|
@ -109,6 +112,7 @@ class PageConnector extends Component {
|
||||||
this.props.dispatchFetchTags();
|
this.props.dispatchFetchTags();
|
||||||
this.props.dispatchFetchQualityProfiles();
|
this.props.dispatchFetchQualityProfiles();
|
||||||
this.props.dispatchFetchLanguageProfiles();
|
this.props.dispatchFetchLanguageProfiles();
|
||||||
|
this.props.dispatchFetchMetadataProfiles();
|
||||||
this.props.dispatchFetchUISettings();
|
this.props.dispatchFetchUISettings();
|
||||||
this.props.dispatchFetchStatus();
|
this.props.dispatchFetchStatus();
|
||||||
}
|
}
|
||||||
|
@ -132,6 +136,7 @@ class PageConnector extends Component {
|
||||||
dispatchFetchTags,
|
dispatchFetchTags,
|
||||||
dispatchFetchQualityProfiles,
|
dispatchFetchQualityProfiles,
|
||||||
dispatchFetchLanguageProfiles,
|
dispatchFetchLanguageProfiles,
|
||||||
|
dispatchFetchMetadataProfiles,
|
||||||
dispatchFetchUISettings,
|
dispatchFetchUISettings,
|
||||||
dispatchFetchStatus,
|
dispatchFetchStatus,
|
||||||
...otherProps
|
...otherProps
|
||||||
|
@ -169,6 +174,7 @@ PageConnector.propTypes = {
|
||||||
dispatchFetchTags: PropTypes.func.isRequired,
|
dispatchFetchTags: PropTypes.func.isRequired,
|
||||||
dispatchFetchQualityProfiles: PropTypes.func.isRequired,
|
dispatchFetchQualityProfiles: PropTypes.func.isRequired,
|
||||||
dispatchFetchLanguageProfiles: PropTypes.func.isRequired,
|
dispatchFetchLanguageProfiles: PropTypes.func.isRequired,
|
||||||
|
dispatchFetchMetadataProfiles: PropTypes.func.isRequired,
|
||||||
dispatchFetchUISettings: PropTypes.func.isRequired,
|
dispatchFetchUISettings: PropTypes.func.isRequired,
|
||||||
dispatchFetchStatus: PropTypes.func.isRequired,
|
dispatchFetchStatus: PropTypes.func.isRequired,
|
||||||
onSidebarVisibleChange: PropTypes.func.isRequired
|
onSidebarVisibleChange: PropTypes.func.isRequired
|
||||||
|
|
|
@ -7,6 +7,7 @@ export const PASSWORD = 'password';
|
||||||
export const PATH = 'path';
|
export const PATH = 'path';
|
||||||
export const QUALITY_PROFILE_SELECT = 'qualityProfileSelect';
|
export const QUALITY_PROFILE_SELECT = 'qualityProfileSelect';
|
||||||
export const LANGUAGE_PROFILE_SELECT = 'languageProfileSelect';
|
export const LANGUAGE_PROFILE_SELECT = 'languageProfileSelect';
|
||||||
|
export const METADATA_PROFILE_SELECT = 'metadataProfileSelect';
|
||||||
export const ROOT_FOLDER_SELECT = 'rootFolderSelect';
|
export const ROOT_FOLDER_SELECT = 'rootFolderSelect';
|
||||||
export const SELECT = 'select';
|
export const SELECT = 'select';
|
||||||
export const SERIES_TYPE_SELECT = 'artistTypeSelect';
|
export const SERIES_TYPE_SELECT = 'artistTypeSelect';
|
||||||
|
@ -24,6 +25,7 @@ export const all = [
|
||||||
PATH,
|
PATH,
|
||||||
QUALITY_PROFILE_SELECT,
|
QUALITY_PROFILE_SELECT,
|
||||||
LANGUAGE_PROFILE_SELECT,
|
LANGUAGE_PROFILE_SELECT,
|
||||||
|
METADATA_PROFILE_SELECT,
|
||||||
ROOT_FOLDER_SELECT,
|
ROOT_FOLDER_SELECT,
|
||||||
SELECT,
|
SELECT,
|
||||||
SERIES_TYPE_SELECT,
|
SERIES_TYPE_SELECT,
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React from 'react';
|
||||||
|
import Modal from 'Components/Modal/Modal';
|
||||||
|
import EditMetadataProfileModalContentConnector from './EditMetadataProfileModalContentConnector';
|
||||||
|
|
||||||
|
function EditMetadataProfileModal({ isOpen, onModalClose, ...otherProps }) {
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
isOpen={isOpen}
|
||||||
|
onModalClose={onModalClose}
|
||||||
|
>
|
||||||
|
<EditMetadataProfileModalContentConnector
|
||||||
|
{...otherProps}
|
||||||
|
onModalClose={onModalClose}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
EditMetadataProfileModal.propTypes = {
|
||||||
|
isOpen: PropTypes.bool.isRequired,
|
||||||
|
onModalClose: PropTypes.func.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EditMetadataProfileModal;
|
|
@ -0,0 +1,43 @@
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { clearPendingChanges } from 'Store/Actions/baseActions';
|
||||||
|
import EditMetadataProfileModal from './EditMetadataProfileModal';
|
||||||
|
|
||||||
|
function mapStateToProps() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapDispatchToProps = {
|
||||||
|
clearPendingChanges
|
||||||
|
};
|
||||||
|
|
||||||
|
class EditMetadataProfileModalConnector extends Component {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Listeners
|
||||||
|
|
||||||
|
onModalClose = () => {
|
||||||
|
this.props.clearPendingChanges({ section: 'metadataProfiles' });
|
||||||
|
this.props.onModalClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<EditMetadataProfileModal
|
||||||
|
{...this.props}
|
||||||
|
onModalClose={this.onModalClose}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EditMetadataProfileModalConnector.propTypes = {
|
||||||
|
onModalClose: PropTypes.func.isRequired,
|
||||||
|
clearPendingChanges: PropTypes.func.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(EditMetadataProfileModalConnector);
|
|
@ -0,0 +1,3 @@
|
||||||
|
.deleteButtonContainer {
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
|
@ -0,0 +1,145 @@
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React from 'react';
|
||||||
|
import { inputTypes, kinds } from 'Helpers/Props';
|
||||||
|
import Button from 'Components/Link/Button';
|
||||||
|
import SpinnerErrorButton from 'Components/Link/SpinnerErrorButton';
|
||||||
|
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
|
||||||
|
import ModalContent from 'Components/Modal/ModalContent';
|
||||||
|
import ModalHeader from 'Components/Modal/ModalHeader';
|
||||||
|
import ModalBody from 'Components/Modal/ModalBody';
|
||||||
|
import ModalFooter from 'Components/Modal/ModalFooter';
|
||||||
|
import Form from 'Components/Form/Form';
|
||||||
|
import FormGroup from 'Components/Form/FormGroup';
|
||||||
|
import FormLabel from 'Components/Form/FormLabel';
|
||||||
|
import FormInputGroup from 'Components/Form/FormInputGroup';
|
||||||
|
import PrimaryTypeItems from './PrimaryTypeItems';
|
||||||
|
import SecondaryTypeItems from './SecondaryTypeItems';
|
||||||
|
import styles from './EditMetadataProfileModalContent.css';
|
||||||
|
|
||||||
|
function EditMetadataProfileModalContent(props) {
|
||||||
|
const {
|
||||||
|
isFetching,
|
||||||
|
error,
|
||||||
|
isSaving,
|
||||||
|
saveError,
|
||||||
|
primaryAlbumTypes,
|
||||||
|
secondaryAlbumTypes,
|
||||||
|
item,
|
||||||
|
isInUse,
|
||||||
|
onInputChange,
|
||||||
|
onSavePress,
|
||||||
|
onModalClose,
|
||||||
|
onDeleteMetadataProfilePress,
|
||||||
|
...otherProps
|
||||||
|
} = props;
|
||||||
|
|
||||||
|
const {
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
primaryAlbumTypes: itemPrimaryAlbumTypes,
|
||||||
|
secondaryAlbumTypes: itemSecondaryAlbumTypes
|
||||||
|
} = item;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModalContent onModalClose={onModalClose}>
|
||||||
|
<ModalHeader>
|
||||||
|
{id ? 'Edit Metadata Profile' : 'Add Metadata Profile'}
|
||||||
|
</ModalHeader>
|
||||||
|
|
||||||
|
<ModalBody>
|
||||||
|
{
|
||||||
|
isFetching &&
|
||||||
|
<LoadingIndicator />
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
!isFetching && !!error &&
|
||||||
|
<div>Unable to add a new metadata profile, please try again.</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
!isFetching && !error &&
|
||||||
|
<Form
|
||||||
|
{...otherProps}
|
||||||
|
>
|
||||||
|
<FormGroup>
|
||||||
|
<FormLabel>Name</FormLabel>
|
||||||
|
|
||||||
|
<FormInputGroup
|
||||||
|
type={inputTypes.TEXT}
|
||||||
|
name="name"
|
||||||
|
{...name}
|
||||||
|
onChange={onInputChange}
|
||||||
|
/>
|
||||||
|
</FormGroup>
|
||||||
|
|
||||||
|
<PrimaryTypeItems
|
||||||
|
metadataProfileItems={itemPrimaryAlbumTypes.value}
|
||||||
|
errors={itemPrimaryAlbumTypes.errors}
|
||||||
|
warnings={itemPrimaryAlbumTypes.warnings}
|
||||||
|
formLabel="Primary Album Types"
|
||||||
|
{...otherProps}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<SecondaryTypeItems
|
||||||
|
metadataProfileItems={itemSecondaryAlbumTypes.value}
|
||||||
|
errors={itemSecondaryAlbumTypes.errors}
|
||||||
|
warnings={itemSecondaryAlbumTypes.warnings}
|
||||||
|
formLabel="Secondary Album Types"
|
||||||
|
{...otherProps}
|
||||||
|
/>
|
||||||
|
|
||||||
|
</Form>
|
||||||
|
}
|
||||||
|
</ModalBody>
|
||||||
|
<ModalFooter>
|
||||||
|
{
|
||||||
|
id &&
|
||||||
|
<div
|
||||||
|
className={styles.deleteButtonContainer}
|
||||||
|
title={isInUse && 'Can\'t delete a metadata profile that is attached to a artist'}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
kind={kinds.DANGER}
|
||||||
|
isDisabled={isInUse}
|
||||||
|
onPress={onDeleteMetadataProfilePress}
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<Button
|
||||||
|
onPress={onModalClose}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<SpinnerErrorButton
|
||||||
|
isSpinning={isSaving}
|
||||||
|
error={saveError}
|
||||||
|
onPress={onSavePress}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</SpinnerErrorButton>
|
||||||
|
</ModalFooter>
|
||||||
|
</ModalContent>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
EditMetadataProfileModalContent.propTypes = {
|
||||||
|
isFetching: PropTypes.bool.isRequired,
|
||||||
|
error: PropTypes.object,
|
||||||
|
isSaving: PropTypes.bool.isRequired,
|
||||||
|
saveError: PropTypes.object,
|
||||||
|
primaryAlbumTypes: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
|
secondaryAlbumTypes: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
|
item: PropTypes.object.isRequired,
|
||||||
|
isInUse: PropTypes.bool.isRequired,
|
||||||
|
onInputChange: PropTypes.func.isRequired,
|
||||||
|
onSavePress: PropTypes.func.isRequired,
|
||||||
|
onModalClose: PropTypes.func.isRequired,
|
||||||
|
onDeleteMetadataProfilePress: PropTypes.func
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EditMetadataProfileModalContent;
|
|
@ -0,0 +1,180 @@
|
||||||
|
import _ from 'lodash';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
import createProfileInUseSelector from 'Store/Selectors/createProfileInUseSelector';
|
||||||
|
import createProviderSettingsSelector from 'Store/Selectors/createProviderSettingsSelector';
|
||||||
|
import { fetchMetadataProfileSchema, setMetadataProfileValue, saveMetadataProfile } from 'Store/Actions/settingsActions';
|
||||||
|
import connectSection from 'Store/connectSection';
|
||||||
|
import EditMetadataProfileModalContent from './EditMetadataProfileModalContent';
|
||||||
|
|
||||||
|
function createPrimaryAlbumTypesSelector() {
|
||||||
|
return createSelector(
|
||||||
|
createProviderSettingsSelector(),
|
||||||
|
(metadataProfile) => {
|
||||||
|
const primaryAlbumTypes = metadataProfile.item.primaryAlbumTypes;
|
||||||
|
if (!primaryAlbumTypes || !primaryAlbumTypes.value) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return _.reduceRight(primaryAlbumTypes.value, (result, { allowed, albumType }) => {
|
||||||
|
if (allowed) {
|
||||||
|
result.push({
|
||||||
|
key: albumType.id,
|
||||||
|
value: albumType.name
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createSecondaryAlbumTypesSelector() {
|
||||||
|
return createSelector(
|
||||||
|
createProviderSettingsSelector(),
|
||||||
|
(metadataProfile) => {
|
||||||
|
const secondaryAlbumTypes = metadataProfile.item.secondaryAlbumTypes;
|
||||||
|
if (!secondaryAlbumTypes || !secondaryAlbumTypes.value) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return _.reduceRight(secondaryAlbumTypes.value, (result, { allowed, albumType }) => {
|
||||||
|
if (allowed) {
|
||||||
|
result.push({
|
||||||
|
key: albumType.id,
|
||||||
|
value: albumType.name
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createMapStateToProps() {
|
||||||
|
return createSelector(
|
||||||
|
createProviderSettingsSelector(),
|
||||||
|
createPrimaryAlbumTypesSelector(),
|
||||||
|
createSecondaryAlbumTypesSelector(),
|
||||||
|
createProfileInUseSelector('metadataProfileId'),
|
||||||
|
(metadataProfile, primaryAlbumTypes, secondaryAlbumTypes, isInUse) => {
|
||||||
|
return {
|
||||||
|
primaryAlbumTypes,
|
||||||
|
secondaryAlbumTypes,
|
||||||
|
...metadataProfile,
|
||||||
|
isInUse
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapDispatchToProps = {
|
||||||
|
fetchMetadataProfileSchema,
|
||||||
|
setMetadataProfileValue,
|
||||||
|
saveMetadataProfile
|
||||||
|
};
|
||||||
|
|
||||||
|
class EditMetadataProfileModalContentConnector extends Component {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lifecycle
|
||||||
|
|
||||||
|
constructor(props, context) {
|
||||||
|
super(props, context);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
dragIndex: null,
|
||||||
|
dropIndex: null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
if (!this.props.id) {
|
||||||
|
this.props.fetchMetadataProfileSchema();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps, prevState) {
|
||||||
|
if (prevProps.isSaving && !this.props.isSaving && !this.props.saveError) {
|
||||||
|
this.props.onModalClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Listeners
|
||||||
|
|
||||||
|
onInputChange = ({ name, value }) => {
|
||||||
|
this.props.setMetadataProfileValue({ name, value });
|
||||||
|
}
|
||||||
|
|
||||||
|
onSavePress = () => {
|
||||||
|
this.props.saveMetadataProfile({ id: this.props.id });
|
||||||
|
}
|
||||||
|
|
||||||
|
onMetadataPrimaryTypeItemAllowedChange = (id, allowed) => {
|
||||||
|
const metadataProfile = _.cloneDeep(this.props.item);
|
||||||
|
|
||||||
|
const item = _.find(metadataProfile.primaryAlbumTypes.value, (i) => i.albumType.id === id);
|
||||||
|
item.allowed = allowed;
|
||||||
|
|
||||||
|
this.props.setMetadataProfileValue({
|
||||||
|
name: 'primaryAlbumTypes',
|
||||||
|
value: metadataProfile.primaryAlbumTypes.value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMetadataSecondaryTypeItemAllowedChange = (id, allowed) => {
|
||||||
|
const metadataProfile = _.cloneDeep(this.props.item);
|
||||||
|
|
||||||
|
const item = _.find(metadataProfile.secondaryAlbumTypes.value, (i) => i.albumType.id === id);
|
||||||
|
item.allowed = allowed;
|
||||||
|
|
||||||
|
this.props.setMetadataProfileValue({
|
||||||
|
name: 'secondaryAlbumTypes',
|
||||||
|
value: metadataProfile.secondaryAlbumTypes.value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if (_.isEmpty(this.props.item.primaryAlbumTypes) && !this.props.isFetching) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<EditMetadataProfileModalContent
|
||||||
|
{...this.state}
|
||||||
|
{...this.props}
|
||||||
|
onSavePress={this.onSavePress}
|
||||||
|
onInputChange={this.onInputChange}
|
||||||
|
onMetadataPrimaryTypeItemAllowedChange={this.onMetadataPrimaryTypeItemAllowedChange}
|
||||||
|
onMetadataSecondaryTypeItemAllowedChange={this.onMetadataSecondaryTypeItemAllowedChange}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EditMetadataProfileModalContentConnector.propTypes = {
|
||||||
|
id: PropTypes.number,
|
||||||
|
isFetching: PropTypes.bool.isRequired,
|
||||||
|
isSaving: PropTypes.bool.isRequired,
|
||||||
|
saveError: PropTypes.object,
|
||||||
|
item: PropTypes.object.isRequired,
|
||||||
|
setMetadataProfileValue: PropTypes.func.isRequired,
|
||||||
|
fetchMetadataProfileSchema: PropTypes.func.isRequired,
|
||||||
|
saveMetadataProfile: PropTypes.func.isRequired,
|
||||||
|
onModalClose: PropTypes.func.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connectSection(
|
||||||
|
createMapStateToProps,
|
||||||
|
mapDispatchToProps,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
{ section: 'metadataProfiles' }
|
||||||
|
)(EditMetadataProfileModalContentConnector);
|
19
frontend/src/Settings/Profiles/Metadata/MetadataProfile.css
Normal file
19
frontend/src/Settings/Profiles/Metadata/MetadataProfile.css
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
.metadataProfile {
|
||||||
|
composes: card from 'Components/Card.css';
|
||||||
|
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.name {
|
||||||
|
@add-mixin truncate;
|
||||||
|
|
||||||
|
margin-bottom: 20px;
|
||||||
|
font-weight: 300;
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.albumTypes {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
142
frontend/src/Settings/Profiles/Metadata/MetadataProfile.js
Normal file
142
frontend/src/Settings/Profiles/Metadata/MetadataProfile.js
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import { kinds } from 'Helpers/Props';
|
||||||
|
import Card from 'Components/Card';
|
||||||
|
import Label from 'Components/Label';
|
||||||
|
import ConfirmModal from 'Components/Modal/ConfirmModal';
|
||||||
|
import EditMetadataProfileModalConnector from './EditMetadataProfileModalConnector';
|
||||||
|
import styles from './MetadataProfile.css';
|
||||||
|
|
||||||
|
class MetadataProfile extends Component {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lifecycle
|
||||||
|
|
||||||
|
constructor(props, context) {
|
||||||
|
super(props, context);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
isEditMetadataProfileModalOpen: false,
|
||||||
|
isDeleteMetadataProfileModalOpen: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Listeners
|
||||||
|
|
||||||
|
onEditMetadataProfilePress = () => {
|
||||||
|
this.setState({ isEditMetadataProfileModalOpen: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
onEditMetadataProfileModalClose = () => {
|
||||||
|
this.setState({ isEditMetadataProfileModalOpen: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
onDeleteMetadataProfilePress = () => {
|
||||||
|
this.setState({
|
||||||
|
isEditMetadataProfileModalOpen: false,
|
||||||
|
isDeleteMetadataProfileModalOpen: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onDeleteMetadataProfileModalClose = () => {
|
||||||
|
this.setState({ isDeleteMetadataProfileModalOpen: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
onConfirmDeleteMetadataProfile = () => {
|
||||||
|
this.props.onConfirmDeleteMetadataProfile(this.props.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
primaryAlbumTypes,
|
||||||
|
secondaryAlbumTypes,
|
||||||
|
isDeleting
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
className={styles.metadataProfile}
|
||||||
|
onPress={this.onEditMetadataProfilePress}
|
||||||
|
>
|
||||||
|
<div className={styles.name}>
|
||||||
|
{name}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.albumTypes}>
|
||||||
|
{
|
||||||
|
primaryAlbumTypes.map((item) => {
|
||||||
|
if (!item.allowed) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Label
|
||||||
|
key={item.albumType.id}
|
||||||
|
kind={kinds.default}
|
||||||
|
title={null}
|
||||||
|
>
|
||||||
|
{item.albumType.name}
|
||||||
|
</Label>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={styles.albumTypes}>
|
||||||
|
{
|
||||||
|
secondaryAlbumTypes.map((item) => {
|
||||||
|
if (!item.allowed) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Label
|
||||||
|
key={item.albumType.id}
|
||||||
|
kind={kinds.INFO}
|
||||||
|
title={null}
|
||||||
|
>
|
||||||
|
{item.albumType.name}
|
||||||
|
</Label>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<EditMetadataProfileModalConnector
|
||||||
|
id={id}
|
||||||
|
isOpen={this.state.isEditMetadataProfileModalOpen}
|
||||||
|
onModalClose={this.onEditMetadataProfileModalClose}
|
||||||
|
onDeleteMetadataProfilePress={this.onDeleteMetadataProfilePress}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ConfirmModal
|
||||||
|
isOpen={this.state.isDeleteMetadataProfileModalOpen}
|
||||||
|
kind={kinds.DANGER}
|
||||||
|
title="Delete Metadata Profile"
|
||||||
|
message={`Are you sure you want to delete the metadata profile '${name}'?`}
|
||||||
|
confirmLabel="Delete"
|
||||||
|
isSpinning={isDeleting}
|
||||||
|
onConfirm={this.onConfirmDeleteMetadataProfile}
|
||||||
|
onCancel={this.onDeleteMetadataProfileModalClose}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MetadataProfile.propTypes = {
|
||||||
|
id: PropTypes.number.isRequired,
|
||||||
|
name: PropTypes.string.isRequired,
|
||||||
|
primaryAlbumTypes: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
|
secondaryAlbumTypes: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
|
isDeleting: PropTypes.bool.isRequired,
|
||||||
|
onConfirmDeleteMetadataProfile: PropTypes.func.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MetadataProfile;
|
21
frontend/src/Settings/Profiles/Metadata/MetadataProfiles.css
Normal file
21
frontend/src/Settings/Profiles/Metadata/MetadataProfiles.css
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
.metadataProfiles {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addMetadataProfile {
|
||||||
|
composes: metadataProfile from './MetadataProfile.css';
|
||||||
|
|
||||||
|
background-color: $cardAlternateBackgroundColor;
|
||||||
|
color: $gray;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 45px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.center {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 5px 20px 0;
|
||||||
|
border: 1px solid $borderColor;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: $white;
|
||||||
|
}
|
102
frontend/src/Settings/Profiles/Metadata/MetadataProfiles.js
Normal file
102
frontend/src/Settings/Profiles/Metadata/MetadataProfiles.js
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import sortByName from 'Utilities/Array/sortByName';
|
||||||
|
import { icons } from 'Helpers/Props';
|
||||||
|
import FieldSet from 'Components/FieldSet';
|
||||||
|
import Card from 'Components/Card';
|
||||||
|
import Icon from 'Components/Icon';
|
||||||
|
import PageSectionContent from 'Components/Page/PageSectionContent';
|
||||||
|
import MetadataProfile from './MetadataProfile';
|
||||||
|
import EditMetadataProfileModalConnector from './EditMetadataProfileModalConnector';
|
||||||
|
import styles from './MetadataProfiles.css';
|
||||||
|
|
||||||
|
class MetadataProfiles extends Component {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lifecycle
|
||||||
|
|
||||||
|
constructor(props, context) {
|
||||||
|
super(props, context);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
isMetadataProfileModalOpen: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Listeners
|
||||||
|
|
||||||
|
onEditMetadataProfilePress = () => {
|
||||||
|
this.setState({ isMetadataProfileModalOpen: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
onModalClose = () => {
|
||||||
|
this.setState({ isMetadataProfileModalOpen: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {
|
||||||
|
items,
|
||||||
|
isDeleting,
|
||||||
|
onConfirmDeleteMetadataProfile,
|
||||||
|
...otherProps
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FieldSet
|
||||||
|
legend="Metadata Profiles"
|
||||||
|
>
|
||||||
|
<PageSectionContent
|
||||||
|
errorMessage="Unable to load Metadata Profiles"
|
||||||
|
{...otherProps}
|
||||||
|
>
|
||||||
|
<div className={styles.metadataProfiles}>
|
||||||
|
{
|
||||||
|
items.sort(sortByName).map((item) => {
|
||||||
|
return (
|
||||||
|
<MetadataProfile
|
||||||
|
key={item.id}
|
||||||
|
{...item}
|
||||||
|
isDeleting={isDeleting}
|
||||||
|
onConfirmDeleteMetadataProfile={onConfirmDeleteMetadataProfile}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
<Card
|
||||||
|
className={styles.addMetadataProfile}
|
||||||
|
onPress={this.onEditMetadataProfilePress}
|
||||||
|
>
|
||||||
|
<div className={styles.center}>
|
||||||
|
<Icon
|
||||||
|
name={icons.ADD}
|
||||||
|
size={45}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<EditMetadataProfileModalConnector
|
||||||
|
isOpen={this.state.isMetadataProfileModalOpen}
|
||||||
|
onModalClose={this.onModalClose}
|
||||||
|
/>
|
||||||
|
</PageSectionContent>
|
||||||
|
</FieldSet>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MetadataProfiles.propTypes = {
|
||||||
|
advancedSettings: PropTypes.bool.isRequired,
|
||||||
|
isFetching: PropTypes.bool.isRequired,
|
||||||
|
error: PropTypes.object,
|
||||||
|
items: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
|
isDeleting: PropTypes.bool.isRequired,
|
||||||
|
onConfirmDeleteMetadataProfile: PropTypes.func.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MetadataProfiles;
|
|
@ -0,0 +1,60 @@
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
import { fetchMetadataProfiles, deleteMetadataProfile } from 'Store/Actions/settingsActions';
|
||||||
|
import MetadataProfiles from './MetadataProfiles';
|
||||||
|
|
||||||
|
function createMapStateToProps() {
|
||||||
|
return createSelector(
|
||||||
|
(state) => state.settings.advancedSettings,
|
||||||
|
(state) => state.settings.metadataProfiles,
|
||||||
|
(advancedSettings, metadataProfiles) => {
|
||||||
|
return {
|
||||||
|
advancedSettings,
|
||||||
|
...metadataProfiles
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapDispatchToProps = {
|
||||||
|
fetchMetadataProfiles,
|
||||||
|
deleteMetadataProfile
|
||||||
|
};
|
||||||
|
|
||||||
|
class MetadataProfilesConnector extends Component {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lifecycle
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.props.fetchMetadataProfiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Listeners
|
||||||
|
|
||||||
|
onConfirmDeleteMetadataProfile = (id) => {
|
||||||
|
this.props.deleteMetadataProfile({ id });
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<MetadataProfiles
|
||||||
|
onConfirmDeleteMetadataProfile={this.onConfirmDeleteMetadataProfile}
|
||||||
|
{...this.props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MetadataProfilesConnector.propTypes = {
|
||||||
|
fetchMetadataProfiles: PropTypes.func.isRequired,
|
||||||
|
deleteMetadataProfile: PropTypes.func.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(createMapStateToProps, mapDispatchToProps)(MetadataProfilesConnector);
|
60
frontend/src/Settings/Profiles/Metadata/PrimaryTypeItem.js
Normal file
60
frontend/src/Settings/Profiles/Metadata/PrimaryTypeItem.js
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import CheckInput from 'Components/Form/CheckInput';
|
||||||
|
import styles from './TypeItem.css';
|
||||||
|
|
||||||
|
class PrimaryTypeItem extends Component {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Listeners
|
||||||
|
|
||||||
|
onAllowedChange = ({ value }) => {
|
||||||
|
const {
|
||||||
|
albumTypeId,
|
||||||
|
onMetadataPrimaryTypeItemAllowedChange
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
onMetadataPrimaryTypeItemAllowedChange(albumTypeId, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {
|
||||||
|
name,
|
||||||
|
allowed
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={classNames(
|
||||||
|
styles.metadataProfileItem
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
className={styles.albumTypeName}
|
||||||
|
>
|
||||||
|
<CheckInput
|
||||||
|
containerClassName={styles.checkContainer}
|
||||||
|
name={name}
|
||||||
|
value={allowed}
|
||||||
|
onChange={this.onAllowedChange}
|
||||||
|
/>
|
||||||
|
{name}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PrimaryTypeItem.propTypes = {
|
||||||
|
albumTypeId: PropTypes.number.isRequired,
|
||||||
|
name: PropTypes.string.isRequired,
|
||||||
|
allowed: PropTypes.bool.isRequired,
|
||||||
|
sortIndex: PropTypes.number.isRequired,
|
||||||
|
onMetadataPrimaryTypeItemAllowedChange: PropTypes.func
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PrimaryTypeItem;
|
87
frontend/src/Settings/Profiles/Metadata/PrimaryTypeItems.js
Normal file
87
frontend/src/Settings/Profiles/Metadata/PrimaryTypeItems.js
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import FormGroup from 'Components/Form/FormGroup';
|
||||||
|
import FormLabel from 'Components/Form/FormLabel';
|
||||||
|
import FormInputHelpText from 'Components/Form/FormInputHelpText';
|
||||||
|
import PrimaryTypeItem from './PrimaryTypeItem';
|
||||||
|
import styles from './TypeItems.css';
|
||||||
|
|
||||||
|
class PrimaryTypeItems extends Component {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {
|
||||||
|
metadataProfileItems,
|
||||||
|
errors,
|
||||||
|
warnings,
|
||||||
|
...otherProps
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FormGroup>
|
||||||
|
<FormLabel>Primary Types</FormLabel>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
{
|
||||||
|
errors.map((error, index) => {
|
||||||
|
return (
|
||||||
|
<FormInputHelpText
|
||||||
|
key={index}
|
||||||
|
text={error.message}
|
||||||
|
isError={true}
|
||||||
|
isCheckInput={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
warnings.map((warning, index) => {
|
||||||
|
return (
|
||||||
|
<FormInputHelpText
|
||||||
|
key={index}
|
||||||
|
text={warning.message}
|
||||||
|
isWarning={true}
|
||||||
|
isCheckInput={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
<div className={styles.albumTypes}>
|
||||||
|
{
|
||||||
|
metadataProfileItems.map(({ allowed, albumType }, index) => {
|
||||||
|
return (
|
||||||
|
<PrimaryTypeItem
|
||||||
|
key={albumType.id}
|
||||||
|
albumTypeId={albumType.id}
|
||||||
|
name={albumType.name}
|
||||||
|
allowed={allowed}
|
||||||
|
sortIndex={index}
|
||||||
|
{...otherProps}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}).reverse()
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</FormGroup>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PrimaryTypeItems.propTypes = {
|
||||||
|
metadataProfileItems: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
|
errors: PropTypes.arrayOf(PropTypes.object),
|
||||||
|
warnings: PropTypes.arrayOf(PropTypes.object),
|
||||||
|
formLabel: PropTypes.string
|
||||||
|
};
|
||||||
|
|
||||||
|
PrimaryTypeItems.defaultProps = {
|
||||||
|
errors: [],
|
||||||
|
warnings: []
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PrimaryTypeItems;
|
60
frontend/src/Settings/Profiles/Metadata/SecondaryTypeItem.js
Normal file
60
frontend/src/Settings/Profiles/Metadata/SecondaryTypeItem.js
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import CheckInput from 'Components/Form/CheckInput';
|
||||||
|
import styles from './TypeItem.css';
|
||||||
|
|
||||||
|
class SecondaryTypeItem extends Component {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Listeners
|
||||||
|
|
||||||
|
onAllowedChange = ({ value }) => {
|
||||||
|
const {
|
||||||
|
albumTypeId,
|
||||||
|
onMetadataSecondaryTypeItemAllowedChange
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
onMetadataSecondaryTypeItemAllowedChange(albumTypeId, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {
|
||||||
|
name,
|
||||||
|
allowed
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={classNames(
|
||||||
|
styles.metadataProfileItem
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
className={styles.albumTypeName}
|
||||||
|
>
|
||||||
|
<CheckInput
|
||||||
|
containerClassName={styles.checkContainer}
|
||||||
|
name={name}
|
||||||
|
value={allowed}
|
||||||
|
onChange={this.onAllowedChange}
|
||||||
|
/>
|
||||||
|
{name}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SecondaryTypeItem.propTypes = {
|
||||||
|
albumTypeId: PropTypes.number.isRequired,
|
||||||
|
name: PropTypes.string.isRequired,
|
||||||
|
allowed: PropTypes.bool.isRequired,
|
||||||
|
sortIndex: PropTypes.number.isRequired,
|
||||||
|
onMetadataSecondaryTypeItemAllowedChange: PropTypes.func
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SecondaryTypeItem;
|
|
@ -0,0 +1,87 @@
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
import FormGroup from 'Components/Form/FormGroup';
|
||||||
|
import FormLabel from 'Components/Form/FormLabel';
|
||||||
|
import FormInputHelpText from 'Components/Form/FormInputHelpText';
|
||||||
|
import SecondaryTypeItem from './SecondaryTypeItem';
|
||||||
|
import styles from './TypeItems.css';
|
||||||
|
|
||||||
|
class SecondaryTypeItems extends Component {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Render
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {
|
||||||
|
metadataProfileItems,
|
||||||
|
errors,
|
||||||
|
warnings,
|
||||||
|
...otherProps
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FormGroup>
|
||||||
|
<FormLabel>Secondary Types</FormLabel>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
{
|
||||||
|
errors.map((error, index) => {
|
||||||
|
return (
|
||||||
|
<FormInputHelpText
|
||||||
|
key={index}
|
||||||
|
text={error.message}
|
||||||
|
isError={true}
|
||||||
|
isCheckInput={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
warnings.map((warning, index) => {
|
||||||
|
return (
|
||||||
|
<FormInputHelpText
|
||||||
|
key={index}
|
||||||
|
text={warning.message}
|
||||||
|
isWarning={true}
|
||||||
|
isCheckInput={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
<div className={styles.albumTypes}>
|
||||||
|
{
|
||||||
|
metadataProfileItems.map(({ allowed, albumType }, index) => {
|
||||||
|
return (
|
||||||
|
<SecondaryTypeItem
|
||||||
|
key={albumType.id}
|
||||||
|
albumTypeId={albumType.id}
|
||||||
|
name={albumType.name}
|
||||||
|
allowed={allowed}
|
||||||
|
sortIndex={index}
|
||||||
|
{...otherProps}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}).reverse()
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</FormGroup>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SecondaryTypeItems.propTypes = {
|
||||||
|
metadataProfileItems: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
|
errors: PropTypes.arrayOf(PropTypes.object),
|
||||||
|
warnings: PropTypes.arrayOf(PropTypes.object),
|
||||||
|
formLabel: PropTypes.string
|
||||||
|
};
|
||||||
|
|
||||||
|
SecondaryTypeItems.defaultProps = {
|
||||||
|
errors: [],
|
||||||
|
warnings: []
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SecondaryTypeItems;
|
25
frontend/src/Settings/Profiles/Metadata/TypeItem.css
Normal file
25
frontend/src/Settings/Profiles/Metadata/TypeItem.css
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
.metadataProfileItem {
|
||||||
|
display: flex;
|
||||||
|
align-items: stretch;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkContainer {
|
||||||
|
position: relative;
|
||||||
|
margin-right: 4px;
|
||||||
|
margin-bottom: 7px;
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.albumTypeName {
|
||||||
|
display: flex;
|
||||||
|
flex-grow: 1;
|
||||||
|
margin-bottom: 0;
|
||||||
|
margin-left: 2px;
|
||||||
|
font-weight: normal;
|
||||||
|
line-height: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.isDragging {
|
||||||
|
opacity: 0.25;
|
||||||
|
}
|
6
frontend/src/Settings/Profiles/Metadata/TypeItems.css
Normal file
6
frontend/src/Settings/Profiles/Metadata/TypeItems.css
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
.albumTypes {
|
||||||
|
margin-top: 10px;
|
||||||
|
/* TODO: This should consider the number of types in the list */
|
||||||
|
min-height: 200px;
|
||||||
|
user-select: none;
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector';
|
||||||
import SettingsToolbarConnector from 'Settings/SettingsToolbarConnector';
|
import SettingsToolbarConnector from 'Settings/SettingsToolbarConnector';
|
||||||
import QualityProfilesConnector from './Quality/QualityProfilesConnector';
|
import QualityProfilesConnector from './Quality/QualityProfilesConnector';
|
||||||
import LanguageProfilesConnector from './Language/LanguageProfilesConnector';
|
import LanguageProfilesConnector from './Language/LanguageProfilesConnector';
|
||||||
|
import MetadataProfilesConnector from './Metadata/MetadataProfilesConnector';
|
||||||
import DelayProfilesConnector from './Delay/DelayProfilesConnector';
|
import DelayProfilesConnector from './Delay/DelayProfilesConnector';
|
||||||
|
|
||||||
class Profiles extends Component {
|
class Profiles extends Component {
|
||||||
|
@ -23,6 +24,7 @@ class Profiles extends Component {
|
||||||
<PageContentBodyConnector>
|
<PageContentBodyConnector>
|
||||||
<QualityProfilesConnector />
|
<QualityProfilesConnector />
|
||||||
<LanguageProfilesConnector />
|
<LanguageProfilesConnector />
|
||||||
|
<MetadataProfilesConnector />
|
||||||
<DelayProfilesConnector />
|
<DelayProfilesConnector />
|
||||||
</PageContentBodyConnector>
|
</PageContentBodyConnector>
|
||||||
</PageContent>
|
</PageContent>
|
||||||
|
|
|
@ -32,7 +32,7 @@ function Settings() {
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<div className={styles.summary}>
|
<div className={styles.summary}>
|
||||||
Quality, Language and Delay profiles
|
Quality, Language, Metadata, and Delay profiles
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
|
|
|
@ -241,6 +241,12 @@ export const SET_LANGUAGE_PROFILE_VALUE = 'SET_LANGUAGE_PROFILE_VALUE';
|
||||||
export const SAVE_LANGUAGE_PROFILE = 'SAVE_LANGUAGE_PROFILE';
|
export const SAVE_LANGUAGE_PROFILE = 'SAVE_LANGUAGE_PROFILE';
|
||||||
export const DELETE_LANGUAGE_PROFILE = 'DELETE_LANGUAGE_PROFILE';
|
export const DELETE_LANGUAGE_PROFILE = 'DELETE_LANGUAGE_PROFILE';
|
||||||
|
|
||||||
|
export const FETCH_METADATA_PROFILES = 'FETCH_METADATA_PROFILES';
|
||||||
|
export const FETCH_METADATA_PROFILE_SCHEMA = 'FETCH_METADATA_PROFILE_SCHEMA';
|
||||||
|
export const SET_METADATA_PROFILE_VALUE = 'SET_METADATA_PROFILE_VALUE';
|
||||||
|
export const SAVE_METADATA_PROFILE = 'SAVE_METADATA_PROFILE';
|
||||||
|
export const DELETE_METADATA_PROFILE = 'DELETE_METADATA_PROFILE';
|
||||||
|
|
||||||
export const FETCH_DELAY_PROFILES = 'FETCH_DELAY_PROFILES';
|
export const FETCH_DELAY_PROFILES = 'FETCH_DELAY_PROFILES';
|
||||||
export const SET_DELAY_PROFILE_VALUE = 'SET_DELAY_PROFILE_VALUE';
|
export const SET_DELAY_PROFILE_VALUE = 'SET_DELAY_PROFILE_VALUE';
|
||||||
export const SAVE_DELAY_PROFILE = 'SAVE_DELAY_PROFILE';
|
export const SAVE_DELAY_PROFILE = 'SAVE_DELAY_PROFILE';
|
||||||
|
|
|
@ -111,6 +111,19 @@ const settingsActionHandlers = {
|
||||||
'/languageprofile',
|
'/languageprofile',
|
||||||
(state) => state.settings.languageProfiles),
|
(state) => state.settings.languageProfiles),
|
||||||
|
|
||||||
|
[types.FETCH_METADATA_PROFILES]: createFetchHandler('metadataProfiles', '/metadataprofile'),
|
||||||
|
[types.FETCH_METADATA_PROFILE_SCHEMA]: createFetchSchemaHandler('metadataProfiles', '/metadataprofile/schema'),
|
||||||
|
|
||||||
|
[types.SAVE_METADATA_PROFILE]: createSaveProviderHandler(
|
||||||
|
'metadataProfiles',
|
||||||
|
'/metadataprofile',
|
||||||
|
(state) => state.settings.metadataProfiles),
|
||||||
|
|
||||||
|
[types.DELETE_METADATA_PROFILE]: createRemoveItemHandler(
|
||||||
|
'metadataProfiles',
|
||||||
|
'/metadataprofile',
|
||||||
|
(state) => state.settings.metadataProfiles),
|
||||||
|
|
||||||
[types.FETCH_DELAY_PROFILES]: createFetchHandler('delayProfiles', '/delayprofile'),
|
[types.FETCH_DELAY_PROFILES]: createFetchHandler('delayProfiles', '/delayprofile'),
|
||||||
|
|
||||||
[types.SAVE_DELAY_PROFILE]: createSaveProviderHandler(
|
[types.SAVE_DELAY_PROFILE]: createSaveProviderHandler(
|
||||||
|
|
|
@ -57,6 +57,18 @@ export const setLanguageProfileValue = createAction(types.SET_LANGUAGE_PROFILE_V
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const fetchMetadataProfiles = settingsActionHandlers[types.FETCH_METADATA_PROFILES];
|
||||||
|
export const fetchMetadataProfileSchema = settingsActionHandlers[types.FETCH_METADATA_PROFILE_SCHEMA];
|
||||||
|
export const saveMetadataProfile = settingsActionHandlers[types.SAVE_METADATA_PROFILE];
|
||||||
|
export const deleteMetadataProfile = settingsActionHandlers[types.DELETE_METADATA_PROFILE];
|
||||||
|
|
||||||
|
export const setMetadataProfileValue = createAction(types.SET_METADATA_PROFILE_VALUE, (payload) => {
|
||||||
|
return {
|
||||||
|
section: 'metadataProfiles',
|
||||||
|
...payload
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
export const fetchDelayProfiles = settingsActionHandlers[types.FETCH_DELAY_PROFILES];
|
export const fetchDelayProfiles = settingsActionHandlers[types.FETCH_DELAY_PROFILES];
|
||||||
export const saveDelayProfile = settingsActionHandlers[types.SAVE_DELAY_PROFILE];
|
export const saveDelayProfile = settingsActionHandlers[types.SAVE_DELAY_PROFILE];
|
||||||
export const deleteDelayProfile = settingsActionHandlers[types.DELETE_DELAY_PROFILE];
|
export const deleteDelayProfile = settingsActionHandlers[types.DELETE_DELAY_PROFILE];
|
||||||
|
|
|
@ -22,8 +22,7 @@ export const defaultState = {
|
||||||
monitor: 'allEpisodes',
|
monitor: 'allEpisodes',
|
||||||
qualityProfileId: 0,
|
qualityProfileId: 0,
|
||||||
languageProfileId: 0,
|
languageProfileId: 0,
|
||||||
primaryAlbumTypes: ['Album', 'EP'],
|
metadataProfileId: 0,
|
||||||
secondaryAlbumTypes: ['Studio'],
|
|
||||||
albumFolder: true,
|
albumFolder: true,
|
||||||
tags: []
|
tags: []
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,12 @@ export const defaultState = {
|
||||||
isSortable: true,
|
isSortable: true,
|
||||||
isVisible: false
|
isVisible: false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'metadataProfileId',
|
||||||
|
label: 'Metadata Profile',
|
||||||
|
isSortable: true,
|
||||||
|
isVisible: false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'nextAiring',
|
name: 'nextAiring',
|
||||||
label: 'Next Airing',
|
label: 'Next Airing',
|
||||||
|
|
|
@ -83,6 +83,22 @@ export const defaultState = {
|
||||||
pendingChanges: {}
|
pendingChanges: {}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
metadataProfiles: {
|
||||||
|
isFetching: false,
|
||||||
|
isPopulated: false,
|
||||||
|
error: null,
|
||||||
|
isDeleting: false,
|
||||||
|
deleteError: null,
|
||||||
|
isFetchingSchema: false,
|
||||||
|
schemaPopulated: false,
|
||||||
|
schemaError: null,
|
||||||
|
schema: {},
|
||||||
|
isSaving: false,
|
||||||
|
saveError: null,
|
||||||
|
items: [],
|
||||||
|
pendingChanges: {}
|
||||||
|
},
|
||||||
|
|
||||||
delayProfiles: {
|
delayProfiles: {
|
||||||
isFetching: false,
|
isFetching: false,
|
||||||
isPopulated: false,
|
isPopulated: false,
|
||||||
|
@ -243,6 +259,7 @@ const propertyNames = [
|
||||||
const providerPropertyNames = [
|
const providerPropertyNames = [
|
||||||
'qualityProfiles',
|
'qualityProfiles',
|
||||||
'languageProfiles',
|
'languageProfiles',
|
||||||
|
'metadataProfiles',
|
||||||
'delayProfiles',
|
'delayProfiles',
|
||||||
'indexers',
|
'indexers',
|
||||||
'restrictions',
|
'restrictions',
|
||||||
|
@ -270,6 +287,7 @@ const settingsReducers = handleActions({
|
||||||
[types.SET_NAMING_SETTINGS_VALUE]: createSetSettingValueReducer('naming'),
|
[types.SET_NAMING_SETTINGS_VALUE]: createSetSettingValueReducer('naming'),
|
||||||
[types.SET_QUALITY_PROFILE_VALUE]: createSetSettingValueReducer('qualityProfiles'),
|
[types.SET_QUALITY_PROFILE_VALUE]: createSetSettingValueReducer('qualityProfiles'),
|
||||||
[types.SET_LANGUAGE_PROFILE_VALUE]: createSetSettingValueReducer('languageProfiles'),
|
[types.SET_LANGUAGE_PROFILE_VALUE]: createSetSettingValueReducer('languageProfiles'),
|
||||||
|
[types.SET_METADATA_PROFILE_VALUE]: createSetSettingValueReducer('metadataProfiles'),
|
||||||
[types.SET_DELAY_PROFILE_VALUE]: createSetSettingValueReducer('delayProfiles'),
|
[types.SET_DELAY_PROFILE_VALUE]: createSetSettingValueReducer('delayProfiles'),
|
||||||
|
|
||||||
[types.SET_QUALITY_DEFINITION_VALUE]: function(state, { payload }) {
|
[types.SET_QUALITY_DEFINITION_VALUE]: function(state, { payload }) {
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import _ from 'lodash';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
|
function createMetadataProfileSelector() {
|
||||||
|
return createSelector(
|
||||||
|
(state, { metadataProfileId }) => metadataProfileId,
|
||||||
|
(state) => state.settings.metadataProfiles.items,
|
||||||
|
(metadataProfileId, metadataProfiles) => {
|
||||||
|
return _.find(metadataProfiles, { id: metadataProfileId });
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default createMetadataProfileSelector;
|
|
@ -6,10 +6,9 @@ function getNewSeries(artist, payload) {
|
||||||
monitor,
|
monitor,
|
||||||
qualityProfileId,
|
qualityProfileId,
|
||||||
languageProfileId,
|
languageProfileId,
|
||||||
|
metadataProfileId,
|
||||||
artistType,
|
artistType,
|
||||||
albumFolder,
|
albumFolder,
|
||||||
primaryAlbumTypes,
|
|
||||||
secondaryAlbumTypes,
|
|
||||||
tags,
|
tags,
|
||||||
searchForMissingAlbums = false
|
searchForMissingAlbums = false
|
||||||
} = payload;
|
} = payload;
|
||||||
|
@ -25,11 +24,10 @@ function getNewSeries(artist, payload) {
|
||||||
artist.monitored = true;
|
artist.monitored = true;
|
||||||
artist.qualityProfileId = qualityProfileId;
|
artist.qualityProfileId = qualityProfileId;
|
||||||
artist.languageProfileId = languageProfileId;
|
artist.languageProfileId = languageProfileId;
|
||||||
|
artist.metadataProfileId = metadataProfileId;
|
||||||
artist.rootFolderPath = rootFolderPath;
|
artist.rootFolderPath = rootFolderPath;
|
||||||
artist.artistType = artistType;
|
artist.artistType = artistType;
|
||||||
artist.albumFolder = albumFolder;
|
artist.albumFolder = albumFolder;
|
||||||
artist.primaryAlbumTypes = primaryAlbumTypes;
|
|
||||||
artist.secondaryAlbumTypes = secondaryAlbumTypes;
|
|
||||||
artist.tags = tags;
|
artist.tags = tags;
|
||||||
|
|
||||||
return artist;
|
return artist;
|
||||||
|
|
|
@ -35,6 +35,16 @@ namespace Lidarr.Api.V1.Artist
|
||||||
artist.ProfileId = resource.QualityProfileId.Value;
|
artist.ProfileId = resource.QualityProfileId.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resource.LanguageProfileId.HasValue)
|
||||||
|
{
|
||||||
|
artist.LanguageProfileId = resource.LanguageProfileId.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resource.MetadataProfileId.HasValue)
|
||||||
|
{
|
||||||
|
artist.MetadataProfileId = resource.MetadataProfileId.Value;
|
||||||
|
}
|
||||||
|
|
||||||
if (resource.AlbumFolder.HasValue)
|
if (resource.AlbumFolder.HasValue)
|
||||||
{
|
{
|
||||||
artist.AlbumFolder = resource.AlbumFolder.Value;
|
artist.AlbumFolder = resource.AlbumFolder.Value;
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace Lidarr.Api.V1.Artist
|
||||||
public bool? Monitored { get; set; }
|
public bool? Monitored { get; set; }
|
||||||
public int? QualityProfileId { get; set; }
|
public int? QualityProfileId { get; set; }
|
||||||
public int? LanguageProfileId { get; set; }
|
public int? LanguageProfileId { get; set; }
|
||||||
|
public int? MetadataProfileId { get; set; }
|
||||||
//public SeriesTypes? SeriesType { get; set; }
|
//public SeriesTypes? SeriesType { get; set; }
|
||||||
public bool? AlbumFolder { get; set; }
|
public bool? AlbumFolder { get; set; }
|
||||||
public string RootFolderPath { get; set; }
|
public string RootFolderPath { get; set; }
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace Lidarr.Api.V1.Artist
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
public int QualityProfileId { get; set; }
|
public int QualityProfileId { get; set; }
|
||||||
public int LanguageProfileId { get; set; }
|
public int LanguageProfileId { get; set; }
|
||||||
|
public int MetadataProfileId { get; set; }
|
||||||
|
|
||||||
//Editing Only
|
//Editing Only
|
||||||
public bool AlbumFolder { get; set; }
|
public bool AlbumFolder { get; set; }
|
||||||
|
@ -89,9 +90,6 @@ namespace Lidarr.Api.V1.Artist
|
||||||
ArtistType = model.ArtistType,
|
ArtistType = model.ArtistType,
|
||||||
Disambiguation = model.Disambiguation,
|
Disambiguation = model.Disambiguation,
|
||||||
|
|
||||||
PrimaryAlbumTypes = model.PrimaryAlbumTypes,
|
|
||||||
SecondaryAlbumTypes = model.SecondaryAlbumTypes,
|
|
||||||
|
|
||||||
Images = model.Images,
|
Images = model.Images,
|
||||||
|
|
||||||
Albums = model.Albums.ToResource(),
|
Albums = model.Albums.ToResource(),
|
||||||
|
@ -100,6 +98,7 @@ namespace Lidarr.Api.V1.Artist
|
||||||
Path = model.Path,
|
Path = model.Path,
|
||||||
QualityProfileId = model.ProfileId,
|
QualityProfileId = model.ProfileId,
|
||||||
LanguageProfileId = model.LanguageProfileId,
|
LanguageProfileId = model.LanguageProfileId,
|
||||||
|
MetadataProfileId = model.MetadataProfileId,
|
||||||
Links = model.Links,
|
Links = model.Links,
|
||||||
|
|
||||||
AlbumFolder = model.AlbumFolder,
|
AlbumFolder = model.AlbumFolder,
|
||||||
|
@ -146,9 +145,8 @@ namespace Lidarr.Api.V1.Artist
|
||||||
Path = resource.Path,
|
Path = resource.Path,
|
||||||
ProfileId = resource.QualityProfileId,
|
ProfileId = resource.QualityProfileId,
|
||||||
LanguageProfileId = resource.LanguageProfileId,
|
LanguageProfileId = resource.LanguageProfileId,
|
||||||
|
MetadataProfileId = resource.MetadataProfileId,
|
||||||
Links = resource.Links,
|
Links = resource.Links,
|
||||||
PrimaryAlbumTypes = resource.PrimaryAlbumTypes,
|
|
||||||
SecondaryAlbumTypes = resource.SecondaryAlbumTypes,
|
|
||||||
|
|
||||||
AlbumFolder = resource.AlbumFolder,
|
AlbumFolder = resource.AlbumFolder,
|
||||||
Monitored = resource.Monitored,
|
Monitored = resource.Monitored,
|
||||||
|
|
|
@ -94,6 +94,10 @@
|
||||||
<Compile Include="Commands\CommandResource.cs" />
|
<Compile Include="Commands\CommandResource.cs" />
|
||||||
<Compile Include="Config\MetadataProviderConfigModule.cs" />
|
<Compile Include="Config\MetadataProviderConfigModule.cs" />
|
||||||
<Compile Include="Config\MetadataProviderConfigResource.cs" />
|
<Compile Include="Config\MetadataProviderConfigResource.cs" />
|
||||||
|
<Compile Include="Profiles\Metadata\MetadataProfileModule.cs" />
|
||||||
|
<Compile Include="Profiles\Metadata\MetadataProfileResource.cs" />
|
||||||
|
<Compile Include="Profiles\Metadata\MetadataProfileSchemaModule.cs" />
|
||||||
|
<Compile Include="Profiles\Metadata\MetadataValidator.cs" />
|
||||||
<Compile Include="Profiles\Quality\QualityCutoffValidator.cs" />
|
<Compile Include="Profiles\Quality\QualityCutoffValidator.cs" />
|
||||||
<Compile Include="Profiles\Quality\QualityItemsValidator.cs" />
|
<Compile Include="Profiles\Quality\QualityItemsValidator.cs" />
|
||||||
<Compile Include="TrackFiles\TrackFileListResource.cs" />
|
<Compile Include="TrackFiles\TrackFileListResource.cs" />
|
||||||
|
|
57
src/Lidarr.Api.V1/Profiles/Metadata/MetadataProfileModule.cs
Normal file
57
src/Lidarr.Api.V1/Profiles/Metadata/MetadataProfileModule.cs
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using FluentValidation;
|
||||||
|
using NzbDrone.Core.Profiles.Metadata;
|
||||||
|
using Lidarr.Http;
|
||||||
|
|
||||||
|
namespace Lidarr.Api.V1.Profiles.Metadata
|
||||||
|
{
|
||||||
|
public class MetadataProfileModule : LidarrRestModule<MetadataProfileResource>
|
||||||
|
{
|
||||||
|
private readonly IMetadataProfileService _profileService;
|
||||||
|
|
||||||
|
public MetadataProfileModule(IMetadataProfileService profileService)
|
||||||
|
{
|
||||||
|
_profileService = profileService;
|
||||||
|
SharedValidator.RuleFor(c => c.Name).NotEmpty();
|
||||||
|
SharedValidator.RuleFor(c => c.PrimaryAlbumTypes).MustHaveAllowedPrimaryType();
|
||||||
|
SharedValidator.RuleFor(c => c.SecondaryAlbumTypes).MustHaveAllowedSecondaryType();
|
||||||
|
|
||||||
|
GetResourceAll = GetAll;
|
||||||
|
GetResourceById = GetById;
|
||||||
|
UpdateResource = Update;
|
||||||
|
CreateResource = Create;
|
||||||
|
DeleteResource = DeleteProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int Create(MetadataProfileResource resource)
|
||||||
|
{
|
||||||
|
var model = resource.ToModel();
|
||||||
|
model = _profileService.Add(model);
|
||||||
|
return model.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeleteProfile(int id)
|
||||||
|
{
|
||||||
|
_profileService.Delete(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update(MetadataProfileResource resource)
|
||||||
|
{
|
||||||
|
var model = resource.ToModel();
|
||||||
|
|
||||||
|
_profileService.Update(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MetadataProfileResource GetById(int id)
|
||||||
|
{
|
||||||
|
return _profileService.Get(id).ToResource();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<MetadataProfileResource> GetAll()
|
||||||
|
{
|
||||||
|
var profiles = _profileService.All().ToResource();
|
||||||
|
|
||||||
|
return profiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
110
src/Lidarr.Api.V1/Profiles/Metadata/MetadataProfileResource.cs
Normal file
110
src/Lidarr.Api.V1/Profiles/Metadata/MetadataProfileResource.cs
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NzbDrone.Core.Profiles.Metadata;
|
||||||
|
using Lidarr.Http.REST;
|
||||||
|
|
||||||
|
namespace Lidarr.Api.V1.Profiles.Metadata
|
||||||
|
{
|
||||||
|
public class MetadataProfileResource : RestResource
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public List<ProfilePrimaryAlbumTypeItemResource> PrimaryAlbumTypes { get; set; }
|
||||||
|
public List<ProfileSecondaryAlbumTypeItemResource> SecondaryAlbumTypes { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ProfilePrimaryAlbumTypeItemResource : RestResource
|
||||||
|
{
|
||||||
|
public NzbDrone.Core.Music.PrimaryAlbumType AlbumType { get; set; }
|
||||||
|
public bool Allowed { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ProfileSecondaryAlbumTypeItemResource : RestResource
|
||||||
|
{
|
||||||
|
public NzbDrone.Core.Music.SecondaryAlbumType AlbumType { get; set; }
|
||||||
|
public bool Allowed { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MetadataProfileResourceMapper
|
||||||
|
{
|
||||||
|
public static MetadataProfileResource ToResource(this MetadataProfile model)
|
||||||
|
{
|
||||||
|
if (model == null) return null;
|
||||||
|
|
||||||
|
return new MetadataProfileResource
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
PrimaryAlbumTypes = model.PrimaryAlbumTypes.ConvertAll(ToResource),
|
||||||
|
SecondaryAlbumTypes = model.SecondaryAlbumTypes.ConvertAll(ToResource)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProfilePrimaryAlbumTypeItemResource ToResource(this ProfilePrimaryAlbumTypeItem model)
|
||||||
|
{
|
||||||
|
if (model == null) return null;
|
||||||
|
|
||||||
|
return new ProfilePrimaryAlbumTypeItemResource
|
||||||
|
{
|
||||||
|
AlbumType = model.PrimaryAlbumType,
|
||||||
|
Allowed = model.Allowed
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProfileSecondaryAlbumTypeItemResource ToResource(this ProfileSecondaryAlbumTypeItem model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ProfileSecondaryAlbumTypeItemResource
|
||||||
|
{
|
||||||
|
AlbumType = model.SecondaryAlbumType,
|
||||||
|
Allowed = model.Allowed
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MetadataProfile ToModel(this MetadataProfileResource resource)
|
||||||
|
{
|
||||||
|
if (resource == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new MetadataProfile
|
||||||
|
{
|
||||||
|
Id = resource.Id,
|
||||||
|
Name = resource.Name,
|
||||||
|
PrimaryAlbumTypes = resource.PrimaryAlbumTypes.ConvertAll(ToModel),
|
||||||
|
SecondaryAlbumTypes = resource.SecondaryAlbumTypes.ConvertAll(ToModel)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProfilePrimaryAlbumTypeItem ToModel(this ProfilePrimaryAlbumTypeItemResource resource)
|
||||||
|
{
|
||||||
|
if (resource == null) return null;
|
||||||
|
|
||||||
|
return new ProfilePrimaryAlbumTypeItem
|
||||||
|
{
|
||||||
|
PrimaryAlbumType = (NzbDrone.Core.Music.PrimaryAlbumType)resource.AlbumType.Id,
|
||||||
|
Allowed = resource.Allowed
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProfileSecondaryAlbumTypeItem ToModel(this ProfileSecondaryAlbumTypeItemResource resource)
|
||||||
|
{
|
||||||
|
if (resource == null) return null;
|
||||||
|
|
||||||
|
return new ProfileSecondaryAlbumTypeItem
|
||||||
|
{
|
||||||
|
SecondaryAlbumType = (NzbDrone.Core.Music.SecondaryAlbumType)resource.AlbumType.Id,
|
||||||
|
Allowed = resource.Allowed
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<MetadataProfileResource> ToResource(this IEnumerable<MetadataProfile> models)
|
||||||
|
{
|
||||||
|
return models.Select(ToResource).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
using System.Linq;
|
||||||
|
using NzbDrone.Core.Profiles.Metadata;
|
||||||
|
using Lidarr.Http;
|
||||||
|
|
||||||
|
namespace Lidarr.Api.V1.Profiles.Metadata
|
||||||
|
{
|
||||||
|
public class MetadataProfileSchemaModule : LidarrRestModule<MetadataProfileResource>
|
||||||
|
{
|
||||||
|
|
||||||
|
public MetadataProfileSchemaModule()
|
||||||
|
: base("/metadataprofile/schema")
|
||||||
|
{
|
||||||
|
GetResourceSingle = GetAll;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MetadataProfileResource GetAll()
|
||||||
|
{
|
||||||
|
var orderedPrimTypes = NzbDrone.Core.Music.PrimaryAlbumType.All
|
||||||
|
.OrderByDescending(l => l.Id)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var orderedSecTypes = NzbDrone.Core.Music.SecondaryAlbumType.All
|
||||||
|
.OrderByDescending(l => l.Id)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var primTypes = orderedPrimTypes.Select(v => new ProfilePrimaryAlbumTypeItem {PrimaryAlbumType = v, Allowed = false})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var secTypes = orderedSecTypes.Select(v => new ProfileSecondaryAlbumTypeItem { SecondaryAlbumType = v, Allowed = false })
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var profile = new MetadataProfile
|
||||||
|
{
|
||||||
|
PrimaryAlbumTypes = primTypes,
|
||||||
|
SecondaryAlbumTypes = secTypes
|
||||||
|
};
|
||||||
|
|
||||||
|
return profile.ToResource();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
src/Lidarr.Api.V1/Profiles/Metadata/MetadataValidator.cs
Normal file
75
src/Lidarr.Api.V1/Profiles/Metadata/MetadataValidator.cs
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using FluentValidation;
|
||||||
|
using FluentValidation.Validators;
|
||||||
|
|
||||||
|
namespace Lidarr.Api.V1.Profiles.Metadata
|
||||||
|
{
|
||||||
|
public static class MetadataValidation
|
||||||
|
{
|
||||||
|
public static IRuleBuilderOptions<T, IList<ProfilePrimaryAlbumTypeItemResource>> MustHaveAllowedPrimaryType<T>(this IRuleBuilder<T, IList<ProfilePrimaryAlbumTypeItemResource>> ruleBuilder)
|
||||||
|
{
|
||||||
|
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
||||||
|
|
||||||
|
return ruleBuilder.SetValidator(new PrimaryTypeValidator<T>());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IRuleBuilderOptions<T, IList<ProfileSecondaryAlbumTypeItemResource>> MustHaveAllowedSecondaryType<T>(this IRuleBuilder<T, IList<ProfileSecondaryAlbumTypeItemResource>> ruleBuilder)
|
||||||
|
{
|
||||||
|
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
||||||
|
|
||||||
|
return ruleBuilder.SetValidator(new SecondaryTypeValidator<T>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class PrimaryTypeValidator<T> : PropertyValidator
|
||||||
|
{
|
||||||
|
public PrimaryTypeValidator()
|
||||||
|
: base("Must have at least one allowed primary type")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool IsValid(PropertyValidatorContext context)
|
||||||
|
{
|
||||||
|
var list = context.PropertyValue as IList<ProfilePrimaryAlbumTypeItemResource>;
|
||||||
|
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!list.Any(c => c.Allowed))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SecondaryTypeValidator<T> : PropertyValidator
|
||||||
|
{
|
||||||
|
public SecondaryTypeValidator()
|
||||||
|
: base("Must have at least one allowed secondary type")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool IsValid(PropertyValidatorContext context)
|
||||||
|
{
|
||||||
|
var list = context.PropertyValue as IList<ProfileSecondaryAlbumTypeItemResource>;
|
||||||
|
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!list.Any(c => c.Allowed))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook
|
||||||
[TestCase("66c662b6-6e2f-4930-8610-912e24c63ed1", "AC/DC")]
|
[TestCase("66c662b6-6e2f-4930-8610-912e24c63ed1", "AC/DC")]
|
||||||
public void should_be_able_to_get_artist_detail(string mbId, string name)
|
public void should_be_able_to_get_artist_detail(string mbId, string name)
|
||||||
{
|
{
|
||||||
var details = Subject.GetArtistInfo(mbId, new List<string> { "Album" }, new List<string> { "Studio" });
|
var details = Subject.GetArtistInfo(mbId, 0);
|
||||||
|
|
||||||
ValidateArtist(details.Item1);
|
ValidateArtist(details.Item1);
|
||||||
ValidateAlbums(details.Item2);
|
ValidateAlbums(details.Item2);
|
||||||
|
@ -37,13 +37,13 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook
|
||||||
[Test]
|
[Test]
|
||||||
public void getting_details_of_invalid_artist()
|
public void getting_details_of_invalid_artist()
|
||||||
{
|
{
|
||||||
Assert.Throws<ArtistNotFoundException>(() => Subject.GetArtistInfo("aaaaaa-aaa-aaaa-aaaa", new List<string> { "Album" }, new List<string> { "Studio" }));
|
Assert.Throws<ArtistNotFoundException>(() => Subject.GetArtistInfo("aaaaaa-aaa-aaaa-aaaa", 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_have_period_at_start_of_name_slug()
|
public void should_not_have_period_at_start_of_name_slug()
|
||||||
{
|
{
|
||||||
var details = Subject.GetArtistInfo("b6db95cd-88d9-492f-bbf6-a34e0e89b2e5", new List<string> { "Album" }, new List<string> { "Studio" });
|
var details = Subject.GetArtistInfo("b6db95cd-88d9-492f-bbf6-a34e0e89b2e5", 0);
|
||||||
|
|
||||||
details.Item1.NameSlug.Should().Be("dothack");
|
details.Item1.NameSlug.Should().Be("dothack");
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.MusicTests
|
||||||
private void GivenValidArtist(string lidarrId)
|
private void GivenValidArtist(string lidarrId)
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IProvideArtistInfo>()
|
Mocker.GetMock<IProvideArtistInfo>()
|
||||||
.Setup(s => s.GetArtistInfo(lidarrId, It.IsAny<List<string>>(), It.IsAny<List<string>>()))
|
.Setup(s => s.GetArtistInfo(lidarrId, It.IsAny<int>()))
|
||||||
.Returns(new Tuple<Artist, List<Album>>(_fakeArtist, new List<Album>()));
|
.Returns(new Tuple<Artist, List<Album>>(_fakeArtist, new List<Album>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ namespace NzbDrone.Core.Test.MusicTests
|
||||||
};
|
};
|
||||||
|
|
||||||
Mocker.GetMock<IProvideArtistInfo>()
|
Mocker.GetMock<IProvideArtistInfo>()
|
||||||
.Setup(s => s.GetArtistInfo(newArtist.ForeignArtistId, newArtist.PrimaryAlbumTypes, newArtist.SecondaryAlbumTypes))
|
.Setup(s => s.GetArtistInfo(newArtist.ForeignArtistId, newArtist.MetadataProfileId))
|
||||||
.Throws(new ArtistNotFoundException(newArtist.ForeignArtistId));
|
.Throws(new ArtistNotFoundException(newArtist.ForeignArtistId));
|
||||||
|
|
||||||
Mocker.GetMock<IAddArtistValidator>()
|
Mocker.GetMock<IAddArtistValidator>()
|
||||||
|
|
|
@ -38,14 +38,14 @@ namespace NzbDrone.Core.Test.MusicTests
|
||||||
.Returns(_artist);
|
.Returns(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IProvideArtistInfo>()
|
Mocker.GetMock<IProvideArtistInfo>()
|
||||||
.Setup(s => s.GetArtistInfo(It.IsAny<string>(), It.IsAny<List<string>>(), It.IsAny<List<string>>()))
|
.Setup(s => s.GetArtistInfo(It.IsAny<string>(), It.IsAny<int>()))
|
||||||
.Callback(() => { throw new ArtistNotFoundException(_artist.ForeignArtistId); });
|
.Callback(() => { throw new ArtistNotFoundException(_artist.ForeignArtistId); });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenNewArtistInfo(Artist artist)
|
private void GivenNewArtistInfo(Artist artist)
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IProvideArtistInfo>()
|
Mocker.GetMock<IProvideArtistInfo>()
|
||||||
.Setup(s => s.GetArtistInfo(_artist.ForeignArtistId, _artist.PrimaryAlbumTypes, _artist.SecondaryAlbumTypes))
|
.Setup(s => s.GetArtistInfo(_artist.ForeignArtistId, _artist.MetadataProfileId))
|
||||||
.Returns(new Tuple<Artist, List<Album>>(artist, new List<Album>()));
|
.Returns(new Tuple<Artist, List<Album>>(artist, new List<Album>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,6 +280,8 @@
|
||||||
<Compile Include="OrganizerTests\FileNameBuilderTests\TitleTheFixture.cs" />
|
<Compile Include="OrganizerTests\FileNameBuilderTests\TitleTheFixture.cs" />
|
||||||
<Compile Include="ParserTests\MusicParserFixture.cs" />
|
<Compile Include="ParserTests\MusicParserFixture.cs" />
|
||||||
<Compile Include="Profiles\Delay\DelayProfileServiceFixture.cs" />
|
<Compile Include="Profiles\Delay\DelayProfileServiceFixture.cs" />
|
||||||
|
<Compile Include="Profiles\Metadata\MetadataProfileServiceFixture.cs" />
|
||||||
|
<Compile Include="Profiles\Metadata\MetadataProfileRepositoryFixture.cs" />
|
||||||
<Compile Include="Profiles\Qualities\QualityIndexCompareToFixture.cs" />
|
<Compile Include="Profiles\Qualities\QualityIndexCompareToFixture.cs" />
|
||||||
<Compile Include="Qualities\RevisionComparableFixture.cs" />
|
<Compile Include="Qualities\RevisionComparableFixture.cs" />
|
||||||
<Compile Include="QueueTests\QueueServiceFixture.cs" />
|
<Compile Include="QueueTests\QueueServiceFixture.cs" />
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
using FluentAssertions;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Core.Profiles.Metadata;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.Profiles.Metadata
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class MetadataProfileRepositoryFixture : DbTest<MetadataProfileRepository, MetadataProfile>
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void should_be_able_to_read_and_write()
|
||||||
|
{
|
||||||
|
var profile = new MetadataProfile
|
||||||
|
{
|
||||||
|
PrimaryAlbumTypes = PrimaryAlbumType.All.OrderByDescending(l => l.Name).Select(l => new ProfilePrimaryAlbumTypeItem
|
||||||
|
{
|
||||||
|
PrimaryAlbumType = l,
|
||||||
|
Allowed = l == PrimaryAlbumType.Album
|
||||||
|
}).ToList(),
|
||||||
|
|
||||||
|
SecondaryAlbumTypes = SecondaryAlbumType.All.OrderByDescending(l => l.Name).Select(l => new ProfileSecondaryAlbumTypeItem
|
||||||
|
{
|
||||||
|
SecondaryAlbumType = l,
|
||||||
|
Allowed = l == SecondaryAlbumType.Studio
|
||||||
|
}).ToList(),
|
||||||
|
|
||||||
|
Name = "TestProfile"
|
||||||
|
};
|
||||||
|
|
||||||
|
Subject.Insert(profile);
|
||||||
|
|
||||||
|
|
||||||
|
StoredModel.Name.Should().Be(profile.Name);
|
||||||
|
|
||||||
|
StoredModel.PrimaryAlbumTypes.Should().Equal(profile.PrimaryAlbumTypes, (a, b) => a.PrimaryAlbumType == b.PrimaryAlbumType && a.Allowed == b.Allowed);
|
||||||
|
StoredModel.SecondaryAlbumTypes.Should().Equal(profile.SecondaryAlbumTypes, (a, b) => a.SecondaryAlbumType == b.SecondaryAlbumType && a.Allowed == b.Allowed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
using System.Linq;
|
||||||
|
using FizzWare.NBuilder;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Lifecycle;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
using NzbDrone.Core.Profiles.Metadata;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.Profiles.Metadata
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
|
||||||
|
public class MetadataProfileServiceFixture : CoreTest<MetadataProfileService>
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void init_should_add_default_profiles()
|
||||||
|
{
|
||||||
|
Subject.Handle(new ApplicationStartedEvent());
|
||||||
|
|
||||||
|
Mocker.GetMock<IMetadataProfileRepository>()
|
||||||
|
.Verify(v => v.Insert(It.IsAny<MetadataProfile>()), Times.Once());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
//This confirms that new profiles are added only if no other profiles exists.
|
||||||
|
//We don't want to keep adding them back if a user deleted them on purpose.
|
||||||
|
public void Init_should_skip_if_any_profiles_already_exist()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<IMetadataProfileRepository>()
|
||||||
|
.Setup(s => s.All())
|
||||||
|
.Returns(Builder<MetadataProfile>.CreateListOfSize(2).Build().ToList());
|
||||||
|
|
||||||
|
Subject.Handle(new ApplicationStartedEvent());
|
||||||
|
|
||||||
|
Mocker.GetMock<IMetadataProfileRepository>()
|
||||||
|
.Verify(v => v.Insert(It.IsAny<MetadataProfile>()), Times.Never());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_not_be_able_to_delete_profile_if_assigned_to_artist()
|
||||||
|
{
|
||||||
|
var artistList = Builder<Artist>.CreateListOfSize(3)
|
||||||
|
.Random(1)
|
||||||
|
.With(c => c.MetadataProfileId = 2)
|
||||||
|
.Build().ToList();
|
||||||
|
|
||||||
|
|
||||||
|
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
||||||
|
|
||||||
|
Assert.Throws<MetadataProfileInUseException>(() => Subject.Delete(2));
|
||||||
|
|
||||||
|
Mocker.GetMock<IMetadataProfileRepository>().Verify(c => c.Delete(It.IsAny<int>()), Times.Never());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_delete_profile_if_not_assigned_to_series()
|
||||||
|
{
|
||||||
|
var artistList = Builder<Artist>.CreateListOfSize(3)
|
||||||
|
.All()
|
||||||
|
.With(c => c.MetadataProfileId = 2)
|
||||||
|
.Build().ToList();
|
||||||
|
|
||||||
|
|
||||||
|
Mocker.GetMock<IArtistService>().Setup(c => c.GetAllArtists()).Returns(artistList);
|
||||||
|
|
||||||
|
Subject.Delete(1);
|
||||||
|
|
||||||
|
Mocker.GetMock<IMetadataProfileRepository>().Verify(c => c.Delete(1), Times.Once());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
using Marr.Data.Converters;
|
||||||
|
using Marr.Data.Mapping;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Converters
|
||||||
|
{
|
||||||
|
public class PrimaryAlbumTypeIntConverter : JsonConverter, IConverter
|
||||||
|
{
|
||||||
|
public object FromDB(ConverterContext context)
|
||||||
|
{
|
||||||
|
if (context.DbValue == DBNull.Value)
|
||||||
|
{
|
||||||
|
return PrimaryAlbumType.Album;
|
||||||
|
}
|
||||||
|
|
||||||
|
var val = Convert.ToInt32(context.DbValue);
|
||||||
|
|
||||||
|
return (PrimaryAlbumType) val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object FromDB(ColumnMap map, object dbValue)
|
||||||
|
{
|
||||||
|
return FromDB(new ConverterContext {ColumnMap = map, DbValue = dbValue});
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ToDB(object clrValue)
|
||||||
|
{
|
||||||
|
if (clrValue == DBNull.Value)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clrValue as PrimaryAlbumType == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Attempted to save a albumtype that isn't really a albumtype");
|
||||||
|
}
|
||||||
|
|
||||||
|
var language = (PrimaryAlbumType) clrValue;
|
||||||
|
return (int) language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type DbType => typeof(int);
|
||||||
|
|
||||||
|
public override bool CanConvert(Type objectType)
|
||||||
|
{
|
||||||
|
return objectType == typeof(PrimaryAlbumType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
|
||||||
|
JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
var item = reader.Value;
|
||||||
|
return (PrimaryAlbumType) Convert.ToInt32(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
writer.WriteValue(ToDB(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
using System;
|
||||||
|
using Marr.Data.Converters;
|
||||||
|
using Marr.Data.Mapping;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Converters
|
||||||
|
{
|
||||||
|
public class SecondaryAlbumTypeIntConverter : JsonConverter, IConverter
|
||||||
|
{
|
||||||
|
public object FromDB(ConverterContext context)
|
||||||
|
{
|
||||||
|
if (context.DbValue == DBNull.Value)
|
||||||
|
{
|
||||||
|
return SecondaryAlbumType.Studio;
|
||||||
|
}
|
||||||
|
|
||||||
|
var val = Convert.ToInt32(context.DbValue);
|
||||||
|
|
||||||
|
return (SecondaryAlbumType) val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object FromDB(ColumnMap map, object dbValue)
|
||||||
|
{
|
||||||
|
return FromDB(new ConverterContext {ColumnMap = map, DbValue = dbValue});
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ToDB(object clrValue)
|
||||||
|
{
|
||||||
|
if (clrValue == DBNull.Value)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clrValue as SecondaryAlbumType == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Attempted to save a albumtype that isn't really a albumtype");
|
||||||
|
}
|
||||||
|
|
||||||
|
var language = (SecondaryAlbumType) clrValue;
|
||||||
|
return (int) language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type DbType => typeof(int);
|
||||||
|
|
||||||
|
public override bool CanConvert(Type objectType)
|
||||||
|
{
|
||||||
|
return objectType == typeof(SecondaryAlbumType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
|
||||||
|
JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
var item = reader.Value;
|
||||||
|
return (SecondaryAlbumType) Convert.ToInt32(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
writer.WriteValue(ToDB(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
using FluentMigrator;
|
||||||
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Migration
|
||||||
|
{
|
||||||
|
[Migration(5)]
|
||||||
|
public class metadata_profiles : NzbDroneMigrationBase
|
||||||
|
{
|
||||||
|
protected override void MainDbUpgrade()
|
||||||
|
{
|
||||||
|
Create.TableForModel("MetadataProfiles")
|
||||||
|
.WithColumn("Name").AsString().Unique()
|
||||||
|
.WithColumn("PrimaryAlbumTypes").AsString()
|
||||||
|
.WithColumn("SecondaryAlbumTypes").AsString();
|
||||||
|
|
||||||
|
Alter.Table("Artists").AddColumn("MetadataProfileId").AsInt32().WithDefaultValue(1);
|
||||||
|
|
||||||
|
Delete.Column("PrimaryAlbumTypes").FromTable("Artists");
|
||||||
|
Delete.Column("SecondaryAlbumTypes").FromTable("Artists");
|
||||||
|
|
||||||
|
Alter.Table("Albums").AddColumn("SecondaryTypes").AsString().Nullable();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,6 +18,8 @@ using NzbDrone.Core.RemotePathMappings;
|
||||||
using NzbDrone.Core.Notifications;
|
using NzbDrone.Core.Notifications;
|
||||||
using NzbDrone.Core.Organizer;
|
using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using NzbDrone.Core.Profiles.Languages;
|
||||||
|
using NzbDrone.Core.Profiles.Metadata;
|
||||||
using NzbDrone.Core.Profiles.Qualities;
|
using NzbDrone.Core.Profiles.Qualities;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Restrictions;
|
using NzbDrone.Core.Restrictions;
|
||||||
|
@ -26,6 +28,7 @@ using NzbDrone.Core.ArtistStats;
|
||||||
using NzbDrone.Core.Tags;
|
using NzbDrone.Core.Tags;
|
||||||
using NzbDrone.Core.ThingiProvider;
|
using NzbDrone.Core.ThingiProvider;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
|
using NzbDrone.Common.Serializer;
|
||||||
using NzbDrone.Core.Authentication;
|
using NzbDrone.Core.Authentication;
|
||||||
using NzbDrone.Core.Extras.Metadata;
|
using NzbDrone.Core.Extras.Metadata;
|
||||||
using NzbDrone.Core.Extras.Metadata.Files;
|
using NzbDrone.Core.Extras.Metadata.Files;
|
||||||
|
@ -34,7 +37,6 @@ using NzbDrone.Core.Extras.Lyrics;
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Core.Languages;
|
using NzbDrone.Core.Languages;
|
||||||
using NzbDrone.Core.Profiles.Languages;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Datastore
|
namespace NzbDrone.Core.Datastore
|
||||||
{
|
{
|
||||||
|
@ -77,7 +79,8 @@ namespace NzbDrone.Core.Datastore
|
||||||
.Ignore(s => s.RootFolderPath)
|
.Ignore(s => s.RootFolderPath)
|
||||||
.Relationship()
|
.Relationship()
|
||||||
.HasOne(a => a.Profile, a => a.ProfileId)
|
.HasOne(a => a.Profile, a => a.ProfileId)
|
||||||
.HasOne(s => s.LanguageProfile, s => s.LanguageProfileId);
|
.HasOne(s => s.LanguageProfile, s => s.LanguageProfileId)
|
||||||
|
.HasOne(s => s.MetadataProfile, s => s.MetadataProfileId);
|
||||||
|
|
||||||
Mapper.Entity<Album>().RegisterModel("Albums");
|
Mapper.Entity<Album>().RegisterModel("Albums");
|
||||||
|
|
||||||
|
@ -104,6 +107,7 @@ namespace NzbDrone.Core.Datastore
|
||||||
|
|
||||||
Mapper.Entity<Profile>().RegisterModel("Profiles");
|
Mapper.Entity<Profile>().RegisterModel("Profiles");
|
||||||
Mapper.Entity<LanguageProfile>().RegisterModel("LanguageProfiles");
|
Mapper.Entity<LanguageProfile>().RegisterModel("LanguageProfiles");
|
||||||
|
Mapper.Entity<MetadataProfile>().RegisterModel("MetadataProfiles");
|
||||||
Mapper.Entity<Log>().RegisterModel("Logs");
|
Mapper.Entity<Log>().RegisterModel("Logs");
|
||||||
Mapper.Entity<NamingConfig>().RegisterModel("NamingConfig");
|
Mapper.Entity<NamingConfig>().RegisterModel("NamingConfig");
|
||||||
Mapper.Entity<AlbumStatistics>().MapResultSet();
|
Mapper.Entity<AlbumStatistics>().MapResultSet();
|
||||||
|
@ -146,6 +150,8 @@ namespace NzbDrone.Core.Datastore
|
||||||
MapRepository.Instance.RegisterTypeConverter(typeof(Language), new LanguageIntConverter());
|
MapRepository.Instance.RegisterTypeConverter(typeof(Language), new LanguageIntConverter());
|
||||||
MapRepository.Instance.RegisterTypeConverter(typeof(List<string>), new EmbeddedDocumentConverter());
|
MapRepository.Instance.RegisterTypeConverter(typeof(List<string>), new EmbeddedDocumentConverter());
|
||||||
MapRepository.Instance.RegisterTypeConverter(typeof(List<ProfileLanguageItem>), new EmbeddedDocumentConverter(new LanguageIntConverter()));
|
MapRepository.Instance.RegisterTypeConverter(typeof(List<ProfileLanguageItem>), new EmbeddedDocumentConverter(new LanguageIntConverter()));
|
||||||
|
MapRepository.Instance.RegisterTypeConverter(typeof(List<ProfilePrimaryAlbumTypeItem>), new EmbeddedDocumentConverter(new PrimaryAlbumTypeIntConverter()));
|
||||||
|
MapRepository.Instance.RegisterTypeConverter(typeof(List<ProfileSecondaryAlbumTypeItem>), new EmbeddedDocumentConverter(new SecondaryAlbumTypeIntConverter()));
|
||||||
MapRepository.Instance.RegisterTypeConverter(typeof(ParsedAlbumInfo), new EmbeddedDocumentConverter());
|
MapRepository.Instance.RegisterTypeConverter(typeof(ParsedAlbumInfo), new EmbeddedDocumentConverter());
|
||||||
MapRepository.Instance.RegisterTypeConverter(typeof(ParsedTrackInfo), new EmbeddedDocumentConverter());
|
MapRepository.Instance.RegisterTypeConverter(typeof(ParsedTrackInfo), new EmbeddedDocumentConverter());
|
||||||
MapRepository.Instance.RegisterTypeConverter(typeof(ReleaseInfo), new EmbeddedDocumentConverter());
|
MapRepository.Instance.RegisterTypeConverter(typeof(ReleaseInfo), new EmbeddedDocumentConverter());
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using NzbDrone.Core.Profiles.Metadata;
|
||||||
|
|
||||||
namespace NzbDrone.Core.MetadataSource
|
namespace NzbDrone.Core.MetadataSource
|
||||||
{
|
{
|
||||||
public interface IProvideArtistInfo
|
public interface IProvideArtistInfo
|
||||||
{
|
{
|
||||||
Tuple<Artist, List<Album>> GetArtistInfo(string lidarrId, List<string> primaryAlbumTypes, List<string> secondaryAlbumTypes);
|
Tuple<Artist, List<Album>> GetArtistInfo(string lidarrId, int metadataProfileId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook.Resource
|
||||||
public List<string> Genres { get; set; }
|
public List<string> Genres { get; set; }
|
||||||
public List<string> Labels { get; set; }
|
public List<string> Labels { get; set; }
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
|
public List<string> SecondaryTypes { get; set; }
|
||||||
public List<MediumResource> Media { get; set; }
|
public List<MediumResource> Media { get; set; }
|
||||||
public List<TrackResource> Tracks { get; set; }
|
public List<TrackResource> Tracks { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ using NzbDrone.Core.Music;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using NzbDrone.Core.Profiles.Metadata;
|
||||||
|
|
||||||
namespace NzbDrone.Core.MetadataSource.SkyHook
|
namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
{
|
{
|
||||||
|
@ -25,39 +26,36 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
private readonly IArtistService _artistService;
|
private readonly IArtistService _artistService;
|
||||||
private readonly IHttpRequestBuilderFactory _requestBuilder;
|
private readonly IHttpRequestBuilderFactory _requestBuilder;
|
||||||
private readonly IConfigService _configService;
|
private readonly IConfigService _configService;
|
||||||
|
private readonly IMetadataProfileService _metadataProfileService;
|
||||||
|
|
||||||
private IHttpRequestBuilderFactory customerRequestBuilder;
|
private IHttpRequestBuilderFactory customerRequestBuilder;
|
||||||
|
|
||||||
public SkyHookProxy(IHttpClient httpClient, ILidarrCloudRequestBuilder requestBuilder, IArtistService artistService, Logger logger, IConfigService configService)
|
public SkyHookProxy(IHttpClient httpClient, ILidarrCloudRequestBuilder requestBuilder, IArtistService artistService, Logger logger, IConfigService configService, IMetadataProfileService metadataProfileService)
|
||||||
{
|
{
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
|
_metadataProfileService = metadataProfileService;
|
||||||
_requestBuilder = requestBuilder.Search;
|
_requestBuilder = requestBuilder.Search;
|
||||||
_artistService = artistService;
|
_artistService = artistService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tuple<Artist, List<Album>> GetArtistInfo(string foreignArtistId, List<string> primaryAlbumTypes, List<string> secondaryAlbumTypes)
|
public Tuple<Artist, List<Album>> GetArtistInfo(string foreignArtistId, int metadataProfileId)
|
||||||
{
|
{
|
||||||
|
|
||||||
_logger.Debug("Getting Artist with LidarrAPI.MetadataID of {0}", foreignArtistId);
|
_logger.Debug("Getting Artist with LidarrAPI.MetadataID of {0}", foreignArtistId);
|
||||||
|
|
||||||
SetCustomProvider();
|
SetCustomProvider();
|
||||||
|
|
||||||
if (primaryAlbumTypes == null)
|
var metadataProfile = _metadataProfileService.Get(metadataProfileId);
|
||||||
{
|
|
||||||
primaryAlbumTypes = new List<string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secondaryAlbumTypes == null)
|
var primaryTypes = metadataProfile.PrimaryAlbumTypes.Where(s => s.Allowed).Select(s => s.PrimaryAlbumType.Name);
|
||||||
{
|
var secondaryTypes = metadataProfile.SecondaryAlbumTypes.Where(s => s.Allowed).Select(s => s.SecondaryAlbumType.Name);
|
||||||
secondaryAlbumTypes = new List<string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
var httpRequest = customerRequestBuilder.Create()
|
var httpRequest = customerRequestBuilder.Create()
|
||||||
.SetSegment("route", "artists/" + foreignArtistId)
|
.SetSegment("route", "artists/" + foreignArtistId)
|
||||||
.AddQueryParam("primTypes", string.Join("|",primaryAlbumTypes))
|
.AddQueryParam("primTypes", string.Join("|", primaryTypes))
|
||||||
.AddQueryParam("secTypes", string.Join("|", secondaryAlbumTypes))
|
.AddQueryParam("secTypes", string.Join("|", secondaryTypes))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
httpRequest.AllowAutoRedirect = true;
|
httpRequest.AllowAutoRedirect = true;
|
||||||
|
@ -102,7 +100,8 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new List<Artist> { GetArtistInfo(slug, new List<string>{"Album"}, new List<string>{"Studio"}).Item1 };
|
var metadataProfile = _metadataProfileService.All().First().Id; //Change this to Use last Used profile?
|
||||||
|
return new List<Artist> { GetArtistInfo(slug, metadataProfile).Item1 };
|
||||||
}
|
}
|
||||||
catch (ArtistNotFoundException)
|
catch (ArtistNotFoundException)
|
||||||
{
|
{
|
||||||
|
@ -160,6 +159,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
|
|
||||||
album.Media = resource.Media.Select(MapMedium).ToList();
|
album.Media = resource.Media.Select(MapMedium).ToList();
|
||||||
album.Tracks = resource.Tracks.Select(MapTrack).ToList();
|
album.Tracks = resource.Tracks.Select(MapTrack).ToList();
|
||||||
|
album.SecondaryTypes = resource.SecondaryTypes.Select(MapSecondaryTypes).ToList();
|
||||||
|
|
||||||
|
|
||||||
return album;
|
return album;
|
||||||
|
@ -297,6 +297,35 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static SecondaryAlbumType MapSecondaryTypes(string albumType)
|
||||||
|
{
|
||||||
|
switch (albumType.ToLowerInvariant())
|
||||||
|
{
|
||||||
|
case "compilation":
|
||||||
|
return SecondaryAlbumType.Compilation;
|
||||||
|
case "soundtrack":
|
||||||
|
return SecondaryAlbumType.Soundtrack;
|
||||||
|
case "spokenword":
|
||||||
|
return SecondaryAlbumType.Spokenword;
|
||||||
|
case "interview":
|
||||||
|
return SecondaryAlbumType.Interview;
|
||||||
|
case "audiobook":
|
||||||
|
return SecondaryAlbumType.Audiobook;
|
||||||
|
case "live":
|
||||||
|
return SecondaryAlbumType.Live;
|
||||||
|
case "remix":
|
||||||
|
return SecondaryAlbumType.Remix;
|
||||||
|
case "dj-mix":
|
||||||
|
return SecondaryAlbumType.DJMix;
|
||||||
|
case "mixtape/street":
|
||||||
|
return SecondaryAlbumType.Mixtape;
|
||||||
|
case "demo":
|
||||||
|
return SecondaryAlbumType.Demo;
|
||||||
|
default:
|
||||||
|
return SecondaryAlbumType.Studio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SetCustomProvider()
|
private void SetCustomProvider()
|
||||||
{
|
{
|
||||||
if (_configService.MetadataSource.IsNotNullOrWhiteSpace())
|
if (_configService.MetadataSource.IsNotNullOrWhiteSpace())
|
||||||
|
|
|
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Music
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tuple = _artistInfo.GetArtistInfo(newArtist.ForeignArtistId, newArtist.PrimaryAlbumTypes, newArtist.SecondaryAlbumTypes);
|
tuple = _artistInfo.GetArtistInfo(newArtist.ForeignArtistId, newArtist.MetadataProfileId);
|
||||||
}
|
}
|
||||||
catch (ArtistNotFoundException)
|
catch (ArtistNotFoundException)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace NzbDrone.Core.Music
|
||||||
public DateTime? LastDiskSync { get; set; }
|
public DateTime? LastDiskSync { get; set; }
|
||||||
public DateTime Added { get; set; }
|
public DateTime Added { get; set; }
|
||||||
public String AlbumType { get; set; }
|
public String AlbumType { get; set; }
|
||||||
|
public List<SecondaryAlbumType> SecondaryTypes { get; set; }
|
||||||
//public string ArtworkUrl { get; set; }
|
//public string ArtworkUrl { get; set; }
|
||||||
//public string Explicitness { get; set; }
|
//public string Explicitness { get; set; }
|
||||||
public AddArtistOptions AddOptions { get; set; }
|
public AddArtistOptions AddOptions { get; set; }
|
||||||
|
|
|
@ -3,6 +3,7 @@ using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Profiles.Qualities;
|
using NzbDrone.Core.Profiles.Qualities;
|
||||||
using NzbDrone.Core.Profiles.Languages;
|
using NzbDrone.Core.Profiles.Languages;
|
||||||
|
using NzbDrone.Core.Profiles.Metadata;
|
||||||
using NzbDrone.Core.Music;
|
using NzbDrone.Core.Music;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -36,8 +37,6 @@ namespace NzbDrone.Core.Music
|
||||||
public string Overview { get; set; }
|
public string Overview { get; set; }
|
||||||
public string Disambiguation { get; set; }
|
public string Disambiguation { get; set; }
|
||||||
public string ArtistType { get; set; }
|
public string ArtistType { get; set; }
|
||||||
public List<string> PrimaryAlbumTypes { get; set; }
|
|
||||||
public List<string> SecondaryAlbumTypes { get; set; }
|
|
||||||
public bool Monitored { get; set; }
|
public bool Monitored { get; set; }
|
||||||
public bool AlbumFolder { get; set; }
|
public bool AlbumFolder { get; set; }
|
||||||
public DateTime? LastInfoSync { get; set; }
|
public DateTime? LastInfoSync { get; set; }
|
||||||
|
@ -51,8 +50,10 @@ namespace NzbDrone.Core.Music
|
||||||
public DateTime Added { get; set; }
|
public DateTime Added { get; set; }
|
||||||
public LazyLoaded<Profile> Profile { get; set; }
|
public LazyLoaded<Profile> Profile { get; set; }
|
||||||
public LazyLoaded<LanguageProfile> LanguageProfile { get; set; }
|
public LazyLoaded<LanguageProfile> LanguageProfile { get; set; }
|
||||||
|
public LazyLoaded<MetadataProfile> MetadataProfile { get; set; }
|
||||||
public int ProfileId { get; set; }
|
public int ProfileId { get; set; }
|
||||||
public int LanguageProfileId { get; set; }
|
public int LanguageProfileId { get; set; }
|
||||||
|
public int MetadataProfileId { get; set; }
|
||||||
public List<Album> Albums { get; set; }
|
public List<Album> Albums { get; set; }
|
||||||
public HashSet<int> Tags { get; set; }
|
public HashSet<int> Tags { get; set; }
|
||||||
public AddArtistOptions AddOptions { get; set; }
|
public AddArtistOptions AddOptions { get; set; }
|
||||||
|
@ -73,10 +74,9 @@ namespace NzbDrone.Core.Music
|
||||||
|
|
||||||
Profile = otherArtist.Profile;
|
Profile = otherArtist.Profile;
|
||||||
LanguageProfileId = otherArtist.LanguageProfileId;
|
LanguageProfileId = otherArtist.LanguageProfileId;
|
||||||
|
MetadataProfileId = otherArtist.MetadataProfileId;
|
||||||
|
|
||||||
Albums = otherArtist.Albums;
|
Albums = otherArtist.Albums;
|
||||||
PrimaryAlbumTypes = otherArtist.PrimaryAlbumTypes;
|
|
||||||
SecondaryAlbumTypes = otherArtist.SecondaryAlbumTypes;
|
|
||||||
|
|
||||||
ProfileId = otherArtist.ProfileId;
|
ProfileId = otherArtist.ProfileId;
|
||||||
Tags = otherArtist.Tags;
|
Tags = otherArtist.Tags;
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Music
|
||||||
public void Handle(ArtistEditedEvent message)
|
public void Handle(ArtistEditedEvent message)
|
||||||
{
|
{
|
||||||
// Refresh Artist is we change AlbumType Preferences
|
// Refresh Artist is we change AlbumType Preferences
|
||||||
if (message.Artist.PrimaryAlbumTypes != message.OldArtist.PrimaryAlbumTypes || message.Artist.SecondaryAlbumTypes != message.OldArtist.SecondaryAlbumTypes)
|
if (message.Artist.LanguageProfileId != message.OldArtist.LanguageProfileId)
|
||||||
{
|
{
|
||||||
_commandQueueManager.Push(new RefreshArtistCommand(message.Artist.Id));
|
_commandQueueManager.Push(new RefreshArtistCommand(message.Artist.Id));
|
||||||
}
|
}
|
||||||
|
|
121
src/NzbDrone.Core/Music/PrimaryAlbumType.cs
Normal file
121
src/NzbDrone.Core/Music/PrimaryAlbumType.cs
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Music
|
||||||
|
{
|
||||||
|
public class PrimaryAlbumType : IEmbeddedDocument, IEquatable<PrimaryAlbumType>
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public PrimaryAlbumType()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private PrimaryAlbumType(int id, string name)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return Id.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(PrimaryAlbumType other)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(null, other))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (ReferenceEquals(this, other))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return Id.Equals(other.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(null, obj))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ReferenceEquals(this, obj) || Equals(obj as PrimaryAlbumType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(PrimaryAlbumType left, PrimaryAlbumType right)
|
||||||
|
{
|
||||||
|
return Equals(left, right);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(PrimaryAlbumType left, PrimaryAlbumType right)
|
||||||
|
{
|
||||||
|
return !Equals(left, right);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PrimaryAlbumType Album => new PrimaryAlbumType(0, "Album");
|
||||||
|
public static PrimaryAlbumType EP => new PrimaryAlbumType(1, "EP");
|
||||||
|
public static PrimaryAlbumType Single => new PrimaryAlbumType(2, "Single");
|
||||||
|
public static PrimaryAlbumType Broadcast => new PrimaryAlbumType(3, "Broadcast");
|
||||||
|
public static PrimaryAlbumType Other => new PrimaryAlbumType(4, "Other");
|
||||||
|
|
||||||
|
|
||||||
|
public static readonly List<PrimaryAlbumType> All = new List<PrimaryAlbumType>
|
||||||
|
{
|
||||||
|
Album,
|
||||||
|
EP,
|
||||||
|
Single,
|
||||||
|
Broadcast,
|
||||||
|
Other
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public static PrimaryAlbumType FindById(int id)
|
||||||
|
{
|
||||||
|
if (id == 0)
|
||||||
|
{
|
||||||
|
return Album;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrimaryAlbumType albumType = All.FirstOrDefault(v => v.Id == id);
|
||||||
|
|
||||||
|
if (albumType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException(@"ID does not match a known album type", nameof(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
return albumType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static explicit operator PrimaryAlbumType(int id)
|
||||||
|
{
|
||||||
|
return FindById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static explicit operator int(PrimaryAlbumType albumType)
|
||||||
|
{
|
||||||
|
return albumType.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static explicit operator PrimaryAlbumType(string type)
|
||||||
|
{
|
||||||
|
var albumType = All.FirstOrDefault(v => v.Name.Equals(type, StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
|
||||||
|
if (albumType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException(@"Type does not match a known album type", nameof(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
return albumType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,7 +39,6 @@ namespace NzbDrone.Core.Music
|
||||||
var failCount = 0;
|
var failCount = 0;
|
||||||
|
|
||||||
var existingAlbums = _albumService.GetAlbumsByArtist(artist.Id);
|
var existingAlbums = _albumService.GetAlbumsByArtist(artist.Id);
|
||||||
var albums = artist.Albums;
|
|
||||||
|
|
||||||
var updateList = new List<Album>();
|
var updateList = new List<Album>();
|
||||||
var newList = new List<Album>();
|
var newList = new List<Album>();
|
||||||
|
@ -79,6 +78,7 @@ namespace NzbDrone.Core.Music
|
||||||
albumToUpdate.CleanTitle = Parser.Parser.CleanArtistName(albumToUpdate.Title);
|
albumToUpdate.CleanTitle = Parser.Parser.CleanArtistName(albumToUpdate.Title);
|
||||||
albumToUpdate.ArtistId = artist.Id;
|
albumToUpdate.ArtistId = artist.Id;
|
||||||
albumToUpdate.AlbumType = album.AlbumType;
|
albumToUpdate.AlbumType = album.AlbumType;
|
||||||
|
albumToUpdate.SecondaryTypes = album.SecondaryTypes;
|
||||||
albumToUpdate.Genres = album.Genres;
|
albumToUpdate.Genres = album.Genres;
|
||||||
albumToUpdate.Media = album.Media;
|
albumToUpdate.Media = album.Media;
|
||||||
albumToUpdate.Label = album.Label;
|
albumToUpdate.Label = album.Label;
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace NzbDrone.Core.Music
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tuple = _artistInfo.GetArtistInfo(artist.ForeignArtistId, artist.PrimaryAlbumTypes, artist.SecondaryAlbumTypes);
|
tuple = _artistInfo.GetArtistInfo(artist.ForeignArtistId, artist.MetadataProfileId);
|
||||||
}
|
}
|
||||||
catch (ArtistNotFoundException)
|
catch (ArtistNotFoundException)
|
||||||
{
|
{
|
||||||
|
|
131
src/NzbDrone.Core/Music/SecondaryAlbumType.cs
Normal file
131
src/NzbDrone.Core/Music/SecondaryAlbumType.cs
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Music
|
||||||
|
{
|
||||||
|
public class SecondaryAlbumType : IEmbeddedDocument, IEquatable<SecondaryAlbumType>
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public SecondaryAlbumType()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private SecondaryAlbumType(int id, string name)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return Id.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(SecondaryAlbumType other)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(null, other))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (ReferenceEquals(this, other))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return Id.Equals(other.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(null, obj))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ReferenceEquals(this, obj) || Equals(obj as SecondaryAlbumType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(SecondaryAlbumType left, SecondaryAlbumType right)
|
||||||
|
{
|
||||||
|
return Equals(left, right);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(SecondaryAlbumType left, SecondaryAlbumType right)
|
||||||
|
{
|
||||||
|
return !Equals(left, right);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SecondaryAlbumType Studio => new SecondaryAlbumType(0, "Studio");
|
||||||
|
public static SecondaryAlbumType Compilation => new SecondaryAlbumType(1, "Compilation");
|
||||||
|
public static SecondaryAlbumType Soundtrack => new SecondaryAlbumType(2, "Soundtrack");
|
||||||
|
public static SecondaryAlbumType Spokenword => new SecondaryAlbumType(3, "Spokenword");
|
||||||
|
public static SecondaryAlbumType Interview => new SecondaryAlbumType(4, "Interview");
|
||||||
|
public static SecondaryAlbumType Audiobook => new SecondaryAlbumType(5, "Audiobook");
|
||||||
|
public static SecondaryAlbumType Live => new SecondaryAlbumType(6, "Live");
|
||||||
|
public static SecondaryAlbumType Remix => new SecondaryAlbumType(7, "Remix");
|
||||||
|
public static SecondaryAlbumType DJMix => new SecondaryAlbumType(8, "DJ-Mix");
|
||||||
|
public static SecondaryAlbumType Mixtape => new SecondaryAlbumType(9, "Mixtape/Street");
|
||||||
|
public static SecondaryAlbumType Demo => new SecondaryAlbumType(10, "Demo");
|
||||||
|
|
||||||
|
|
||||||
|
public static readonly List<SecondaryAlbumType> All = new List<SecondaryAlbumType>
|
||||||
|
{
|
||||||
|
Studio,
|
||||||
|
Compilation,
|
||||||
|
Soundtrack,
|
||||||
|
Spokenword,
|
||||||
|
Interview,
|
||||||
|
Live,
|
||||||
|
Remix,
|
||||||
|
DJMix,
|
||||||
|
Mixtape
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public static SecondaryAlbumType FindById(int id)
|
||||||
|
{
|
||||||
|
if (id == 0)
|
||||||
|
{
|
||||||
|
return Studio;
|
||||||
|
}
|
||||||
|
|
||||||
|
SecondaryAlbumType albumType = All.FirstOrDefault(v => v.Id == id);
|
||||||
|
|
||||||
|
if (albumType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException(@"ID does not match a known album type", nameof(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
return albumType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static explicit operator SecondaryAlbumType(int id)
|
||||||
|
{
|
||||||
|
return FindById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static explicit operator int(SecondaryAlbumType albumType)
|
||||||
|
{
|
||||||
|
return albumType.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static explicit operator SecondaryAlbumType(string type)
|
||||||
|
{
|
||||||
|
var albumType = All.FirstOrDefault(v => v.Name.Equals(type, StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
|
||||||
|
if (albumType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException(@"Type does not match a known album type", nameof(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
return albumType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -150,6 +150,8 @@
|
||||||
<Compile Include="Datastore\Converters\DoubleConverter.cs" />
|
<Compile Include="Datastore\Converters\DoubleConverter.cs" />
|
||||||
<Compile Include="Datastore\Converters\EmbeddedDocumentConverter.cs" />
|
<Compile Include="Datastore\Converters\EmbeddedDocumentConverter.cs" />
|
||||||
<Compile Include="Datastore\Converters\EnumIntConverter.cs" />
|
<Compile Include="Datastore\Converters\EnumIntConverter.cs" />
|
||||||
|
<Compile Include="Datastore\Converters\SecondaryAlbumTypeIntConverter.cs" />
|
||||||
|
<Compile Include="Datastore\Converters\PrimaryAlbumTypeIntConverter.cs" />
|
||||||
<Compile Include="Datastore\Converters\LanguageIntConverter.cs" />
|
<Compile Include="Datastore\Converters\LanguageIntConverter.cs" />
|
||||||
<Compile Include="Datastore\Converters\TimeSpanConverter.cs" />
|
<Compile Include="Datastore\Converters\TimeSpanConverter.cs" />
|
||||||
<Compile Include="Datastore\Converters\Int32Converter.cs" />
|
<Compile Include="Datastore\Converters\Int32Converter.cs" />
|
||||||
|
@ -172,6 +174,7 @@
|
||||||
<Compile Include="Datastore\LogDatabase.cs" />
|
<Compile Include="Datastore\LogDatabase.cs" />
|
||||||
<Compile Include="Datastore\Migration\001_initial_setup.cs" />
|
<Compile Include="Datastore\Migration\001_initial_setup.cs" />
|
||||||
<Compile Include="Datastore\Migration\002_add_reason_to_pending_releases.cs" />
|
<Compile Include="Datastore\Migration\002_add_reason_to_pending_releases.cs" />
|
||||||
|
<Compile Include="Datastore\Migration\005_metadata_profiles.cs" />
|
||||||
<Compile Include="Datastore\Migration\004_add_various_qualities_in_profile.cs" />
|
<Compile Include="Datastore\Migration\004_add_various_qualities_in_profile.cs" />
|
||||||
<Compile Include="Datastore\Migration\003_add_medium_support.cs" />
|
<Compile Include="Datastore\Migration\003_add_medium_support.cs" />
|
||||||
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
|
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
|
||||||
|
@ -745,6 +748,8 @@
|
||||||
<Compile Include="Extras\Metadata\MetadataType.cs" />
|
<Compile Include="Extras\Metadata\MetadataType.cs" />
|
||||||
<Compile Include="Music\ArtistStatusType.cs" />
|
<Compile Include="Music\ArtistStatusType.cs" />
|
||||||
<Compile Include="Music\AlbumCutoffService.cs" />
|
<Compile Include="Music\AlbumCutoffService.cs" />
|
||||||
|
<Compile Include="Music\SecondaryAlbumType.cs" />
|
||||||
|
<Compile Include="Music\PrimaryAlbumType.cs" />
|
||||||
<Compile Include="Music\Links.cs" />
|
<Compile Include="Music\Links.cs" />
|
||||||
<Compile Include="Music\Commands\MoveArtistCommand.cs" />
|
<Compile Include="Music\Commands\MoveArtistCommand.cs" />
|
||||||
<Compile Include="Music\Events\ArtistMovedEvent.cs" />
|
<Compile Include="Music\Events\ArtistMovedEvent.cs" />
|
||||||
|
@ -863,6 +868,12 @@
|
||||||
<Compile Include="Profiles\Languages\LanguageProfileRepository.cs" />
|
<Compile Include="Profiles\Languages\LanguageProfileRepository.cs" />
|
||||||
<Compile Include="Profiles\Languages\LanguageProfileService.cs" />
|
<Compile Include="Profiles\Languages\LanguageProfileService.cs" />
|
||||||
<Compile Include="Profiles\Languages\ProfileLanguageItem.cs" />
|
<Compile Include="Profiles\Languages\ProfileLanguageItem.cs" />
|
||||||
|
<Compile Include="Profiles\Metadata\MetadataProfileService.cs" />
|
||||||
|
<Compile Include="Profiles\Metadata\MetadataProfileInUseException.cs" />
|
||||||
|
<Compile Include="Profiles\Metadata\MetadataProfile.cs" />
|
||||||
|
<Compile Include="Profiles\Metadata\MetadataProfileRepository.cs" />
|
||||||
|
<Compile Include="Profiles\Metadata\ProfileSecondaryAlbumTypeItem.cs" />
|
||||||
|
<Compile Include="Profiles\Metadata\ProfilePrimaryAlbumTypeItem.cs" />
|
||||||
<Compile Include="Profiles\Quality\ProfileRepository.cs" />
|
<Compile Include="Profiles\Quality\ProfileRepository.cs" />
|
||||||
<Compile Include="Profiles\Quality\QualityIndex.cs" />
|
<Compile Include="Profiles\Quality\QualityIndex.cs" />
|
||||||
<Compile Include="ProgressMessaging\ProgressMessageContext.cs" />
|
<Compile Include="ProgressMessaging\ProgressMessageContext.cs" />
|
||||||
|
|
14
src/NzbDrone.Core/Profiles/Metadata/MetadataProfile.cs
Normal file
14
src/NzbDrone.Core/Profiles/Metadata/MetadataProfile.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.Indexers;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Profiles.Metadata
|
||||||
|
{
|
||||||
|
public class MetadataProfile : ModelBase
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public List<ProfilePrimaryAlbumTypeItem> PrimaryAlbumTypes { get; set; }
|
||||||
|
public List<ProfileSecondaryAlbumTypeItem> SecondaryAlbumTypes { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
using NzbDrone.Common.Exceptions;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Profiles.Metadata
|
||||||
|
{
|
||||||
|
public class MetadataProfileInUseException : NzbDroneException
|
||||||
|
{
|
||||||
|
public MetadataProfileInUseException(int profileId)
|
||||||
|
: base("Metadata profile [{0}] is in use.", profileId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.Messaging.Events;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Profiles.Metadata
|
||||||
|
{
|
||||||
|
public interface IMetadataProfileRepository : IBasicRepository<MetadataProfile>
|
||||||
|
{
|
||||||
|
bool Exists(int id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MetadataProfileRepository : BasicRepository<MetadataProfile>, IMetadataProfileRepository
|
||||||
|
{
|
||||||
|
public MetadataProfileRepository(IMainDatabase database, IEventAggregator eventAggregator)
|
||||||
|
: base(database, eventAggregator)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Exists(int id)
|
||||||
|
{
|
||||||
|
return DataMapper.Query<MetadataProfile>().Where(p => p.Id == id).GetRowCount() == 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
102
src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs
Normal file
102
src/NzbDrone.Core/Profiles/Metadata/MetadataProfileService.cs
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
using NLog;
|
||||||
|
using NzbDrone.Core.Lifecycle;
|
||||||
|
using NzbDrone.Core.Messaging.Events;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Profiles.Metadata
|
||||||
|
{
|
||||||
|
public interface IMetadataProfileService
|
||||||
|
{
|
||||||
|
MetadataProfile Add(MetadataProfile profile);
|
||||||
|
void Update(MetadataProfile profile);
|
||||||
|
void Delete(int id);
|
||||||
|
List<MetadataProfile> All();
|
||||||
|
MetadataProfile Get(int id);
|
||||||
|
bool Exists(int id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MetadataProfileService : IMetadataProfileService, IHandle<ApplicationStartedEvent>
|
||||||
|
{
|
||||||
|
private readonly IMetadataProfileRepository _profileRepository;
|
||||||
|
private readonly IArtistService _artistService;
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
|
public MetadataProfileService(IMetadataProfileRepository profileRepository, IArtistService artistService, Logger logger)
|
||||||
|
{
|
||||||
|
_profileRepository = profileRepository;
|
||||||
|
_artistService = artistService;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetadataProfile Add(MetadataProfile profile)
|
||||||
|
{
|
||||||
|
return _profileRepository.Insert(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(MetadataProfile profile)
|
||||||
|
{
|
||||||
|
_profileRepository.Update(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(int id)
|
||||||
|
{
|
||||||
|
if (_artistService.GetAllArtists().Any(c => c.MetadataProfileId == id))
|
||||||
|
{
|
||||||
|
throw new MetadataProfileInUseException(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
_profileRepository.Delete(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MetadataProfile> All()
|
||||||
|
{
|
||||||
|
return _profileRepository.All().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetadataProfile Get(int id)
|
||||||
|
{
|
||||||
|
return _profileRepository.Get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Exists(int id)
|
||||||
|
{
|
||||||
|
return _profileRepository.Exists(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddDefaultProfile(string name, List<PrimaryAlbumType> primAllowed, List<SecondaryAlbumType> secAllowed)
|
||||||
|
{
|
||||||
|
var primaryTypes = PrimaryAlbumType.All
|
||||||
|
.OrderByDescending(l => l.Name)
|
||||||
|
.Select(v => new ProfilePrimaryAlbumTypeItem { PrimaryAlbumType = v, Allowed = primAllowed.Contains(v) })
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var secondaryTypes = SecondaryAlbumType.All
|
||||||
|
.OrderByDescending(l => l.Name)
|
||||||
|
.Select(v => new ProfileSecondaryAlbumTypeItem { SecondaryAlbumType = v, Allowed = secAllowed.Contains(v) })
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var profile = new MetadataProfile
|
||||||
|
{
|
||||||
|
Name = name,
|
||||||
|
PrimaryAlbumTypes = primaryTypes,
|
||||||
|
SecondaryAlbumTypes = secondaryTypes
|
||||||
|
};
|
||||||
|
|
||||||
|
Add(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Handle(ApplicationStartedEvent message)
|
||||||
|
{
|
||||||
|
if (All().Any())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Info("Setting up default metadata profile");
|
||||||
|
|
||||||
|
AddDefaultProfile("Standard", new List<PrimaryAlbumType>{PrimaryAlbumType.Album}, new List<SecondaryAlbumType>{ SecondaryAlbumType.Studio });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Profiles.Metadata
|
||||||
|
{
|
||||||
|
public class ProfilePrimaryAlbumTypeItem : IEmbeddedDocument
|
||||||
|
{
|
||||||
|
public PrimaryAlbumType PrimaryAlbumType { get; set; }
|
||||||
|
public bool Allowed { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Profiles.Metadata
|
||||||
|
{
|
||||||
|
public class ProfileSecondaryAlbumTypeItem : IEmbeddedDocument
|
||||||
|
{
|
||||||
|
public SecondaryAlbumType SecondaryAlbumType { get; set; }
|
||||||
|
public bool Allowed { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue