started adding the back to front api via websocket and json

This commit is contained in:
2017-12-24 10:42:12 -05:00
parent 2e1eb8e4e1
commit 8a5f7eaa09
37 changed files with 676 additions and 666 deletions

View File

@@ -73459,7 +73459,6 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // contains the font for material UI
//import PhotoCamera from 'material-ui-icons/PhotoCamera';
//Redux
@@ -73504,6 +73503,16 @@ var IconButtons = function (_React$Component) {
var _this = _possibleConstructorReturn(this, (IconButtons.__proto__ || Object.getPrototypeOf(IconButtons)).call(this, props));
_this.startTorrentState = {
messageType: "startTorrents",
Payload: _this.props.selection
};
_this.startTorrent = function (selection) {
console.log("Starting Torrents", selection);
ws.send();
};
_this.buttonHandler = function (buttonState) {
console.log("BUTTONSTATE", buttonState);
};
@@ -73582,15 +73591,14 @@ IconButtons.propTypes = {
var mapStateToProps = function mapStateToProps(state) {
return {
buttonState: state.buttonState
buttonState: state.buttonState,
selection: state.selection
};
};
var mapDispatchToProps = function mapDispatchToProps(dispatch) {
return {
changeSelection: function changeSelection(selection) {
return dispatch({ type: actionTypes.CHANGE_SELECTION, selection: selection });
}
//changeSelection: (selection) => dispatch({type: actionTypes.CHANGE_SELECTION, selection: selection})
};
};
@@ -81221,9 +81229,13 @@ var addTorrentPopup = function (_React$Component) {
_this.setState({ open: false });
}, _this.handleSubmit = function () {
_this.setState({ open: false });
var magnetLinkSubmit = _this.state.textValue;
console.log("Sending magnet link: ", magnetLinkSubmit);
ws.send(magnetLinkSubmit);
//let magnetLinkSubmit = this.state.textValue;
var magnetLinkMessage = {
messageType: "magnetLinkSubmit",
Payload: { MagnetLink: _this.state.textValue }
};
console.log("Sending magnet link: ", magnetLinkMessage);
ws.send(JSON.stringify(magnetLinkMessage));
}, _this.setTextValue = function (event) {
_this.setState({ textValue: event.target.value });
}, _temp), _possibleConstructorReturn(_this, _ret);
@@ -89953,38 +89965,45 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
var title = document.title; //Set the number of active torrents in the title
var torrents = [];
//websocket is started in kickwebsocket.js and is picked up here so "ws" is already defined
ws.onmessage = function (evt) {
//When we recieve a message from the websocket
if (evt.data == "clientUpdate") {
console.log("Client Update Incoming...");
} else {
// recieving data
console.log("Recieved Client Update...");
var clientUpdate = JSON.parse(evt.data);
if (clientUpdate.total) {
// if it has a total field it is a torrentlist update
torrents = []; //clearing out the torrent array to make room for new (so that it does keep adding)
for (var i = 0; i < clientUpdate.total; i++) {
torrents.push({
TorrentHashString: clientUpdate.data[i].TorrentHash,
TorrentName: clientUpdate.data[i].TorrentName,
DownloadedSize: clientUpdate.data[i].DownloadedSize,
Size: clientUpdate.data[i].Size,
DownloadSpeed: clientUpdate.data[i].DownloadSpeed,
UploadSpeed: clientUpdate.data[i].UploadSpeed,
PercentDone: clientUpdate.data[i].PercentDone,
StoragePath: clientUpdate.data[i].StoragePath,
DateAdded: clientUpdate.data[i].DateAdded,
Status: clientUpdate.data[i].Status,
BytesCompleted: clientUpdate.data[i].BytesCompleted,
ActivePeers: clientUpdate.data[i].ActivePeers,
ETA: clientUpdate.data[i].ETA
});
}
var torrentListRequest = {
messageType: "torrentListRequest"
var newTitle = '(' + clientUpdate.total + ')' + title; //updating the title
document.title = newTitle;
//websocket is started in kickwebsocket.js and is picked up here so "ws" is already defined 22
};ws.onmessage = function (evt) {
//When we recieve a message from the websocket
var serverMessage = JSON.parse(evt.data);
if (serverMessage.MessageType == "torrentList") {
console.log("Recieved Client Update...");
//var serverMessage = JSON.parse(evt.data);
torrents = []; //clearing out the torrent array to make room for new (so that it does keep adding)
for (var i = 0; i < serverMessage.total; i++) {
torrents.push({
TorrentHashString: serverMessage.data[i].TorrentHash,
TorrentName: serverMessage.data[i].TorrentName,
DownloadedSize: serverMessage.data[i].DownloadedSize,
Size: serverMessage.data[i].Size,
DownloadSpeed: serverMessage.data[i].DownloadSpeed,
UploadSpeed: serverMessage.data[i].UploadSpeed,
PercentDone: serverMessage.data[i].PercentDone,
StoragePath: serverMessage.data[i].StoragePath,
DateAdded: serverMessage.data[i].DateAdded,
Status: serverMessage.data[i].Status,
BytesCompleted: serverMessage.data[i].BytesCompleted,
ActivePeers: serverMessage.data[i].ActivePeers,
ETA: serverMessage.data[i].ETA
});
}
var newTitle = '(' + serverMessage.total + ')' + title; //updating the title
document.title = newTitle;
} else if (serverMessage.MessageType == "fileList") {
console.log("Recieved FileListUpdate", serverMessage.fileList);
fileList = [];
for (var i = 0; i < serverMessage.total; i++) {
fileList.push({
FileList: serverMessage.fileList[i]
});
}
}
};
@@ -90029,11 +90048,8 @@ var BackendSocket = function (_React$Component) {
}, {
key: 'tick',
value: function tick() {
ws.send("clientUpdateRequest"); //talking to the server to get the torrent list
ws.send(JSON.stringify(torrentListRequest)); //talking to the server to get the torrent list
this.props.newTorrentList(torrents);
//console.log("STATE:", this.state.torrentList)
//console.log("Torrents", torrents);
}
}, {
key: 'render',
@@ -92541,13 +92557,10 @@ var TorrentListTable = function (_React$Component) {
if (selection.length === 0) {
//if selection is empty buttons will be default
console.log("No Selection");
_this.props.setButtonState(_this.props.buttonStateDefault); //if no selection dispatch that to redux
} else {
// if we have selection continue on with logic to determine button state
var selectedRows = []; //array of all the selected Rows
selection.forEach(function (element) {
selectedRows.push(_this.props.torrentList[element]); //pushing the selected rows out of torrentlist
});