Finished Frontend notifications, added file prio (needs test), started Settings Button work

This commit is contained in:
2018-01-23 23:21:25 -05:00
parent 5856052f82
commit 52e245d11f
15 changed files with 241 additions and 126 deletions

View File

@@ -1499,6 +1499,7 @@ var NEW_RSS_FEED_STORE = exports.NEW_RSS_FEED_STORE = 'NEW_RSS_FEED_STORE';
var RSS_MODAL_OPEN_STATE = exports.RSS_MODAL_OPEN_STATE = 'RSS_MODAL_OPEN_STATE';
var RSS_TORRENT_LIST = exports.RSS_TORRENT_LIST = 'RSS_TORRENT_LIST';
var SERVER_MESSAGE = exports.SERVER_MESSAGE = 'SERVER_MESSAGE';
var WEBSOCKET_STATE = exports.WEBSOCKET_STATE = 'WEBSOCKET_STATE';
/***/ }),
/* 25 */
@@ -79006,7 +79007,8 @@ var initialState = {
RSSList: [],
RSSTorrentList: [],
RSSModalOpen: false,
serverMessage: []
serverPushMessage: [],
webSocketState: false
};
var reducer = function reducer() {
@@ -79014,6 +79016,11 @@ var reducer = function reducer() {
var action = arguments[1];
switch (action.type) {
case actionTypes.WEBSOCKET_STATE:
console.log("Websocket closed...");
return _extends({}, state, {
webSocketState: action.webSocketState
});
case actionTypes.CHANGE_SELECTION:
console.log("Change Selection", action.selection);
@@ -79079,9 +79086,9 @@ var reducer = function reducer() {
});
case actionTypes.SERVER_MESSAGE:
console.log("New server push message", action.serverMessage);
console.log("New server push message", action.serverPushMessage);
return _extends({}, state, {
serverMessage: action.serverMessage
serverPushMessage: action.serverPushMessage
});
case actionTypes.SET_BUTTON_STATE:
@@ -87013,6 +87020,9 @@ var addTorrentPopup = function (_React$Component) {
};
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.setMagnetLinkValue = function (event) {
_this.setState({ magnetLinkValue: event.target.value });
}, _this.setStorageValue = function (event) {
@@ -117173,6 +117183,8 @@ var fileList = [];
var RSSList = [];
var RSSTorrentList = [];
var serverMessage = [];
var serverPushMessage = [];
var webSocketState = false;
var torrentListRequest = {
messageType: "torrentListRequest"
@@ -117181,7 +117193,7 @@ var torrentListRequest = {
};ws.onmessage = function (evt) {
//When we recieve a message from the websocket
var serverMessage = JSON.parse(evt.data);
//console.log("message", serverMessage.MessageType)
console.log("message", serverMessage.MessageType);
switch (serverMessage.MessageType) {
case "torrentList":
@@ -117275,10 +117287,11 @@ var torrentListRequest = {
PublishDate: serverMessage.Torrents[i].PubDate
});
}
break;
case "serverPushMessage":
console.log("Server push notification receieved", evt.data);
serverMessage = [serverMessage.Type, serverMessage.body];
this.props.newServerMessage(serverMessage);
console.log("SERVER PUSHED MESSAGE", serverMessage);
serverPushMessage = [serverMessage.MessageLevel, serverMessage.Payload];
break;
}
};
@@ -117357,6 +117370,11 @@ var BackendSocket = function (_React$Component) {
this.timerID = setInterval(function () {
return _this2.tick();
}, 2000);
if (ws.readyState === (ws.CONNECTING || ws.OPEN)) {
//checking to make sure we have a websocket connection
webSocketState = true;
this.props.webSocketStateUpdate(webSocketState);
}
}
}, {
key: 'componentWillUnmount',
@@ -117373,8 +117391,17 @@ var BackendSocket = function (_React$Component) {
if (this.props.RSSTorrentList != RSSTorrentList & this.props.RSSModalOpen == true) {
this.props.RSSTorrentList(RSSTorrentList); //pushing the new RSSTorrentList to Redux
}
if (this.props.serverPushMessage != serverPushMessage & serverPushMessage[0] != null) {
console.log("PROPSSERVER", this.props.serverPushMessage, "SERVERPUSH", serverPushMessage);
this.props.newServerMessage(serverPushMessage);
}
ws.send(JSON.stringify(torrentListRequest)); //talking to the server to get the torrent list
if (ws.readyState === ws.CLOSED) {
//if our websocket gets closed inform the user
webSocketState = false;
this.props.webSocketStateUpdate(webSocketState);
}
//console.log("Torrentlist", torrents)
this.props.setButtonState(this.props.selection); //forcing an update to the buttons
this.props.newTorrentList(torrents); //sending the list of torrents to torrentlist.js
@@ -117403,7 +117430,7 @@ var BackendSocket = function (_React$Component) {
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
console.log("Lenght", nextProps.selectionHashes.length, "value", nextProps.selectionHashes);
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
this.selectionHandler(nextProps.selectionHashes, nextProps.selectedTab);
@@ -117429,7 +117456,8 @@ var mapStateToProps = function mapStateToProps(state) {
selectedTab: state.selectedTab,
selection: state.selection,
RSSModalOpen: state.RSSModalOpen,
RSSTorrentList: state.RSSTorrentList
RSSTorrentList: state.RSSTorrentList,
serverPushMessage: state.serverPushMessage
};
};
@@ -117453,8 +117481,11 @@ var mapDispatchToProps = function mapDispatchToProps(dispatch) {
RSSTorrentList: function RSSTorrentList(_RSSTorrentList) {
return dispatch({ type: actionTypes.RSS_TORRENT_LIST, RSSTorrentList: _RSSTorrentList });
},
newServerMessage: function newServerMessage(serverMessage) {
return dispatch({ type: actionTypes.SERVER_MESSAGE, serverMessage: serverMessage });
newServerMessage: function newServerMessage(serverPushMessage) {
return dispatch({ type: actionTypes.SERVER_MESSAGE, serverPushMessage: serverPushMessage });
},
webSocketStateUpdate: function webSocketStateUpdate(webSocketState) {
return dispatch({ type: actionTypes.WEBSOCKET_STATE, webSocketState: webSocketState });
}
//changeSelection: (selection) => dispatch({type: actionTypes.CHANGE_SELECTION, selection}),//forcing an update to the buttons
@@ -129694,35 +129725,38 @@ var FileTab = function (_React$Component) {
}
};
_this.sendPriorityRequest = function (priority, sendfileNames) {
_this.sendPriorityRequest = function (priority, selectionHash) {
var filePaths = [];
_this.state.fileSelection.forEach(function (element) {
console.log("element", element);
sendFileNames.push(element.FilePath);
filePaths.push(element.FilePath);
});
var setFilePriority = {
MessageType: "setFilePriority",
Payload: sendFileNames
MessageDetail: priority,
MessageDetailTwo: selectionHash,
Payload: filePaths
};
console.log(JSON.stringify(setFilePriority));
ws.send(JSON.stringify(setFilePriority));
};
_this.setHighPriority = function () {
var priorty = "High";
var priority = "High";
var selectionHash = _this.props.selectionHashes[0]; //getting the first element (should be the only one)
var sendFileNames = [selectionHash, "High"]; // adding the selection hash as the first element will be stripped out by the server, second element is the prioty request
_this.sendPriorityRequest(priority, selectionHash);
};
_this.setNormalPriority = function () {
var priorty = "Normal";
var priority = "Normal";
var selectionHash = _this.props.selectionHashes[0]; //getting the first element (should be the only one)
var sendFileNames = [selectionHash, "Normal"]; // adding the selection hash as the first element will be stripped out by the server, second element is the prioty request
_this.sendPriorityRequest(priority, selectionHash);
};
_this.setCancelPriority = function () {
var priorty = "Cancel";
var priority = "Cancel";
var selectionHash = _this.props.selectionHashes[0]; //getting the first element (should be the only one)
var sendFileNames = [selectionHash, "Cancel"]; // adding the selection hash as the first element will be stripped out by the server, second element is the prioty request
_this.sendPriorityRequest(priority, selectionHash);
};
_this.state = { //rows are stored in redux they are sent over from the server
@@ -129734,7 +129768,6 @@ var FileTab = function (_React$Component) {
selected: []
};
_this.changeColumnOrder = function (columnOrder) {
return _this.setState({ columnOrder: columnOrder });
};
@@ -129813,9 +129846,7 @@ var mapStateToProps = function mapStateToProps(state) {
var mapDispatchToProps = function mapDispatchToProps(dispatch) {
return {
//changeFileSelection: (fileSelection) => dispatch({type: actionTypes.CHANGE_FILE_SELECTION, fileSelection}),
sendSelectionHashes: function sendSelectionHashes(selectionHashes) {
return dispatch({ type: actionTypes.SELECTION_HASHES, selectionHashes: selectionHashes });
}
@@ -130567,24 +130598,28 @@ var Notifications = function (_React$Component) {
function Notifications(props) {
_classCallCheck(this, Notifications);
var _this = _possibleConstructorReturn(this, (Notifications.__proto__ || Object.getPrototypeOf(Notifications)).call(this, props));
_this.state = { serverMessage: ["info", "A props message"] };
return _this;
return _possibleConstructorReturn(this, (Notifications.__proto__ || Object.getPrototypeOf(Notifications)).call(this, props));
}
_createClass(Notifications, [{
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextprops) {
if (nextprops.serverMessage != this.state.serverMessage) {
(0, _reactToastify.toast)(this.state.serverMessage[1]);
if (nextprops.serverPushMessage != this.props.serverPushMessage) {
(0, _reactToastify.toast)(nextprops.serverPushMessage[1], {
type: nextprops.serverPushMessage[0]
});
console.log("Server Push Message", nextprops.serverPushMessage);
}
if (nextprops.webSocketState != this.props.webSocketState) {
if (nextprops.webSocketState == true) {
_reactToastify.toast.success("Websocket Connection Open!");
} else {
(0, _reactToastify.toast)("Websocket Connection Closed!", {
type: "error",
autoClose: false
});
}
}
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
(0, _reactToastify.toast)("Testing toast custom settings");
}
}, {
key: 'render',
@@ -130592,7 +130627,7 @@ var Notifications = function (_React$Component) {
return _react2.default.createElement(
'div',
null,
_react2.default.createElement(_reactToastify.ToastContainer, { type: this.state.serverMessage[0], position: _reactToastify.toast.POSITION.TOP_RIGHT, autoClose: 8000 })
_react2.default.createElement(_reactToastify.ToastContainer, { position: _reactToastify.toast.POSITION.TOP_RIGHT, autoClose: 8000 })
);
}
}]);
@@ -130602,7 +130637,8 @@ var Notifications = function (_React$Component) {
var mapStateToProps = function mapStateToProps(state) {
return {
//serverMessage: state.serverMessage,
serverPushMessage: state.serverPushMessage,
webSocketState: state.webSocketState
};
};