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

@@ -52,7 +52,7 @@ var RSSList = [];
var RSSTorrentList = [];
var torrentListRequest = {
messageType: "torrentListRequest"
MessageType: "torrentListRequest"
//websocket is started in kickwebsocket.js and is picked up here so "ws" is already defined 22
};ws.onmessage = function (evt) {

View File

@@ -116,9 +116,9 @@ var addTorrentFilePopup = function (_React$Component) {
console.log("Base64", base64data);
var torrentFileMessage = {
messageType: "torrentFileSubmit",
messageDetail: _this.state.torrentFileName,
messageDetailTwo: _this.state.storageValue,
MessageType: "torrentFileSubmit",
MessageDetail: this.state.torrentFileName,
MessageDetailTwo: this.state.storageValue,
Payload: [base64data]
};
console.log("Sending magnet link: ", torrentFileMessage);

View File

@@ -22,7 +22,7 @@ let serverPushMessage = [];
let webSocketState = false;
var torrentListRequest = {
messageType: "torrentListRequest"
MessageType: "torrentListRequest"
}
@@ -61,7 +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,
TorrentLabel: serverMessage.data[i].TorrentLabel,
})
}
var newTitle = '(' + serverMessage.total + ')' + title; //updating the title
@@ -143,20 +143,18 @@ ws.onclose = function() {
console.log('Closing connection')
};
var divStyle = {
display: 'inline-block',
paddingTop: '10px',
paddingLeft: '10px',
}
var buttonStyle ={
fontSize: '60px',
marginLeft: '20px',
}
const inlineStyle = {
display: 'inline-block',
backdrop: 'static',
}
class BackendSocket extends React.Component {
selectionHandler = (selectionHashes, selectedTab) => {
switch (selectedTab) {
case 0:
@@ -258,6 +256,7 @@ class BackendSocket extends React.Component {
}
componentWillReceiveProps (nextProps) {
console.log("Length", nextProps.selectionHashes.length, "value", nextProps.selectionHashes)
if (nextProps.selectionHashes.length === 1){ //if we have a selection pass it on for the tabs to verify
@@ -268,12 +267,9 @@ class BackendSocket extends React.Component {
render() {
return (
<div style={divStyle}>
<BackendIcon styles={buttonStyle} color="primary" data-tip="BackendStatus: Green=Good" aria-label="Settings" />
<div style={inlineStyle}>
<BackendIcon style={buttonStyle} color="primary" data-tip="BackendStatus: Green=Good" aria-label="Settings" />
</div>
);
}

View File

@@ -35,7 +35,6 @@ class GeneralTab extends React.Component {
}
componentWillReceiveProps = () => {
//console.log("recieving props in generaltab", "TYPE", this.props.selectionHashes[Object.keys(this.props.selectionHashes)[0]])
if (this.props.selectionHashes.length === 1) { //if one torrent is selected
let selectionHashTemp = this.props.selectionHashes[Object.keys(this.props.selectionHashes)[0]]// extract out the hash of the single selection
let selectedTorrentTemp = []
@@ -44,7 +43,6 @@ class GeneralTab extends React.Component {
selectedTorrentTemp = singleTorrent
}
})
//selectedTorrentTemp = this.props.torrentList.filter(torrent => torrent.TorrentHashString === this.props.selectionHashes)
//console.log("SelectedTorrentTemp", selectedTorrentTemp)
this.setState({ selectedTorrent: selectedTorrentTemp });
} else {
@@ -52,7 +50,6 @@ class GeneralTab extends React.Component {
}
}
render() {
const { classes } = this.props;
return (
@@ -90,9 +87,6 @@ class GeneralTab extends React.Component {
}
const mapStateToProps = state => {
return {
selectionHashes: state.selectionHashes,

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))

View File

@@ -55,12 +55,21 @@ class SimpleList extends React.Component {
}
}
setActiveElement = (listItem) => {
componentWillReceiveProps = (nextprops) => {
const { classes } = this.props;
if (nextprops.filter[0].columnName == "TorrentName"){ //If we are using the top searchbox move back to all torrents
this.setState({
allTorrentsClass: classes.active,
downloadingClass: '',
seedingClass: '',
activeTorrentsClass: '',
completedTorrentsClass: '',
})
}
}
setFilter = (filterState, id) => {
const { classes } = this.props;
filterState = [{columnName: 'Status', value: filterState}]

View File

@@ -19,7 +19,8 @@ const initialState = {
RSSTorrentList: [],
RSSModalOpen: false,
serverPushMessage: [],
webSocketState: false
webSocketState: false,
searchFilterTerm: ""
}

View File

@@ -116,9 +116,7 @@ class TorrentListTable extends React.Component {
filterHandler = (filter) => { //TODO, figure out how to do multiple filter
//console.log("Changing FIlter", filter)
if (filter.value ==="Active"){
console.log("This filter doesn't fucking work")
}
}
@@ -149,13 +147,6 @@ class TorrentListTable extends React.Component {
<TableColumnReordering order={this.state.columnOrder} onOrderChange={this.changeColumnOrder} />
<TableSelection selectByRowClick highlightSelected />
<TableHeaderRow allowSorting allowResizing allowDragging />
</Grid>
</Paper>
);