Adding logic to change torrent storage path
This commit is contained in:
@@ -61,6 +61,7 @@ ws.onmessage = function (evt) { //When we recieve a message from the websocket
|
||||
FileNumber: serverMessage.data[i].NumberofFiles,
|
||||
PieceNumber: serverMessage.data[i].NumberofPieces,
|
||||
MaxConnections: serverMessage.data[i].MaxConnections,
|
||||
Label: serverMessage.data[i].TorrentLabel,
|
||||
})
|
||||
}
|
||||
var newTitle = '(' + serverMessage.total + ')' + title; //updating the title
|
||||
|
@@ -64,7 +64,7 @@ class GeneralTab extends React.Component {
|
||||
<Paper className={classes.paper}>Storage Path: <span className={classes.floatRight}>{this.state.selectedTorrent["StoragePath"]} </span> </Paper>
|
||||
<Paper className={classes.paper}>Date Added: <span className={classes.floatRight}> {this.state.selectedTorrent["DateAdded"]} </span> </Paper>
|
||||
<Paper className={classes.paper}>Source Type: <span className={classes.floatRight}> {this.state.selectedTorrent["SourceType"]} </span> </Paper>
|
||||
<Paper className={classes.paper}>Label: <span className={classes.floatRight}> None </span> </Paper>
|
||||
<Paper className={classes.paper}>Label: <span className={classes.floatRight}> {this.state.selectedTorrent["TorrentLabel"]} </span> </Paper>
|
||||
<Paper className={classes.paper}>Torrent Hash: <span className={classes.floatRight}> {this.state.selectedTorrent["TorrentHashString"]} </span> </Paper>
|
||||
|
||||
</Grid>
|
||||
@@ -82,8 +82,6 @@ class GeneralTab extends React.Component {
|
||||
<Paper className={classes.paper}>Number of Files: <span className={classes.floatRight}>{this.state.selectedTorrent["FileNumber"]} </span> </Paper>
|
||||
<Paper className={classes.paper}>Number of Pieces: <span className={classes.floatRight}>{this.state.selectedTorrent["PieceNumber"]} </span> </Paper>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</div>
|
||||
|
@@ -74,7 +74,6 @@ const inlineStyle = {
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@@ -46,6 +46,7 @@ export default class addTorrentFilePopup extends React.Component {
|
||||
torrentFileValue: [],
|
||||
storageValue: ``, //raw string for possible windows filepath
|
||||
showDrop: true,
|
||||
torrentLabel: "",
|
||||
};
|
||||
|
||||
handleClickOpen = () => {
|
||||
@@ -68,8 +69,9 @@ export default class addTorrentFilePopup extends React.Component {
|
||||
|
||||
let torrentFileMessage = {
|
||||
messageType: "torrentFileSubmit",
|
||||
messageDetail: this.state.torrentFileName,
|
||||
messageDetailTwo: this.state.storageValue,
|
||||
torrentFileName: this.state.torrentFileName,
|
||||
torrentStorageValue : this.state.storageValue,
|
||||
torrentLabelValue: this.state.torrentLabel,
|
||||
Payload: [base64data],
|
||||
}
|
||||
console.log("Sending magnet link: ", torrentFileMessage);
|
||||
@@ -85,7 +87,9 @@ export default class addTorrentFilePopup extends React.Component {
|
||||
console.log("File Name", file[0].name)
|
||||
}
|
||||
|
||||
|
||||
setLabelValue = (event) => {
|
||||
this.setState({torrentLabel: event.target.value})
|
||||
}
|
||||
|
||||
setStorageValue = (event) => {
|
||||
this.setState({storageValue: event.target.value})
|
||||
@@ -114,6 +118,7 @@ export default class addTorrentFilePopup extends React.Component {
|
||||
this.state.torrentFileName
|
||||
}
|
||||
<TextField id="storagePath" type="text" label="Storage Path" placeholder="Empty will be default torrent storage path" fullWidth onChange={this.setStorageValue} />
|
||||
<TextField id="labelValue" type="text" label="Label Value" placeholder="Empty will be no label" fullWidth onChange={this.setLabelValue} />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={this.handleRequestClose} color="primary">
|
||||
|
@@ -37,6 +37,7 @@ export default class addTorrentPopup extends React.Component {
|
||||
open: false,
|
||||
magnetLinkValue: "",
|
||||
storageValue: ``,
|
||||
torrentLabel: "",
|
||||
|
||||
};
|
||||
|
||||
@@ -53,14 +54,13 @@ export default class addTorrentPopup extends React.Component {
|
||||
//let magnetLinkSubmit = this.state.textValue;
|
||||
let magnetLinkMessage = {
|
||||
messageType: "magnetLinkSubmit",
|
||||
messageDetail: this.state.storageValue,
|
||||
storageValue: this.state.storageValue,
|
||||
torrentLabel: this.state.torrentLabel,
|
||||
Payload: [this.state.magnetLinkValue]
|
||||
}
|
||||
console.log("Sending magnet link: ", magnetLinkMessage);
|
||||
ws.send(JSON.stringify(magnetLinkMessage));
|
||||
this.setState({magnetLinkValue: ""})
|
||||
this.setState({storageValue: ``})
|
||||
console.log("Magnet Link", this.state.magnetLinkValue)
|
||||
this.setState({magnetLinkValue: ""}, {torrentLabel: ""}, {storageValue: ``})
|
||||
}
|
||||
|
||||
setMagnetLinkValue = (event) => {
|
||||
@@ -71,6 +71,10 @@ export default class addTorrentPopup extends React.Component {
|
||||
this.setState({storageValue: event.target.value})
|
||||
}
|
||||
|
||||
setLabelValue = (event) => {
|
||||
this.setState({torrentLabel: event.target.value})
|
||||
}
|
||||
|
||||
render() {
|
||||
const { classes, onRequestClose, handleRequestClose, handleSubmit } = this.props;
|
||||
return (
|
||||
@@ -96,6 +100,7 @@ export default class addTorrentPopup extends React.Component {
|
||||
onChange={this.setMagnetLinkValue}
|
||||
/>
|
||||
<TextField id="storagePath" type="text" label="Storage Path" placeholder="Empty will be default torrent storage path" fullWidth onChange={this.setStorageValue} />
|
||||
<TextField id="labelValue" type="text" label="Label Value" placeholder="Empty will be no label" fullWidth onChange={this.setLabelValue} />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={this.handleRequestClose} color="primary">
|
||||
@@ -109,5 +114,4 @@ export default class addTorrentPopup extends React.Component {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
|
116
goTorrentWebUI/src/TopMenu/Modals/changeStorageModal.js
Normal file
116
goTorrentWebUI/src/TopMenu/Modals/changeStorageModal.js
Normal file
@@ -0,0 +1,116 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import Button from 'material-ui/Button';
|
||||
import TextField from 'material-ui/TextField';
|
||||
import { withStyles } from 'material-ui/styles';
|
||||
import PropTypes from 'prop-types';
|
||||
import Dialog, {
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
DialogTitle,
|
||||
} from 'material-ui/Dialog';
|
||||
import StorageIcon from 'material-ui-icons/Storage';
|
||||
import ReactTooltip from 'react-tooltip'
|
||||
import Icon from 'material-ui/Icon';
|
||||
import IconButton from 'material-ui/IconButton';
|
||||
//Importing Redux
|
||||
import {connect} from 'react-redux';
|
||||
import * as actionTypes from '../store/actions';
|
||||
|
||||
|
||||
|
||||
const button = {
|
||||
fontSize: '60px',
|
||||
paddingRight: '20px',
|
||||
paddingLeft: '20px',
|
||||
}
|
||||
|
||||
const inlineStyle = {
|
||||
display: 'inline-block',
|
||||
backdrop: 'static',
|
||||
}
|
||||
|
||||
class addTorrentPopup extends React.Component {
|
||||
|
||||
state = {
|
||||
open: false,
|
||||
storageValue: ``,
|
||||
};
|
||||
|
||||
handleClickOpen = () => {
|
||||
this.setState({ open: true });
|
||||
};
|
||||
|
||||
handleRequestClose = () => {
|
||||
this.setState({ open: false });
|
||||
};
|
||||
|
||||
handleSubmit = () => {
|
||||
this.setState({ open: false });
|
||||
//let magnetLinkSubmit = this.state.textValue;
|
||||
let changeStorageMessage = {
|
||||
messageType: "changeStorageValue",
|
||||
newStorageValue: this.state.storageValue,
|
||||
Payload: [this.props.selectionHashes]
|
||||
}
|
||||
console.log("Sending new Storage Location: ", changeStorageMessage);
|
||||
ws.send(JSON.stringify(changeStorageMessage));
|
||||
this.setState({storageValue: ``})
|
||||
}
|
||||
|
||||
setStorageValue = (event) => {
|
||||
this.setState({storageValue: event.target.value})
|
||||
}
|
||||
|
||||
render() {
|
||||
const { classes, onRequestClose, handleRequestClose, handleSubmit } = this.props;
|
||||
return (
|
||||
<div style={inlineStyle}>
|
||||
<IconButton onClick={this.handleClickOpen} color="primary" data-tip="Change Storage Location" style={button} centerRipple aria-label="Change Storage Location" >
|
||||
<ReactTooltip place="top" type="light" effect="float" />
|
||||
<StorageIcon />
|
||||
</IconButton>
|
||||
<Dialog open={this.state.open} onRequestClose={this.handleRequestClose}>
|
||||
<DialogTitle>Change Storage Value</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText>
|
||||
Add a new Storage Location for selected Torrents and hit Submit
|
||||
</DialogContentText>
|
||||
<TextField
|
||||
autoFocus
|
||||
margin="dense"
|
||||
id="name"
|
||||
label="Storage Value"
|
||||
type="text"
|
||||
placeholder="Enter Storage Value Here"
|
||||
fullWidth
|
||||
onChange={this.setStorageValue}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={this.handleRequestClose} color="primary">
|
||||
Cancel
|
||||
</Button>
|
||||
<Button onClick={this.handleSubmit} color="primary">
|
||||
Submit
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
selectionHashes: state.selectionHashes,
|
||||
selection: state.selection,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export default connect(mapStateToProps)(BackendSocket);
|
Reference in New Issue
Block a user