Wire up torrent options state

This commit is contained in:
Drew DeVault 2017-09-07 15:31:29 +09:00
parent a31051d7c5
commit ff24e098ff

View File

@ -31,8 +31,22 @@ class Throttle extends Component {
invokeChange() { invokeChange() {
const { onChange } = this.props; const { onChange } = this.props;
if (!onChange) {
return;
}
const { strategy, limit, unit } = this.state; const { strategy, limit, unit } = this.state;
this.onChange && this.onChange(strategy, convertToBitrate(limit, unit)); switch (strategy) {
case "global":
onChange(null);
break;
case "unlimited":
onChange(-1);
break;
default:
onChange(convertToBitrate(limit, unit));
break;
}
} }
setStrategy(strategy) { setStrategy(strategy) {
@ -132,7 +146,10 @@ class AddTorrent extends Component {
file: null, file: null,
torrent: null, torrent: null,
files: [], files: [],
startImmediately: true startImmediately: true,
uploadThrottle: -1,
downloadThrottle: -1,
priority: 3,
}; };
} }
@ -218,16 +235,31 @@ class AddTorrent extends Component {
</FormGroup> </FormGroup>
<FormGroup> <FormGroup>
<Label for="priority">Priority</Label> <Label for="priority">Priority</Label>
<Input type="select" id="priority" value={3}> <Input
<option value={1}>Lowest</option> type="select"
<option value={2}>Low</option> id="priority"
<option value={3}>Normal</option> value={this.state.priority}
<option value={4}>High</option> onChange={e =>
<option value={5}>Highest</option> this.setState({ priority: parseInt(e.target.value)})
}
>
<option value="1">Lowest</option>
<option value="2">Low</option>
<option value="3">Normal</option>
<option value="4">High</option>
<option value="5">Highest</option>
</Input> </Input>
</FormGroup> </FormGroup>
<Throttle for="dl-throttle" legend="Download throttle" /> <Throttle
<Throttle for="ul-throttle" legend="Upload throttle" /> prop="dl-throttle"
legend="Download throttle"
onChange={limit => this.setState({ downloadThrottle: limit })}
/>
<Throttle
prop="ul-throttle"
legend="Upload throttle"
onChange={limit => this.setState({ uploadThrottle: limit })}
/>
</CardBlock> </CardBlock>
</Card> </Card>
); );