mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
New: Bulk Manage Applications, Download Clients
Co-authored-by: Qstick <qstick@gmail.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { batchActions } from 'redux-batched-actions';
|
||||
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
||||
import { set, updateItem } from '../baseActions';
|
||||
|
||||
function createBulkEditItemHandler(section, url) {
|
||||
return function(getState, payload, dispatch) {
|
||||
|
||||
dispatch(set({ section, isSaving: true }));
|
||||
|
||||
const ajaxOptions = {
|
||||
url: `${url}`,
|
||||
method: 'PUT',
|
||||
data: JSON.stringify(payload),
|
||||
dataType: 'json'
|
||||
};
|
||||
|
||||
const promise = createAjaxRequest(ajaxOptions).request;
|
||||
|
||||
promise.done((data) => {
|
||||
dispatch(batchActions([
|
||||
set({
|
||||
section,
|
||||
isSaving: false,
|
||||
saveError: null
|
||||
}),
|
||||
|
||||
...data.map((provider) => {
|
||||
|
||||
const {
|
||||
...propsToUpdate
|
||||
} = provider;
|
||||
|
||||
return updateItem({
|
||||
id: provider.id,
|
||||
section,
|
||||
...propsToUpdate
|
||||
});
|
||||
})
|
||||
]));
|
||||
});
|
||||
|
||||
promise.fail((xhr) => {
|
||||
dispatch(set({
|
||||
section,
|
||||
isSaving: false,
|
||||
saveError: xhr
|
||||
}));
|
||||
});
|
||||
|
||||
return promise;
|
||||
};
|
||||
}
|
||||
|
||||
export default createBulkEditItemHandler;
|
@@ -0,0 +1,48 @@
|
||||
import { batchActions } from 'redux-batched-actions';
|
||||
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
||||
import { removeItem, set } from '../baseActions';
|
||||
|
||||
function createBulkRemoveItemHandler(section, url) {
|
||||
return function(getState, payload, dispatch) {
|
||||
const {
|
||||
ids
|
||||
} = payload;
|
||||
|
||||
dispatch(set({ section, isDeleting: true }));
|
||||
|
||||
const ajaxOptions = {
|
||||
url: `${url}`,
|
||||
method: 'DELETE',
|
||||
data: JSON.stringify(payload),
|
||||
dataType: 'json'
|
||||
};
|
||||
|
||||
const promise = createAjaxRequest(ajaxOptions).request;
|
||||
|
||||
promise.done((data) => {
|
||||
dispatch(batchActions([
|
||||
set({
|
||||
section,
|
||||
isDeleting: false,
|
||||
deleteError: null
|
||||
}),
|
||||
|
||||
...ids.map((id) => {
|
||||
return removeItem({ section, id });
|
||||
})
|
||||
]));
|
||||
});
|
||||
|
||||
promise.fail((xhr) => {
|
||||
dispatch(set({
|
||||
section,
|
||||
isDeleting: false,
|
||||
deleteError: xhr
|
||||
}));
|
||||
});
|
||||
|
||||
return promise;
|
||||
};
|
||||
}
|
||||
|
||||
export default createBulkRemoveItemHandler;
|
@@ -52,14 +52,14 @@ export default {
|
||||
isFetching: false,
|
||||
isPopulated: false,
|
||||
error: null,
|
||||
isDeleting: false,
|
||||
deleteError: null,
|
||||
isSchemaFetching: false,
|
||||
isSchemaPopulated: false,
|
||||
schemaError: null,
|
||||
schema: {},
|
||||
isSaving: false,
|
||||
saveError: null,
|
||||
isDeleting: false,
|
||||
deleteError: null,
|
||||
items: [],
|
||||
pendingChanges: {}
|
||||
},
|
||||
|
@@ -1,4 +1,6 @@
|
||||
import { createAction } from 'redux-actions';
|
||||
import createBulkEditItemHandler from 'Store/Actions/Creators/createBulkEditItemHandler';
|
||||
import createBulkRemoveItemHandler from 'Store/Actions/Creators/createBulkRemoveItemHandler';
|
||||
import createFetchHandler from 'Store/Actions/Creators/createFetchHandler';
|
||||
import createFetchSchemaHandler from 'Store/Actions/Creators/createFetchSchemaHandler';
|
||||
import createRemoveItemHandler from 'Store/Actions/Creators/createRemoveItemHandler';
|
||||
@@ -29,6 +31,8 @@ export const DELETE_APPLICATION = 'settings/applications/deleteApplication';
|
||||
export const TEST_APPLICATION = 'settings/applications/testApplication';
|
||||
export const CANCEL_TEST_APPLICATION = 'settings/applications/cancelTestApplication';
|
||||
export const TEST_ALL_APPLICATIONS = 'indexers/testAllApplications';
|
||||
export const BULK_EDIT_APPLICATIONS = 'settings/applications/bulkEditApplications';
|
||||
export const BULK_DELETE_APPLICATIONS = 'settings/applications/bulkDeleteApplications';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
@@ -43,6 +47,8 @@ export const deleteApplication = createThunk(DELETE_APPLICATION);
|
||||
export const testApplication = createThunk(TEST_APPLICATION);
|
||||
export const cancelTestApplication = createThunk(CANCEL_TEST_APPLICATION);
|
||||
export const testAllApplications = createThunk(TEST_ALL_APPLICATIONS);
|
||||
export const bulkEditApplications = createThunk(BULK_EDIT_APPLICATIONS);
|
||||
export const bulkDeleteApplications = createThunk(BULK_DELETE_APPLICATIONS);
|
||||
|
||||
export const setApplicationValue = createAction(SET_APPLICATION_VALUE, (payload) => {
|
||||
return {
|
||||
@@ -77,6 +83,8 @@ export default {
|
||||
selectedSchema: {},
|
||||
isSaving: false,
|
||||
saveError: null,
|
||||
isDeleting: false,
|
||||
deleteError: null,
|
||||
isTesting: false,
|
||||
isTestingAll: false,
|
||||
items: [],
|
||||
@@ -95,7 +103,9 @@ export default {
|
||||
[DELETE_APPLICATION]: createRemoveItemHandler(section, '/applications'),
|
||||
[TEST_APPLICATION]: createTestProviderHandler(section, '/applications'),
|
||||
[CANCEL_TEST_APPLICATION]: createCancelTestProviderHandler(section),
|
||||
[TEST_ALL_APPLICATIONS]: createTestAllProvidersHandler(section, '/applications')
|
||||
[TEST_ALL_APPLICATIONS]: createTestAllProvidersHandler(section, '/applications'),
|
||||
[BULK_EDIT_APPLICATIONS]: createBulkEditItemHandler(section, '/applications/bulk'),
|
||||
[BULK_DELETE_APPLICATIONS]: createBulkRemoveItemHandler(section, '/applications/bulk')
|
||||
},
|
||||
|
||||
//
|
||||
|
@@ -75,6 +75,8 @@ export default {
|
||||
selectedSchema: {},
|
||||
isSaving: false,
|
||||
saveError: null,
|
||||
isDeleting: false,
|
||||
deleteError: null,
|
||||
items: [],
|
||||
pendingChanges: {}
|
||||
},
|
||||
|
@@ -1,4 +1,6 @@
|
||||
import { createAction } from 'redux-actions';
|
||||
import createBulkEditItemHandler from 'Store/Actions/Creators/createBulkEditItemHandler';
|
||||
import createBulkRemoveItemHandler from 'Store/Actions/Creators/createBulkRemoveItemHandler';
|
||||
import createFetchHandler from 'Store/Actions/Creators/createFetchHandler';
|
||||
import createFetchSchemaHandler from 'Store/Actions/Creators/createFetchSchemaHandler';
|
||||
import createRemoveItemHandler from 'Store/Actions/Creators/createRemoveItemHandler';
|
||||
@@ -30,6 +32,8 @@ export const DELETE_DOWNLOAD_CLIENT = 'settings/downloadClients/deleteDownloadCl
|
||||
export const TEST_DOWNLOAD_CLIENT = 'settings/downloadClients/testDownloadClient';
|
||||
export const CANCEL_TEST_DOWNLOAD_CLIENT = 'settings/downloadClients/cancelTestDownloadClient';
|
||||
export const TEST_ALL_DOWNLOAD_CLIENTS = 'settings/downloadClients/testAllDownloadClients';
|
||||
export const BULK_EDIT_DOWNLOAD_CLIENTS = 'settings/downloadClients/bulkEditDownloadClients';
|
||||
export const BULK_DELETE_DOWNLOAD_CLIENTS = 'settings/downloadClients/bulkDeleteDownloadClients';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
@@ -44,6 +48,8 @@ export const deleteDownloadClient = createThunk(DELETE_DOWNLOAD_CLIENT);
|
||||
export const testDownloadClient = createThunk(TEST_DOWNLOAD_CLIENT);
|
||||
export const cancelTestDownloadClient = createThunk(CANCEL_TEST_DOWNLOAD_CLIENT);
|
||||
export const testAllDownloadClients = createThunk(TEST_ALL_DOWNLOAD_CLIENTS);
|
||||
export const bulkEditDownloadClients = createThunk(BULK_EDIT_DOWNLOAD_CLIENTS);
|
||||
export const bulkDeleteDownloadClients = createThunk(BULK_DELETE_DOWNLOAD_CLIENTS);
|
||||
|
||||
export const setDownloadClientValue = createAction(SET_DOWNLOAD_CLIENT_VALUE, (payload) => {
|
||||
return {
|
||||
@@ -78,6 +84,8 @@ export default {
|
||||
selectedSchema: {},
|
||||
isSaving: false,
|
||||
saveError: null,
|
||||
isDeleting: false,
|
||||
deleteError: null,
|
||||
isTesting: false,
|
||||
isTestingAll: false,
|
||||
items: [],
|
||||
@@ -120,7 +128,9 @@ export default {
|
||||
},
|
||||
|
||||
[CANCEL_TEST_DOWNLOAD_CLIENT]: createCancelTestProviderHandler(section),
|
||||
[TEST_ALL_DOWNLOAD_CLIENTS]: createTestAllProvidersHandler(section, '/downloadclient')
|
||||
[TEST_ALL_DOWNLOAD_CLIENTS]: createTestAllProvidersHandler(section, '/downloadclient'),
|
||||
[BULK_EDIT_DOWNLOAD_CLIENTS]: createBulkEditItemHandler(section, '/downloadclient/bulk'),
|
||||
[BULK_DELETE_DOWNLOAD_CLIENTS]: createBulkRemoveItemHandler(section, '/downloadclient/bulk')
|
||||
},
|
||||
|
||||
//
|
||||
|
@@ -74,6 +74,8 @@ export default {
|
||||
selectedSchema: {},
|
||||
isSaving: false,
|
||||
saveError: null,
|
||||
isDeleting: false,
|
||||
deleteError: null,
|
||||
isTesting: false,
|
||||
items: [],
|
||||
pendingChanges: {}
|
||||
|
@@ -74,6 +74,8 @@ export default {
|
||||
selectedSchema: {},
|
||||
isSaving: false,
|
||||
saveError: null,
|
||||
isDeleting: false,
|
||||
deleteError: null,
|
||||
isTesting: false,
|
||||
items: [],
|
||||
pendingChanges: {}
|
||||
|
@@ -13,6 +13,8 @@ import dateFilterPredicate from 'Utilities/Date/dateFilterPredicate';
|
||||
import getSectionState from 'Utilities/State/getSectionState';
|
||||
import updateSectionState from 'Utilities/State/updateSectionState';
|
||||
import translate from 'Utilities/String/translate';
|
||||
import createBulkEditItemHandler from './Creators/createBulkEditItemHandler';
|
||||
import createBulkRemoveItemHandler from './Creators/createBulkRemoveItemHandler';
|
||||
import createHandleActions from './Creators/createHandleActions';
|
||||
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
|
||||
|
||||
@@ -95,6 +97,8 @@ export const DELETE_INDEXER = 'indexers/deleteIndexer';
|
||||
export const TEST_INDEXER = 'indexers/testIndexer';
|
||||
export const CANCEL_TEST_INDEXER = 'indexers/cancelTestIndexer';
|
||||
export const TEST_ALL_INDEXERS = 'indexers/testAllIndexers';
|
||||
export const BULK_EDIT_INDEXERS = 'indexers/bulkEditIndexers';
|
||||
export const BULK_DELETE_INDEXERS = 'indexers/bulkDeleteIndexers';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
@@ -111,6 +115,8 @@ export const deleteIndexer = createThunk(DELETE_INDEXER);
|
||||
export const testIndexer = createThunk(TEST_INDEXER);
|
||||
export const cancelTestIndexer = createThunk(CANCEL_TEST_INDEXER);
|
||||
export const testAllIndexers = createThunk(TEST_ALL_INDEXERS);
|
||||
export const bulkEditIndexers = createThunk(BULK_EDIT_INDEXERS);
|
||||
export const bulkDeleteIndexers = createThunk(BULK_DELETE_INDEXERS);
|
||||
|
||||
export const setIndexerValue = createAction(SET_INDEXER_VALUE, (payload) => {
|
||||
return {
|
||||
@@ -163,7 +169,9 @@ export const actionHandlers = handleThunks({
|
||||
[DELETE_INDEXER]: createRemoveItemHandler(section, '/indexer'),
|
||||
[TEST_INDEXER]: createTestProviderHandler(section, '/indexer'),
|
||||
[CANCEL_TEST_INDEXER]: createCancelTestProviderHandler(section),
|
||||
[TEST_ALL_INDEXERS]: createTestAllProvidersHandler(section, '/indexer')
|
||||
[TEST_ALL_INDEXERS]: createTestAllProvidersHandler(section, '/indexer'),
|
||||
[BULK_EDIT_INDEXERS]: createBulkEditItemHandler(section, '/indexer/bulk'),
|
||||
[BULK_DELETE_INDEXERS]: createBulkRemoveItemHandler(section, '/indexer/bulk')
|
||||
});
|
||||
|
||||
//
|
||||
|
@@ -1,10 +1,6 @@
|
||||
import { createAction } from 'redux-actions';
|
||||
import { batchActions } from 'redux-batched-actions';
|
||||
import { filterBuilderTypes, filterBuilderValueTypes, sortDirections } from 'Helpers/Props';
|
||||
import { createThunk, handleThunks } from 'Store/thunks';
|
||||
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
||||
import translate from 'Utilities/String/translate';
|
||||
import { removeItem, set, updateItem } from './baseActions';
|
||||
import createHandleActions from './Creators/createHandleActions';
|
||||
import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer';
|
||||
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
|
||||
@@ -90,6 +86,30 @@ export const defaultState = {
|
||||
isSortable: false,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'minimumSeeders',
|
||||
label: translate('MinimumSeeders'),
|
||||
isSortable: true,
|
||||
isVisible: false
|
||||
},
|
||||
{
|
||||
name: 'seedRatio',
|
||||
label: translate('SeedRatio'),
|
||||
isSortable: true,
|
||||
isVisible: false
|
||||
},
|
||||
{
|
||||
name: 'seedTime',
|
||||
label: translate('SeedTime'),
|
||||
isSortable: true,
|
||||
isVisible: false
|
||||
},
|
||||
{
|
||||
name: 'packSeedTime',
|
||||
label: translate('PackSeedTime'),
|
||||
isSortable: true,
|
||||
isVisible: false
|
||||
},
|
||||
{
|
||||
name: 'tags',
|
||||
label: translate('Tags'),
|
||||
@@ -186,8 +206,6 @@ export const SET_INDEXER_SORT = 'indexerIndex/setIndexerSort';
|
||||
export const SET_INDEXER_FILTER = 'indexerIndex/setIndexerFilter';
|
||||
export const SET_INDEXER_VIEW = 'indexerIndex/setIndexerView';
|
||||
export const SET_INDEXER_TABLE_OPTION = 'indexerIndex/setIndexerTableOption';
|
||||
export const SAVE_INDEXER_EDITOR = 'indexerIndex/saveIndexerEditor';
|
||||
export const BULK_DELETE_INDEXERS = 'indexerIndex/bulkDeleteIndexers';
|
||||
|
||||
//
|
||||
// Action Creators
|
||||
@@ -196,89 +214,6 @@ export const setIndexerSort = createAction(SET_INDEXER_SORT);
|
||||
export const setIndexerFilter = createAction(SET_INDEXER_FILTER);
|
||||
export const setIndexerView = createAction(SET_INDEXER_VIEW);
|
||||
export const setIndexerTableOption = createAction(SET_INDEXER_TABLE_OPTION);
|
||||
export const saveIndexerEditor = createThunk(SAVE_INDEXER_EDITOR);
|
||||
export const bulkDeleteIndexers = createThunk(BULK_DELETE_INDEXERS);
|
||||
|
||||
//
|
||||
// Action Handlers
|
||||
|
||||
export const actionHandlers = handleThunks({
|
||||
[SAVE_INDEXER_EDITOR]: function(getState, payload, dispatch) {
|
||||
dispatch(set({
|
||||
section,
|
||||
isSaving: true
|
||||
}));
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
url: '/indexer/editor',
|
||||
method: 'PUT',
|
||||
data: JSON.stringify(payload),
|
||||
dataType: 'json'
|
||||
}).request;
|
||||
|
||||
promise.done((data) => {
|
||||
dispatch(batchActions([
|
||||
...data.map((indexer) => {
|
||||
return updateItem({
|
||||
id: indexer.id,
|
||||
section: 'indexers',
|
||||
...indexer
|
||||
});
|
||||
}),
|
||||
|
||||
set({
|
||||
section,
|
||||
isSaving: false,
|
||||
saveError: null
|
||||
})
|
||||
]));
|
||||
});
|
||||
|
||||
promise.fail((xhr) => {
|
||||
dispatch(set({
|
||||
section,
|
||||
isSaving: false,
|
||||
saveError: xhr
|
||||
}));
|
||||
});
|
||||
},
|
||||
|
||||
[BULK_DELETE_INDEXERS]: function(getState, payload, dispatch) {
|
||||
dispatch(set({
|
||||
section,
|
||||
isDeleting: true
|
||||
}));
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
url: '/indexer/editor',
|
||||
method: 'DELETE',
|
||||
data: JSON.stringify(payload),
|
||||
dataType: 'json'
|
||||
}).request;
|
||||
|
||||
promise.done(() => {
|
||||
dispatch(batchActions([
|
||||
...payload.indexerIds.map((id) => {
|
||||
return removeItem({ section: 'indexers', id });
|
||||
}),
|
||||
|
||||
set({
|
||||
section,
|
||||
isDeleting: false,
|
||||
deleteError: null
|
||||
})
|
||||
]));
|
||||
});
|
||||
|
||||
promise.fail((xhr) => {
|
||||
dispatch(set({
|
||||
section,
|
||||
isDeleting: false,
|
||||
deleteError: xhr
|
||||
}));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
// Reducers
|
||||
|
Reference in New Issue
Block a user