working on pulling settings from file using viper, finished basic RSS feed and cron job

This commit is contained in:
2018-01-10 20:07:00 -05:00
parent 08b3a14576
commit f079a5f067
18 changed files with 30486 additions and 28934 deletions

View File

@@ -14,6 +14,7 @@ let torrents= [];
let peerList = [];
let fileList = [];
let RSSList = [];
let RSSTorrentList = [];
var torrentListRequest = {
messageType: "torrentListRequest"
@@ -100,14 +101,25 @@ ws.onmessage = function (evt) { //When we recieve a message from the websocket
RSSList = [];
for (var i = 0; i < serverMessage.TotalRSSFeeds; i++){
RSSList.push({
RSSURL: serverMessage.RSSFeeds[i]
RSSURL: serverMessage.RSSFeeds[i].RSSFeedURL,
RSSName: serverMessage.RSSFeeds[i].RSSName,
})
}
console.log("RSSURLS", RSSList)
console.log("FIRSTURL", RSSList[0])
console.log("FULLURL", RSSList[0].RSSURL)
console.log("FIRSTURL", RSSList[1])
console.log("FULLURL", RSSList[1].RSSURL)
break;
case "rssTorrentList":
//console.log("RSSTorrentList recieved", evt.data)
RSSTorrentList = [];
for (var i = 0; i < serverMessage.TotalTorrents; i++){
RSSTorrentList.push({
TorrentName: serverMessage.Torrents[i].Title,
TorrentLink: serverMessage.Torrents[i].Link,
PublishDate: serverMessage.Torrents[i].PubDate,
})
}
}
}
@@ -175,15 +187,23 @@ class BackendSocket extends React.Component {
this.timerID = setInterval(
() => this.tick(),
2000
);
);
}
componentWillUnmount() {
clearInterval(this.timerID);
}
tick() { // this tick is the main tick that updates ALL of the components that update on tick... which is a lot
tick() { // this tick is the main tick that updates ALL of the components that update on tick... which is a lot
if (this.props.RSSList != RSSList & this.props.RSSModalOpen == true) {
this.props.newRSSFeedStore(RSSList) //pushing the new RSSList to Redux
}
if (this.props.RSSTorrentList != RSSTorrentList & this.props.RSSModalOpen == true){
this.props.RSSTorrentList(RSSTorrentList) //pushing the new RSSTorrentList to Redux
}
ws.send(JSON.stringify(torrentListRequest))//talking to the server to get the torrent list
//console.log("Torrentlist", torrents)
this.props.setButtonState(this.props.selection) //forcing an update to the buttons
@@ -218,7 +238,6 @@ class BackendSocket extends React.Component {
if (nextProps.selectionHashes.length === 1){ //if we have a selection pass it on for the tabs to verify
this.selectionHandler(nextProps.selectionHashes, nextProps.selectedTab)
}
}
@@ -241,6 +260,8 @@ const mapStateToProps = state => {
selectionHashes: state.selectionHashes,
selectedTab: state.selectedTab,
selection: state.selection,
RSSModalOpen: state.RSSModalOpen,
RSSTorrentList: state.RSSTorrentList,
};
}
@@ -254,6 +275,7 @@ const mapDispatchToProps = dispatch => {
newFileList: (fileList) => dispatch({type: actionTypes.FILE_LIST, fileList}),
setButtonState: (buttonState) => dispatch({type: actionTypes.SET_BUTTON_STATE, buttonState}),
newRSSFeedStore: (RSSList) => dispatch({type: actionTypes.NEW_RSS_FEED_STORE, RSSList}),
RSSTorrentList: (RSSTorrentList) => dispatch({type: actionTypes.RSS_TORRENT_LIST, RSSTorrentList}),
//changeSelection: (selection) => dispatch({type: actionTypes.CHANGE_SELECTION, selection}),//forcing an update to the buttons
}

View File

@@ -56,13 +56,16 @@ const inlineStyle = {
open: false,
};
componentWillMount () {
componentDidMount () {
let RSSRequest = {
messageType: "rssFeedRequest",
}
ws.send(JSON.stringify(RSSRequest)) //Immediatly request an update of the feed when you add a new URL
ws.send(JSON.stringify(RSSRequest)) //Immediatly request an update of the feed when you add a new URL
}
handleClickOpen = () => {
this.setState({ open: true });
}
@@ -104,7 +107,7 @@ const inlineStyle = {
<ReactTooltip place="top" type="light" effect="float" />
<RSSTorrentIcon />
</IconButton>
<Dialog fullWidth open={this.state.open} onRequestClose={this.handleRequestClose}>
<Dialog fullScreen open={this.state.open} onRequestClose={this.handleRequestClose}>
<DialogTitle>Manage RSS Feeds</DialogTitle>
<DialogContent>
<TextField
@@ -115,13 +118,13 @@ const inlineStyle = {
label="Add New RSS URL"
type="text"
placeholder="Enter RSS URL Here.."
//onChange={this.setTextValue}
onChange={this.setTextValue}
/>
<IconButton onClick={this.handleAddRSSFeed} color="primary" data-tip="Manage RSS Feeds" style={smallButton} aria-label="Add RSS Feeds">
<ReactTooltip place="top" type="light" effect="float" />
<AddRSSIcon />
</IconButton>
{this.state.open === true &&
{this.state.open === true && //if the modal is open mount the list of torrents
<RSSModalList />
}
</DialogContent>

View File

@@ -22,7 +22,8 @@ import Icon from 'material-ui/Icon';
import IconButton from 'material-ui/IconButton';
import RSSTorrentIcon from 'material-ui-icons/RssFeed';
import AddRSSIcon from 'material-ui-icons/AddCircle';
import DeleteIcon from 'material-ui-icons/Delete';
import RSSTorrentList from './addRSSTorrentList';
//Redux
import {connect} from 'react-redux';
@@ -54,34 +55,77 @@ const inlineStyle = {
state = {
testRSSFeeds: [],
showList: false,
selectedIndex: 0,
};
componentWillMount () {
console.log("SECONDARY MOUNT", this.props.RSSFeed)
componentDidMount () {
console.log("SECONDARY MOUNT", this.props.RSSList)
this.props.RSSModalOpen(true)
}
componentWillUnmount () {
this.props.RSSModalOpen(false)
}
showRSSFiles = (key) => {
let RSSTorrentsRequest = {
messageType: "rssTorrentsRequest",
Payload: [this.props.RSSList[key].RSSURL]
}
ws.send(JSON.stringify(RSSTorrentsRequest))
this.setState({selectedIndex: key}) //setting our selected index for styling
console.log("RSSFEED", key, "sending message", JSON.stringify(RSSTorrentsRequest))
showRSSFiles = (RSSFeed) => {
console.log("RSSFEED", RSSFeed)
}
//{this.props.RSSList.map(function(RSSFeed, i){ return (
// <ListItem key={i}><ListItemText primary="FEED" /></ListItem>
// )})}
getStyle = (index) => {
console.log("SettingStye", selectedIndex, index)
if (selectedIndex == index){
console.log("Returning activestyle")
style = "{{backgroundColor: '#80b3ff'}}"
return style
}
style = "{{backgroundColor: '#f44295'}}"
return style
}
deleteRSSFeed = (key) => {
let RSSURLDelete = {
messageType: "deleteRSSFeed",
Payload: [this.props.RSSList[key]]
}
console.log("Deleting THIS", this.props.RSSList[key])
//ws.send(JSON.stringify(RSSURLDelete));
}
render() {
const { classes, onRequestClose, handleRequestClose, handleSubmit } = this.props;
//const { classes, onRequestClose, handleRequestClose, handleSubmit } = this.props;
if (this.props.RSSList.length > 0 && this.state.showList == false){
console.log("Setting list to show....")
this.setState({showList: true})
}
return (
<div style={inlineStyle}>
<List dense>
<ListItem button={true} onClick={ () => this.showRSSFiles('RSSFEEDTEST')}>
<ListItemIcon >
<AddRSSIcon />
</ListItemIcon>
<ListItemText primary={this.props.RSSList[0].RSSURL} />
</ListItem>
</List>
{this.state.showList == true && //if we have any rss torrent feeds then display them in list }
<List dense>
{this.props.RSSList.map((RSSFeed, index) => {
return (
<ListItem button={true} onClick={() => this.showRSSFiles(index)} key={index}>
<ListItemText primary={RSSFeed.RSSName} />
<ListItemSecondaryAction>
<IconButton key={index} onClick={() => this.deleteRSSFeed(index)} aria-label="Delete">
<DeleteIcon />
</IconButton>
</ListItemSecondaryAction>
</ListItem>
)})}
</List>
}
<RSSTorrentList />
</div>
);
}
@@ -94,5 +138,9 @@ const mapStateToProps = state => {
};
}
export default connect(mapStateToProps)(RSSModalList)
const mapDispatchToProps = dispatch => {
return {
RSSModalOpen: (RSSModalOpen) => dispatch({type: actionTypes.RSS_MODAL_OPEN, RSSModalOpen}), //sending modal state to backendwebsocket so we can update RSS lists
}
}
export default connect(mapStateToProps, mapDispatchToProps)(RSSModalList)

View File

@@ -0,0 +1,126 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Button from 'material-ui/Button';
import {
SortingState, LocalSorting, VirtualTableLayout, SelectionState,
} from '@devexpress/dx-react-grid';
import {
Grid, TableHeaderRow, PagingPanel, VirtualTableView, TableColumnResizing,
DragDropContext, TableColumnReordering, TableSelection,
} from '@devexpress/dx-react-grid-material-ui';
import {connect} from 'react-redux';
import * as actionTypes from '../../store/actions';
const tableStyle = {
}
class RSSTorrentList extends React.Component {
constructor(props) {
super(props);
this.state = { //rows are stored in redux they are sent over from the server
columns: [
{ name: 'TorrentName', title: 'Title'},
{ name: 'TorrentLink', title: 'Magnet Link' },
{ name: 'PublishDate', title: 'Date Published'},
],
sorting: [],
columnOrder: ['TorrentName', 'TorrentLink', 'PublishDate'],
columnWidths: {TorrentName: 450, TorrentLink: 650, PublishDate: 200},
fileSelection: [],
selected: [],
};
this.changeColumnOrder = columnOrder => this.setState({columnOrder});
this.changeColumnWidths = columnWidths => this.setState({columnWidths});
this.changeSorting = sorting => this.setState({sorting});
}
changeSelection = (selection) => {
console.log("TorrentList is changing selection now", selection)
this.setState({selected: selection})
if (selection.length > 0) { //if selection is empty buttons will be default and selectionHashes will be blanked out and pushed to redux
console.log("Getting the selected Rows")
const selectedRows = [] //array of all the selected Rows
selection.forEach(element => {
selectedRows.push(this.props.RSSTorrentList[element]) //pushing the selected rows out of torrentlist
});
this.setState({fileSelection: selectedRows})
}
}
sendMagnetLinks = (priority, sendfileNames) => {
this.state.fileSelection.forEach(element => {
console.log("element", element)
sendFileNames.push(element.FilePath)
})
let setFilePriority = {
MessageType: "setFilePriority",
Payload: sendFileNames,
}
console.log(JSON.stringify(setFilePriority))
ws.send(JSON.stringify(setFilePriority))
}
componentWillReceiveProps () {
console.log("New torrentlist", this.props.RSSTorrentList)
}
render() {
return (
//Buttons here
<div>
<Button raised color="primary" onClick={this.setHighPriority}>
Download Torrents
</Button>
<Grid rows={this.props.RSSTorrentList} columns={this.state.columns}>
<SortingState sorting={this.state.sorting} onSortingChange={this.changeSorting} />
<LocalSorting />
<DragDropContext />
<SelectionState onSelectionChange={this.changeSelection} selection={this.state.selection}/>
<VirtualTableView height={300} />
<TableColumnResizing columnWidths={this.state.columnWidths} onColumnWidthsChange={this.changeColumnWidths}/>
<TableColumnReordering order={this.state.columnOrder} onOrderChange={this.changeColumnOrder} />
<TableSelection selectByRowClick highlightSelected />
<TableHeaderRow allowSorting allowResizing allowDragging />
</Grid>
</div>
);
}
}
const mapStateToProps = state => {
return {
selectionHashes: state.selectionHashes,
RSSTorrentList: state.RSSTorrentList,
//fileSelectionNames: state.fileSelectionNames,
};
}
const mapDispatchToProps = dispatch => {
return {
//changeFileSelection: (fileSelection) => dispatch({type: actionTypes.CHANGE_FILE_SELECTION, fileSelection}),
//sendSelectionHashes: (selectionHashes) => dispatch({type: actionTypes.SELECTION_HASHES, selectionHashes}),
}
}
export default connect(mapStateToProps, mapDispatchToProps)(RSSTorrentList)

View File

@@ -8,4 +8,6 @@ export const SELECTED_TAB = 'SELECTED_TAB';
export const PEER_LIST = 'PEER_LIST';
export const FILE_LIST = 'FILE_LIST';
export const CHANGE_FILE_SELECTION = 'CHANGE_FILE_SELECTION';
export const NEW_RSS_FEED_STORE = 'NEW_RSS_FEED_STORE';
export const NEW_RSS_FEED_STORE = 'NEW_RSS_FEED_STORE';
export const RSS_MODAL_OPEN = 'RSS_MODAL_OPEN';
export const RSS_TORRENT_LIST = 'RSS_TORRENT_LIST';

View File

@@ -16,6 +16,8 @@ const initialState = {
torrentDetailInfo: [],
selectedTab: 0,
RSSList: [],
RSSTorrentList: [],
RSSModalOpen: false,
}
@@ -40,6 +42,13 @@ const reducer = (state = initialState, action) => {
...state,
RSSList: action.RSSList,
}
case actionTypes.RSS_TORRENT_LIST:
console.log("New RSS Torrent List IN REDUCER", action.RSSTorrentList)
return {
...state,
RSSTorrentList: action.RSSTorrentList,
}
case actionTypes.SELECTION_HASHES:
console.log("Selection hashes REDUX", action.selectionHashes)
@@ -81,6 +90,12 @@ const reducer = (state = initialState, action) => {
...state,
selectedTab: action.selectedTab
}
case actionTypes.RSS_MODAL_OPEN:
return {
...state,
RSSModalOpen: action.RSSModalOpen
}
case actionTypes.SET_BUTTON_STATE:
if (action.buttonState.length === 0) { //if selection is empty buttons will be default and selectionHashes will be blanked out and pushed to redux