Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

22
goTorrentWebUI/node_modules/react-websocket/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Pim Voeten
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

79
goTorrentWebUI/node_modules/react-websocket/README.md generated vendored Normal file
View File

@@ -0,0 +1,79 @@
# react-websocket [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/mehmetkose/react-websocket/edit/master/README.md)
`react-websocket` is a simple to use component for ReactJS applications to setup websocket communication.
The component renders an empty element in the DOM.
When mounting the component, a websocket connection is opened.
The connection will be closed when the component will be unmounted.
### Installing
```
npm install --save react-websocket
```
### Usage
```js
import React from 'react';
import Websocket from 'react-websocket';
class ProductDetail extends React.Component {
constructor(props) {
super(props);
this.state = {
count: 90
};
}
handleData(data) {
let result = JSON.parse(data);
this.setState({count: this.state.count + result.movement});
}
render() {
return (
<div>
Count: <strong>{this.state.count}</strong>
<Websocket url='ws://localhost:8888/live/product/12345/'
onMessage={this.handleData.bind(this)}/>
</div>
);
}
}
export default ProductDetail;
```
### Properties
#### url
**required**
The url the websocket connection is listening to.
#### onMessage
**required**
The callback called when data is received. Data is `JSON.parse`'d
#### onOpen
The callback called when the connection is successfully opened.
#### onClose
The callback called when the connection is closed either due to server disconnect or network error.
#### debug
default: **false**
Set to **true** to see console logging
#### reconnect
default: **true**
accelerated reconnection time

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

87
goTorrentWebUI/node_modules/react-websocket/index.jsx generated vendored Normal file
View File

@@ -0,0 +1,87 @@
import React from 'react';
import PropTypes from 'prop-types';
class Websocket extends React.Component {
constructor(props) {
super(props);
this.state = {
ws: new WebSocket(this.props.url, this.props.protocol),
attempts: 1
};
}
logging(logline) {
if (this.props.debug === true) {
console.log(logline);
}
}
generateInterval (k) {
if(this.props.reconnectIntervalInMilliSeconds > 0) {
return this.props.reconnectIntervalInMilliSeconds;
}
return Math.min(30, (Math.pow(2, k) - 1)) * 1000;
}
setupWebsocket() {
let websocket = this.state.ws;
websocket.onopen = () => {
this.logging('Websocket connected');
if (typeof this.props.onOpen !== 'undefined') this.props.onOpen();
};
websocket.onmessage = (evt) => {
this.props.onMessage(evt.data);
};
this.shouldReconnect = this.props.reconnect;
websocket.onclose = () => {
this.logging('Websocket disconnected');
if (typeof this.props.onClose !== 'undefined') this.props.onClose();
if (this.shouldReconnect) {
let time = this.generateInterval(this.state.attempts);
setTimeout(() => {
this.setState({attempts: this.state.attempts+1});
this.setState({ws: new WebSocket(this.props.url, this.props.protocol)});
this.setupWebsocket();
}, time);
}
}
}
componentDidMount() {
this.setupWebsocket();
}
componentWillUnmount() {
this.shouldReconnect = false;
let websocket = this.state.ws;
websocket.close();
}
render() {
return (
<div></div>
);
}
}
Websocket.defaultProps = {
debug: false,
reconnect: true
};
Websocket.propTypes = {
url: PropTypes.string.isRequired,
onMessage: PropTypes.func.isRequired,
onOpen: PropTypes.func,
onClose: PropTypes.func,
debug: PropTypes.bool,
reconnect: PropTypes.bool,
protocol: PropTypes.string,
reconnectIntervalInMilliSeconds : PropTypes.number
};
export default Websocket;

View File

@@ -0,0 +1,80 @@
{
"_args": [
[
"react-websocket@1.2.0",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "react-websocket@1.2.0",
"_id": "react-websocket@1.2.0",
"_inBundle": false,
"_integrity": "sha512-0OworWBqMs7J5K7LY3wEVObii/is43mgfDCiHAbIdKrCV3190t+HTTygRHjUTMy7zJvrLk3gNox08YZ2sbUyjQ==",
"_location": "/react-websocket",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "react-websocket@1.2.0",
"name": "react-websocket",
"escapedName": "react-websocket",
"rawSpec": "1.2.0",
"saveSpec": null,
"fetchSpec": "1.2.0"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/react-websocket/-/react-websocket-1.2.0.tgz",
"_spec": "1.2.0",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"bugs": {
"url": "https://github.com/mehmetkose/react-websocket/issues"
},
"description": "ReactJS Websocket Listener Component",
"devDependencies": {
"babel": "^5.8.23",
"babel-loader": "^5.3.1",
"cross-env": "^3.1.4",
"prop-types": "^15.5.8",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-hot-loader": "^1.3.0",
"webpack": "^1.10.1",
"webpack-dev-server": "^1.10.1"
},
"example": {
"script": "example/component.jsx"
},
"homepage": "https://github.com/mehmetkose/react-websocket",
"keywords": [
"reactjs",
"websocket",
"react",
"connection"
],
"license": "MIT",
"main": "build/index.js",
"maintainers": [
{
"name": "Mehmet Kose",
"email": "mehmet@linux.com",
"url": "https://mehmetkose.github.io/"
}
],
"name": "react-websocket",
"peerDependencies": {
"react": ">0.14.5",
"react-dom": ">0.14.5"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/mehmetkose/react-websocket.git"
},
"scripts": {
"compile-example": "webpack",
"prerelease": "cross-env NODE_ENV=production webpack --config webpack.prod.config.js",
"start": "cross-env NODE_ENV=development node server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.2.0"
}

18
goTorrentWebUI/node_modules/react-websocket/server.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config');
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
stats: {
chunkModules: false,
colors: true,
},
}).listen(3000, 'localhost', function (err) {
if (err) {
console.log(err);
}
console.log('Listening at localhost:3000');
});

View File

@@ -0,0 +1,35 @@
var path = require('path');
var webpack = require('webpack');
var entry = ['./example/index.jsx'];
if (process.env.NODE_ENV === 'development') {
entry = entry.concat([
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
]);
}
module.exports = {
devtool: 'eval',
entry: entry,
output: {
path: path.join(__dirname, 'example', 'static'),
filename: 'bundle.js',
publicPath: '/example/static/',
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
],
resolve: {
extensions: ['', '.js', '.jsx'],
},
module: {
loaders: [{
test: /\.jsx?$/,
loaders: ['react-hot', 'babel'],
exclude: /build|lib|node_modules/,
}],
},
};

View File

@@ -0,0 +1,37 @@
var path = require('path');
// currently, this is for bower
var config = {
devtool: 'sourcemap',
entry: {
index: './index.jsx',
},
output: {
path: path.join(__dirname, 'build'),
publicPath: './build',
filename: 'index.js',
sourceMapFilename: 'index.map',
library: 'Spinner',
libraryTarget: 'umd',
},
module: {
loaders: [{
test: /\.(js|jsx)/,
loader: 'babel',
}],
},
plugins: [],
resolve: {
extensions: ['', '.js', '.jsx'],
},
externals: {
'react': {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
},
},
};
module.exports = config;