From 1f483c3a3c25fa368bae91eacb1a883bc5655b29 Mon Sep 17 00:00:00 2001 From: ta264 Date: Tue, 5 Mar 2019 01:16:56 +0000 Subject: [PATCH] Add options to expand album types by default (#644) * Add options to expand album types by default * Remove isAfter and simplify slightly * Fix display of settings on large screens --- .../src/Artist/Details/ArtistDetailsSeason.js | 19 ++++---- .../Details/ArtistDetailsSeasonConnector.js | 7 ++- frontend/src/Settings/UI/UISettings.css | 3 ++ frontend/src/Settings/UI/UISettings.js | 46 +++++++++++++++++++ src/Lidarr.Api.V1/Config/UiConfigResource.cs | 12 +++++ .../Configuration/ConfigService.cs | 35 ++++++++++++++ .../Configuration/IConfigService.cs | 6 +++ 7 files changed, 118 insertions(+), 10 deletions(-) create mode 100644 frontend/src/Settings/UI/UISettings.css diff --git a/frontend/src/Artist/Details/ArtistDetailsSeason.js b/frontend/src/Artist/Details/ArtistDetailsSeason.js index f3d105dc0..aeeaf6529 100644 --- a/frontend/src/Artist/Details/ArtistDetailsSeason.js +++ b/frontend/src/Artist/Details/ArtistDetailsSeason.js @@ -1,7 +1,6 @@ import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import isAfter from 'Utilities/Date/isAfter'; import getToggledRange from 'Utilities/Table/getToggledRange'; import { icons, sortDirections } from 'Helpers/Props'; import Icon from 'Components/Icon'; @@ -51,13 +50,16 @@ class ArtistDetailsSeason extends Component { const { name, onExpandPress, - items + items, + uiSettings } = this.props; - const expand = _.some(items, (item) => { - return isAfter(item.releaseDate) || - isAfter(item.releaseDate, { days: -365 }); - }); + const expand = _.some(items, (item) => + ((item.albumType === 'Album') && uiSettings.expandAlbumByDefault) || + ((item.albumType === 'Single') && uiSettings.expandSingleByDefault) || + ((item.albumType === 'EP') && uiSettings.expandEPByDefault) || + ((item.albumType === 'Broadcast') && uiSettings.expandBroadcastByDefault) || + ((item.albumType === 'Other') && uiSettings.expandOtherByDefault)); onExpandPress(name, expand); } @@ -199,7 +201,7 @@ class ArtistDetailsSeason extends Component { :
- No albums in this group + No releases in this group
}
@@ -243,7 +245,8 @@ ArtistDetailsSeason.propTypes = { onTableOptionChange: PropTypes.func.isRequired, onExpandPress: PropTypes.func.isRequired, onSortPress: PropTypes.func.isRequired, - onMonitorAlbumPress: PropTypes.func.isRequired + onMonitorAlbumPress: PropTypes.func.isRequired, + uiSettings: PropTypes.object.isRequired }; export default ArtistDetailsSeason; diff --git a/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js b/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js index 21e25a67d..ffb84ba2c 100644 --- a/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js +++ b/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js @@ -8,6 +8,7 @@ import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; import createArtistSelector from 'Store/Selectors/createArtistSelector'; import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createClientSideCollectionSelector from 'Store/Selectors/createClientSideCollectionSelector'; +import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; import { toggleAlbumsMonitored, setAlbumsTableOption, setAlbumsSort } from 'Store/Actions/albumActions'; import { executeCommand } from 'Store/Actions/commandActions'; import ArtistDetailsSeason from './ArtistDetailsSeason'; @@ -19,7 +20,8 @@ function createMapStateToProps() { createArtistSelector(), createCommandsSelector(), createDimensionsSelector(), - (label, albums, artist, commands, dimensions) => { + createUISettingsSelector(), + (label, albums, artist, commands, dimensions, uiSettings) => { const albumsInGroup = _.filter(albums.items, { albumType: label }); @@ -37,7 +39,8 @@ function createMapStateToProps() { sortKey: albums.sortKey, sortDirection: albums.sortDirection, artistMonitored: artist.monitored, - isSmallScreen: dimensions.isSmallScreen + isSmallScreen: dimensions.isSmallScreen, + uiSettings }; } ); diff --git a/frontend/src/Settings/UI/UISettings.css b/frontend/src/Settings/UI/UISettings.css new file mode 100644 index 000000000..2e6213823 --- /dev/null +++ b/frontend/src/Settings/UI/UISettings.css @@ -0,0 +1,3 @@ +.columnGroup { + flex-direction: column; +} diff --git a/frontend/src/Settings/UI/UISettings.js b/frontend/src/Settings/UI/UISettings.js index 71356a5f0..dc249487c 100644 --- a/frontend/src/Settings/UI/UISettings.js +++ b/frontend/src/Settings/UI/UISettings.js @@ -10,6 +10,7 @@ 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 styles from './UISettings.css'; export const firstDayOfWeekOptions = [ { key: 0, value: 'Sunday' }, @@ -173,6 +174,51 @@ class UISettings extends Component { {...settings.enableColorImpairedMode} /> + + + Expand Items by Default +
+ + + + + + + + + +
+
} diff --git a/src/Lidarr.Api.V1/Config/UiConfigResource.cs b/src/Lidarr.Api.V1/Config/UiConfigResource.cs index 6f66a1166..e04ab7c6a 100644 --- a/src/Lidarr.Api.V1/Config/UiConfigResource.cs +++ b/src/Lidarr.Api.V1/Config/UiConfigResource.cs @@ -16,6 +16,12 @@ namespace Lidarr.Api.V1.Config public bool ShowRelativeDates { get; set; } public bool EnableColorImpairedMode { get; set; } + + public bool ExpandAlbumByDefault { get; set; } + public bool ExpandSingleByDefault { get; set; } + public bool ExpandEPByDefault { get; set; } + public bool ExpandBroadcastByDefault { get; set; } + public bool ExpandOtherByDefault { get; set; } } public static class UiConfigResourceMapper @@ -33,6 +39,12 @@ namespace Lidarr.Api.V1.Config ShowRelativeDates = model.ShowRelativeDates, EnableColorImpairedMode = model.EnableColorImpairedMode, + + ExpandAlbumByDefault = model.ExpandAlbumByDefault, + ExpandSingleByDefault = model.ExpandSingleByDefault, + ExpandEPByDefault = model.ExpandEPByDefault, + ExpandBroadcastByDefault = model.ExpandBroadcastByDefault, + ExpandOtherByDefault = model.ExpandOtherByDefault }; } } diff --git a/src/NzbDrone.Core/Configuration/ConfigService.cs b/src/NzbDrone.Core/Configuration/ConfigService.cs index e446f2f0a..be5765be4 100644 --- a/src/NzbDrone.Core/Configuration/ConfigService.cs +++ b/src/NzbDrone.Core/Configuration/ConfigService.cs @@ -314,6 +314,41 @@ namespace NzbDrone.Core.Configuration set { SetValue("EnableColorImpairedMode", value); } } + public bool ExpandAlbumByDefault + { + get { return GetValueBoolean("ExpandAlbumByDefault", false); } + + set { SetValue("ExpandAlbumByDefault", value); } + } + + public bool ExpandEPByDefault + { + get { return GetValueBoolean("ExpandEPByDefault", false); } + + set { SetValue("ExpandEPByDefault", value); } + } + + public bool ExpandSingleByDefault + { + get { return GetValueBoolean("ExpandSingleByDefault", false); } + + set { SetValue("ExpandSingleByDefault", value); } + } + + public bool ExpandBroadcastByDefault + { + get { return GetValueBoolean("ExpandBroadcastByDefault", false); } + + set { SetValue("ExpandBroadcastByDefault", value); } + } + + public bool ExpandOtherByDefault + { + get { return GetValueBoolean("ExpandOtherByDefault", false); } + + set { SetValue("ExpandOtherByDefault", value); } + } + public bool CleanupMetadataImages { get { return GetValueBoolean("CleanupMetadataImages", true); } diff --git a/src/NzbDrone.Core/Configuration/IConfigService.cs b/src/NzbDrone.Core/Configuration/IConfigService.cs index f23d226db..3ba61b2ad 100644 --- a/src/NzbDrone.Core/Configuration/IConfigService.cs +++ b/src/NzbDrone.Core/Configuration/IConfigService.cs @@ -57,6 +57,12 @@ namespace NzbDrone.Core.Configuration string TimeFormat { get; set; } bool ShowRelativeDates { get; set; } bool EnableColorImpairedMode { get; set; } + + bool ExpandAlbumByDefault { get; set; } + bool ExpandSingleByDefault { get; set; } + bool ExpandEPByDefault { get; set; } + bool ExpandBroadcastByDefault { get; set; } + bool ExpandOtherByDefault { get; set; } //Internal bool CleanupMetadataImages { get; set; }