Fixed: Batch Monitor/Unmonitor on Wanted Pages

pull/110/head
Qstick 7 years ago
parent b99b23b4bb
commit 9f079fb8ba

@ -15,7 +15,7 @@ function createMapStateToProps() {
createCommandsSelector(), createCommandsSelector(),
(albumId, sceneSeasonNumber, artist, commands) => { (albumId, sceneSeasonNumber, artist, commands) => {
const isSearching = _.some(commands, (command) => { const isSearching = _.some(commands, (command) => {
const episodeSearch = command.name === commandNames.EPISODE_SEARCH; const episodeSearch = command.name === commandNames.ALBUM_SEARCH;
if (!episodeSearch) { if (!episodeSearch) {
return false; return false;
@ -37,7 +37,7 @@ function createMapDispatchToProps(dispatch, props) {
return { return {
onSearchPress(name, path) { onSearchPress(name, path) {
dispatch(executeCommand({ dispatch(executeCommand({
name: commandNames.EPISODE_SEARCH, name: commandNames.ALBUM_SEARCH,
albumIds: [props.albumId] albumIds: [props.albumId]
})); }));
} }

@ -46,7 +46,7 @@ class EpisodeSearchConnector extends Component {
onQuickSearchPress = () => { onQuickSearchPress = () => {
this.props.executeCommand({ this.props.executeCommand({
name: commandNames.EPISODE_SEARCH, name: commandNames.ALBUM_SEARCH,
albumIds: [this.props.albumId] albumIds: [this.props.albumId]
}); });

@ -3,11 +3,11 @@ export const BACKUP = 'Backup';
export const CHECK_FOR_FINISHED_DOWNLOAD = 'CheckForFinishedDownload'; export const CHECK_FOR_FINISHED_DOWNLOAD = 'CheckForFinishedDownload';
export const CLEAR_BLACKLIST = 'ClearBlacklist'; export const CLEAR_BLACKLIST = 'ClearBlacklist';
export const CLEAR_LOGS = 'ClearLog'; 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_LOG_FILES = 'DeleteLogFiles';
export const DELETE_UPDATE_LOG_FILES = 'DeleteUpdateLogFiles'; export const DELETE_UPDATE_LOG_FILES = 'DeleteUpdateLogFiles';
export const DOWNLOADED_ALBUMS_SCAN = 'DownloadedAlbumsScan'; export const DOWNLOADED_ALBUMS_SCAN = 'DownloadedAlbumsScan';
export const EPISODE_SEARCH = 'AlbumSearch'; export const ALBUM_SEARCH = 'AlbumSearch';
export const INTERACTIVE_IMPORT = 'ManualImport'; export const INTERACTIVE_IMPORT = 'ManualImport';
export const MISSING_ALBUM_SEARCH = 'MissingAlbumSearch'; export const MISSING_ALBUM_SEARCH = 'MissingAlbumSearch';
export const REFRESH_ARTIST = 'RefreshArtist'; export const REFRESH_ARTIST = 'RefreshArtist';

@ -1,7 +1,7 @@
import $ from 'jquery'; 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(payload) {
return function(dispatch, getState) { return function(dispatch, getState) {
const { const {
@ -11,26 +11,26 @@ function createBatchToggleEpisodeMonitoredHandler(section, getFromState) {
const state = getFromState(getState()); const state = getFromState(getState());
updateEpisodes(dispatch, section, state.items, albumIds, { updateAlbums(dispatch, section, state.items, albumIds, {
isSaving: true isSaving: true
}); });
const promise = $.ajax({ const promise = $.ajax({
url: '/episode/monitor', url: '/album/monitor',
method: 'PUT', method: 'PUT',
data: JSON.stringify({ albumIds, monitored }), data: JSON.stringify({ albumIds, monitored }),
dataType: 'json' dataType: 'json'
}); });
promise.done(() => { promise.done(() => {
updateEpisodes(dispatch, section, state.items, albumIds, { updateAlbums(dispatch, section, state.items, albumIds, {
isSaving: false, isSaving: false,
monitored monitored
}); });
}); });
promise.fail(() => { promise.fail(() => {
updateEpisodes(dispatch, section, state.items, albumIds, { updateAlbums(dispatch, section, state.items, albumIds, {
isSaving: false isSaving: false
}); });
}); });
@ -38,4 +38,4 @@ function createBatchToggleEpisodeMonitoredHandler(section, getFromState) {
}; };
} }
export default createBatchToggleEpisodeMonitoredHandler; export default createBatchToggleAlbumMonitoredHandler;

@ -1,7 +1,7 @@
import $ from 'jquery'; 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(payload) {
return function(dispatch, getState) { return function(dispatch, getState) {
const { const {
@ -11,26 +11,26 @@ function createToggleEpisodeMonitoredHandler(section, getFromState) {
const state = getFromState(getState()); const state = getFromState(getState());
updateEpisodes(dispatch, section, state.items, [albumId], { updateAlbums(dispatch, section, state.items, [albumId], {
isSaving: true isSaving: true
}); });
const promise = $.ajax({ const promise = $.ajax({
url: `/episode/${albumId}`, url: `/album/${albumId}`,
method: 'PUT', method: 'PUT',
data: JSON.stringify({ monitored }), data: JSON.stringify({ monitored }),
dataType: 'json' dataType: 'json'
}); });
promise.done(() => { promise.done(() => {
updateEpisodes(dispatch, section, state.items, [albumId], { updateAlbums(dispatch, section, state.items, [albumId], {
isSaving: false, isSaving: false,
monitored monitored
}); });
}); });
promise.fail(() => { promise.fail(() => {
updateEpisodes(dispatch, section, state.items, [albumId], { updateAlbums(dispatch, section, state.items, [albumId], {
isSaving: false isSaving: false
}); });
}); });
@ -38,4 +38,4 @@ function createToggleEpisodeMonitoredHandler(section, getFromState) {
}; };
} }
export default createToggleEpisodeMonitoredHandler; export default createToggleAlbumMonitoredHandler;

@ -103,7 +103,7 @@ export const DELETE_TRACK_FILES = 'DELETE_TRACK_FILES';
export const UPDATE_TRACK_FILES = 'UPDATE_TRACK_FILES'; export const UPDATE_TRACK_FILES = 'UPDATE_TRACK_FILES';
// //
// Episode History // Album History
export const FETCH_ALBUM_HISTORY = 'FETCH_ALBUM_HISTORY'; export const FETCH_ALBUM_HISTORY = 'FETCH_ALBUM_HISTORY';
export const CLEAR_ALBUM_HISTORY = 'CLEAR_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 SET_MISSING_TABLE_OPTION = 'SET_MISSING_TABLE_OPTION';
export const CLEAR_MISSING = 'CLEAR_MISSING'; 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 FETCH_CUTOFF_UNMET = 'FETCH_CUTOFF_UNMET';
export const GOTO_FIRST_CUTOFF_UNMET_PAGE = 'GOTO_FIRST_CUTOFF_UNMET_PAGE'; 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 SET_CUTOFF_UNMET_TABLE_OPTION = 'SET_CUTOFF_UNMET_TABLE_OPTION';
export const CLEAR_CUTOFF_UNMET = 'CLEAR_CUTOFF_UNMET'; 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 // Settings

@ -1,5 +1,5 @@
import serverSideCollectionHandlers from 'Utilities/serverSideCollectionHandlers'; import serverSideCollectionHandlers from 'Utilities/serverSideCollectionHandlers';
import createBatchToggleEpisodeMonitoredHandler from './Creators/createBatchToggleEpisodeMonitoredHandler'; import createBatchToggleAlbumMonitoredHandler from './Creators/createBatchToggleAlbumMonitoredHandler';
import createServerSideCollectionHandlers from './Creators/createServerSideCollectionHandlers'; import createServerSideCollectionHandlers from './Creators/createServerSideCollectionHandlers';
import * as types from './actionTypes'; import * as types from './actionTypes';
@ -15,7 +15,7 @@ const wantedActionHandlers = {
[serverSideCollectionHandlers.FILTER]: types.SET_MISSING_FILTER [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, { ...createServerSideCollectionHandlers('cutoffUnmet', '/wanted/cutoff', (state) => state.wanted, {
[serverSideCollectionHandlers.FETCH]: types.FETCH_CUTOFF_UNMET, [serverSideCollectionHandlers.FETCH]: types.FETCH_CUTOFF_UNMET,
@ -28,7 +28,7 @@ const wantedActionHandlers = {
[serverSideCollectionHandlers.FILTER]: types.SET_CUTOFF_UNMET_FILTER [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; export default wantedActionHandlers;

@ -16,7 +16,7 @@ export const setMissingFilter = wantedActionHandlers[types.SET_MISSING_FILTER];
export const setMissingTableOption = createAction(types.SET_MISSING_TABLE_OPTION); export const setMissingTableOption = createAction(types.SET_MISSING_TABLE_OPTION);
export const clearMissing = createAction(types.CLEAR_MISSING); 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 // 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 setCutoffUnmetTableOption= createAction(types.SET_CUTOFF_UNMET_TABLE_OPTION);
export const clearCutoffUnmet= createAction(types.CLEAR_CUTOFF_UNMET); 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];

@ -1,7 +1,7 @@
import _ from 'lodash'; import _ from 'lodash';
import { update } from 'Store/Actions/baseActions'; 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) => { const data = _.reduce(episodes, (result, item) => {
if (albumIds.indexOf(item.id) > -1) { if (albumIds.indexOf(item.id) > -1) {
result.push({ result.push({
@ -18,4 +18,4 @@ function updateEpisodes(dispatch, section, episodes, albumIds, options) {
dispatch(update({ section, data })); dispatch(update({ section, data }));
} }
export default updateEpisodes; export default updateAlbums;

@ -109,7 +109,7 @@ class CutoffUnmet extends Component {
columns, columns,
totalRecords, totalRecords,
isSearchingForAlbums, isSearchingForAlbums,
isSearchingForCutoffUnmetEpisodes, isSearchingForCutoffUnmetAlbums,
isSaving, isSaving,
filterKey, filterKey,
filterValue, filterValue,
@ -150,7 +150,7 @@ class CutoffUnmet extends Component {
<PageToolbarButton <PageToolbarButton
label="Search All" label="Search All"
iconName={icons.SEARCH} iconName={icons.SEARCH}
isSpinning={isSearchingForCutoffUnmetEpisodes} isSpinning={isSearchingForCutoffUnmetAlbums}
onPress={this.onSearchAllCutoffUnmetPress} onPress={this.onSearchAllCutoffUnmetPress}
/> />
@ -272,7 +272,7 @@ CutoffUnmet.propTypes = {
columns: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired,
totalRecords: PropTypes.number, totalRecords: PropTypes.number,
isSearchingForAlbums: PropTypes.bool.isRequired, isSearchingForAlbums: PropTypes.bool.isRequired,
isSearchingForCutoffUnmetEpisodes: PropTypes.bool.isRequired, isSearchingForCutoffUnmetAlbums: PropTypes.bool.isRequired,
isSaving: PropTypes.bool.isRequired, isSaving: PropTypes.bool.isRequired,
filterKey: PropTypes.string, filterKey: PropTypes.string,
filterValue: PropTypes.oneOfType([PropTypes.bool, PropTypes.number, PropTypes.string]), filterValue: PropTypes.oneOfType([PropTypes.bool, PropTypes.number, PropTypes.string]),

@ -19,12 +19,12 @@ function createMapStateToProps() {
(state) => state.wanted.cutoffUnmet, (state) => state.wanted.cutoffUnmet,
createCommandsSelector(), createCommandsSelector(),
(cutoffUnmet, commands) => { (cutoffUnmet, commands) => {
const isSearchingForAlbums = _.some(commands, { name: commandNames.EPISODE_SEARCH }); const isSearchingForAlbums = _.some(commands, { name: commandNames.ALBUM_SEARCH });
const isSearchingForCutoffUnmetEpisodes = _.some(commands, { name: commandNames.CUTOFF_UNMET_EPISODE_SEARCH }); const isSearchingForCutoffUnmetAlbums = _.some(commands, { name: commandNames.CUTOFF_UNMET_ALBUM_SEARCH });
return { return {
isSearchingForAlbums, isSearchingForAlbums,
isSearchingForCutoffUnmetEpisodes, isSearchingForCutoffUnmetAlbums,
isSaving: _.some(cutoffUnmet.items, { isSaving: true }), isSaving: _.some(cutoffUnmet.items, { isSaving: true }),
...cutoffUnmet ...cutoffUnmet
}; };
@ -119,7 +119,7 @@ class CutoffUnmetConnector extends Component {
onSearchSelectedPress = (selected) => { onSearchSelectedPress = (selected) => {
this.props.executeCommand({ this.props.executeCommand({
name: commandNames.EPISODE_SEARCH, name: commandNames.ALBUM_SEARCH,
albumIds: selected albumIds: selected
}); });
} }
@ -130,7 +130,7 @@ class CutoffUnmetConnector extends Component {
filterValue filterValue
} = this.props; } = this.props;
this.props.batchToggleCutoffUnmetEpisodes({ this.props.batchToggleCutoffUnmetAlbums({
albumIds: selected, albumIds: selected,
monitored: filterKey !== 'monitored' || !filterValue monitored: filterKey !== 'monitored' || !filterValue
}); });
@ -138,7 +138,7 @@ class CutoffUnmetConnector extends Component {
onSearchAllCutoffUnmetPress = () => { onSearchAllCutoffUnmetPress = () => {
this.props.executeCommand({ 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, setCutoffUnmetSort: PropTypes.func.isRequired,
setCutoffUnmetFilter: PropTypes.func.isRequired, setCutoffUnmetFilter: PropTypes.func.isRequired,
setCutoffUnmetTableOption: PropTypes.func.isRequired, setCutoffUnmetTableOption: PropTypes.func.isRequired,
batchToggleCutoffUnmetEpisodes: PropTypes.func.isRequired, batchToggleCutoffUnmetAlbums: PropTypes.func.isRequired,
clearCutoffUnmet: PropTypes.func.isRequired, clearCutoffUnmet: PropTypes.func.isRequired,
executeCommand: PropTypes.func.isRequired, executeCommand: PropTypes.func.isRequired,
fetchQueueDetails: PropTypes.func.isRequired, fetchQueueDetails: PropTypes.func.isRequired,

@ -18,7 +18,7 @@ function createMapStateToProps() {
(state) => state.wanted.missing, (state) => state.wanted.missing,
createCommandsSelector(), createCommandsSelector(),
(missing, commands) => { (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 }); const isSearchingForMissingAlbums = _.some(commands, { name: commandNames.MISSING_ALBUM_SEARCH });
return { return {
@ -109,7 +109,7 @@ class MissingConnector extends Component {
onSearchSelectedPress = (selected) => { onSearchSelectedPress = (selected) => {
this.props.executeCommand({ this.props.executeCommand({
name: commandNames.EPISODE_SEARCH, name: commandNames.ALBUM_SEARCH,
albumIds: selected albumIds: selected
}); });
} }
@ -120,7 +120,7 @@ class MissingConnector extends Component {
filterValue filterValue
} = this.props; } = this.props;
this.props.batchToggleMissingEpisodes({ this.props.batchToggleMissingAlbums({
albumIds: selected, albumIds: selected,
monitored: filterKey !== 'monitored' || !filterValue monitored: filterKey !== 'monitored' || !filterValue
}); });
@ -169,7 +169,7 @@ MissingConnector.propTypes = {
setMissingFilter: PropTypes.func.isRequired, setMissingFilter: PropTypes.func.isRequired,
setMissingTableOption: PropTypes.func.isRequired, setMissingTableOption: PropTypes.func.isRequired,
clearMissing: PropTypes.func.isRequired, clearMissing: PropTypes.func.isRequired,
batchToggleMissingEpisodes: PropTypes.func.isRequired, batchToggleMissingAlbums: PropTypes.func.isRequired,
executeCommand: PropTypes.func.isRequired, executeCommand: PropTypes.func.isRequired,
fetchQueueDetails: PropTypes.func.isRequired, fetchQueueDetails: PropTypes.func.isRequired,
clearQueueDetails: PropTypes.func.isRequired clearQueueDetails: PropTypes.func.isRequired

Loading…
Cancel
Save