mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-23 22:25:09 -04:00
New: Readarr 0.1
This commit is contained in:
@@ -5,25 +5,25 @@ import getSectionState from 'Utilities/State/getSectionState';
|
||||
function createBatchToggleAlbumMonitoredHandler(section, fetchHandler) {
|
||||
return function(getState, payload, dispatch) {
|
||||
const {
|
||||
albumIds,
|
||||
bookIds,
|
||||
monitored
|
||||
} = payload;
|
||||
|
||||
const state = getSectionState(getState(), section, true);
|
||||
|
||||
dispatch(updateAlbums(section, state.items, albumIds, {
|
||||
dispatch(updateAlbums(section, state.items, bookIds, {
|
||||
isSaving: true
|
||||
}));
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
url: '/album/monitor',
|
||||
method: 'PUT',
|
||||
data: JSON.stringify({ albumIds, monitored }),
|
||||
data: JSON.stringify({ bookIds, monitored }),
|
||||
dataType: 'json'
|
||||
}).request;
|
||||
|
||||
promise.done(() => {
|
||||
dispatch(updateAlbums(section, state.items, albumIds, {
|
||||
dispatch(updateAlbums(section, state.items, bookIds, {
|
||||
isSaving: false,
|
||||
monitored
|
||||
}));
|
||||
@@ -32,7 +32,7 @@ function createBatchToggleAlbumMonitoredHandler(section, fetchHandler) {
|
||||
});
|
||||
|
||||
promise.fail(() => {
|
||||
dispatch(updateAlbums(section, state.items, albumIds, {
|
||||
dispatch(updateAlbums(section, state.items, bookIds, {
|
||||
isSaving: false
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -46,6 +46,11 @@ export default {
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
schema: {
|
||||
isCalibreLibrary: false,
|
||||
host: 'localhost',
|
||||
port: 8080,
|
||||
useSsl: false,
|
||||
outputProfile: 0,
|
||||
defaultTags: []
|
||||
},
|
||||
isSaving: false,
|
||||
|
||||
@@ -57,28 +57,11 @@ export const defaultState = {
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'secondaryTypes',
|
||||
label: 'Secondary Types',
|
||||
isSortable: true,
|
||||
isVisible: false
|
||||
},
|
||||
{
|
||||
name: 'mediumCount',
|
||||
label: 'Media Count',
|
||||
isVisible: false
|
||||
},
|
||||
{
|
||||
name: 'trackCount',
|
||||
label: 'Track Count',
|
||||
isVisible: false
|
||||
},
|
||||
{
|
||||
name: 'duration',
|
||||
label: 'Duration',
|
||||
isSortable: true,
|
||||
isVisible: false
|
||||
},
|
||||
{
|
||||
name: 'rating',
|
||||
label: 'Rating',
|
||||
@@ -157,7 +140,7 @@ export const actionHandlers = handleThunks({
|
||||
|
||||
[TOGGLE_ALBUM_MONITORED]: function(getState, payload, dispatch) {
|
||||
const {
|
||||
albumId,
|
||||
bookId,
|
||||
albumEntity = albumEntities.ALBUMS,
|
||||
monitored
|
||||
} = payload;
|
||||
@@ -165,13 +148,13 @@ export const actionHandlers = handleThunks({
|
||||
const albumSection = _.last(albumEntity.split('.'));
|
||||
|
||||
dispatch(updateItem({
|
||||
id: albumId,
|
||||
id: bookId,
|
||||
section: albumSection,
|
||||
isSaving: true
|
||||
}));
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
url: `/album/${albumId}`,
|
||||
url: `/album/${bookId}`,
|
||||
method: 'PUT',
|
||||
data: JSON.stringify({ monitored }),
|
||||
dataType: 'json'
|
||||
@@ -179,7 +162,7 @@ export const actionHandlers = handleThunks({
|
||||
|
||||
promise.done((data) => {
|
||||
dispatch(updateItem({
|
||||
id: albumId,
|
||||
id: bookId,
|
||||
section: albumSection,
|
||||
isSaving: false,
|
||||
monitored
|
||||
@@ -188,7 +171,7 @@ export const actionHandlers = handleThunks({
|
||||
|
||||
promise.fail((xhr) => {
|
||||
dispatch(updateItem({
|
||||
id: albumId,
|
||||
id: bookId,
|
||||
section: albumSection,
|
||||
isSaving: false
|
||||
}));
|
||||
@@ -197,15 +180,15 @@ export const actionHandlers = handleThunks({
|
||||
|
||||
[TOGGLE_ALBUMS_MONITORED]: function(getState, payload, dispatch) {
|
||||
const {
|
||||
albumIds,
|
||||
bookIds,
|
||||
albumEntity = albumEntities.ALBUMS,
|
||||
monitored
|
||||
} = payload;
|
||||
|
||||
dispatch(batchActions(
|
||||
albumIds.map((albumId) => {
|
||||
bookIds.map((bookId) => {
|
||||
return updateItem({
|
||||
id: albumId,
|
||||
id: bookId,
|
||||
section: albumEntity,
|
||||
isSaving: true
|
||||
});
|
||||
@@ -215,15 +198,15 @@ export const actionHandlers = handleThunks({
|
||||
const promise = createAjaxRequest({
|
||||
url: '/album/monitor',
|
||||
method: 'PUT',
|
||||
data: JSON.stringify({ albumIds, monitored }),
|
||||
data: JSON.stringify({ bookIds, monitored }),
|
||||
dataType: 'json'
|
||||
}).request;
|
||||
|
||||
promise.done((data) => {
|
||||
dispatch(batchActions(
|
||||
albumIds.map((albumId) => {
|
||||
bookIds.map((bookId) => {
|
||||
return updateItem({
|
||||
id: albumId,
|
||||
id: bookId,
|
||||
section: albumEntity,
|
||||
isSaving: false,
|
||||
monitored
|
||||
@@ -234,9 +217,9 @@ export const actionHandlers = handleThunks({
|
||||
|
||||
promise.fail((xhr) => {
|
||||
dispatch(batchActions(
|
||||
albumIds.map((albumId) => {
|
||||
bookIds.map((bookId) => {
|
||||
return updateItem({
|
||||
id: albumId,
|
||||
id: bookId,
|
||||
section: albumEntity,
|
||||
isSaving: false
|
||||
});
|
||||
|
||||
@@ -48,7 +48,7 @@ export const actionHandlers = handleThunks({
|
||||
page: 1,
|
||||
sortKey: 'date',
|
||||
sortDirection: sortDirections.DESCENDING,
|
||||
albumId: payload.albumId
|
||||
bookId: payload.bookId
|
||||
};
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
@@ -82,7 +82,7 @@ export const actionHandlers = handleThunks({
|
||||
[ALBUM_HISTORY_MARK_AS_FAILED]: function(getState, payload, dispatch) {
|
||||
const {
|
||||
historyId,
|
||||
albumId
|
||||
bookId
|
||||
} = payload;
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
@@ -94,7 +94,7 @@ export const actionHandlers = handleThunks({
|
||||
}).request;
|
||||
|
||||
promise.done(() => {
|
||||
dispatch(fetchAlbumHistory({ albumId }));
|
||||
dispatch(fetchAlbumHistory({ bookId }));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -100,14 +100,14 @@ export const actionHandlers = handleThunks({
|
||||
|
||||
[SAVE_ALBUM_STUDIO]: function(getState, payload, dispatch) {
|
||||
const {
|
||||
artistIds,
|
||||
authorIds,
|
||||
monitored,
|
||||
monitor
|
||||
} = payload;
|
||||
|
||||
const artist = [];
|
||||
|
||||
artistIds.forEach((id) => {
|
||||
authorIds.forEach((id) => {
|
||||
const artistToUpdate = { id };
|
||||
|
||||
if (payload.hasOwnProperty('monitored')) {
|
||||
|
||||
@@ -224,7 +224,7 @@ export const actionHandlers = handleThunks({
|
||||
|
||||
[TOGGLE_ARTIST_MONITORED]: (getState, payload, dispatch) => {
|
||||
const {
|
||||
artistId: id,
|
||||
authorId: id,
|
||||
monitored
|
||||
} = payload;
|
||||
|
||||
@@ -266,7 +266,7 @@ export const actionHandlers = handleThunks({
|
||||
|
||||
[TOGGLE_ALBUM_MONITORED]: function(getState, payload, dispatch) {
|
||||
const {
|
||||
artistId: id,
|
||||
authorId: id,
|
||||
seasonNumber,
|
||||
monitored
|
||||
} = payload;
|
||||
@@ -296,7 +296,7 @@ export const actionHandlers = handleThunks({
|
||||
}).request;
|
||||
|
||||
promise.done((data) => {
|
||||
const albums = _.filter(getState().albums.items, { artistId: id, seasonNumber });
|
||||
const albums = _.filter(getState().albums.items, { authorId: id, seasonNumber });
|
||||
|
||||
dispatch(batchActions([
|
||||
updateItem({
|
||||
|
||||
@@ -110,7 +110,7 @@ export const actionHandlers = handleThunks({
|
||||
}));
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
url: '/artist/editor',
|
||||
url: '/author/editor',
|
||||
method: 'PUT',
|
||||
data: JSON.stringify(payload),
|
||||
dataType: 'json'
|
||||
@@ -150,7 +150,7 @@ export const actionHandlers = handleThunks({
|
||||
}));
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
url: '/artist/editor',
|
||||
url: '/author/editor',
|
||||
method: 'DELETE',
|
||||
data: JSON.stringify(payload),
|
||||
dataType: 'json'
|
||||
|
||||
@@ -73,8 +73,8 @@ export const actionHandlers = handleThunks({
|
||||
[ARTIST_HISTORY_MARK_AS_FAILED]: function(getState, payload, dispatch) {
|
||||
const {
|
||||
historyId,
|
||||
artistId,
|
||||
albumId
|
||||
authorId,
|
||||
bookId
|
||||
} = payload;
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
@@ -86,7 +86,7 @@ export const actionHandlers = handleThunks({
|
||||
}).request;
|
||||
|
||||
promise.done(() => {
|
||||
dispatch(fetchArtistHistory({ artistId, albumId }));
|
||||
dispatch(fetchArtistHistory({ authorId, bookId }));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ export const defaultState = {
|
||||
|
||||
columns: [
|
||||
{
|
||||
name: 'artist.sortName',
|
||||
name: 'authors.sortName',
|
||||
label: 'Artist Name',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
|
||||
@@ -345,11 +345,11 @@ export const actionHandlers = handleThunks({
|
||||
},
|
||||
|
||||
[SEARCH_MISSING]: function(getState, payload, dispatch) {
|
||||
const { albumIds } = payload;
|
||||
const { bookIds } = payload;
|
||||
|
||||
const commandPayload = {
|
||||
name: commandNames.ALBUM_SEARCH,
|
||||
albumIds
|
||||
bookIds
|
||||
};
|
||||
|
||||
executeCommandHelper(commandPayload, dispatch).then((data) => {
|
||||
|
||||
@@ -34,22 +34,17 @@ export const defaultState = {
|
||||
isModifiable: false
|
||||
},
|
||||
{
|
||||
name: 'artist.sortName',
|
||||
label: 'Artist',
|
||||
name: 'authors.sortName',
|
||||
label: 'Author',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'album.title',
|
||||
label: 'Album Title',
|
||||
name: 'books.title',
|
||||
label: 'Book',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'trackTitle',
|
||||
label: 'Track Title',
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'quality',
|
||||
label: 'Quality',
|
||||
|
||||
@@ -21,6 +21,7 @@ import * as artist from './artistActions';
|
||||
import * as artistEditor from './artistEditorActions';
|
||||
import * as artistHistory from './artistHistoryActions';
|
||||
import * as artistIndex from './artistIndexActions';
|
||||
import * as series from './seriesActions';
|
||||
import * as search from './searchActions';
|
||||
import * as settings from './settingsActions';
|
||||
import * as system from './systemActions';
|
||||
@@ -52,6 +53,7 @@ export default [
|
||||
artistEditor,
|
||||
artistHistory,
|
||||
artistIndex,
|
||||
series,
|
||||
search,
|
||||
settings,
|
||||
system,
|
||||
|
||||
@@ -55,7 +55,7 @@ export const defaultState = {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
sortKey: 'albumTitle',
|
||||
sortKey: 'title',
|
||||
sortDirection: sortDirections.ASCENDING,
|
||||
items: []
|
||||
},
|
||||
@@ -64,7 +64,7 @@ export const defaultState = {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
sortKey: 'relataivePath',
|
||||
sortKey: 'relativePath',
|
||||
sortDirection: sortDirections.ASCENDING,
|
||||
items: []
|
||||
}
|
||||
|
||||
@@ -63,20 +63,20 @@ export const defaultState = {
|
||||
isModifiable: false
|
||||
},
|
||||
{
|
||||
name: 'artist.sortName',
|
||||
label: 'Artist',
|
||||
name: 'authors.sortName',
|
||||
label: 'Author',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'album.title',
|
||||
label: 'Album Title',
|
||||
name: 'books.title',
|
||||
label: 'Book Title',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'album.releaseDate',
|
||||
label: 'Album Release Date',
|
||||
name: 'books.releaseDate',
|
||||
label: 'Release Date',
|
||||
isSortable: true,
|
||||
isVisible: false
|
||||
},
|
||||
|
||||
@@ -151,7 +151,7 @@ export const defaultState = {
|
||||
},
|
||||
|
||||
artist: {
|
||||
selectedFilterKey: 'discography-pack'
|
||||
selectedFilterKey: 'all'
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ export const defaultState = {
|
||||
monitor: monitorOptions[0].key,
|
||||
qualityProfileId: 0,
|
||||
metadataProfileId: 0,
|
||||
albumFolder: true,
|
||||
tags: []
|
||||
}
|
||||
};
|
||||
@@ -108,9 +107,9 @@ export const actionHandlers = handleThunks({
|
||||
[ADD_ARTIST]: function(getState, payload, dispatch) {
|
||||
dispatch(set({ section, isAdding: true }));
|
||||
|
||||
const foreignArtistId = payload.foreignArtistId;
|
||||
const foreignAuthorId = payload.foreignAuthorId;
|
||||
const items = getState().search.items;
|
||||
const itemToAdd = _.find(items, { foreignId: foreignArtistId });
|
||||
const itemToAdd = _.find(items, { foreignId: foreignAuthorId });
|
||||
const newArtist = getNewArtist(_.cloneDeep(itemToAdd.artist), payload);
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
@@ -146,9 +145,9 @@ export const actionHandlers = handleThunks({
|
||||
[ADD_ALBUM]: function(getState, payload, dispatch) {
|
||||
dispatch(set({ section, isAdding: true }));
|
||||
|
||||
const foreignAlbumId = payload.foreignAlbumId;
|
||||
const foreignBookId = payload.foreignBookId;
|
||||
const items = getState().search.items;
|
||||
const itemToAdd = _.find(items, { foreignId: foreignAlbumId });
|
||||
const itemToAdd = _.find(items, { foreignId: foreignBookId });
|
||||
const newAlbum = getNewAlbum(_.cloneDeep(itemToAdd.album), payload);
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
import { createAction } from 'redux-actions';
|
||||
import { sortDirections } from 'Helpers/Props';
|
||||
import { createThunk, handleThunks } from 'Store/thunks';
|
||||
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
|
||||
import createFetchHandler from './Creators/createFetchHandler';
|
||||
import createHandleActions from './Creators/createHandleActions';
|
||||
|
||||
//
|
||||
// Variables
|
||||
|
||||
export const section = 'series';
|
||||
|
||||
//
|
||||
// State
|
||||
|
||||
export const defaultState = {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
isSaving: false,
|
||||
saveError: null,
|
||||
sortKey: 'position',
|
||||
sortDirection: sortDirections.ASCENDING,
|
||||
items: [],
|
||||
|
||||
columns: [
|
||||
{
|
||||
name: 'monitored',
|
||||
columnLabel: 'Monitored',
|
||||
isVisible: true,
|
||||
isModifiable: false
|
||||
},
|
||||
{
|
||||
name: 'title',
|
||||
label: 'Title',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'position',
|
||||
label: 'Number',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'releaseDate',
|
||||
label: 'Release Date',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'secondaryTypes',
|
||||
label: 'Secondary Types',
|
||||
isSortable: true,
|
||||
isVisible: false
|
||||
},
|
||||
{
|
||||
name: 'mediumCount',
|
||||
label: 'Media Count',
|
||||
isVisible: false
|
||||
},
|
||||
{
|
||||
name: 'trackCount',
|
||||
label: 'Track Count',
|
||||
isVisible: false
|
||||
},
|
||||
{
|
||||
name: 'duration',
|
||||
label: 'Duration',
|
||||
isSortable: true,
|
||||
isVisible: false
|
||||
},
|
||||
{
|
||||
name: 'rating',
|
||||
label: 'Rating',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'status',
|
||||
label: 'Status',
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'actions',
|
||||
columnLabel: 'Actions',
|
||||
isVisible: true,
|
||||
isModifiable: false
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
//
|
||||
// Actions Types
|
||||
|
||||
export const FETCH_SERIES = 'series/fetchSeries';
|
||||
export const SET_SERIES_SORT = 'albums/setSeriesSort';
|
||||
export const CLEAR_SERIES = 'series/clearSeries';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
|
||||
export const fetchSeries = createThunk(FETCH_SERIES);
|
||||
export const setSeriesSort = createAction(SET_SERIES_SORT);
|
||||
export const clearSeries = createAction(CLEAR_SERIES);
|
||||
|
||||
//
|
||||
// Action Handlers
|
||||
|
||||
export const actionHandlers = handleThunks({
|
||||
[FETCH_SERIES]: createFetchHandler(section, '/series')
|
||||
});
|
||||
|
||||
//
|
||||
// Reducers
|
||||
|
||||
export const reducers = createHandleActions({
|
||||
|
||||
[SET_SERIES_SORT]: createSetClientSideCollectionSortReducer(section),
|
||||
|
||||
[CLEAR_SERIES]: (state) => {
|
||||
return Object.assign({}, state, {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
items: []
|
||||
});
|
||||
}
|
||||
|
||||
}, defaultState, section);
|
||||
@@ -28,20 +28,14 @@ export const defaultState = {
|
||||
|
||||
columns: [
|
||||
{
|
||||
name: 'artist.sortName',
|
||||
label: 'Artist Name',
|
||||
name: 'authors.sortName',
|
||||
label: 'Author',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'albumTitle',
|
||||
label: 'Album Title',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'albumType',
|
||||
label: 'Album Type',
|
||||
name: 'books.title',
|
||||
label: 'Book',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
@@ -51,11 +45,6 @@ export const defaultState = {
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
// {
|
||||
// name: 'status',
|
||||
// label: 'Status',
|
||||
// isVisible: true
|
||||
// },
|
||||
{
|
||||
name: 'actions',
|
||||
columnLabel: 'Actions',
|
||||
@@ -102,20 +91,14 @@ export const defaultState = {
|
||||
|
||||
columns: [
|
||||
{
|
||||
name: 'artist.sortName',
|
||||
label: 'Artist Name',
|
||||
name: 'authors.sortName',
|
||||
label: 'Author',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'albumTitle',
|
||||
label: 'Album Title',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'albumType',
|
||||
label: 'Album Type',
|
||||
name: 'books.Title',
|
||||
label: 'Book',
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
@@ -125,11 +108,6 @@ export const defaultState = {
|
||||
isSortable: true,
|
||||
isVisible: true
|
||||
},
|
||||
// {
|
||||
// name: 'status',
|
||||
// label: 'Status',
|
||||
// isVisible: true
|
||||
// },
|
||||
{
|
||||
name: 'actions',
|
||||
columnLabel: 'Actions',
|
||||
|
||||
Reference in New Issue
Block a user