Renames in Frontend

This commit is contained in:
Qstick
2020-05-15 23:32:52 -04:00
committed by ta264
parent ee4e44b81a
commit ee43ccf620
387 changed files with 4036 additions and 4364 deletions
@@ -1,8 +1,8 @@
import createAjaxRequest from 'Utilities/createAjaxRequest';
import updateAlbums from 'Utilities/Album/updateAlbums';
import updateBooks from 'Utilities/Book/updateBooks';
import getSectionState from 'Utilities/State/getSectionState';
function createBatchToggleAlbumMonitoredHandler(section, fetchHandler) {
function createBatchToggleBookMonitoredHandler(section, fetchHandler) {
return function(getState, payload, dispatch) {
const {
bookIds,
@@ -11,19 +11,19 @@ function createBatchToggleAlbumMonitoredHandler(section, fetchHandler) {
const state = getSectionState(getState(), section, true);
dispatch(updateAlbums(section, state.items, bookIds, {
dispatch(updateBooks(section, state.items, bookIds, {
isSaving: true
}));
const promise = createAjaxRequest({
url: '/album/monitor',
url: '/book/monitor',
method: 'PUT',
data: JSON.stringify({ bookIds, monitored }),
dataType: 'json'
}).request;
promise.done(() => {
dispatch(updateAlbums(section, state.items, bookIds, {
dispatch(updateBooks(section, state.items, bookIds, {
isSaving: false,
monitored
}));
@@ -32,11 +32,11 @@ function createBatchToggleAlbumMonitoredHandler(section, fetchHandler) {
});
promise.fail(() => {
dispatch(updateAlbums(section, state.items, bookIds, {
dispatch(updateBooks(section, state.items, bookIds, {
isSaving: false
}));
});
};
}
export default createBatchToggleAlbumMonitoredHandler;
export default createBatchToggleBookMonitoredHandler;
@@ -108,7 +108,7 @@ export default {
[SELECT_IMPORT_LIST_SCHEMA]: (state, { payload }) => {
return selectProviderSchema(state, section, payload, (selectedSchema) => {
selectedSchema.enableAutomaticAdd = true;
selectedSchema.shouldMonitor = 'entireArtist';
selectedSchema.shouldMonitor = 'entireAuthor';
return selectedSchema;
});
@@ -15,7 +15,7 @@ import { updateItem } from './baseActions';
//
// Variables
export const section = 'artist';
export const section = 'authors';
export const filters = [
{
@@ -69,7 +69,7 @@ export const filters = [
},
{
key: 'missing',
label: 'Missing Tracks',
label: 'Missing Books',
filters: [
{
key: 'missing',
@@ -84,15 +84,15 @@ export const filterPredicates = {
missing: function(item) {
const { statistics = {} } = item;
return statistics.trackCount - statistics.trackFileCount > 0;
return statistics.bookCount - statistics.bookFileCount > 0;
},
nextAlbum: function(item, filterValue, type) {
return dateFilterPredicate(item.nextAlbum, filterValue, type);
nextBook: function(item, filterValue, type) {
return dateFilterPredicate(item.nextBook, filterValue, type);
},
lastAlbum: function(item, filterValue, type) {
return dateFilterPredicate(item.lastAlbum, filterValue, type);
lastBook: function(item, filterValue, type) {
return dateFilterPredicate(item.lastBook, filterValue, type);
},
added: function(item, filterValue, type) {
@@ -105,11 +105,11 @@ export const filterPredicates = {
return predicate(item.ratings.value * 10, filterValue);
},
albumCount: function(item, filterValue, type) {
bookCount: function(item, filterValue, type) {
const predicate = filterTypePredicates[type];
const albumCount = item.statistics ? item.statistics.albumCount : 0;
const bookCount = item.statistics ? item.statistics.bookCount : 0;
return predicate(albumCount, filterValue);
return predicate(bookCount, filterValue);
},
sizeOnDisk: function(item, filterValue, type) {
@@ -154,19 +154,19 @@ export const defaultState = {
//
// Actions Types
export const FETCH_ARTIST = 'artist/fetchArtist';
export const SET_ARTIST_VALUE = 'artist/setArtistValue';
export const SAVE_ARTIST = 'artist/saveArtist';
export const DELETE_ARTIST = 'artist/deleteArtist';
export const FETCH_AUTHOR = 'authors/fetchAuthor';
export const SET_AUTHOR_VALUE = 'authors/setAuthorValue';
export const SAVE_AUTHOR = 'authors/saveAuthor';
export const DELETE_AUTHOR = 'authors/deleteAuthor';
export const TOGGLE_ARTIST_MONITORED = 'artist/toggleArtistMonitored';
export const TOGGLE_ALBUM_MONITORED = 'artist/toggleAlbumMonitored';
export const TOGGLE_AUTHOR_MONITORED = 'authors/toggleAuthorMonitored';
export const TOGGLE_BOOK_MONITORED = 'authors/toggleBookMonitored';
//
// Action Creators
export const fetchArtist = createThunk(FETCH_ARTIST);
export const saveArtist = createThunk(SAVE_ARTIST, (payload) => {
export const fetchAuthor = createThunk(FETCH_AUTHOR);
export const saveAuthor = createThunk(SAVE_AUTHOR, (payload) => {
const newPayload = {
...payload
};
@@ -182,7 +182,7 @@ export const saveArtist = createThunk(SAVE_ARTIST, (payload) => {
return newPayload;
});
export const deleteArtist = createThunk(DELETE_ARTIST, (payload) => {
export const deleteAuthor = createThunk(DELETE_AUTHOR, (payload) => {
return {
...payload,
queryParams: {
@@ -192,10 +192,10 @@ export const deleteArtist = createThunk(DELETE_ARTIST, (payload) => {
};
});
export const toggleArtistMonitored = createThunk(TOGGLE_ARTIST_MONITORED);
export const toggleAlbumMonitored = createThunk(TOGGLE_ALBUM_MONITORED);
export const toggleAuthorMonitored = createThunk(TOGGLE_AUTHOR_MONITORED);
export const toggleBookMonitored = createThunk(TOGGLE_BOOK_MONITORED);
export const setArtistValue = createAction(SET_ARTIST_VALUE, (payload) => {
export const setAuthorValue = createAction(SET_AUTHOR_VALUE, (payload) => {
return {
section,
...payload
@@ -218,17 +218,17 @@ function getSaveAjaxOptions({ ajaxOptions, payload }) {
export const actionHandlers = handleThunks({
[FETCH_ARTIST]: createFetchHandler(section, '/artist'),
[SAVE_ARTIST]: createSaveProviderHandler(section, '/artist', { getAjaxOptions: getSaveAjaxOptions }),
[DELETE_ARTIST]: createRemoveItemHandler(section, '/artist'),
[FETCH_AUTHOR]: createFetchHandler(section, '/author'),
[SAVE_AUTHOR]: createSaveProviderHandler(section, '/author', { getAjaxOptions: getSaveAjaxOptions }),
[DELETE_AUTHOR]: createRemoveItemHandler(section, '/author'),
[TOGGLE_ARTIST_MONITORED]: (getState, payload, dispatch) => {
[TOGGLE_AUTHOR_MONITORED]: (getState, payload, dispatch) => {
const {
authorId: id,
monitored
} = payload;
const artist = _.find(getState().artist.items, { id });
const author = _.find(getState().authors.items, { id });
dispatch(updateItem({
id,
@@ -237,10 +237,10 @@ export const actionHandlers = handleThunks({
}));
const promise = createAjaxRequest({
url: `/artist/${id}`,
url: `/author/${id}`,
method: 'PUT',
data: JSON.stringify({
...artist,
...author,
monitored
}),
dataType: 'json'
@@ -264,15 +264,15 @@ export const actionHandlers = handleThunks({
});
},
[TOGGLE_ALBUM_MONITORED]: function(getState, payload, dispatch) {
[TOGGLE_BOOK_MONITORED]: function(getState, payload, dispatch) {
const {
authorId: id,
seasonNumber,
monitored
} = payload;
const artist = _.find(getState().artist.items, { id });
const seasons = _.cloneDeep(artist.seasons);
const author = _.find(getState().authors.items, { id });
const seasons = _.cloneDeep(author.seasons);
const season = _.find(seasons, { seasonNumber });
season.isSaving = true;
@@ -286,17 +286,17 @@ export const actionHandlers = handleThunks({
season.monitored = monitored;
const promise = createAjaxRequest({
url: `/artist/${id}`,
url: `/author/${id}`,
method: 'PUT',
data: JSON.stringify({
...artist,
...author,
seasons
}),
dataType: 'json'
}).request;
promise.done((data) => {
const albums = _.filter(getState().albums.items, { authorId: id, seasonNumber });
const books = _.filter(getState().books.items, { authorId: id, seasonNumber });
dispatch(batchActions([
updateItem({
@@ -305,10 +305,10 @@ export const actionHandlers = handleThunks({
...data
}),
...albums.map((album) => {
...books.map((book) => {
return updateItem({
id: album.id,
section: 'albums',
id: book.id,
section: 'books',
monitored
});
})
@@ -319,7 +319,7 @@ export const actionHandlers = handleThunks({
dispatch(updateItem({
id,
section,
seasons: artist.seasons
seasons: author.seasons
}));
});
}
@@ -331,6 +331,6 @@ export const actionHandlers = handleThunks({
export const reducers = createHandleActions({
[SET_ARTIST_VALUE]: createSetSettingValueReducer(section)
[SET_AUTHOR_VALUE]: createSetSettingValueReducer(section)
}, defaultState, section);
@@ -7,12 +7,12 @@ import createSetClientSideCollectionSortReducer from './Creators/Reducers/create
import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer';
import createHandleActions from './Creators/createHandleActions';
import { set, updateItem } from './baseActions';
import { filters, filterPredicates, sortPredicates } from './artistActions';
import { filters, filterPredicates, sortPredicates } from './authorActions';
//
// Variables
export const section = 'artistEditor';
export const section = 'authorEditor';
//
// State
@@ -41,7 +41,7 @@ export const defaultState = {
name: 'status',
label: 'Status',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.ARTIST_STATUS
valueType: filterBuilderValueTypes.AUTHOR_STATUS
},
{
name: 'qualityProfileId',
@@ -77,33 +77,33 @@ export const defaultState = {
};
export const persistState = [
'artistEditor.sortKey',
'artistEditor.sortDirection',
'artistEditor.selectedFilterKey',
'artistEditor.customFilters'
'authorEditor.sortKey',
'authorEditor.sortDirection',
'authorEditor.selectedFilterKey',
'authorEditor.customFilters'
];
//
// Actions Types
export const SET_ARTIST_EDITOR_SORT = 'artistEditor/setArtistEditorSort';
export const SET_ARTIST_EDITOR_FILTER = 'artistEditor/setArtistEditorFilter';
export const SAVE_ARTIST_EDITOR = 'artistEditor/saveArtistEditor';
export const BULK_DELETE_ARTIST = 'artistEditor/bulkDeleteArtist';
export const SET_AUTHOR_EDITOR_SORT = 'authorEditor/setAuthorEditorSort';
export const SET_AUTHOR_EDITOR_FILTER = 'authorEditor/setAuthorEditorFilter';
export const SAVE_AUTHOR_EDITOR = 'authorEditor/saveAuthorEditor';
export const BULK_DELETE_AUTHOR = 'authorEditor/bulkDeleteAuthor';
//
// Action Creators
export const setArtistEditorSort = createAction(SET_ARTIST_EDITOR_SORT);
export const setArtistEditorFilter = createAction(SET_ARTIST_EDITOR_FILTER);
export const saveArtistEditor = createThunk(SAVE_ARTIST_EDITOR);
export const bulkDeleteArtist = createThunk(BULK_DELETE_ARTIST);
export const setAuthorEditorSort = createAction(SET_AUTHOR_EDITOR_SORT);
export const setAuthorEditorFilter = createAction(SET_AUTHOR_EDITOR_FILTER);
export const saveAuthorEditor = createThunk(SAVE_AUTHOR_EDITOR);
export const bulkDeleteAuthor = createThunk(BULK_DELETE_AUTHOR);
//
// Action Handlers
export const actionHandlers = handleThunks({
[SAVE_ARTIST_EDITOR]: function(getState, payload, dispatch) {
[SAVE_AUTHOR_EDITOR]: function(getState, payload, dispatch) {
dispatch(set({
section,
isSaving: true
@@ -118,11 +118,11 @@ export const actionHandlers = handleThunks({
promise.done((data) => {
dispatch(batchActions([
...data.map((artist) => {
...data.map((author) => {
return updateItem({
id: artist.id,
section: 'artist',
...artist
id: author.id,
section: 'authors',
...author
});
}),
@@ -143,7 +143,7 @@ export const actionHandlers = handleThunks({
});
},
[BULK_DELETE_ARTIST]: function(getState, payload, dispatch) {
[BULK_DELETE_AUTHOR]: function(getState, payload, dispatch) {
dispatch(set({
section,
isDeleting: true
@@ -157,7 +157,7 @@ export const actionHandlers = handleThunks({
}).request;
promise.done(() => {
// SignalR will take care of removing the artist from the collection
// SignalR will take care of removing the author from the collection
dispatch(set({
section,
@@ -181,7 +181,7 @@ export const actionHandlers = handleThunks({
export const reducers = createHandleActions({
[SET_ARTIST_EDITOR_SORT]: createSetClientSideCollectionSortReducer(section),
[SET_ARTIST_EDITOR_FILTER]: createSetClientSideCollectionFilterReducer(section)
[SET_AUTHOR_EDITOR_SORT]: createSetClientSideCollectionSortReducer(section),
[SET_AUTHOR_EDITOR_FILTER]: createSetClientSideCollectionFilterReducer(section)
}, defaultState, section);
@@ -8,7 +8,7 @@ import { set, update } from './baseActions';
//
// Variables
export const section = 'artistHistory';
export const section = 'authorHistory';
//
// State
@@ -23,27 +23,27 @@ export const defaultState = {
//
// Actions Types
export const FETCH_ARTIST_HISTORY = 'artistHistory/fetchArtistHistory';
export const CLEAR_ARTIST_HISTORY = 'artistHistory/clearArtistHistory';
export const ARTIST_HISTORY_MARK_AS_FAILED = 'artistHistory/artistHistoryMarkAsFailed';
export const FETCH_AUTHOR_HISTORY = 'authorHistory/fetchAuthorHistory';
export const CLEAR_AUTHOR_HISTORY = 'authorHistory/clearAuthorHistory';
export const AUTHOR_HISTORY_MARK_AS_FAILED = 'authorHistory/authorHistoryMarkAsFailed';
//
// Action Creators
export const fetchArtistHistory = createThunk(FETCH_ARTIST_HISTORY);
export const clearArtistHistory = createAction(CLEAR_ARTIST_HISTORY);
export const artistHistoryMarkAsFailed = createThunk(ARTIST_HISTORY_MARK_AS_FAILED);
export const fetchAuthorHistory = createThunk(FETCH_AUTHOR_HISTORY);
export const clearAuthorHistory = createAction(CLEAR_AUTHOR_HISTORY);
export const authorHistoryMarkAsFailed = createThunk(AUTHOR_HISTORY_MARK_AS_FAILED);
//
// Action Handlers
export const actionHandlers = handleThunks({
[FETCH_ARTIST_HISTORY]: function(getState, payload, dispatch) {
[FETCH_AUTHOR_HISTORY]: function(getState, payload, dispatch) {
dispatch(set({ section, isFetching: true }));
const promise = createAjaxRequest({
url: '/history/artist',
url: '/history/author',
data: payload
}).request;
@@ -70,7 +70,7 @@ export const actionHandlers = handleThunks({
});
},
[ARTIST_HISTORY_MARK_AS_FAILED]: function(getState, payload, dispatch) {
[AUTHOR_HISTORY_MARK_AS_FAILED]: function(getState, payload, dispatch) {
const {
historyId,
authorId,
@@ -86,7 +86,7 @@ export const actionHandlers = handleThunks({
}).request;
promise.done(() => {
dispatch(fetchArtistHistory({ authorId, bookId }));
dispatch(fetchAuthorHistory({ authorId, bookId }));
});
}
});
@@ -96,7 +96,7 @@ export const actionHandlers = handleThunks({
export const reducers = createHandleActions({
[CLEAR_ARTIST_HISTORY]: (state) => {
[CLEAR_AUTHOR_HISTORY]: (state) => {
return Object.assign({}, state, defaultState);
}
@@ -5,12 +5,12 @@ import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptio
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer';
import createHandleActions from './Creators/createHandleActions';
import { filters, filterPredicates, sortPredicates } from './artistActions';
import { filters, filterPredicates, sortPredicates } from './authorActions';
//
// Variables
export const section = 'artistIndex';
export const section = 'authorIndex';
//
// State
@@ -45,9 +45,9 @@ export const defaultState = {
size: 'medium',
showMonitored: true,
showQualityProfile: true,
showLastAlbum: false,
showLastBook: false,
showAdded: false,
showAlbumCount: true,
showBookCount: true,
showPath: false,
showSizeOnDisk: false,
showSearchAction: false
@@ -68,13 +68,13 @@ export const defaultState = {
},
{
name: 'sortName',
label: 'Artist Name',
label: 'Author Name',
isSortable: true,
isVisible: true,
isModifiable: false
},
{
name: 'artistType',
name: 'authorType',
label: 'Type',
isSortable: true,
isVisible: true
@@ -92,14 +92,14 @@ export const defaultState = {
isVisible: false
},
{
name: 'nextAlbum',
label: 'Next Album',
name: 'nextBook',
label: 'Next Book',
isSortable: true,
isVisible: true
},
{
name: 'lastAlbum',
label: 'Last Album',
name: 'lastBook',
label: 'Last Book',
isSortable: true,
isVisible: false
},
@@ -110,23 +110,11 @@ export const defaultState = {
isVisible: false
},
{
name: 'albumCount',
label: 'Albums',
name: 'bookProgress',
label: 'Books',
isSortable: true,
isVisible: true
},
{
name: 'trackProgress',
label: 'Tracks',
isSortable: true,
isVisible: true
},
{
name: 'trackCount',
label: 'Track Count',
isSortable: true,
isVisible: false
},
{
name: 'path',
label: 'Path',
@@ -168,43 +156,37 @@ export const defaultState = {
sortPredicates: {
...sortPredicates,
trackProgress: function(item) {
bookProgress: function(item) {
const { statistics = {} } = item;
const {
trackCount = 0,
trackFileCount
bookCount = 0,
bookFileCount
} = statistics;
const progress = trackCount ? trackFileCount / trackCount * 100 : 100;
const progress = bookCount ? bookFileCount / bookCount * 100 : 100;
return progress + trackCount / 1000000;
return progress + bookCount / 1000000;
},
nextAlbum: function(item) {
if (item.nextAlbum) {
return item.nextAlbum.releaseDate;
nextBook: function(item) {
if (item.nextBook) {
return item.nextBook.releaseDate;
}
return '1/1/1000';
},
lastAlbum: function(item) {
if (item.lastAlbum) {
return item.lastAlbum.releaseDate;
lastBook: function(item) {
if (item.lastBook) {
return item.lastBook.releaseDate;
}
return '1/1/1000';
},
albumCount: function(item) {
bookCount: function(item) {
const { statistics = {} } = item;
return statistics.albumCount;
},
trackCount: function(item) {
const { statistics = {} } = item;
return statistics.totalTrackCount;
return statistics.bookCount;
},
sizeOnDisk: function(item) {
@@ -227,16 +209,16 @@ export const defaultState = {
filterPredicates: {
...filterPredicates,
trackProgress: function(item, filterValue, type) {
bookProgress: function(item, filterValue, type) {
const { statistics = {} } = item;
const {
trackCount = 0,
trackFileCount
bookCount = 0,
bookFileCount
} = statistics;
const progress = trackCount ?
trackFileCount / trackCount * 100 :
const progress = bookCount ?
bookFileCount / bookCount * 100 :
100;
const predicate = filterTypePredicates[type];
@@ -256,7 +238,7 @@ export const defaultState = {
name: 'status',
label: 'Status',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.ARTIST_STATUS
valueType: filterBuilderValueTypes.AUTHOR_STATUS
},
{
name: 'qualityProfileId',
@@ -271,14 +253,14 @@ export const defaultState = {
valueType: filterBuilderValueTypes.METADATA_PROFILE
},
{
name: 'nextAlbum',
label: 'Next Album',
name: 'nextBook',
label: 'Next Book',
type: filterBuilderTypes.DATE,
valueType: filterBuilderValueTypes.DATE
},
{
name: 'lastAlbum',
label: 'Last Album',
name: 'lastBook',
label: 'Last Book',
type: filterBuilderTypes.DATE,
valueType: filterBuilderValueTypes.DATE
},
@@ -289,13 +271,13 @@ export const defaultState = {
valueType: filterBuilderValueTypes.DATE
},
{
name: 'albumCount',
label: 'Album Count',
name: 'bookCount',
label: 'Book Count',
type: filterBuilderTypes.NUMBER
},
{
name: 'trackProgress',
label: 'Track Progress',
name: 'bookProgress',
label: 'Book Progress',
type: filterBuilderTypes.NUMBER
},
{
@@ -314,8 +296,8 @@ export const defaultState = {
label: 'Genres',
type: filterBuilderTypes.ARRAY,
optionsSelector: function(items) {
const tagList = items.reduce((acc, artist) => {
artist.genres.forEach((genre) => {
const tagList = items.reduce((acc, author) => {
author.genres.forEach((genre) => {
acc.push({
id: genre,
name: genre
@@ -343,55 +325,55 @@ export const defaultState = {
};
export const persistState = [
'artistIndex.sortKey',
'artistIndex.sortDirection',
'artistIndex.selectedFilterKey',
'artistIndex.customFilters',
'artistIndex.view',
'artistIndex.columns',
'artistIndex.posterOptions',
'artistIndex.bannerOptions',
'artistIndex.overviewOptions',
'artistIndex.tableOptions'
'authorIndex.sortKey',
'authorIndex.sortDirection',
'authorIndex.selectedFilterKey',
'authorIndex.customFilters',
'authorIndex.view',
'authorIndex.columns',
'authorIndex.posterOptions',
'authorIndex.bannerOptions',
'authorIndex.overviewOptions',
'authorIndex.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';
export const SET_AUTHOR_SORT = 'authorIndex/setAuthorSort';
export const SET_AUTHOR_FILTER = 'authorIndex/setAuthorFilter';
export const SET_AUTHOR_VIEW = 'authorIndex/setAuthorView';
export const SET_AUTHOR_TABLE_OPTION = 'authorIndex/setAuthorTableOption';
export const SET_AUTHOR_POSTER_OPTION = 'authorIndex/setAuthorPosterOption';
export const SET_AUTHOR_BANNER_OPTION = 'authorIndex/setAuthorBannerOption';
export const SET_AUTHOR_OVERVIEW_OPTION = 'authorIndex/setAuthorOverviewOption';
//
// 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);
export const setAuthorSort = createAction(SET_AUTHOR_SORT);
export const setAuthorFilter = createAction(SET_AUTHOR_FILTER);
export const setAuthorView = createAction(SET_AUTHOR_VIEW);
export const setAuthorTableOption = createAction(SET_AUTHOR_TABLE_OPTION);
export const setAuthorPosterOption = createAction(SET_AUTHOR_POSTER_OPTION);
export const setAuthorBannerOption = createAction(SET_AUTHOR_BANNER_OPTION);
export const setAuthorOverviewOption = createAction(SET_AUTHOR_OVERVIEW_OPTION);
//
// Reducers
export const reducers = createHandleActions({
[SET_ARTIST_SORT]: createSetClientSideCollectionSortReducer(section),
[SET_ARTIST_FILTER]: createSetClientSideCollectionFilterReducer(section),
[SET_AUTHOR_SORT]: createSetClientSideCollectionSortReducer(section),
[SET_AUTHOR_FILTER]: createSetClientSideCollectionFilterReducer(section),
[SET_ARTIST_VIEW]: function(state, { payload }) {
[SET_AUTHOR_VIEW]: function(state, { payload }) {
return Object.assign({}, state, { view: payload.view });
},
[SET_ARTIST_TABLE_OPTION]: createSetTableOptionReducer(section),
[SET_AUTHOR_TABLE_OPTION]: createSetTableOptionReducer(section),
[SET_ARTIST_POSTER_OPTION]: function(state, { payload }) {
[SET_AUTHOR_POSTER_OPTION]: function(state, { payload }) {
const posterOptions = state.posterOptions;
return {
@@ -403,7 +385,7 @@ export const reducers = createHandleActions({
};
},
[SET_ARTIST_BANNER_OPTION]: function(state, { payload }) {
[SET_AUTHOR_BANNER_OPTION]: function(state, { payload }) {
const bannerOptions = state.bannerOptions;
return {
@@ -415,7 +397,7 @@ export const reducers = createHandleActions({
};
},
[SET_ARTIST_OVERVIEW_OPTION]: function(state, { payload }) {
[SET_AUTHOR_OVERVIEW_OPTION]: function(state, { payload }) {
const overviewOptions = state.overviewOptions;
return {
@@ -28,7 +28,7 @@ export const defaultState = {
columns: [
{
name: 'authors.sortName',
label: 'Artist Name',
label: 'Author Name',
isSortable: true,
isVisible: true
},
@@ -8,7 +8,7 @@ import createSetClientSideCollectionSortReducer from './Creators/Reducers/create
import createSetSettingValueReducer from './Creators/Reducers/createSetSettingValueReducer';
import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer';
import createSaveProviderHandler from './Creators/createSaveProviderHandler';
import albumEntities from 'Album/albumEntities';
import bookEntities from 'Book/bookEntities';
import createFetchHandler from './Creators/createFetchHandler';
import createRemoveItemHandler from './Creators/createRemoveItemHandler';
import createHandleActions from './Creators/createHandleActions';
@@ -17,7 +17,7 @@ import { updateItem } from './baseActions';
//
// Variables
export const section = 'albums';
export const section = 'books';
//
// State
@@ -58,8 +58,8 @@ export const defaultState = {
isVisible: true
},
{
name: 'trackCount',
label: 'Track Count',
name: 'bookCount',
label: 'Book Count',
isVisible: false
},
{
@@ -83,37 +83,37 @@ export const defaultState = {
};
export const persistState = [
'albums.sortKey',
'albums.sortDirection',
'albums.columns'
'books.sortKey',
'books.sortDirection',
'books.columns'
];
//
// Actions Types
export const FETCH_ALBUMS = 'albums/fetchAlbums';
export const SET_ALBUMS_SORT = 'albums/setAlbumsSort';
export const SET_ALBUMS_TABLE_OPTION = 'albums/setAlbumsTableOption';
export const CLEAR_ALBUMS = 'albums/clearAlbums';
export const SET_ALBUM_VALUE = 'albums/setAlbumValue';
export const SAVE_ALBUM = 'albums/saveAlbum';
export const DELETE_ALBUM = 'albums/deleteAlbum';
export const TOGGLE_ALBUM_MONITORED = 'albums/toggleAlbumMonitored';
export const TOGGLE_ALBUMS_MONITORED = 'albums/toggleAlbumsMonitored';
export const FETCH_BOOKS = 'books/fetchBooks';
export const SET_BOOKS_SORT = 'books/setBooksSort';
export const SET_BOOKS_TABLE_OPTION = 'books/setBooksTableOption';
export const CLEAR_BOOKS = 'books/clearBooks';
export const SET_BOOK_VALUE = 'books/setBookValue';
export const SAVE_BOOK = 'books/saveBook';
export const DELETE_BOOK = 'books/deleteBook';
export const TOGGLE_BOOK_MONITORED = 'books/toggleBookMonitored';
export const TOGGLE_BOOKS_MONITORED = 'books/toggleBooksMonitored';
//
// Action Creators
export const fetchAlbums = createThunk(FETCH_ALBUMS);
export const setAlbumsSort = createAction(SET_ALBUMS_SORT);
export const setAlbumsTableOption = createAction(SET_ALBUMS_TABLE_OPTION);
export const clearAlbums = createAction(CLEAR_ALBUMS);
export const toggleAlbumMonitored = createThunk(TOGGLE_ALBUM_MONITORED);
export const toggleAlbumsMonitored = createThunk(TOGGLE_ALBUMS_MONITORED);
export const fetchBooks = createThunk(FETCH_BOOKS);
export const setBooksSort = createAction(SET_BOOKS_SORT);
export const setBooksTableOption = createAction(SET_BOOKS_TABLE_OPTION);
export const clearBooks = createAction(CLEAR_BOOKS);
export const toggleBookMonitored = createThunk(TOGGLE_BOOK_MONITORED);
export const toggleBooksMonitored = createThunk(TOGGLE_BOOKS_MONITORED);
export const saveAlbum = createThunk(SAVE_ALBUM);
export const saveBook = createThunk(SAVE_BOOK);
export const deleteAlbum = createThunk(DELETE_ALBUM, (payload) => {
export const deleteBook = createThunk(DELETE_BOOK, (payload) => {
return {
...payload,
queryParams: {
@@ -123,9 +123,9 @@ export const deleteAlbum = createThunk(DELETE_ALBUM, (payload) => {
};
});
export const setAlbumValue = createAction(SET_ALBUM_VALUE, (payload) => {
export const setBookValue = createAction(SET_BOOK_VALUE, (payload) => {
return {
section: 'albums',
section: 'books',
...payload
};
});
@@ -134,27 +134,27 @@ export const setAlbumValue = createAction(SET_ALBUM_VALUE, (payload) => {
// Action Handlers
export const actionHandlers = handleThunks({
[FETCH_ALBUMS]: createFetchHandler(section, '/album'),
[SAVE_ALBUM]: createSaveProviderHandler(section, '/album'),
[DELETE_ALBUM]: createRemoveItemHandler(section, '/album'),
[FETCH_BOOKS]: createFetchHandler(section, '/book'),
[SAVE_BOOK]: createSaveProviderHandler(section, '/book'),
[DELETE_BOOK]: createRemoveItemHandler(section, '/book'),
[TOGGLE_ALBUM_MONITORED]: function(getState, payload, dispatch) {
[TOGGLE_BOOK_MONITORED]: function(getState, payload, dispatch) {
const {
bookId,
albumEntity = albumEntities.ALBUMS,
bookEntity = bookEntities.BOOKS,
monitored
} = payload;
const albumSection = _.last(albumEntity.split('.'));
const bookSection = _.last(bookEntity.split('.'));
dispatch(updateItem({
id: bookId,
section: albumSection,
section: bookSection,
isSaving: true
}));
const promise = createAjaxRequest({
url: `/album/${bookId}`,
url: `/book/${bookId}`,
method: 'PUT',
data: JSON.stringify({ monitored }),
dataType: 'json'
@@ -163,7 +163,7 @@ export const actionHandlers = handleThunks({
promise.done((data) => {
dispatch(updateItem({
id: bookId,
section: albumSection,
section: bookSection,
isSaving: false,
monitored
}));
@@ -172,16 +172,16 @@ export const actionHandlers = handleThunks({
promise.fail((xhr) => {
dispatch(updateItem({
id: bookId,
section: albumSection,
section: bookSection,
isSaving: false
}));
});
},
[TOGGLE_ALBUMS_MONITORED]: function(getState, payload, dispatch) {
[TOGGLE_BOOKS_MONITORED]: function(getState, payload, dispatch) {
const {
bookIds,
albumEntity = albumEntities.ALBUMS,
bookEntity = bookEntities.BOOKS,
monitored
} = payload;
@@ -189,14 +189,14 @@ export const actionHandlers = handleThunks({
bookIds.map((bookId) => {
return updateItem({
id: bookId,
section: albumEntity,
section: bookEntity,
isSaving: true
});
})
));
const promise = createAjaxRequest({
url: '/album/monitor',
url: '/book/monitor',
method: 'PUT',
data: JSON.stringify({ bookIds, monitored }),
dataType: 'json'
@@ -207,7 +207,7 @@ export const actionHandlers = handleThunks({
bookIds.map((bookId) => {
return updateItem({
id: bookId,
section: albumEntity,
section: bookEntity,
isSaving: false,
monitored
});
@@ -220,7 +220,7 @@ export const actionHandlers = handleThunks({
bookIds.map((bookId) => {
return updateItem({
id: bookId,
section: albumEntity,
section: bookEntity,
isSaving: false
});
})
@@ -234,13 +234,13 @@ export const actionHandlers = handleThunks({
export const reducers = createHandleActions({
[SET_ALBUMS_SORT]: createSetClientSideCollectionSortReducer(section),
[SET_BOOKS_SORT]: createSetClientSideCollectionSortReducer(section),
[SET_ALBUMS_TABLE_OPTION]: createSetTableOptionReducer(section),
[SET_BOOKS_TABLE_OPTION]: createSetTableOptionReducer(section),
[SET_ALBUM_VALUE]: createSetSettingValueReducer(section),
[SET_BOOK_VALUE]: createSetSettingValueReducer(section),
[CLEAR_ALBUMS]: (state) => {
[CLEAR_BOOKS]: (state) => {
return Object.assign({}, state, {
isFetching: false,
isPopulated: false,
@@ -7,7 +7,7 @@ import { createThunk, handleThunks } from 'Store/thunks';
import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer';
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
import createClearReducer from './Creators/Reducers/createClearReducer';
import albumEntities from 'Album/albumEntities';
import bookEntities from 'Book/bookEntities';
import createFetchHandler from './Creators/createFetchHandler';
import createHandleActions from './Creators/createHandleActions';
import createRemoveItemHandler from './Creators/createRemoveItemHandler';
@@ -16,7 +16,7 @@ import { set, removeItem, updateItem } from './baseActions';
//
// Variables
export const section = 'trackFiles';
export const section = 'bookFiles';
//
// State
@@ -76,62 +76,62 @@ export const defaultState = {
};
export const persistState = [
'trackFiles.sortKey',
'trackFiles.sortDirection'
'bookFiles.sortKey',
'bookFiles.sortDirection'
];
//
// Actions Types
export const FETCH_TRACK_FILES = 'trackFiles/fetchTrackFiles';
export const DELETE_TRACK_FILE = 'trackFiles/deleteTrackFile';
export const DELETE_TRACK_FILES = 'trackFiles/deleteTrackFiles';
export const UPDATE_TRACK_FILES = 'trackFiles/updateTrackFiles';
export const SET_TRACK_FILES_SORT = 'trackFiles/setTrackFilesSort';
export const SET_TRACK_FILES_TABLE_OPTION = 'trackFiles/setTrackFilesTableOption';
export const CLEAR_TRACK_FILES = 'trackFiles/clearTrackFiles';
export const FETCH_BOOK_FILES = 'bookFiles/fetchBookFiles';
export const DELETE_BOOK_FILE = 'bookFiles/deleteBookFile';
export const DELETE_BOOK_FILES = 'bookFiles/deleteBookFiles';
export const UPDATE_BOOK_FILES = 'bookFiles/updateBookFiles';
export const SET_BOOK_FILES_SORT = 'bookFiles/setBookFilesSort';
export const SET_BOOK_FILES_TABLE_OPTION = 'bookFiles/setBookFilesTableOption';
export const CLEAR_BOOK_FILES = 'bookFiles/clearBookFiles';
//
// Action Creators
export const fetchTrackFiles = createThunk(FETCH_TRACK_FILES);
export const deleteTrackFile = createThunk(DELETE_TRACK_FILE);
export const deleteTrackFiles = createThunk(DELETE_TRACK_FILES);
export const updateTrackFiles = createThunk(UPDATE_TRACK_FILES);
export const setTrackFilesSort = createAction(SET_TRACK_FILES_SORT);
export const setTrackFilesTableOption = createAction(SET_TRACK_FILES_TABLE_OPTION);
export const clearTrackFiles = createAction(CLEAR_TRACK_FILES);
export const fetchBookFiles = createThunk(FETCH_BOOK_FILES);
export const deleteBookFile = createThunk(DELETE_BOOK_FILE);
export const deleteBookFiles = createThunk(DELETE_BOOK_FILES);
export const updateBookFiles = createThunk(UPDATE_BOOK_FILES);
export const setBookFilesSort = createAction(SET_BOOK_FILES_SORT);
export const setBookFilesTableOption = createAction(SET_BOOK_FILES_TABLE_OPTION);
export const clearBookFiles = createAction(CLEAR_BOOK_FILES);
//
// Helpers
const deleteTrackFileHelper = createRemoveItemHandler(section, '/trackFile');
const deleteBookFileHelper = createRemoveItemHandler(section, '/bookFile');
//
// Action Handlers
export const actionHandlers = handleThunks({
[FETCH_TRACK_FILES]: createFetchHandler(section, '/trackFile'),
[FETCH_BOOK_FILES]: createFetchHandler(section, '/bookFile'),
[DELETE_TRACK_FILE]: function(getState, payload, dispatch) {
[DELETE_BOOK_FILE]: function(getState, payload, dispatch) {
const {
id: trackFileId,
albumEntity = albumEntities.ALBUMS
id: bookFileId,
bookEntity: bookEntity = bookEntities.BOOKS
} = payload;
const albumSection = _.last(albumEntity.split('.'));
const deletePromise = deleteTrackFileHelper(getState, payload, dispatch);
const bookSection = _.last(bookEntity.split('.'));
const deletePromise = deleteBookFileHelper(getState, payload, dispatch);
deletePromise.done(() => {
const albums = getState().albums.items;
const tracksWithRemovedFiles = _.filter(albums, { trackFileId });
const books = getState().books.items;
const booksWithRemovedFiles = _.filter(books, { bookFileId });
dispatch(batchActions([
...tracksWithRemovedFiles.map((track) => {
...booksWithRemovedFiles.map((book) => {
return updateItem({
section: albumSection,
...track,
trackFileId: 0,
section: bookSection,
...book,
bookFileId: 0,
hasFile: false
});
})
@@ -139,38 +139,38 @@ export const actionHandlers = handleThunks({
});
},
[DELETE_TRACK_FILES]: function(getState, payload, dispatch) {
[DELETE_BOOK_FILES]: function(getState, payload, dispatch) {
const {
trackFileIds
bookFileIds: bookFileIds
} = payload;
dispatch(set({ section, isDeleting: true }));
const promise = createAjaxRequest({
url: '/trackFile/bulk',
url: '/bookFile/bulk',
method: 'DELETE',
dataType: 'json',
data: JSON.stringify({ trackFileIds })
data: JSON.stringify({ bookFileIds })
}).request;
promise.done(() => {
const tracks = getState().tracks.items;
const tracksWithRemovedFiles = trackFileIds.reduce((acc, trackFileId) => {
acc.push(..._.filter(tracks, { trackFileId }));
const books = getState().books.items;
const booksWithRemovedFiles = bookFileIds.reduce((acc, bookFileId) => {
acc.push(..._.filter(books, { bookFileId }));
return acc;
}, []);
dispatch(batchActions([
...trackFileIds.map((id) => {
...bookFileIds.map((id) => {
return removeItem({ section, id });
}),
...tracksWithRemovedFiles.map((track) => {
...booksWithRemovedFiles.map((book) => {
return updateItem({
section: 'tracks',
...track,
trackFileId: 0,
section: 'books',
...book,
bookFileId: 0,
hasFile: false
});
}),
@@ -192,16 +192,16 @@ export const actionHandlers = handleThunks({
});
},
[UPDATE_TRACK_FILES]: function(getState, payload, dispatch) {
[UPDATE_BOOK_FILES]: function(getState, payload, dispatch) {
const {
trackFileIds,
bookFileIds,
quality
} = payload;
dispatch(set({ section, isSaving: true }));
const data = {
trackFileIds
bookFileIds
};
if (quality) {
@@ -209,7 +209,7 @@ export const actionHandlers = handleThunks({
}
const promise = createAjaxRequest({
url: '/trackFile/editor',
url: '/bookFile/editor',
method: 'PUT',
dataType: 'json',
data: JSON.stringify(data)
@@ -217,7 +217,7 @@ export const actionHandlers = handleThunks({
promise.done(() => {
dispatch(batchActions([
...trackFileIds.map((id) => {
...bookFileIds.map((id) => {
const props = {};
if (quality) {
@@ -249,10 +249,10 @@ export const actionHandlers = handleThunks({
// Reducers
export const reducers = createHandleActions({
[SET_TRACK_FILES_SORT]: createSetClientSideCollectionSortReducer(section),
[SET_TRACK_FILES_TABLE_OPTION]: createSetTableOptionReducer(section),
[SET_BOOK_FILES_SORT]: createSetClientSideCollectionSortReducer(section),
[SET_BOOK_FILES_TABLE_OPTION]: createSetTableOptionReducer(section),
[CLEAR_TRACK_FILES]: createClearReducer(section, {
[CLEAR_BOOK_FILES]: createClearReducer(section, {
isFetching: false,
isPopulated: false,
error: null,
@@ -9,7 +9,7 @@ import { set, update } from './baseActions';
//
// Variables
export const section = 'albumHistory';
export const section = 'bookHistory';
//
// State
@@ -24,23 +24,23 @@ export const defaultState = {
//
// Actions Types
export const FETCH_ALBUM_HISTORY = 'albumHistory/fetchAlbumHistory';
export const CLEAR_ALBUM_HISTORY = 'albumHistory/clearAlbumHistory';
export const ALBUM_HISTORY_MARK_AS_FAILED = 'albumHistory/albumHistoryMarkAsFailed';
export const FETCH_BOOK_HISTORY = 'bookHistory/fetchBookHistory';
export const CLEAR_BOOK_HISTORY = 'bookHistory/clearBookHistory';
export const BOOK_HISTORY_MARK_AS_FAILED = 'bookHistory/bookHistoryMarkAsFailed';
//
// Action Creators
export const fetchAlbumHistory = createThunk(FETCH_ALBUM_HISTORY);
export const clearAlbumHistory = createAction(CLEAR_ALBUM_HISTORY);
export const albumHistoryMarkAsFailed = createThunk(ALBUM_HISTORY_MARK_AS_FAILED);
export const fetchBookHistory = createThunk(FETCH_BOOK_HISTORY);
export const clearBookHistory = createAction(CLEAR_BOOK_HISTORY);
export const bookHistoryMarkAsFailed = createThunk(BOOK_HISTORY_MARK_AS_FAILED);
//
// Action Handlers
export const actionHandlers = handleThunks({
[FETCH_ALBUM_HISTORY]: function(getState, payload, dispatch) {
[FETCH_BOOK_HISTORY]: function(getState, payload, dispatch) {
dispatch(set({ section, isFetching: true }));
const queryParams = {
@@ -79,7 +79,7 @@ export const actionHandlers = handleThunks({
});
},
[ALBUM_HISTORY_MARK_AS_FAILED]: function(getState, payload, dispatch) {
[BOOK_HISTORY_MARK_AS_FAILED]: function(getState, payload, dispatch) {
const {
historyId,
bookId
@@ -94,7 +94,7 @@ export const actionHandlers = handleThunks({
}).request;
promise.done(() => {
dispatch(fetchAlbumHistory({ bookId }));
dispatch(fetchBookHistory({ bookId }));
});
}
});
@@ -104,7 +104,7 @@ export const actionHandlers = handleThunks({
export const reducers = createHandleActions({
[CLEAR_ALBUM_HISTORY]: (state) => {
[CLEAR_BOOK_HISTORY]: (state) => {
return Object.assign({}, state, defaultState);
}
@@ -6,13 +6,13 @@ import createSetClientSideCollectionSortReducer from './Creators/Reducers/create
import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer';
import createHandleActions from './Creators/createHandleActions';
import { set } from './baseActions';
import { fetchAlbums } from './albumActions';
import { filters, filterPredicates } from './artistActions';
import { fetchBooks } from './bookActions';
import { filters, filterPredicates } from './authorActions';
//
// Variables
export const section = 'albumStudio';
export const section = 'bookshelf';
//
// State
@@ -39,11 +39,11 @@ export const defaultState = {
name: 'status',
label: 'Status',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.ARTIST_STATUS
valueType: filterBuilderValueTypes.AUTHOR_STATUS
},
{
name: 'artistType',
label: 'Artist Type',
name: 'authorType',
label: 'Author Type',
type: filterBuilderTypes.EXACT
},
{
@@ -73,48 +73,48 @@ export const defaultState = {
};
export const persistState = [
'albumStudio.sortKey',
'albumStudio.sortDirection',
'albumStudio.selectedFilterKey',
'albumStudio.customFilters'
'bookshelf.sortKey',
'bookshelf.sortDirection',
'bookshelf.selectedFilterKey',
'bookshelf.customFilters'
];
//
// Actions Types
export const SET_ALBUM_STUDIO_SORT = 'albumStudio/setAlbumStudioSort';
export const SET_ALBUM_STUDIO_FILTER = 'albumStudio/setAlbumStudioFilter';
export const SAVE_ALBUM_STUDIO = 'albumStudio/saveAlbumStudio';
export const SET_BOOKSHELF_SORT = 'bookshelf/setBookshelfSort';
export const SET_BOOKSHELF_FILTER = 'bookshelf/setBookshelfFilter';
export const SAVE_BOOKSHELF = 'bookshelf/saveBookshelf';
//
// Action Creators
export const setAlbumStudioSort = createAction(SET_ALBUM_STUDIO_SORT);
export const setAlbumStudioFilter = createAction(SET_ALBUM_STUDIO_FILTER);
export const saveAlbumStudio = createThunk(SAVE_ALBUM_STUDIO);
export const setBookshelfSort = createAction(SET_BOOKSHELF_SORT);
export const setBookshelfFilter = createAction(SET_BOOKSHELF_FILTER);
export const saveBookshelf = createThunk(SAVE_BOOKSHELF);
//
// Action Handlers
export const actionHandlers = handleThunks({
[SAVE_ALBUM_STUDIO]: function(getState, payload, dispatch) {
[SAVE_BOOKSHELF]: function(getState, payload, dispatch) {
const {
authorIds,
monitored,
monitor
} = payload;
const artist = [];
const authors = [];
authorIds.forEach((id) => {
const artistToUpdate = { id };
const authorToUpdate = { id };
if (payload.hasOwnProperty('monitored')) {
artistToUpdate.monitored = monitored;
authorToUpdate.monitored = monitored;
}
artist.push(artistToUpdate);
authors.push(authorToUpdate);
});
dispatch(set({
@@ -123,17 +123,17 @@ export const actionHandlers = handleThunks({
}));
const promise = createAjaxRequest({
url: '/albumStudio',
url: '/bookshelf',
method: 'POST',
data: JSON.stringify({
artist,
author: authors,
monitoringOptions: { monitor }
}),
dataType: 'json'
}).request;
promise.done((data) => {
dispatch(fetchAlbums());
dispatch(fetchBooks());
dispatch(set({
section,
@@ -157,8 +157,8 @@ export const actionHandlers = handleThunks({
export const reducers = createHandleActions({
[SET_ALBUM_STUDIO_SORT]: createSetClientSideCollectionSortReducer(section),
[SET_ALBUM_STUDIO_FILTER]: createSetClientSideCollectionFilterReducer(section)
[SET_BOOKSHELF_SORT]: createSetClientSideCollectionSortReducer(section),
[SET_BOOKSHELF_FILTER]: createSetClientSideCollectionFilterReducer(section)
}, defaultState, section);
@@ -41,7 +41,7 @@ export const defaultState = {
searchMissingCommandId: null,
options: {
collapseMultipleAlbums: false,
collapseMultipleBooks: false,
showCutoffUnmetIcon: false
},
@@ -348,7 +348,7 @@ export const actionHandlers = handleThunks({
const { bookIds } = payload;
const commandPayload = {
name: commandNames.ALBUM_SEARCH,
name: commandNames.BOOK_SEARCH,
bookIds
};
+2 -2
View File
@@ -99,8 +99,8 @@ export const defaultState = {
]
},
{
key: 'trackFileImported',
label: 'Track Imported',
key: 'bookFileImported',
label: 'Book Imported',
filters: [
{
key: 'eventType',
+16 -18
View File
@@ -4,9 +4,9 @@ import * as calendar from './calendarActions';
import * as captcha from './captchaActions';
import * as customFilters from './customFilterActions';
import * as commands from './commandActions';
import * as albums from './albumActions';
import * as trackFiles from './trackFileActions';
import * as albumHistory from './albumHistoryActions';
import * as books from './bookActions';
import * as bookFiles from './bookFileActions';
import * as bookHistory from './bookHistoryActions';
import * as history from './historyActions';
import * as interactiveImportActions from './interactiveImportActions';
import * as oAuth from './oAuthActions';
@@ -16,17 +16,16 @@ import * as paths from './pathActions';
import * as providerOptions from './providerOptionActions';
import * as queue from './queueActions';
import * as releases from './releaseActions';
import * as albumStudio from './albumStudioActions';
import * as artist from './artistActions';
import * as artistEditor from './artistEditorActions';
import * as artistHistory from './artistHistoryActions';
import * as artistIndex from './artistIndexActions';
import * as bookStudio from './bookshelfActions';
import * as author from './authorActions';
import * as authorEditor from './authorEditorActions';
import * as authorHistory from './authorHistoryActions';
import * as authorIndex from './authorIndexActions';
import * as series from './seriesActions';
import * as search from './searchActions';
import * as settings from './settingsActions';
import * as system from './systemActions';
import * as tags from './tagActions';
import * as tracks from './trackActions';
import * as wanted from './wantedActions';
export default [
@@ -36,9 +35,9 @@ export default [
calendar,
commands,
customFilters,
albums,
trackFiles,
albumHistory,
books,
bookFiles,
bookHistory,
history,
interactiveImportActions,
oAuth,
@@ -48,16 +47,15 @@ export default [
providerOptions,
queue,
releases,
albumStudio,
artist,
artistEditor,
artistHistory,
artistIndex,
bookStudio,
author,
authorEditor,
authorHistory,
authorIndex,
series,
search,
settings,
system,
tags,
tracks,
wanted
];
@@ -16,8 +16,8 @@ import { set, update } from './baseActions';
export const section = 'interactiveImport';
const albumsSection = `${section}.albums`;
const trackFilesSection = `${section}.trackFiles`;
const booksSection = `${section}.books`;
const bookFilesSection = `${section}.bookFiles`;
//
// State
@@ -40,10 +40,10 @@ export const defaultState = {
return path.toLowerCase();
},
artist: function(item, direction) {
const artist = item.artist;
author: function(item, direction) {
const author = item.author;
return artist ? artist.sortName : '';
return author ? author.sortName : '';
},
quality: function(item, direction) {
@@ -51,7 +51,7 @@ export const defaultState = {
}
},
albums: {
books: {
isFetching: false,
isPopulated: false,
error: null,
@@ -60,7 +60,7 @@ export const defaultState = {
items: []
},
trackFiles: {
bookFiles: {
isFetching: false,
isPopulated: false,
error: null,
@@ -88,12 +88,12 @@ export const ADD_RECENT_FOLDER = 'interactiveImport/addRecentFolder';
export const REMOVE_RECENT_FOLDER = 'interactiveImport/removeRecentFolder';
export const SET_INTERACTIVE_IMPORT_MODE = 'interactiveImport/setInteractiveImportMode';
export const FETCH_INTERACTIVE_IMPORT_ALBUMS = 'interactiveImport/fetchInteractiveImportAlbums';
export const SET_INTERACTIVE_IMPORT_ALBUMS_SORT = 'interactiveImport/clearInteractiveImportAlbumsSort';
export const CLEAR_INTERACTIVE_IMPORT_ALBUMS = 'interactiveImport/clearInteractiveImportAlbums';
export const FETCH_INTERACTIVE_IMPORT_BOOKS = 'interactiveImport/fetchInteractiveImportBooks';
export const SET_INTERACTIVE_IMPORT_BOOKS_SORT = 'interactiveImport/clearInteractiveImportBooksSort';
export const CLEAR_INTERACTIVE_IMPORT_BOOKS = 'interactiveImport/clearInteractiveImportBooks';
export const FETCH_INTERACTIVE_IMPORT_TRACKFILES = 'interactiveImport/fetchInteractiveImportTrackFiles';
export const CLEAR_INTERACTIVE_IMPORT_TRACKFILES = 'interactiveImport/clearInteractiveImportTrackFiles';
export const FETCH_INTERACTIVE_IMPORT_TRACKFILES = 'interactiveImport/fetchInteractiveImportBookFiles';
export const CLEAR_INTERACTIVE_IMPORT_TRACKFILES = 'interactiveImport/clearInteractiveImportBookFiles';
//
// Action Creators
@@ -108,12 +108,12 @@ export const addRecentFolder = createAction(ADD_RECENT_FOLDER);
export const removeRecentFolder = createAction(REMOVE_RECENT_FOLDER);
export const setInteractiveImportMode = createAction(SET_INTERACTIVE_IMPORT_MODE);
export const fetchInteractiveImportAlbums = createThunk(FETCH_INTERACTIVE_IMPORT_ALBUMS);
export const setInteractiveImportAlbumsSort = createAction(SET_INTERACTIVE_IMPORT_ALBUMS_SORT);
export const clearInteractiveImportAlbums = createAction(CLEAR_INTERACTIVE_IMPORT_ALBUMS);
export const fetchInteractiveImportBooks = createThunk(FETCH_INTERACTIVE_IMPORT_BOOKS);
export const setInteractiveImportBooksSort = createAction(SET_INTERACTIVE_IMPORT_BOOKS_SORT);
export const clearInteractiveImportBooks = createAction(CLEAR_INTERACTIVE_IMPORT_BOOKS);
export const fetchInteractiveImportTrackFiles = createThunk(FETCH_INTERACTIVE_IMPORT_TRACKFILES);
export const clearInteractiveImportTrackFiles = createAction(CLEAR_INTERACTIVE_IMPORT_TRACKFILES);
export const fetchInteractiveImportBookFiles = createThunk(FETCH_INTERACTIVE_IMPORT_TRACKFILES);
export const clearInteractiveImportBookFiles = createAction(CLEAR_INTERACTIVE_IMPORT_TRACKFILES);
//
// Action Handlers
@@ -156,9 +156,9 @@ export const actionHandlers = handleThunks({
[SAVE_INTERACTIVE_IMPORT_ITEM]: createSaveProviderHandler(section, '/manualimport', {}, true),
[FETCH_INTERACTIVE_IMPORT_ALBUMS]: createFetchHandler(albumsSection, '/album'),
[FETCH_INTERACTIVE_IMPORT_BOOKS]: createFetchHandler(booksSection, '/book'),
[FETCH_INTERACTIVE_IMPORT_TRACKFILES]: createFetchHandler(trackFilesSection, '/trackFile')
[FETCH_INTERACTIVE_IMPORT_TRACKFILES]: createFetchHandler(bookFilesSection, '/bookFile')
});
//
@@ -237,17 +237,17 @@ export const reducers = createHandleActions({
return Object.assign({}, state, { importMode: payload.importMode });
},
[SET_INTERACTIVE_IMPORT_ALBUMS_SORT]: createSetClientSideCollectionSortReducer(albumsSection),
[SET_INTERACTIVE_IMPORT_BOOKS_SORT]: createSetClientSideCollectionSortReducer(booksSection),
[CLEAR_INTERACTIVE_IMPORT_ALBUMS]: (state) => {
return updateSectionState(state, albumsSection, {
...defaultState.albums
[CLEAR_INTERACTIVE_IMPORT_BOOKS]: (state) => {
return updateSectionState(state, booksSection, {
...defaultState.books
});
},
[CLEAR_INTERACTIVE_IMPORT_TRACKFILES]: (state) => {
return updateSectionState(state, trackFilesSection, {
...defaultState.trackFiles
return updateSectionState(state, bookFilesSection, {
...defaultState.bookFiles
});
}
+2 -2
View File
@@ -25,7 +25,7 @@ const paged = `${section}.paged`;
export const defaultState = {
options: {
includeUnknownArtistItems: false
includeUnknownAuthorItems: false
},
status: {
@@ -150,7 +150,7 @@ export const persistState = [
// Helpers
function fetchDataAugmenter(getState, payload, data) {
data.includeUnknownArtistItems = getState().queue.options.includeUnknownArtistItems;
data.includeUnknownAuthorItems = getState().queue.options.includeUnknownAuthorItems;
}
//
+14 -14
View File
@@ -11,8 +11,8 @@ import createHandleActions from './Creators/createHandleActions';
// Variables
export const section = 'releases';
export const albumSection = 'releases.album';
export const artistSection = 'releases.artist';
export const bookSection = 'releases.book';
export const authorSection = 'releases.author';
let abortCurrentRequest = null;
@@ -146,19 +146,19 @@ export const defaultState = {
}
],
album: {
book: {
selectedFilterKey: 'all'
},
artist: {
author: {
selectedFilterKey: 'all'
}
};
export const persistState = [
'releases.selectedFilterKey',
'releases.album.customFilters',
'releases.artist.customFilters'
'releases.book.customFilters',
'releases.author.customFilters'
];
//
@@ -170,8 +170,8 @@ export const SET_RELEASES_SORT = 'releases/setReleasesSort';
export const CLEAR_RELEASES = 'releases/clearReleases';
export const GRAB_RELEASE = 'releases/grabRelease';
export const UPDATE_RELEASE = 'releases/updateRelease';
export const SET_ALBUM_RELEASES_FILTER = 'releases/setAlbumReleasesFilter';
export const SET_ARTIST_RELEASES_FILTER = 'releases/setArtistReleasesFilter';
export const SET_BOOK_RELEASES_FILTER = 'releases/setBookReleasesFilter';
export const SET_AUTHOR_RELEASES_FILTER = 'releases/setAuthorReleasesFilter';
//
// Action Creators
@@ -182,8 +182,8 @@ export const setReleasesSort = createAction(SET_RELEASES_SORT);
export const clearReleases = createAction(CLEAR_RELEASES);
export const grabRelease = createThunk(GRAB_RELEASE);
export const updateRelease = createAction(UPDATE_RELEASE);
export const setAlbumReleasesFilter = createAction(SET_ALBUM_RELEASES_FILTER);
export const setArtistReleasesFilter = createAction(SET_ARTIST_RELEASES_FILTER);
export const setBookReleasesFilter = createAction(SET_BOOK_RELEASES_FILTER);
export const setAuthorReleasesFilter = createAction(SET_AUTHOR_RELEASES_FILTER);
//
// Helpers
@@ -248,8 +248,8 @@ export const reducers = createHandleActions({
[CLEAR_RELEASES]: (state) => {
const {
album,
artist,
book,
author,
...otherDefaultState
} = defaultState;
@@ -276,7 +276,7 @@ export const reducers = createHandleActions({
},
[SET_RELEASES_SORT]: createSetClientSideCollectionSortReducer(section),
[SET_ALBUM_RELEASES_FILTER]: createSetClientSideCollectionFilterReducer(albumSection),
[SET_ARTIST_RELEASES_FILTER]: createSetClientSideCollectionFilterReducer(artistSection)
[SET_BOOK_RELEASES_FILTER]: createSetClientSideCollectionFilterReducer(bookSection),
[SET_AUTHOR_RELEASES_FILTER]: createSetClientSideCollectionFilterReducer(authorSection)
}, defaultState, section);
+19 -19
View File
@@ -1,12 +1,12 @@
import _ from 'lodash';
import { createAction } from 'redux-actions';
import { batchActions } from 'redux-batched-actions';
import monitorOptions from 'Utilities/Artist/monitorOptions';
import monitorOptions from 'Utilities/Author/monitorOptions';
import getSectionState from 'Utilities/State/getSectionState';
import updateSectionState from 'Utilities/State/updateSectionState';
import createAjaxRequest from 'Utilities/createAjaxRequest';
import getNewArtist from 'Utilities/Artist/getNewArtist';
import getNewAlbum from 'Utilities/Album/getNewAlbum';
import getNewAuthor from 'Utilities/Author/getNewAuthor';
import getNewBook from 'Utilities/Book/getNewBook';
import { createThunk, handleThunks } from 'Store/thunks';
import createHandleActions from './Creators/createHandleActions';
import { set, update, updateItem } from './baseActions';
@@ -46,8 +46,8 @@ export const persistState = [
// Actions Types
export const GET_SEARCH_RESULTS = 'search/getSearchResults';
export const ADD_ARTIST = 'search/addArtist';
export const ADD_ALBUM = 'search/addAlbum';
export const ADD_AUTHOR = 'search/addAuthor';
export const ADD_BOOK = 'search/addBook';
export const CLEAR_SEARCH_RESULTS = 'search/clearSearchResults';
export const SET_ADD_DEFAULT = 'search/setAddDefault';
@@ -55,8 +55,8 @@ export const SET_ADD_DEFAULT = 'search/setAddDefault';
// Action Creators
export const getSearchResults = createThunk(GET_SEARCH_RESULTS);
export const addArtist = createThunk(ADD_ARTIST);
export const addAlbum = createThunk(ADD_ALBUM);
export const addAuthor = createThunk(ADD_AUTHOR);
export const addBook = createThunk(ADD_BOOK);
export const clearSearchResults = createAction(CLEAR_SEARCH_RESULTS);
export const setAddDefault = createAction(SET_ADD_DEFAULT);
@@ -104,24 +104,24 @@ export const actionHandlers = handleThunks({
});
},
[ADD_ARTIST]: function(getState, payload, dispatch) {
[ADD_AUTHOR]: function(getState, payload, dispatch) {
dispatch(set({ section, isAdding: true }));
const foreignAuthorId = payload.foreignAuthorId;
const items = getState().search.items;
const itemToAdd = _.find(items, { foreignId: foreignAuthorId });
const newArtist = getNewArtist(_.cloneDeep(itemToAdd.artist), payload);
const newAuthor = getNewAuthor(_.cloneDeep(itemToAdd.author), payload);
const promise = createAjaxRequest({
url: '/artist',
url: '/author',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify(newArtist)
data: JSON.stringify(newAuthor)
}).request;
promise.done((data) => {
dispatch(batchActions([
updateItem({ section: 'artist', ...data }),
updateItem({ section: 'authors', ...data }),
set({
section,
@@ -142,26 +142,26 @@ export const actionHandlers = handleThunks({
});
},
[ADD_ALBUM]: function(getState, payload, dispatch) {
[ADD_BOOK]: function(getState, payload, dispatch) {
dispatch(set({ section, isAdding: true }));
const foreignBookId = payload.foreignBookId;
const items = getState().search.items;
const itemToAdd = _.find(items, { foreignId: foreignBookId });
const newAlbum = getNewAlbum(_.cloneDeep(itemToAdd.album), payload);
const newBook = getNewBook(_.cloneDeep(itemToAdd.book), payload);
const promise = createAjaxRequest({
url: '/album',
url: '/book',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify(newAlbum)
data: JSON.stringify(newBook)
}).request;
promise.done((data) => {
data.releases = itemToAdd.album.releases;
itemToAdd.album = data;
data.releases = itemToAdd.book.releases;
itemToAdd.book = data;
dispatch(batchActions([
updateItem({ section: 'artist', ...data.artist }),
updateItem({ section: 'authors', ...data.author }),
updateItem({ section, ...itemToAdd }),
set({
+3 -3
View File
@@ -60,8 +60,8 @@ export const defaultState = {
isVisible: false
},
{
name: 'trackCount',
label: 'Track Count',
name: 'bookCount',
label: 'Book Count',
isVisible: false
},
{
@@ -94,7 +94,7 @@ export const defaultState = {
// Actions Types
export const FETCH_SERIES = 'series/fetchSeries';
export const SET_SERIES_SORT = 'albums/setSeriesSort';
export const SET_SERIES_SORT = 'books/setSeriesSort';
export const CLEAR_SERIES = 'series/clearSeries';
//
-120
View File
@@ -1,120 +0,0 @@
import { createAction } from 'redux-actions';
import { sortDirections } from 'Helpers/Props';
import { createThunk, handleThunks } from 'Store/thunks';
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer';
import createFetchHandler from './Creators/createFetchHandler';
import createHandleActions from './Creators/createHandleActions';
//
// Variables
export const section = 'tracks';
//
// State
export const defaultState = {
isFetching: false,
isPopulated: false,
error: null,
sortKey: 'mediumNumber',
sortDirection: sortDirections.ASCENDING,
secondarySortKey: 'absoluteTrackNumber',
secondarySortDirection: sortDirections.ASCENDING,
items: [],
columns: [
{
name: 'medium',
label: 'Medium',
isVisible: false
},
{
name: 'absoluteTrackNumber',
label: 'Track',
isVisible: true
},
{
name: 'title',
label: 'Title',
isVisible: true
},
{
name: 'path',
label: 'Path',
isVisible: false
},
{
name: 'duration',
label: 'Duration',
isVisible: true
},
{
name: 'audioInfo',
label: 'Audio Info',
isVisible: true
},
{
name: 'status',
label: 'Status',
isVisible: true
},
{
name: 'actions',
columnLabel: 'Actions',
isVisible: true,
isModifiable: false
}
]
};
export const persistState = [
'tracks.sortKey',
'tracks.sortDirection',
'tracks.columns'
];
//
// Actions Types
export const FETCH_TRACKS = 'tracks/fetchTracks';
export const SET_TRACKS_SORT = 'tracks/setTracksSort';
export const SET_TRACKS_TABLE_OPTION = 'tracks/setTracksTableOption';
export const CLEAR_TRACKS = 'tracks/clearTracks';
//
// Action Creators
export const fetchTracks = createThunk(FETCH_TRACKS);
export const setTracksSort = createAction(SET_TRACKS_SORT);
export const setTracksTableOption = createAction(SET_TRACKS_TABLE_OPTION);
export const clearTracks = createAction(CLEAR_TRACKS);
//
// Action Handlers
export const actionHandlers = handleThunks({
[FETCH_TRACKS]: createFetchHandler(section, '/track')
});
//
// Reducers
export const reducers = createHandleActions({
[SET_TRACKS_TABLE_OPTION]: createSetTableOptionReducer(section),
[FETCH_TRACKS]: (state) => {
return Object.assign({}, state, {
isFetching: false,
isPopulated: false,
error: null,
items: []
});
},
[SET_TRACKS_SORT]: createSetClientSideCollectionSortReducer(section)
}, defaultState, section);
+7 -7
View File
@@ -4,7 +4,7 @@ import { filterTypes, sortDirections } from 'Helpers/Props';
import { createThunk, handleThunks } from 'Store/thunks';
import createClearReducer from './Creators/Reducers/createClearReducer';
import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer';
import createBatchToggleAlbumMonitoredHandler from './Creators/createBatchToggleAlbumMonitoredHandler';
import createBatchToggleBookMonitoredHandler from './Creators/createBatchToggleBookMonitoredHandler';
import createServerSideCollectionHandlers from './Creators/createServerSideCollectionHandlers';
import createHandleActions from './Creators/createHandleActions';
@@ -172,7 +172,7 @@ export const SET_MISSING_FILTER = 'wanted/missing/setMissingFilter';
export const SET_MISSING_TABLE_OPTION = 'wanted/missing/setMissingTableOption';
export const CLEAR_MISSING = 'wanted/missing/clearMissing';
export const BATCH_TOGGLE_MISSING_ALBUMS = 'wanted/missing/batchToggleMissingAlbums';
export const BATCH_TOGGLE_MISSING_BOOKS = 'wanted/missing/batchToggleMissingBooks';
export const FETCH_CUTOFF_UNMET = 'wanted/cutoffUnmet/fetchCutoffUnmet';
export const GOTO_FIRST_CUTOFF_UNMET_PAGE = 'wanted/cutoffUnmet/gotoCutoffUnmetFirstPage';
@@ -185,7 +185,7 @@ export const SET_CUTOFF_UNMET_FILTER = 'wanted/cutoffUnmet/setCutoffUnmetFilter'
export const SET_CUTOFF_UNMET_TABLE_OPTION = 'wanted/cutoffUnmet/setCutoffUnmetTableOption';
export const CLEAR_CUTOFF_UNMET = 'wanted/cutoffUnmet/clearCutoffUnmet';
export const BATCH_TOGGLE_CUTOFF_UNMET_ALBUMS = 'wanted/cutoffUnmet/batchToggleCutoffUnmetAlbums';
export const BATCH_TOGGLE_CUTOFF_UNMET_BOOKS = 'wanted/cutoffUnmet/batchToggleCutoffUnmetBooks';
//
// Action Creators
@@ -201,7 +201,7 @@ export const setMissingFilter = createThunk(SET_MISSING_FILTER);
export const setMissingTableOption = createAction(SET_MISSING_TABLE_OPTION);
export const clearMissing = createAction(CLEAR_MISSING);
export const batchToggleMissingAlbums = createThunk(BATCH_TOGGLE_MISSING_ALBUMS);
export const batchToggleMissingBooks = createThunk(BATCH_TOGGLE_MISSING_BOOKS);
export const fetchCutoffUnmet = createThunk(FETCH_CUTOFF_UNMET);
export const gotoCutoffUnmetFirstPage = createThunk(GOTO_FIRST_CUTOFF_UNMET_PAGE);
@@ -214,7 +214,7 @@ export const setCutoffUnmetFilter = createThunk(SET_CUTOFF_UNMET_FILTER);
export const setCutoffUnmetTableOption = createAction(SET_CUTOFF_UNMET_TABLE_OPTION);
export const clearCutoffUnmet = createAction(CLEAR_CUTOFF_UNMET);
export const batchToggleCutoffUnmetAlbums = createThunk(BATCH_TOGGLE_CUTOFF_UNMET_ALBUMS);
export const batchToggleCutoffUnmetBooks = createThunk(BATCH_TOGGLE_CUTOFF_UNMET_BOOKS);
//
// Action Handlers
@@ -237,7 +237,7 @@ export const actionHandlers = handleThunks({
}
),
[BATCH_TOGGLE_MISSING_ALBUMS]: createBatchToggleAlbumMonitoredHandler('wanted.missing', fetchMissing),
[BATCH_TOGGLE_MISSING_BOOKS]: createBatchToggleBookMonitoredHandler('wanted.missing', fetchMissing),
...createServerSideCollectionHandlers(
'wanted.cutoffUnmet',
@@ -255,7 +255,7 @@ export const actionHandlers = handleThunks({
}
),
[BATCH_TOGGLE_CUTOFF_UNMET_ALBUMS]: createBatchToggleAlbumMonitoredHandler('wanted.cutoffUnmet', fetchCutoffUnmet)
[BATCH_TOGGLE_CUTOFF_UNMET_BOOKS]: createBatchToggleBookMonitoredHandler('wanted.cutoffUnmet', fetchCutoffUnmet)
});