Implement editing live torrents

This commit is contained in:
Drew DeVault 2017-09-10 20:34:39 +09:00
parent 176312617c
commit f44e7a3001
3 changed files with 34 additions and 7 deletions

View File

@ -1,2 +1,10 @@
export const UPDATE_RESOURCES = 'UPDATE_RESOURCES'; export const UPDATE_RESOURCES = 'UPDATE_RESOURCES';
export const RESOURCES_REMOVED = 'RESOURCES_REMOVED'; export const RESOURCES_REMOVED = 'RESOURCES_REMOVED';
import ws_send from '../socket';
export const updateResource = (resource, cb) => dispatch => {
dispatch({ type: UPDATE_RESOURCES, resources: [resource] });
ws_send("UPDATE_RESOURCE", { resource }, cb);
};
// TODO: More resource actions (delete, etc) through this reducer?

View File

@ -12,13 +12,17 @@ import {
CardBlock, CardBlock,
Progress Progress
} from 'reactstrap'; } from 'reactstrap';
import moment from 'moment';
import TorrentOptions from './torrent_options';
import ws_send from '../socket'; import ws_send from '../socket';
import date from '../date';
import selectTorrent, { import selectTorrent, {
EXCLUSIVE, EXCLUSIVE,
UNION, UNION,
SUBTRACT, SUBTRACT,
NONE NONE
} from '../actions/selection'; } from '../actions/selection';
import { updateResource } from '../actions/resources';
function File({ file }) { function File({ file }) {
// TODO: show progress bar // TODO: show progress bar
@ -138,12 +142,27 @@ class Torrent extends Component {
/> />
</ButtonGroup> </ButtonGroup>
<Collapse isOpen={this.state.infoShown}> <Collapse isOpen={this.state.infoShown}>
<Card>
<CardBlock>
<dl> <dl>
<dt>Downloading to</dt> <dt>Downloading to</dt>
<dd>{torrent.path}</dd> <dd>{torrent.path}</dd>
<dt>Created</dt> <dt>Created</dt>
<dd>{torrent.created}</dd> <dd>{date(moment(torrent.created))}</dd>
</dl> </dl>
<TorrentOptions
priority={torrent.priority}
priorityChanged={priority =>
dispatch(updateResource({ id: torrent.id, priority }))}
downloadThrottle={torrent.throttle_down}
downloadThrottleChanged={throttle_down =>
dispatch(updateResource({ id: torrent.id, throttle_down }))}
uploadThrottle={torrent.throttle_up}
uploadThrottleChanged={throttle_up =>
dispatch(updateResource({ id: torrent.id, throttle_up }))}
/>
</CardBlock>
</Card>
</Collapse> </Collapse>
<Collapse isOpen={this.state.filesShown}> <Collapse isOpen={this.state.filesShown}>
<Card style={{marginBottom: "1rem"}}> <Card style={{marginBottom: "1rem"}}>

View File

@ -112,7 +112,7 @@ export default class TorrentOptions extends Component {
} = this.props; } = this.props;
return ( return (
<div> <div>
{typeof start !== undefined && {typeof start !== "undefined" &&
<FormGroup> <FormGroup>
<Label for="start-immediately" check style={{paddingLeft: 0}}> <Label for="start-immediately" check style={{paddingLeft: 0}}>
<input <input