From 9f079fb8ba434e4ca92338dd3028cc77058faba7 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 28 Oct 2017 21:44:06 -0400 Subject: [PATCH] Fixed: Batch Monitor/Unmonitor on Wanted Pages --- frontend/src/Album/EpisodeSearchCellConnector.js | 4 ++-- .../src/Album/Search/EpisodeSearchConnector.js | 2 +- frontend/src/Commands/commandNames.js | 4 ++-- ...s => createBatchToggleAlbumMonitoredHandler.js} | 14 +++++++------- ...ler.js => createToggleAlbumMonitoredHandler.js} | 14 +++++++------- frontend/src/Store/Actions/actionTypes.js | 6 +++--- frontend/src/Store/Actions/wantedActionHandlers.js | 6 +++--- frontend/src/Store/Actions/wantedActions.js | 4 ++-- .../updateEpisodes.js => Album/updateAlbums.js} | 4 ++-- frontend/src/Wanted/CutoffUnmet/CutoffUnmet.js | 6 +++--- .../src/Wanted/CutoffUnmet/CutoffUnmetConnector.js | 14 +++++++------- frontend/src/Wanted/Missing/MissingConnector.js | 8 ++++---- 12 files changed, 43 insertions(+), 43 deletions(-) rename frontend/src/Store/Actions/Creators/{createBatchToggleEpisodeMonitoredHandler.js => createBatchToggleAlbumMonitoredHandler.js} (57%) rename frontend/src/Store/Actions/Creators/{createToggleEpisodeMonitoredHandler.js => createToggleAlbumMonitoredHandler.js} (57%) rename frontend/src/Utilities/{Episode/updateEpisodes.js => Album/updateAlbums.js} (77%) diff --git a/frontend/src/Album/EpisodeSearchCellConnector.js b/frontend/src/Album/EpisodeSearchCellConnector.js index c8ba2cb43..20bffae07 100644 --- a/frontend/src/Album/EpisodeSearchCellConnector.js +++ b/frontend/src/Album/EpisodeSearchCellConnector.js @@ -15,7 +15,7 @@ function createMapStateToProps() { createCommandsSelector(), (albumId, sceneSeasonNumber, artist, commands) => { const isSearching = _.some(commands, (command) => { - const episodeSearch = command.name === commandNames.EPISODE_SEARCH; + const episodeSearch = command.name === commandNames.ALBUM_SEARCH; if (!episodeSearch) { return false; @@ -37,7 +37,7 @@ function createMapDispatchToProps(dispatch, props) { return { onSearchPress(name, path) { dispatch(executeCommand({ - name: commandNames.EPISODE_SEARCH, + name: commandNames.ALBUM_SEARCH, albumIds: [props.albumId] })); } diff --git a/frontend/src/Album/Search/EpisodeSearchConnector.js b/frontend/src/Album/Search/EpisodeSearchConnector.js index 8f511bfa0..0759ec1f0 100644 --- a/frontend/src/Album/Search/EpisodeSearchConnector.js +++ b/frontend/src/Album/Search/EpisodeSearchConnector.js @@ -46,7 +46,7 @@ class EpisodeSearchConnector extends Component { onQuickSearchPress = () => { this.props.executeCommand({ - name: commandNames.EPISODE_SEARCH, + name: commandNames.ALBUM_SEARCH, albumIds: [this.props.albumId] }); diff --git a/frontend/src/Commands/commandNames.js b/frontend/src/Commands/commandNames.js index e13626980..e432c42e2 100644 --- a/frontend/src/Commands/commandNames.js +++ b/frontend/src/Commands/commandNames.js @@ -3,11 +3,11 @@ export const BACKUP = 'Backup'; export const CHECK_FOR_FINISHED_DOWNLOAD = 'CheckForFinishedDownload'; export const CLEAR_BLACKLIST = 'ClearBlacklist'; export const CLEAR_LOGS = 'ClearLog'; -export const CUTOFF_UNMET_EPISODE_SEARCH = 'CutoffUnmetAlbumSearch'; +export const CUTOFF_UNMET_ALBUM_SEARCH = 'CutoffUnmetAlbumSearch'; export const DELETE_LOG_FILES = 'DeleteLogFiles'; export const DELETE_UPDATE_LOG_FILES = 'DeleteUpdateLogFiles'; export const DOWNLOADED_ALBUMS_SCAN = 'DownloadedAlbumsScan'; -export const EPISODE_SEARCH = 'AlbumSearch'; +export const ALBUM_SEARCH = 'AlbumSearch'; export const INTERACTIVE_IMPORT = 'ManualImport'; export const MISSING_ALBUM_SEARCH = 'MissingAlbumSearch'; export const REFRESH_ARTIST = 'RefreshArtist'; diff --git a/frontend/src/Store/Actions/Creators/createBatchToggleEpisodeMonitoredHandler.js b/frontend/src/Store/Actions/Creators/createBatchToggleAlbumMonitoredHandler.js similarity index 57% rename from frontend/src/Store/Actions/Creators/createBatchToggleEpisodeMonitoredHandler.js rename to frontend/src/Store/Actions/Creators/createBatchToggleAlbumMonitoredHandler.js index 9d09b41f4..6d93633a8 100644 --- a/frontend/src/Store/Actions/Creators/createBatchToggleEpisodeMonitoredHandler.js +++ b/frontend/src/Store/Actions/Creators/createBatchToggleAlbumMonitoredHandler.js @@ -1,7 +1,7 @@ import $ from 'jquery'; -import updateEpisodes from 'Utilities/Episode/updateEpisodes'; +import updateAlbums from 'Utilities/Album/updateAlbums'; -function createBatchToggleEpisodeMonitoredHandler(section, getFromState) { +function createBatchToggleAlbumMonitoredHandler(section, getFromState) { return function(payload) { return function(dispatch, getState) { const { @@ -11,26 +11,26 @@ function createBatchToggleEpisodeMonitoredHandler(section, getFromState) { const state = getFromState(getState()); - updateEpisodes(dispatch, section, state.items, albumIds, { + updateAlbums(dispatch, section, state.items, albumIds, { isSaving: true }); const promise = $.ajax({ - url: '/episode/monitor', + url: '/album/monitor', method: 'PUT', data: JSON.stringify({ albumIds, monitored }), dataType: 'json' }); promise.done(() => { - updateEpisodes(dispatch, section, state.items, albumIds, { + updateAlbums(dispatch, section, state.items, albumIds, { isSaving: false, monitored }); }); promise.fail(() => { - updateEpisodes(dispatch, section, state.items, albumIds, { + updateAlbums(dispatch, section, state.items, albumIds, { isSaving: false }); }); @@ -38,4 +38,4 @@ function createBatchToggleEpisodeMonitoredHandler(section, getFromState) { }; } -export default createBatchToggleEpisodeMonitoredHandler; +export default createBatchToggleAlbumMonitoredHandler; diff --git a/frontend/src/Store/Actions/Creators/createToggleEpisodeMonitoredHandler.js b/frontend/src/Store/Actions/Creators/createToggleAlbumMonitoredHandler.js similarity index 57% rename from frontend/src/Store/Actions/Creators/createToggleEpisodeMonitoredHandler.js rename to frontend/src/Store/Actions/Creators/createToggleAlbumMonitoredHandler.js index 3ddee1430..94581aec9 100644 --- a/frontend/src/Store/Actions/Creators/createToggleEpisodeMonitoredHandler.js +++ b/frontend/src/Store/Actions/Creators/createToggleAlbumMonitoredHandler.js @@ -1,7 +1,7 @@ import $ from 'jquery'; -import updateEpisodes from 'Utilities/Episode/updateEpisodes'; +import updateAlbums from 'Utilities/Album/updateAlbums'; -function createToggleEpisodeMonitoredHandler(section, getFromState) { +function createToggleAlbumMonitoredHandler(section, getFromState) { return function(payload) { return function(dispatch, getState) { const { @@ -11,26 +11,26 @@ function createToggleEpisodeMonitoredHandler(section, getFromState) { const state = getFromState(getState()); - updateEpisodes(dispatch, section, state.items, [albumId], { + updateAlbums(dispatch, section, state.items, [albumId], { isSaving: true }); const promise = $.ajax({ - url: `/episode/${albumId}`, + url: `/album/${albumId}`, method: 'PUT', data: JSON.stringify({ monitored }), dataType: 'json' }); promise.done(() => { - updateEpisodes(dispatch, section, state.items, [albumId], { + updateAlbums(dispatch, section, state.items, [albumId], { isSaving: false, monitored }); }); promise.fail(() => { - updateEpisodes(dispatch, section, state.items, [albumId], { + updateAlbums(dispatch, section, state.items, [albumId], { isSaving: false }); }); @@ -38,4 +38,4 @@ function createToggleEpisodeMonitoredHandler(section, getFromState) { }; } -export default createToggleEpisodeMonitoredHandler; +export default createToggleAlbumMonitoredHandler; diff --git a/frontend/src/Store/Actions/actionTypes.js b/frontend/src/Store/Actions/actionTypes.js index 6dfddae70..2c7a4dc50 100644 --- a/frontend/src/Store/Actions/actionTypes.js +++ b/frontend/src/Store/Actions/actionTypes.js @@ -103,7 +103,7 @@ export const DELETE_TRACK_FILES = 'DELETE_TRACK_FILES'; export const UPDATE_TRACK_FILES = 'UPDATE_TRACK_FILES'; // -// Episode History +// Album History export const FETCH_ALBUM_HISTORY = 'FETCH_ALBUM_HISTORY'; export const CLEAR_ALBUM_HISTORY = 'CLEAR_ALBUM_HISTORY'; @@ -195,7 +195,7 @@ export const SET_MISSING_FILTER = 'SET_MISSING_FILTER'; export const SET_MISSING_TABLE_OPTION = 'SET_MISSING_TABLE_OPTION'; export const CLEAR_MISSING = 'CLEAR_MISSING'; -export const BATCH_TOGGLE_MISSING_EPISODES = 'BATCH_TOGGLE_MISSING_EPISODES'; +export const BATCH_TOGGLE_MISSING_ALBUMS = 'BATCH_TOGGLE_MISSING_ALBUMS'; export const FETCH_CUTOFF_UNMET = 'FETCH_CUTOFF_UNMET'; export const GOTO_FIRST_CUTOFF_UNMET_PAGE = 'GOTO_FIRST_CUTOFF_UNMET_PAGE'; @@ -208,7 +208,7 @@ export const SET_CUTOFF_UNMET_FILTER = 'SET_CUTOFF_UNMET_FILTER'; export const SET_CUTOFF_UNMET_TABLE_OPTION = 'SET_CUTOFF_UNMET_TABLE_OPTION'; export const CLEAR_CUTOFF_UNMET = 'CLEAR_CUTOFF_UNMET'; -export const BATCH_TOGGLE_CUTOFF_UNMET_EPISODES = 'BATCH_TOGGLE_CUTOFF_UNMET_EPISODES'; +export const BATCH_TOGGLE_CUTOFF_UNMET_ALBUMS = 'BATCH_TOGGLE_CUTOFF_UNMET_ALBUMS'; // // Settings diff --git a/frontend/src/Store/Actions/wantedActionHandlers.js b/frontend/src/Store/Actions/wantedActionHandlers.js index ad560b088..60cb121b4 100644 --- a/frontend/src/Store/Actions/wantedActionHandlers.js +++ b/frontend/src/Store/Actions/wantedActionHandlers.js @@ -1,5 +1,5 @@ import serverSideCollectionHandlers from 'Utilities/serverSideCollectionHandlers'; -import createBatchToggleEpisodeMonitoredHandler from './Creators/createBatchToggleEpisodeMonitoredHandler'; +import createBatchToggleAlbumMonitoredHandler from './Creators/createBatchToggleAlbumMonitoredHandler'; import createServerSideCollectionHandlers from './Creators/createServerSideCollectionHandlers'; import * as types from './actionTypes'; @@ -15,7 +15,7 @@ const wantedActionHandlers = { [serverSideCollectionHandlers.FILTER]: types.SET_MISSING_FILTER }), - [types.BATCH_TOGGLE_MISSING_EPISODES]: createBatchToggleEpisodeMonitoredHandler('missing', (state) => state.wanted.missing), + [types.BATCH_TOGGLE_MISSING_ALBUMS]: createBatchToggleAlbumMonitoredHandler('missing', (state) => state.wanted.missing), ...createServerSideCollectionHandlers('cutoffUnmet', '/wanted/cutoff', (state) => state.wanted, { [serverSideCollectionHandlers.FETCH]: types.FETCH_CUTOFF_UNMET, @@ -28,7 +28,7 @@ const wantedActionHandlers = { [serverSideCollectionHandlers.FILTER]: types.SET_CUTOFF_UNMET_FILTER }), - [types.BATCH_TOGGLE_CUTOFF_UNMET_EPISODES]: createBatchToggleEpisodeMonitoredHandler('cutoffUnmet', (state) => state.wanted.cutoffUnmet) + [types.BATCH_TOGGLE_CUTOFF_UNMET_ALBUMS]: createBatchToggleAlbumMonitoredHandler('cutoffUnmet', (state) => state.wanted.cutoffUnmet) }; export default wantedActionHandlers; diff --git a/frontend/src/Store/Actions/wantedActions.js b/frontend/src/Store/Actions/wantedActions.js index 9baac1cd5..75aac6e60 100644 --- a/frontend/src/Store/Actions/wantedActions.js +++ b/frontend/src/Store/Actions/wantedActions.js @@ -16,7 +16,7 @@ export const setMissingFilter = wantedActionHandlers[types.SET_MISSING_FILTER]; export const setMissingTableOption = createAction(types.SET_MISSING_TABLE_OPTION); export const clearMissing = createAction(types.CLEAR_MISSING); -export const batchToggleMissingEpisodes = wantedActionHandlers[types.BATCH_TOGGLE_MISSING_EPISODES]; +export const batchToggleMissingAlbums = wantedActionHandlers[types.BATCH_TOGGLE_MISSING_ALBUMS]; // // Cutoff Unmet @@ -32,4 +32,4 @@ export const setCutoffUnmetFilter = wantedActionHandlers[types.SET_CUTOFF_UNMET_ export const setCutoffUnmetTableOption= createAction(types.SET_CUTOFF_UNMET_TABLE_OPTION); export const clearCutoffUnmet= createAction(types.CLEAR_CUTOFF_UNMET); -export const batchToggleCutoffUnmetEpisodes = wantedActionHandlers[types.BATCH_TOGGLE_CUTOFF_UNMET_EPISODES]; +export const batchToggleCutoffUnmetAlbums = wantedActionHandlers[types.BATCH_TOGGLE_CUTOFF_UNMET_ALBUMS]; diff --git a/frontend/src/Utilities/Episode/updateEpisodes.js b/frontend/src/Utilities/Album/updateAlbums.js similarity index 77% rename from frontend/src/Utilities/Episode/updateEpisodes.js rename to frontend/src/Utilities/Album/updateAlbums.js index d3ad6d74f..16d800de9 100644 --- a/frontend/src/Utilities/Episode/updateEpisodes.js +++ b/frontend/src/Utilities/Album/updateAlbums.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import { update } from 'Store/Actions/baseActions'; -function updateEpisodes(dispatch, section, episodes, albumIds, options) { +function updateAlbums(dispatch, section, episodes, albumIds, options) { const data = _.reduce(episodes, (result, item) => { if (albumIds.indexOf(item.id) > -1) { result.push({ @@ -18,4 +18,4 @@ function updateEpisodes(dispatch, section, episodes, albumIds, options) { dispatch(update({ section, data })); } -export default updateEpisodes; +export default updateAlbums; diff --git a/frontend/src/Wanted/CutoffUnmet/CutoffUnmet.js b/frontend/src/Wanted/CutoffUnmet/CutoffUnmet.js index 2a097e276..76ec74085 100644 --- a/frontend/src/Wanted/CutoffUnmet/CutoffUnmet.js +++ b/frontend/src/Wanted/CutoffUnmet/CutoffUnmet.js @@ -109,7 +109,7 @@ class CutoffUnmet extends Component { columns, totalRecords, isSearchingForAlbums, - isSearchingForCutoffUnmetEpisodes, + isSearchingForCutoffUnmetAlbums, isSaving, filterKey, filterValue, @@ -150,7 +150,7 @@ class CutoffUnmet extends Component { @@ -272,7 +272,7 @@ CutoffUnmet.propTypes = { columns: PropTypes.arrayOf(PropTypes.object).isRequired, totalRecords: PropTypes.number, isSearchingForAlbums: PropTypes.bool.isRequired, - isSearchingForCutoffUnmetEpisodes: PropTypes.bool.isRequired, + isSearchingForCutoffUnmetAlbums: PropTypes.bool.isRequired, isSaving: PropTypes.bool.isRequired, filterKey: PropTypes.string, filterValue: PropTypes.oneOfType([PropTypes.bool, PropTypes.number, PropTypes.string]), diff --git a/frontend/src/Wanted/CutoffUnmet/CutoffUnmetConnector.js b/frontend/src/Wanted/CutoffUnmet/CutoffUnmetConnector.js index 3119ca349..423bdad53 100644 --- a/frontend/src/Wanted/CutoffUnmet/CutoffUnmetConnector.js +++ b/frontend/src/Wanted/CutoffUnmet/CutoffUnmetConnector.js @@ -19,12 +19,12 @@ function createMapStateToProps() { (state) => state.wanted.cutoffUnmet, createCommandsSelector(), (cutoffUnmet, commands) => { - const isSearchingForAlbums = _.some(commands, { name: commandNames.EPISODE_SEARCH }); - const isSearchingForCutoffUnmetEpisodes = _.some(commands, { name: commandNames.CUTOFF_UNMET_EPISODE_SEARCH }); + const isSearchingForAlbums = _.some(commands, { name: commandNames.ALBUM_SEARCH }); + const isSearchingForCutoffUnmetAlbums = _.some(commands, { name: commandNames.CUTOFF_UNMET_ALBUM_SEARCH }); return { isSearchingForAlbums, - isSearchingForCutoffUnmetEpisodes, + isSearchingForCutoffUnmetAlbums, isSaving: _.some(cutoffUnmet.items, { isSaving: true }), ...cutoffUnmet }; @@ -119,7 +119,7 @@ class CutoffUnmetConnector extends Component { onSearchSelectedPress = (selected) => { this.props.executeCommand({ - name: commandNames.EPISODE_SEARCH, + name: commandNames.ALBUM_SEARCH, albumIds: selected }); } @@ -130,7 +130,7 @@ class CutoffUnmetConnector extends Component { filterValue } = this.props; - this.props.batchToggleCutoffUnmetEpisodes({ + this.props.batchToggleCutoffUnmetAlbums({ albumIds: selected, monitored: filterKey !== 'monitored' || !filterValue }); @@ -138,7 +138,7 @@ class CutoffUnmetConnector extends Component { onSearchAllCutoffUnmetPress = () => { this.props.executeCommand({ - name: commandNames.CUTOFF_UNMET_EPISODE_SEARCH + name: commandNames.CUTOFF_UNMET_ALBUM_SEARCH }); } @@ -178,7 +178,7 @@ CutoffUnmetConnector.propTypes = { setCutoffUnmetSort: PropTypes.func.isRequired, setCutoffUnmetFilter: PropTypes.func.isRequired, setCutoffUnmetTableOption: PropTypes.func.isRequired, - batchToggleCutoffUnmetEpisodes: PropTypes.func.isRequired, + batchToggleCutoffUnmetAlbums: PropTypes.func.isRequired, clearCutoffUnmet: PropTypes.func.isRequired, executeCommand: PropTypes.func.isRequired, fetchQueueDetails: PropTypes.func.isRequired, diff --git a/frontend/src/Wanted/Missing/MissingConnector.js b/frontend/src/Wanted/Missing/MissingConnector.js index dd9a5de54..80db02eb0 100644 --- a/frontend/src/Wanted/Missing/MissingConnector.js +++ b/frontend/src/Wanted/Missing/MissingConnector.js @@ -18,7 +18,7 @@ function createMapStateToProps() { (state) => state.wanted.missing, createCommandsSelector(), (missing, commands) => { - const isSearchingForAlbums = _.some(commands, { name: commandNames.EPISODE_SEARCH }); + const isSearchingForAlbums = _.some(commands, { name: commandNames.ALBUM_SEARCH }); const isSearchingForMissingAlbums = _.some(commands, { name: commandNames.MISSING_ALBUM_SEARCH }); return { @@ -109,7 +109,7 @@ class MissingConnector extends Component { onSearchSelectedPress = (selected) => { this.props.executeCommand({ - name: commandNames.EPISODE_SEARCH, + name: commandNames.ALBUM_SEARCH, albumIds: selected }); } @@ -120,7 +120,7 @@ class MissingConnector extends Component { filterValue } = this.props; - this.props.batchToggleMissingEpisodes({ + this.props.batchToggleMissingAlbums({ albumIds: selected, monitored: filterKey !== 'monitored' || !filterValue }); @@ -169,7 +169,7 @@ MissingConnector.propTypes = { setMissingFilter: PropTypes.func.isRequired, setMissingTableOption: PropTypes.func.isRequired, clearMissing: PropTypes.func.isRequired, - batchToggleMissingEpisodes: PropTypes.func.isRequired, + batchToggleMissingAlbums: PropTypes.func.isRequired, executeCommand: PropTypes.func.isRequired, fetchQueueDetails: PropTypes.func.isRequired, clearQueueDetails: PropTypes.func.isRequired