You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/frontend/src/Store/Actions/artistIndexActions.js

440 lines
10 KiB

import { createAction } from 'redux-actions';
import { filterBuilderTypes, filterBuilderValueTypes, filterTypePredicates, sortDirections } from 'Helpers/Props';
4 years ago
import sortByName from 'Utilities/Array/sortByName';
import translate from 'Utilities/String/translate';
4 years ago
import { filterPredicates, filters, sortPredicates } from './artistActions';
import createHandleActions from './Creators/createHandleActions';
4 years ago
import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer';
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer';
//
// Variables
export const section = 'artistIndex';
//
// State
export const defaultState = {
sortKey: 'sortName',
sortDirection: sortDirections.ASCENDING,
secondarySortKey: 'sortName',
secondarySortDirection: sortDirections.ASCENDING,
view: 'posters',
posterOptions: {
detailedProgressBar: false,
size: 'large',
showTitle: true,
showMonitored: true,
showQualityProfile: true,
showNextAlbum: true,
showSearchAction: false
},
bannerOptions: {
detailedProgressBar: false,
size: 'large',
showTitle: false,
showMonitored: true,
showQualityProfile: true,
showNextAlbum: true,
showSearchAction: false
},
overviewOptions: {
detailedProgressBar: false,
size: 'medium',
showMonitored: true,
showQualityProfile: true,
showLastAlbum: false,
showAdded: false,
showAlbumCount: true,
showPath: false,
showSizeOnDisk: false,
showSearchAction: false
},
tableOptions: {
showBanners: false,
showSearchAction: false
},
columns: [
{
name: 'status',
columnLabel: () => translate('Status'),
isSortable: true,
isVisible: true,
isModifiable: false
},
{
name: 'sortName',
label: () => translate('ArtistName'),
isSortable: true,
isVisible: true,
isModifiable: false
},
{
name: 'artistType',
label: () => translate('Type'),
isSortable: true,
Whole album matching and fingerprinting (#592) * Cache result of GetAllArtists * Fixed: Manual import not respecting album import notifications * Fixed: partial album imports stay in queue, prompting manual import * Fixed: Allow release if tracks are missing * Fixed: Be tolerant of missing/extra "The" at start of artist name * Improve manual import UI * Omit video tracks from DB entirely * Revert "faster test packaging in build.sh" This reverts commit 2723e2a7b86bcbff9051fd2aced07dd807b4bcb7. -u and -T are not supported on macOS * Fix tests on linux and macOS * Actually lint on linux On linux yarn runs scripts with sh not bash so ** doesn't recursively glob * Match whole albums * Option to disable fingerprinting * Rip out MediaInfo * Don't split up things that have the same album selected in manual import * Try to speed up IndentificationService * More speedups * Some fixes and increase power of recording id * Fix NRE when no tags * Fix NRE when some (but not all) files in a directory have missing tags * Bump taglib, tidy up tag parsing * Add a health check * Remove media info setting * Tags -> audioTags * Add some tests where tags are null * Rename history events * Add missing method to interface * Reinstate MediaInfo tags and update info with artist scan Also adds migration to remove old format media info * This file no longer exists * Don't penalise year if missing from tags * Formatting improvements * Use correct system newline * Switch to the netstandard2.0 library to support net 461 * TagLib.File is IDisposable so should be in a using * Improve filename matching and add tests * Neater logging of parsed tags * Fix disk scan tests for new media info update * Fix quality detection source * Fix Inexact Artist/Album match * Add button to clear track mapping * Fix warning * Pacify eslint * Use \ not / * Fix UI updates * Fix media covers Prevent localizing URL propaging back to the metadata object * Reduce database overhead broadcasting UI updates * Relax timings a bit to make test pass * Remove irrelevant tests * Test framework for identification service * Fix PreferMissingToBadMatch test case * Make fingerprinting more robust * More logging * Penalize unknown media format and country * Prefer USA to UK * Allow Data CD * Fix exception if fingerprinting fails for all files * Fix tests * Fix NRE * Allow apostrophes and remove accents in filename aggregation * Address codacy issues * Cope with old versions of fpcalc and suggest upgrade * fpcalc health check passes if fingerprinting disabled * Get the Artist meta with the artist * Fix the mapper so that lazy loaded lists will be populated on Join And therefore we can join TrackFiles on Tracks by default and avoid an extra query * Rename subtitle -> lyric * Tidy up MediaInfoFormatter
5 years ago
isVisible: true
},
{
name: 'qualityProfileId',
label: () => translate('QualityProfile'),
isSortable: true,
isVisible: true
},
{
name: 'metadataProfileId',
label: () => translate('MetadataProfile'),
isSortable: true,
isVisible: false
},
{
name: 'monitorNewItems',
label: () => translate('MonitorNewItems'),
isSortable: true,
isVisible: false
},
{
name: 'nextAlbum',
label: () => translate('NextAlbum'),
isSortable: true,
isVisible: true
},
{
name: 'lastAlbum',
label: () => translate('LastAlbum'),
isSortable: true,
isVisible: false
},
{
name: 'added',
label: () => translate('Added'),
isSortable: true,
isVisible: false
},
{
name: 'albumCount',
label: () => translate('Albums'),
isSortable: true,
isVisible: true
},
{
name: 'trackProgress',
label: () => translate('Tracks'),
isSortable: true,
isVisible: true
},
{
name: 'trackCount',
label: () => translate('TrackCount'),
isSortable: true,
isVisible: false
},
{
name: 'path',
label: () => translate('Path'),
isSortable: true,
isVisible: false
},
{
name: 'sizeOnDisk',
label: () => translate('SizeOnDisk'),
isSortable: true,
isVisible: false
},
{
name: 'genres',
label: () => translate('Genres'),
isSortable: false,
isVisible: false
},
{
name: 'ratings',
label: () => translate('Rating'),
isSortable: true,
isVisible: false
},
{
name: 'tags',
label: () => translate('Tags'),
isSortable: true,
isVisible: false
},
{
name: 'actions',
columnLabel: () => translate('Actions'),
isVisible: true,
isModifiable: false
}
],
sortPredicates: {
...sortPredicates,
trackProgress: function(item) {
const { statistics = {} } = item;
const {
trackCount = 0,
trackFileCount = 0
} = statistics;
const progress = trackCount ? trackFileCount / trackCount * 100 : 100;
return progress + trackCount / 1000000;
},
nextAlbum: function(item) {
if (item.nextAlbum) {
return item.nextAlbum.releaseDate;
}
return '1/1/1000';
},
lastAlbum: function(item) {
if (item.lastAlbum) {
return item.lastAlbum.releaseDate;
}
return '1/1/1000';
},
albumCount: function(item) {
const { statistics = {} } = item;
return statistics.albumCount || 0;
},
trackCount: function(item) {
const { statistics = {} } = item;
return statistics.totalTrackCount || 0;
},
ratings: function(item) {
const { ratings = {} } = item;
return ratings.value;
}
},
selectedFilterKey: 'all',
filters,
filterPredicates: {
...filterPredicates,
trackProgress: function(item, filterValue, type) {
const { statistics = {} } = item;
const {
trackCount = 0,
trackFileCount = 0
} = statistics;
const progress = trackCount ?
trackFileCount / trackCount * 100 :
100;
const predicate = filterTypePredicates[type];
return predicate(progress, filterValue);
}
},
filterBuilderProps: [
{
name: 'monitored',
label: () => translate('Monitored'),
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.BOOL
},
{
name: 'status',
label: () => translate('Status'),
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.ARTIST_STATUS
},
{
name: 'qualityProfileId',
label: () => translate('QualityProfile'),
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.QUALITY_PROFILE
},
{
name: 'metadataProfileId',
label: () => translate('MetadataProfile'),
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.METADATA_PROFILE
},
{
name: 'monitorNewItems',
label: () => translate('MonitorNewItems'),
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.MONITOR_NEW_ITEMS
},
{
name: 'nextAlbum',
label: () => translate('NextAlbum'),
type: filterBuilderTypes.DATE,
valueType: filterBuilderValueTypes.DATE
},
{
name: 'lastAlbum',
label: () => translate('LastAlbum'),
type: filterBuilderTypes.DATE,
valueType: filterBuilderValueTypes.DATE
},
{
name: 'added',
label: () => translate('Added'),
type: filterBuilderTypes.DATE,
valueType: filterBuilderValueTypes.DATE
},
{
name: 'albumCount',
label: () => translate('AlbumCount'),
type: filterBuilderTypes.NUMBER
},
{
name: 'trackProgress',
label: () => translate('TrackProgress'),
type: filterBuilderTypes.NUMBER
},
{
name: 'path',
label: () => translate('Path'),
type: filterBuilderTypes.STRING
},
{
name: 'sizeOnDisk',
label: () => translate('SizeOnDisk'),
type: filterBuilderTypes.NUMBER,
valueType: filterBuilderValueTypes.BYTES
},
{
name: 'genres',
label: () => translate('Genres'),
type: filterBuilderTypes.ARRAY,
optionsSelector: function(items) {
const tagList = items.reduce((acc, artist) => {
artist.genres.forEach((genre) => {
acc.push({
id: genre,
name: genre
});
});
return acc;
}, []);
return tagList.sort(sortByName);
}
},
{
name: 'ratings',
label: () => translate('Rating'),
type: filterBuilderTypes.NUMBER
},
{
name: 'tags',
label: () => translate('Tags'),
type: filterBuilderTypes.ARRAY,
valueType: filterBuilderValueTypes.TAG
}
]
};
export const persistState = [
'artistIndex.sortKey',
'artistIndex.sortDirection',
'artistIndex.selectedFilterKey',
'artistIndex.customFilters',
'artistIndex.view',
'artistIndex.columns',
'artistIndex.posterOptions',
'artistIndex.bannerOptions',
'artistIndex.overviewOptions',
'artistIndex.tableOptions'
];
//
// Actions Types
export const SET_ARTIST_SORT = 'artistIndex/setArtistSort';
export const SET_ARTIST_FILTER = 'artistIndex/setArtistFilter';
export const SET_ARTIST_VIEW = 'artistIndex/setArtistView';
export const SET_ARTIST_TABLE_OPTION = 'artistIndex/setArtistTableOption';
export const SET_ARTIST_POSTER_OPTION = 'artistIndex/setArtistPosterOption';
export const SET_ARTIST_BANNER_OPTION = 'artistIndex/setArtistBannerOption';
export const SET_ARTIST_OVERVIEW_OPTION = 'artistIndex/setArtistOverviewOption';
//
// Action Creators
export const setArtistSort = createAction(SET_ARTIST_SORT);
export const setArtistFilter = createAction(SET_ARTIST_FILTER);
export const setArtistView = createAction(SET_ARTIST_VIEW);
export const setArtistTableOption = createAction(SET_ARTIST_TABLE_OPTION);
export const setArtistPosterOption = createAction(SET_ARTIST_POSTER_OPTION);
export const setArtistBannerOption = createAction(SET_ARTIST_BANNER_OPTION);
export const setArtistOverviewOption = createAction(SET_ARTIST_OVERVIEW_OPTION);
//
// Reducers
export const reducers = createHandleActions({
[SET_ARTIST_SORT]: createSetClientSideCollectionSortReducer(section),
[SET_ARTIST_FILTER]: createSetClientSideCollectionFilterReducer(section),
[SET_ARTIST_VIEW]: function(state, { payload }) {
return Object.assign({}, state, { view: payload.view });
},
[SET_ARTIST_TABLE_OPTION]: createSetTableOptionReducer(section),
[SET_ARTIST_POSTER_OPTION]: function(state, { payload }) {
const posterOptions = state.posterOptions;
return {
...state,
posterOptions: {
...posterOptions,
...payload
}
};
},
[SET_ARTIST_BANNER_OPTION]: function(state, { payload }) {
const bannerOptions = state.bannerOptions;
return {
...state,
bannerOptions: {
...bannerOptions,
...payload
}
};
},
[SET_ARTIST_OVERVIEW_OPTION]: function(state, { payload }) {
const overviewOptions = state.overviewOptions;
return {
...state,
overviewOptions: {
...overviewOptions,
...payload
}
};
}
}, defaultState, section);