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

View File

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