Merge pull request #47 from emersion/torrent-options-path

Allow to change path when adding a new torrent
This commit is contained in:
Drew DeVault 2018-03-16 11:23:32 -04:00 committed by GitHub
commit fdda72854a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 4 deletions

View File

@ -32,6 +32,7 @@ class AddTorrent extends Component {
torrent: null, torrent: null,
files: [], files: [],
start: true, start: true,
path: null,
uploadThrottle: null, uploadThrottle: null,
downloadThrottle: null, downloadThrottle: null,
priority: 3, priority: 3,
@ -100,7 +101,7 @@ class AddTorrent extends Component {
uploadFile() { uploadFile() {
this.setState({ loading: true }); this.setState({ loading: true });
const { magnet, file, start } = this.state; const { magnet, file, start, path } = this.state;
const { dispatch } = this.props; const { dispatch } = this.props;
const customize = const customize =
this.state.priority !== 3 || this.state.priority !== 3 ||
@ -119,12 +120,14 @@ class AddTorrent extends Component {
if (magnet) { if (magnet) {
ws_send("UPLOAD_MAGNET", { ws_send("UPLOAD_MAGNET", {
uri: magnet, uri: magnet,
start: start && !customize start: start && !customize,
path
}, handleOffer); }, handleOffer);
} else { } else {
ws_send("UPLOAD_TORRENT", { ws_send("UPLOAD_TORRENT", {
size: file.size, size: file.size,
start: start && !customize start: start && !customize,
path
}, handleOffer); }, handleOffer);
} }
} }
@ -168,6 +171,7 @@ class AddTorrent extends Component {
renderOptions() { renderOptions() {
const { const {
start, start,
path,
priority, priority,
downloadThrottle, downloadThrottle,
uploadThrottle uploadThrottle
@ -180,6 +184,8 @@ class AddTorrent extends Component {
id="new-torrent" id="new-torrent"
start={start} start={start}
startChanged={start => this.setState({ start })} startChanged={start => this.setState({ start })}
path={path}
pathChanged={path => this.setState({ path: path || null })}
priority={priority} priority={priority}
priorityChanged={priority => this.setState({ priority })} priorityChanged={priority => this.setState({ priority })}
downloadThrottle={downloadThrottle} downloadThrottle={downloadThrottle}
@ -187,7 +193,7 @@ class AddTorrent extends Component {
this.setState({ downloadThrottle })} this.setState({ downloadThrottle })}
uploadThrottle={uploadThrottle} uploadThrottle={uploadThrottle}
uploadThrottleChanged={uploadThrottle => uploadThrottleChanged={uploadThrottle =>
{ console.log(uploadThrottle); this.setState({ uploadThrottle }); }} this.setState({ uploadThrottle })}
/> />
</CardBlock> </CardBlock>
</Card> </Card>

View File

@ -12,6 +12,8 @@ export default class TorrentOptions extends Component {
id, id,
start, start,
startChanged, startChanged,
path,
pathChanged,
priority, priority,
priorityChanged, priorityChanged,
downloadThrottle, downloadThrottle,
@ -33,6 +35,16 @@ export default class TorrentOptions extends Component {
</Label> </Label>
</FormGroup> </FormGroup>
} }
{typeof path !== "undefined" &&
<FormGroup>
<Input
type="text"
placeholder="Path"
value={path}
onChange={e => pathChanged(e.target.value)}
/>
</FormGroup>
}
<FormGroup> <FormGroup>
<Label for="priority">Priority</Label> <Label for="priority">Priority</Label>
<Input <Input