testing rate limiting, making API changes

This commit is contained in:
2018-01-31 22:28:45 -05:00
parent 6af49b317d
commit 8db9a43b0f
30 changed files with 2160 additions and 1514 deletions

View File

@@ -62,7 +62,7 @@ const inlineStyle = {
showRSSFiles = (key) => {
let RSSTorrentsRequest = {
messageType: "rssTorrentsRequest",
MessageType: "rssTorrentsRequest",
Payload: [this.props.RSSList[key].RSSURL]
}
ws.send(JSON.stringify(RSSTorrentsRequest))
@@ -85,7 +85,7 @@ const inlineStyle = {
deleteRSSFeed = (key) => {
let RSSURLDelete = {
messageType: "deleteRSSFeed",
MessageType: "deleteRSSFeed",
Payload: [this.props.RSSList[key]]
}
console.log("Deleting THIS", this.props.RSSList[key])

View File

@@ -105,12 +105,12 @@ const inlineStyle = {
handleAddRSSFeed = () => {
this.setState({ textValue: "Clear"}) //clearing out the text submitted
let RSSURLSubmit = {
messageType: "addRSSFeed",
MessageType: "addRSSFeed",
Payload: [this.state.textValue]
}
ws.send(JSON.stringify(RSSURLSubmit));
let RSSRequest = {
messageType: "rssFeedRequest",
MessageType: "rssFeedRequest",
}
ws.send(JSON.stringify(RSSRequest)) //Immediatly request an update of the feed when you add a new URL
}

View File

@@ -31,11 +31,9 @@ import * as actionTypes from '../../../store/actions';
const button = {
fontSize: '60px',
paddingRight: '20px',
paddingLeft: '20px',
marginLeft: '20px',
}
const inlineStyle = {
display: 'inline-block',
backdrop: 'static',
@@ -46,7 +44,7 @@ const inlineStyle = {
componentDidMount () { //Immediatly request an update of the feed when loading app
let RSSRequest = {
messageType: "rssFeedRequest",
MessageType: "rssFeedRequest",
}
ws.send(JSON.stringify(RSSRequest))

View File

@@ -20,8 +20,8 @@ import Dropzone from 'react-dropzone';
const button = {
fontSize: '60px',
paddingRight: '20px',
paddingLeft: '20px',
marginLeft: '20px',
marginRight: '20px',
}
const uploadButton = {
@@ -68,13 +68,13 @@ export default class addTorrentFilePopup extends React.Component {
console.log("Base64", base64data)
let torrentFileMessage = {
messageType: "torrentFileSubmit",
torrentFileName: this.state.torrentFileName,
torrentStorageValue : this.state.storageValue,
torrentLabelValue: this.state.torrentLabel,
MessageType: "torrentFileSubmit",
MessageDetail: this.state.torrentFileName, //filename
MessageDetailTwo: this.state.storageValue, //storage path
MessageDetailThree: this.state.torrentLabel, //torrent label
Payload: [base64data],
}
console.log("Sending magnet link: ", torrentFileMessage);
console.log("Sending Torrent File: ", torrentFileMessage);
ws.send(JSON.stringify(torrentFileMessage));
this.setState({torrentFileName: "", storageValue: ``, torrentFileValue: [], showDrop: true})
}

View File

@@ -20,8 +20,7 @@ import IconButton from 'material-ui/IconButton';
const button = {
fontSize: '60px',
paddingRight: '20px',
paddingLeft: '20px',
marginRight: '20px',
}
const inlineStyle = {
@@ -52,15 +51,16 @@ export default class addTorrentPopup extends React.Component {
handleSubmit = () => {
this.setState({ open: false });
//let magnetLinkSubmit = this.state.textValue;
console.log("MagnetLink", this.state.magnetLinkValue)
let magnetLinkMessage = {
messageType: "magnetLinkSubmit",
storageValue: this.state.storageValue,
torrentLabel: this.state.torrentLabel,
MessageType: "magnetLinkSubmit",
MessageDetail: this.state.storageValue, //storage location
MessageDetailTwo: this.state.torrentLabel, //label
Payload: [this.state.magnetLinkValue]
}
console.log("Sending magnet link: ", magnetLinkMessage);
ws.send(JSON.stringify(magnetLinkMessage));
this.setState({magnetLinkValue: ""}, {torrentLabel: ""}, {storageValue: ``})
//this.setState({magnetLinkValue: ""}, {torrentLabel: ""}, {storageValue: ``})
}
setMagnetLinkValue = (event) => {

View File

@@ -16,14 +16,14 @@ 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';
import * as actionTypes from '../../store/actions';
const button = {
fontSize: '60px',
paddingRight: '20px',
paddingLeft: '20px',
marginLeft: '20px',
}
const inlineStyle = {
@@ -31,7 +31,7 @@ const inlineStyle = {
backdrop: 'static',
}
class addTorrentPopup extends React.Component {
class ChangeStorageModal extends React.Component {
state = {
open: false,
@@ -50,9 +50,9 @@ class addTorrentPopup extends React.Component {
this.setState({ open: false });
//let magnetLinkSubmit = this.state.textValue;
let changeStorageMessage = {
messageType: "changeStorageValue",
newStorageValue: this.state.storageValue,
Payload: [this.props.selectionHashes]
MessageType: "changeStorageValue",
MessageDetail: this.state.storageValue, //new storage value
Payload: this.props.selectionHashes, //the selection hashes
}
console.log("Sending new Storage Location: ", changeStorageMessage);
ws.send(JSON.stringify(changeStorageMessage));
@@ -113,4 +113,4 @@ const mapStateToProps = state => {
export default connect(mapStateToProps)(BackendSocket);
export default connect(mapStateToProps)(ChangeStorageModal);

View File

@@ -22,8 +22,7 @@ import * as actionTypes from '../../store/actions';
const button = {
fontSize: '60px',
paddingRight: '20px',
paddingLeft: '20px',
marginRight: '20px',
}
const inlineStyle = {

View File

@@ -9,12 +9,15 @@ import AddTorrentLinkPopup from './Modals/addTorrentLinkModal';
import AddTorrentFilePopup from './Modals/addTorrentFileModal';
import AddRSSModal from './Modals/RSSModal/addRSSModal';
import DeleteTorrentModal from './Modals/deleteTorrentModal';
import ChangeStorageModal from './Modals/changeStorageModal';
import TorrentSearch from './torrentSearch';
import StartTorrentIcon from 'material-ui-icons/PlayArrow';
//import PauseTorrentIcon from 'material-ui-icons/Pause';
import StopTorrentIcon from 'material-ui-icons/Stop';
import RSSTorrentIcon from 'material-ui-icons/RssFeed';
import SettingsIcon from 'material-ui-icons/Settings';
import ForceUploadIcon from 'material-ui-icons/KeyboardArrowUp';
import ReactTooltip from 'react-tooltip'
@@ -38,9 +41,6 @@ const styles = theme => ({
input: {
display: 'none',
},
paddingTest: {
display: 'inline-block'
},
padding: {
paddingTop: '10px',
paddingLeft: '10px',
@@ -61,15 +61,32 @@ const styles = theme => ({
});
class IconButtons extends React.Component {
constructor(props){
super(props);
this.state = { serverMessage: ["info", "A props message"]}
this.state = {
forceStartButton: "default"
}
}
componentWillReceiveProps = (nextprops) => {
if (nextprops.selectionHashes.length > 0){
this.setState({forceStartButton: "primary"})
} else {
this.setState({forceStartButton: "default"})
}
}
forceStartTorrent = () => {
console.log("Force starting Torrents", this.props.selectionHashes)
let forceUploadTorrents = {
MessageType: "forceUploadTorrents",
Payload: this.props.selectionHashes,
}
ws.send(JSON.stringify(forceUploadTorrents))
}
startTorrent = () => {
console.log("Starting Torrents", this.props.selectionHashes)
let startTorrentHashes = {
@@ -99,6 +116,10 @@ class IconButtons extends React.Component {
<AddTorrentFilePopup />
<AddTorrentLinkPopup />
<div className={classes.verticalDivider}></div>
<IconButton color={this.state.forceStartButton} data-tip="Force Upload Torrent (override upload limit)" className={classes.button} aria-label="Force Start Torrent" onClick={this.forceStartTorrent}>
<ReactTooltip place="top" type="light" effect="float" />
<ForceUploadIcon />
</IconButton>
<IconButton color={this.props.buttonState[0].startButton} data-tip="Start Torrent" className={classes.button} aria-label="Start Torrent" onClick={this.startTorrent}>
<ReactTooltip place="top" type="light" effect="float" />
<StartTorrentIcon />
@@ -113,13 +134,17 @@ class IconButtons extends React.Component {
</IconButton>
<DeleteTorrentModal />
<div className={classes.verticalDivider}></div>
<ChangeStorageModal />
<AddRSSModal />
<IconButton color="primary" data-tip="Settings" className={classes.button} aria-label="Settings">
<ReactTooltip place="top" type="light" effect="float" />
<SettingsIcon />
</IconButton>
<div className={classes.verticalDivider}></div>
<TorrentSearch />
<div className={classes.verticalDivider}></div>
<BackendSocket />
</div>
);
}
@@ -141,7 +166,6 @@ const mapStateToProps = state => {
const mapDispatchToProps = dispatch => {
return {
setButtonState: (buttonState) => dispatch({type: actionTypes.SET_BUTTON_STATE, buttonState}),
changeSelection: (selection) => dispatch({type: actionTypes.CHANGE_SELECTION, selection}), //used to force a selection empty after deleting torrent
}
}

View File

@@ -0,0 +1,77 @@
import React from 'react';
import PropTypes from 'prop-types';
import TextField from 'material-ui/TextField';
import { withStyles } from 'material-ui/styles';
//Redux
import {connect} from 'react-redux';
import * as actionTypes from '../store/actions'
const styles = theme => ({
textField: {
marginLeft: theme.spacing.unit,
marginRight: theme.spacing.unit,
marginBottom: '20px',
width: 200,
},
});
class TorrentSearch extends React.Component {
constructor(props){
super(props);
this.state = {
searchValue: "",
}
}
componentWillReceiveProps = (nextprops) => {
if (nextprops.filter[0].columnName == "Status"){ //If we are using the left menu filter clear the searchbox
this.setState({searchValue: ""})
}
}
onChange = (event) => {
this.setState({searchValue: event.target.value})
let filterState = [{columnName: 'TorrentName', value: event.target.value}]
this.props.changeFilter(filterState)
}
render() {
const { classes } = this.props;
return(
<TextField
id="search"
label="Search Torrents"
type="search"
className={classes.textField}
onChange={this.onChange}
value={this.state.searchValue}
margin="normal"
/>
);
}
}
const mapStateToProps = state => {
return {
filter: state.filter,
};
}
const mapDispatchToProps = dispatch => {
return {
changeFilter: (filter) => dispatch({type: actionTypes.CHANGE_FILTER, filter: filter}),
}
}
export default withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(TorrentSearch))