mirror of
https://github.com/zoriya/flood.git
synced 2026-05-31 18:25:25 +00:00
Allow setting tags when adding torrents
This commit is contained in:
@@ -31,8 +31,8 @@ let TorrentActions = {
|
||||
});
|
||||
},
|
||||
|
||||
addTorrentsByFiles: (filesData, destination) => {
|
||||
return axios.post(`${baseURI}api/client/add-files`, filesData)
|
||||
addTorrentsByFiles: (formData, destination) => {
|
||||
return axios.post(`${baseURI}api/client/add-files`, formData)
|
||||
.then((json = {}) => {
|
||||
return json.data;
|
||||
})
|
||||
@@ -40,7 +40,7 @@ let TorrentActions = {
|
||||
AppDispatcher.dispatchServerAction({
|
||||
type: ActionTypes.CLIENT_ADD_TORRENT_SUCCESS,
|
||||
data: {
|
||||
count: filesData.getAll('torrents').length,
|
||||
count: formData.getAll('torrents').length,
|
||||
destination,
|
||||
response
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ const METHODS_TO_BIND = [
|
||||
'handleDestinationChange',
|
||||
'handleFileDrop',
|
||||
'handleFileRemove',
|
||||
'handleStartTorrentsToggle'
|
||||
'handleStartTorrentsToggle',
|
||||
'handleTagsChange'
|
||||
];
|
||||
|
||||
class AddTorrentsByFile extends React.Component {
|
||||
@@ -43,6 +44,7 @@ class AddTorrentsByFile extends React.Component {
|
||||
errors: {},
|
||||
isAddingTorrents: false,
|
||||
files: null,
|
||||
tags: '',
|
||||
startTorrents: SettingsStore.getFloodSettings('startTorrentsOnLoad')
|
||||
};
|
||||
|
||||
@@ -153,10 +155,14 @@ class AddTorrentsByFile extends React.Component {
|
||||
|
||||
let fileData = new FormData();
|
||||
|
||||
this.state.files.forEach((file) => {
|
||||
this.state.files.forEach(file => {
|
||||
fileData.append('torrents', file);
|
||||
});
|
||||
|
||||
this.state.tags.split(',').forEach(tag => {
|
||||
fileData.append('tags', tag);
|
||||
});
|
||||
|
||||
fileData.append('destination', this.state.destination);
|
||||
fileData.append('start', this.state.startTorrents);
|
||||
|
||||
@@ -164,12 +170,16 @@ class AddTorrentsByFile extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
handleDestinationChange(destination) {
|
||||
this.setState({destination});
|
||||
}
|
||||
|
||||
handleStartTorrentsToggle(value) {
|
||||
this.setState({startTorrents: value});
|
||||
}
|
||||
|
||||
handleDestinationChange(destination) {
|
||||
this.setState({destination});
|
||||
handleTagsChange(event) {
|
||||
this.setState({tags: event.target.value});
|
||||
}
|
||||
|
||||
isFormValid() {
|
||||
@@ -224,6 +234,19 @@ class AddTorrentsByFile extends React.Component {
|
||||
<TorrentDestination onChange={this.handleDestinationChange} />
|
||||
</FormColumn>
|
||||
</div>
|
||||
<div className="form__row">
|
||||
<FormColumn>
|
||||
<FormLabel>
|
||||
<FormattedMessage
|
||||
id="torrents.add.tags"
|
||||
defaultMessage="Tags"
|
||||
/>
|
||||
</FormLabel>
|
||||
<input className="textbox"
|
||||
onChange={this.handleTagsChange}
|
||||
value={this.state.tags} />
|
||||
</FormColumn>
|
||||
</div>
|
||||
<AddTorrentsActions dismiss={this.props.dismissModal}
|
||||
onAddTorrentsClick={this.handleAddTorrents}
|
||||
onStartTorrentsToggle={this.handleStartTorrentsToggle}
|
||||
|
||||
@@ -25,6 +25,7 @@ const METHODS_TO_BIND = [
|
||||
'handleAddTorrents',
|
||||
'handleDestinationChange',
|
||||
'handleStartTorrentsToggle',
|
||||
'handleTagsChange',
|
||||
'handleUrlAdd',
|
||||
'handleUrlChange',
|
||||
'handleUrlRemove'
|
||||
@@ -39,6 +40,7 @@ class AddTorrentsByURL extends React.Component {
|
||||
destination: SettingsStore.getFloodSettings('torrentDestination'),
|
||||
errors: {},
|
||||
isAddingTorrents: false,
|
||||
tags: '',
|
||||
urlTextboxes: [{value: ''}],
|
||||
startTorrents: SettingsStore.getFloodSettings('startTorrentsOnLoad')
|
||||
};
|
||||
@@ -67,7 +69,8 @@ class AddTorrentsByURL extends React.Component {
|
||||
TorrentActions.addTorrentsByUrls({
|
||||
urls: torrentURLs,
|
||||
destination: this.state.destination,
|
||||
start: this.state.startTorrents
|
||||
start: this.state.startTorrents,
|
||||
tags: this.state.tags.split(',')
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -80,6 +83,10 @@ class AddTorrentsByURL extends React.Component {
|
||||
this.setState({startTorrents: value});
|
||||
}
|
||||
|
||||
handleTagsChange(event) {
|
||||
this.setState({tags: event.target.value});
|
||||
}
|
||||
|
||||
handleUrlRemove(index) {
|
||||
let urlTextboxes = Object.assign([], this.state.urlTextboxes);
|
||||
urlTextboxes.splice(index, 1);
|
||||
@@ -166,6 +173,19 @@ class AddTorrentsByURL extends React.Component {
|
||||
<TorrentDestination onChange={this.handleDestinationChange} />
|
||||
</FormColumn>
|
||||
</div>
|
||||
<div className="form__row">
|
||||
<FormColumn>
|
||||
<FormLabel>
|
||||
<FormattedMessage
|
||||
id="torrents.add.tags"
|
||||
defaultMessage="Tags"
|
||||
/>
|
||||
</FormLabel>
|
||||
<input className="textbox"
|
||||
onChange={this.handleTagsChange}
|
||||
value={this.state.tags} />
|
||||
</FormColumn>
|
||||
</div>
|
||||
<AddTorrentsActions dismiss={this.props.dismissModal}
|
||||
onAddTorrentsClick={this.handleAddTorrents}
|
||||
onStartTorrentsToggle={this.handleStartTorrentsToggle}
|
||||
|
||||
Reference in New Issue
Block a user