From a306f157a05da6fcb8798018d7be67c59a129be5 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 9 Jul 2026 13:10:57 -0500 Subject: quiet noise --- src/web/.eslintrc.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/web') diff --git a/src/web/.eslintrc.js b/src/web/.eslintrc.js index 0b0f9fb6..a39caf8e 100644 --- a/src/web/.eslintrc.js +++ b/src/web/.eslintrc.js @@ -8,6 +8,7 @@ const overrides = { 'react/prop-types': 'off', // noisy 'canonical/sort-keys': 'off', // noisy 'unicorn/no-array-reduce': 'off', // noisy + 'unicorn/prevent-abbreviations': 'off', }; /** @type {import('eslint').Linter.Config} */ -- cgit v1.2.3 From 9584bc07cdc4ce5e94ec29273d07a1c67904fdda Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 10 Jul 2026 20:22:20 -0500 Subject: add enqueueBatch() --- src/web/src/lib/transfers.js | 61 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 11 deletions(-) (limited to 'src/web') diff --git a/src/web/src/lib/transfers.js b/src/web/src/lib/transfers.js index 7fa58fc3..361926ae 100644 --- a/src/web/src/lib/transfers.js +++ b/src/web/src/lib/transfers.js @@ -20,6 +20,42 @@ export const download = ({ username, files = [] }) => { ); }; +/** + * Enqueues a batch of downloads. + * @param {object} params + * @param {string} params.username - The user to download from. + * @param {{ filename: string, size: number }[]} [params.files] - Files to enqueue. + * @param {string} [params.id] - Optional batch GUID. Generated server-side if omitted. + * @param {string} [params.searchId] - Optional GUID of an associated search. + * @param {{ destination?: string, externalId?: string }} [params.options] - `destination`: path relative to the configured download directory; `externalId`: optional external identifier for the batch. + * @returns {Promise} Resolves with the axios response. + * - 201: all files enqueued successfully + * - 200: batch created, but every file failed to enqueue — check `response.data.failures` + * - 207: partial — some enqueued, some failed — check `response.data.failures` + * @throws On error responses: + * - 400: validation failure (username/files required; duplicate filenames; id or searchId not a valid GUID) + * - 403: forbidden — running as relay agent + * - 404: user is offline + * - 409: a batch with the supplied id already exists + * - 429: a concurrent enqueue request is already in progress + * - 500: unexpected server error + */ +export const enqueueBatch = ({ + username, + files = [], + id, + searchId, + options = { destination: undefined, externalId: undefined }, +}) => { + return api.post('/transfers/downloads/batches', { + files, + id, + options, + searchId, + username, + }); +}; + export const cancel = ({ direction, username, id, remove = false }) => { return api.delete( `/transfers/${direction}s/${encodeURIComponent(username)}/${encodeURIComponent(id)}?remove=${remove}`, @@ -30,23 +66,26 @@ export const clearCompleted = ({ direction }) => { return api.delete(`/transfers/${direction}s/all/completed`); }; -// 'Requested' -// 'Queued, Remotely' -// 'Queued, Locally' -// 'Initializing' -// 'InProgress' -// 'Completed, Succeeded' -// 'Completed, Cancelled' -// 'Completed, TimedOut' -// 'Completed, Errored' -// 'Completed, Rejected' - export const getPlaceInQueue = ({ username, id }) => { return api.get( `/transfers/downloads/${encodeURIComponent(username)}/${encodeURIComponent(id)}/position`, ); }; +/* + states: + + 'Requested' + 'Queued, Remotely' + 'Queued, Locally' + 'Initializing' + 'InProgress' + 'Completed, Succeeded' + 'Completed, Cancelled' + 'Completed, TimedOut' + 'Completed, Errored' + 'Completed, Rejected' +*/ export const isStateRetryable = (state) => state.includes('Completed') && state !== 'Completed, Succeeded'; -- cgit v1.2.3 From 0f5fc71a0f956b4984c42d8d830f130bd32bf814 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 11 Jul 2026 13:30:09 -0500 Subject: replace Directory with Selection --- src/web/src/components/Browse/Directory.jsx | 136 ----------------- src/web/src/components/Browse/Selection.jsx | 221 ++++++++++++++++++++++++++++ 2 files changed, 221 insertions(+), 136 deletions(-) delete mode 100644 src/web/src/components/Browse/Directory.jsx create mode 100644 src/web/src/components/Browse/Selection.jsx (limited to 'src/web') diff --git a/src/web/src/components/Browse/Directory.jsx b/src/web/src/components/Browse/Directory.jsx deleted file mode 100644 index ed88f131..00000000 --- a/src/web/src/components/Browse/Directory.jsx +++ /dev/null @@ -1,136 +0,0 @@ -import * as transfers from '../../lib/transfers'; -import { formatBytes } from '../../lib/util'; -import FileList from '../Shared/FileList'; -import React, { Component } from 'react'; -import { Button, Card, Icon, Label } from 'semantic-ui-react'; - -const initialState = { - downloadError: '', - downloadRequest: undefined, -}; - -class Directory extends Component { - constructor(props) { - super(props); - - this.state = { - ...initialState, - files: this.props.files.map((f) => ({ selected: false, ...f })), - }; - } - - componentDidUpdate(previousProps) { - if (this.props.name !== previousProps.name) { - this.setState({ - files: this.props.files.map((f) => ({ selected: false, ...f })), - }); - } - } - - handleFileSelectionChange = (file, state) => { - file.selected = state; - this.setState((previousState) => ({ - downloadError: '', - downloadRequest: undefined, - tree: previousState.tree, - })); - }; - - download = (username, files) => { - this.setState({ downloadRequest: 'inProgress' }, async () => { - try { - const requests = (files || []).map(({ filename, size }) => ({ - filename, - size, - })); - await transfers.download({ files: requests, username }); - - this.setState({ downloadRequest: 'complete' }); - } catch (error) { - this.setState({ - downloadError: error.response, - downloadRequest: 'error', - }); - } - }); - }; - - render() { - const { locked, marginTop, name, onClose, username } = this.props; - const { downloadError, downloadRequest, files } = this.state; - - const selectedFiles = files.filter((f) => f.selected); - - const selectedSize = formatBytes( - selectedFiles.reduce((total, f) => total + f.size, 0), - ); - - return ( - - -
- -
-
- {selectedFiles.length > 0 && ( - - -