diff options
Diffstat (limited to 'src/web')
| -rw-r--r-- | src/web/src/components/System/Data/index.js | 46 | ||||
| -rw-r--r-- | src/web/src/components/System/System.css | 4 | ||||
| -rw-r--r-- | src/web/src/components/System/System.js | 10 | ||||
| -rw-r--r-- | src/web/src/lib/transfers.js | 4 |
4 files changed, 64 insertions, 0 deletions
diff --git a/src/web/src/components/System/Data/index.js b/src/web/src/components/System/Data/index.js new file mode 100644 index 00000000..742aa309 --- /dev/null +++ b/src/web/src/components/System/Data/index.js @@ -0,0 +1,46 @@ +import React, { useState } from 'react'; +import { Button, Divider, Header, Icon } from 'semantic-ui-react'; +import { toast } from 'react-toastify'; + +import { clearCompleted } from '../../../lib/transfers'; + +const Data = () => { + const [up, setUp] = useState(false); + const [down, setDown] = useState(false); + + const clear = async ({ direction, setState }) => { + setState(true); + await clearCompleted({ direction }); + setState(false); + toast.success(`Completed ${direction}s cleared!`); + }; + + return ( + <div> + <Header as='h3' className='transfer-header'>Transfer Data</Header> + <Divider/> + <p><span> + The Uploads and Downloads pages can become unresponsive if too many transfers are displayed. If you're having + trouble with either page, try using the buttons below to remove completed transfers. + </span></p> + <Button + primary + loading={up} + onClick={() => clear({ direction: 'upload', setState: setUp })} + > + <Icon name='trash alternate'/> + Clear All Completed Uploads + </Button> + <Button + primary + loading={down} + onClick={() => clear({ direction: 'download', setState: setDown })} + > + <Icon name='trash alternate'/> + Clear All Completed Downloads + </Button> + </div> + ); +}; + +export default Data;
\ No newline at end of file diff --git a/src/web/src/components/System/System.css b/src/web/src/components/System/System.css index a463ab08..dc32d583 100644 --- a/src/web/src/components/System/System.css +++ b/src/web/src/components/System/System.css @@ -67,4 +67,8 @@ .share-scan-detail { margin-top: 10px; font-size: 14px; +} + +.transfer-header { + margin-bottom: -15px !important; }
\ No newline at end of file diff --git a/src/web/src/components/System/System.js b/src/web/src/components/System/System.js index 2be10f81..52fc1188 100644 --- a/src/web/src/components/System/System.js +++ b/src/web/src/components/System/System.js @@ -10,6 +10,7 @@ import Logs from './Logs'; import Options from './Options'; import Shares from './Shares'; import { Switch } from '../Shared'; +import Data from './Data'; const System = ({ state = {}, options = {} }) => { const { params: { tab }, ...route } = useRouteMatch(); @@ -50,6 +51,15 @@ const System = ({ state = {}, options = {} }) => { </Menu.Item>), render: () => <Tab.Pane><Shares state={state.shares}/></Tab.Pane>, }, + { + route: 'data', + menuItem: { + key: 'data', + icon: 'database', + content: 'Data', + }, + render: () => <Tab.Pane className='full-height'><Data/></Tab.Pane>, + }, { route: 'logs', menuItem: { diff --git a/src/web/src/lib/transfers.js b/src/web/src/lib/transfers.js index f9815d4d..c95f8f76 100644 --- a/src/web/src/lib/transfers.js +++ b/src/web/src/lib/transfers.js @@ -20,6 +20,10 @@ export const cancel = ({ direction, username, id, remove = false }) => { `/transfers/${direction}s/${encodeURIComponent(username)}/${encodeURIComponent(id)}?remove=${remove}`); }; +export const clearCompleted = ({ direction }) => { + return api.delete(`/transfers/${direction}s/all/completed`); +}; + // 'Requested' // 'Queued, Remotely' // 'Queued, Locally' |
