started adding the logic for RSS feeds, started storing metainfo and torrent files in database directly
This commit is contained in:
		@@ -13,6 +13,7 @@ var title = document.title; //Set the number of active torrents in the title
 | 
			
		||||
let torrents= []; 
 | 
			
		||||
let peerList = [];
 | 
			
		||||
let fileList = [];
 | 
			
		||||
let RSSList = [];
 | 
			
		||||
 | 
			
		||||
var torrentListRequest = {
 | 
			
		||||
    messageType: "torrentListRequest"
 | 
			
		||||
@@ -24,7 +25,7 @@ var torrentListRequest = {
 | 
			
		||||
//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)
 | 
			
		||||
    console.log("message", serverMessage.MessageType)
 | 
			
		||||
    //console.log("message", serverMessage.MessageType)
 | 
			
		||||
    switch (serverMessage.MessageType) {
 | 
			
		||||
 | 
			
		||||
        case "torrentList":
 | 
			
		||||
@@ -50,6 +51,8 @@ ws.onmessage = function (evt) { //When we recieve a message from the websocket
 | 
			
		||||
                    ETA: serverMessage.data[i].ETA,
 | 
			
		||||
                    TotalUploadedSize: serverMessage.data[i].TotalUploadedSize,
 | 
			
		||||
                    Ratio: serverMessage.data[i].UploadRatio,
 | 
			
		||||
                    FileNumber: serverMessage.data[i].NumberofFiles,
 | 
			
		||||
                    PieceNumber: serverMessage.data[i].NumberofPieces,
 | 
			
		||||
                })    
 | 
			
		||||
            } 
 | 
			
		||||
            var newTitle = '(' + serverMessage.total + ')' + title; //updating the title
 | 
			
		||||
@@ -57,7 +60,6 @@ ws.onmessage = function (evt) { //When we recieve a message from the websocket
 | 
			
		||||
            break;
 | 
			
		||||
        
 | 
			
		||||
        case "torrentPeerList":
 | 
			
		||||
            console.log("Full EVENT", evt.data)
 | 
			
		||||
            peerList = []; //clearing out the peerlist array to make room for new (so that it does keep adding)
 | 
			
		||||
            
 | 
			
		||||
            for(var i = 0; i < serverMessage.TotalPeers; i++){
 | 
			
		||||
@@ -69,11 +71,9 @@ ws.onmessage = function (evt) { //When we recieve a message from the websocket
 | 
			
		||||
                    SupportsEncryption: serverMessage.PeerList[i].SupportsEncryption.toString(),
 | 
			
		||||
                })
 | 
			
		||||
            }
 | 
			
		||||
            console.log("Peerlist", peerList)
 | 
			
		||||
            break    
 | 
			
		||||
 | 
			
		||||
        case "torrentFileList":
 | 
			
		||||
            console.log("Recieved FileListUpdate", evt.data)
 | 
			
		||||
            fileList = [];
 | 
			
		||||
            for (var i = 0; i < serverMessage.TotalFiles; i++){
 | 
			
		||||
                fileList.push({
 | 
			
		||||
@@ -94,6 +94,20 @@ ws.onmessage = function (evt) { //When we recieve a message from the websocket
 | 
			
		||||
        case "loggerData":
 | 
			
		||||
            console.log("Logger data requested")
 | 
			
		||||
            break;
 | 
			
		||||
    
 | 
			
		||||
        case "rssListRequest":
 | 
			
		||||
            console.log("RSSListRequest recieved", evt.data)
 | 
			
		||||
            RSSList = [];
 | 
			
		||||
            for (var i = 0; i < serverMessage.TotalRSSFeeds; i++){
 | 
			
		||||
                RSSList.push({
 | 
			
		||||
                    RSSURL: serverMessage.RSSFeeds[i]
 | 
			
		||||
                })
 | 
			
		||||
            }
 | 
			
		||||
            console.log("RSSURLS", RSSList)
 | 
			
		||||
            console.log("FIRSTURL", RSSList[0])
 | 
			
		||||
            console.log("FULLURL", RSSList[0].RSSURL)
 | 
			
		||||
            break;
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
                                    
 | 
			
		||||
}
 | 
			
		||||
@@ -157,15 +171,12 @@ class BackendSocket extends React.Component {
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    componentDidMount() {
 | 
			
		||||
        this.timerID = setInterval(
 | 
			
		||||
          () => this.tick(),
 | 
			
		||||
          2000
 | 
			
		||||
        );    
 | 
			
		||||
 
 | 
			
		||||
      
 | 
			
		||||
    } 
 | 
			
		||||
 | 
			
		||||
    componentWillUnmount() {
 | 
			
		||||
@@ -174,7 +185,8 @@ class BackendSocket extends React.Component {
 | 
			
		||||
 | 
			
		||||
    tick() { // this tick is the main tick that updates ALL of the components that update on tick... which is a lot
 | 
			
		||||
        ws.send(JSON.stringify(torrentListRequest))//talking to the server to get the torrent list
 | 
			
		||||
        console.log("Torrentlist", torrents)
 | 
			
		||||
        //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 
 | 
			
		||||
        if (this.props.selectionHashes.length === 1){
 | 
			
		||||
            switch(this.props.selectedTab){
 | 
			
		||||
@@ -191,7 +203,6 @@ class BackendSocket extends React.Component {
 | 
			
		||||
                        MessageType: "torrentFileListRequest",
 | 
			
		||||
                        Payload: this.props.selectionHashes,
 | 
			
		||||
                    }
 | 
			
		||||
                    console.log("Files tab information requested", fileList)
 | 
			
		||||
                    ws.send(JSON.stringify(fileListHashes))
 | 
			
		||||
                    this.props.newFileList(fileList)
 | 
			
		||||
                    break;
 | 
			
		||||
@@ -229,6 +240,7 @@ const mapStateToProps = state => {
 | 
			
		||||
    return {
 | 
			
		||||
        selectionHashes: state.selectionHashes,
 | 
			
		||||
        selectedTab: state.selectedTab,
 | 
			
		||||
        selection: state.selection,
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -240,6 +252,10 @@ const mapDispatchToProps = dispatch => {
 | 
			
		||||
        newTorrentList: (torrentList) => dispatch({type: actionTypes.TORRENT_LIST, torrentList }),
 | 
			
		||||
        newPeerList: (peerList) => dispatch({type: actionTypes.PEER_LIST, peerList}),
 | 
			
		||||
        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}),
 | 
			
		||||
        //changeSelection: (selection) => dispatch({type: actionTypes.CHANGE_SELECTION, selection}),//forcing an update to the buttons
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,17 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import ReactDOM from 'react-dom';
 | 
			
		||||
import Button from 'material-ui/Button';
 | 
			
		||||
 | 
			
		||||
import { ProgressBarCell } from '../../CustomCells/progressBarCell';
 | 
			
		||||
 | 
			
		||||
import {BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table';
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
    SortingState, LocalSorting, VirtualTableLayout, SelectionState,
 | 
			
		||||
} from '@devexpress/dx-react-grid';
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
    Grid, TableView, TableHeaderRow, PagingPanel, VirtualTableView, TableColumnResizing,
 | 
			
		||||
    DragDropContext, TableColumnReordering,
 | 
			
		||||
    Grid, TableHeaderRow, PagingPanel, VirtualTableView, TableColumnResizing,
 | 
			
		||||
    DragDropContext, TableColumnReordering, TableSelection,
 | 
			
		||||
} from '@devexpress/dx-react-grid-material-ui';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -17,6 +19,7 @@ import {connect} from 'react-redux';
 | 
			
		||||
import * as actionTypes from '../../store/actions';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class FileTab extends React.Component {
 | 
			
		||||
    
 | 
			
		||||
    constructor(props) {
 | 
			
		||||
@@ -26,31 +29,108 @@ class FileTab extends React.Component {
 | 
			
		||||
                { name: 'FileName', title: 'File Name'},
 | 
			
		||||
                { name: 'FilePath', title: 'File Path' },
 | 
			
		||||
                { name: 'FileSize', title: 'File Size'},
 | 
			
		||||
                //{ name: 'Country', title: 'Country of Origin'}, //TODO map IP to country
 | 
			
		||||
                { name: 'FilePercent', title: 'File Percent'},
 | 
			
		||||
                { name: 'FilePriority', title: 'File Priority'}, //T=Tracker, I=Incoming, Hg=DHTGetPeers, Ha=DHTAnnouncePeer, X=PEX
 | 
			
		||||
                { name: 'FilePriority', title: 'File Priority'}, 
 | 
			
		||||
            ],
 | 
			
		||||
            sorting: [],
 | 
			
		||||
            columnOrder: ['FileName', 'FilePath', 'FileSize', 'FilePercent', 'FilePriority'],
 | 
			
		||||
            columnWidths: {FileName: 250, FilePath: 450, FileSize: 100, FilePercent: 100, FilePriority: 75},
 | 
			
		||||
        };
 | 
			
		||||
            columnWidths: {FileName: 450, FilePath: 650, FileSize: 100, FilePercent: 100, FilePriority: 75},
 | 
			
		||||
            fileSelection: [],
 | 
			
		||||
            selected: [],
 | 
			
		||||
 
 | 
			
		||||
            
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        this.changeColumnOrder = columnOrder => this.setState({columnOrder});
 | 
			
		||||
        this.changeColumnWidths = columnWidths => this.setState({columnWidths});
 | 
			
		||||
        this.changeSorting = sorting => this.setState({sorting});
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    changeSelection = (selection) => {
 | 
			
		||||
        console.log("Filelist 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.fileList[element])   //pushing the selected rows out of torrentlist
 | 
			
		||||
            });
 | 
			
		||||
           this.setState({fileSelection: selectedRows})
 | 
			
		||||
        }
 | 
			
		||||
       
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    sendPriorityRequest = (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))
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    setHighPriority = () => {
 | 
			
		||||
        let priorty = "High"
 | 
			
		||||
        let selectionHash = this.props.selectionHashes[0] //getting the first element (should be the only one)
 | 
			
		||||
        let sendFileNames = [selectionHash, "High"]// adding the selection hash as the first element will be stripped out by the server, second element is the prioty request
 | 
			
		||||
    }
 | 
			
		||||
    setNormalPriority = () => {
 | 
			
		||||
        let priorty = "Normal"
 | 
			
		||||
        let selectionHash = this.props.selectionHashes[0] //getting the first element (should be the only one)
 | 
			
		||||
        let sendFileNames = [selectionHash, "Normal"]// adding the selection hash as the first element will be stripped out by the server, second element is the prioty request
 | 
			
		||||
    }
 | 
			
		||||
    setCancelPriority = () => {
 | 
			
		||||
        let priorty = "Cancel"
 | 
			
		||||
        let selectionHash = this.props.selectionHashes[0] //getting the first element (should be the only one)
 | 
			
		||||
        let sendFileNames = [selectionHash, "Cancel"]// adding the selection hash as the first element will be stripped out by the server, second element is the prioty request
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    render() {
 | 
			
		||||
        return (   
 | 
			
		||||
            <Grid rows={this.props.fileList} columns={this.state.columns}>
 | 
			
		||||
                <SortingState sorting={this.state.sorting} onSortingChange={this.changeSorting} />
 | 
			
		||||
                <LocalSorting />
 | 
			
		||||
                <DragDropContext />
 | 
			
		||||
                <TableView />
 | 
			
		||||
                <TableColumnResizing columnWidths={this.state.columnWidths} onColumnWidthsChange={this.changeColumnWidths}/>
 | 
			
		||||
                <TableColumnReordering order={this.state.columnOrder} onOrderChange={this.changeColumnOrder} />
 | 
			
		||||
                <TableHeaderRow allowSorting allowResizing allowDragging />
 | 
			
		||||
            </Grid>
 | 
			
		||||
        return (  
 | 
			
		||||
            //Buttons here 
 | 
			
		||||
            <div>
 | 
			
		||||
                Set File Priority: 
 | 
			
		||||
                <Button raised color="primary" onClick={this.setHighPriority}>
 | 
			
		||||
                    High
 | 
			
		||||
                </Button>
 | 
			
		||||
                <Button raised color="primary" onClick={this.setNormalPriority}>
 | 
			
		||||
                    Normal
 | 
			
		||||
                </Button>
 | 
			
		||||
                <Button raised color="accent" onClick={this.setCancelPriority}>
 | 
			
		||||
                    Do Not Download
 | 
			
		||||
                </Button>
 | 
			
		||||
                <Grid rows={this.props.fileList} 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} tableCellTemplate={({ row, column, style }) => {
 | 
			
		||||
                    if (column.name === 'FilePercent') {
 | 
			
		||||
                        return (
 | 
			
		||||
                            <ProgressBarCell value={row.FilePercent * 100} style={style} />
 | 
			
		||||
                        );
 | 
			
		||||
                        }
 | 
			
		||||
                        return undefined;
 | 
			
		||||
                    }}/>/>
 | 
			
		||||
    
 | 
			
		||||
                    <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>
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -63,7 +143,17 @@ const mapStateToProps = state => {
 | 
			
		||||
    return {
 | 
			
		||||
        selectionHashes: state.selectionHashes,
 | 
			
		||||
        fileList: state.fileList,
 | 
			
		||||
        //fileSelectionNames: state.fileSelectionNames,
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
export default connect(mapStateToProps)(FileTab)
 | 
			
		||||
  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)(FileTab)
 | 
			
		||||
@@ -45,7 +45,7 @@ class GeneralTab extends React.Component {
 | 
			
		||||
                }
 | 
			
		||||
            })
 | 
			
		||||
            //selectedTorrentTemp = this.props.torrentList.filter(torrent => torrent.TorrentHashString === this.props.selectionHashes)
 | 
			
		||||
            console.log("SelectedTorrentTemp", selectedTorrentTemp)
 | 
			
		||||
            //console.log("SelectedTorrentTemp", selectedTorrentTemp)
 | 
			
		||||
            this.setState({ selectedTorrent: selectedTorrentTemp });    
 | 
			
		||||
        } else {
 | 
			
		||||
            this.setState({ selectedTorrent: [] })
 | 
			
		||||
@@ -78,8 +78,8 @@ class GeneralTab extends React.Component {
 | 
			
		||||
                    
 | 
			
		||||
                </Grid>
 | 
			
		||||
                <Grid item xs={12} sm={4}>
 | 
			
		||||
                    <Paper className={classes.paper}>Status: <span className={classes.floatRight}>{this.state.selectedTorrent["Status"]} </span> </Paper>
 | 
			
		||||
                    <Paper className={classes.paper}>Torrent DL Amount: {this.state.selectedTorrent["DownloadedSize"]} </Paper>
 | 
			
		||||
                    <Paper className={classes.paper}>Number of Files: <span className={classes.floatRight}>{this.state.selectedTorrent["FileNumber"]} </span> </Paper>
 | 
			
		||||
                    <Paper className={classes.paper}>Number of Pieces: <span className={classes.floatRight}>{this.state.selectedTorrent["PieceNumber"]} </span> </Paper>
 | 
			
		||||
                
 | 
			
		||||
                
 | 
			
		||||
                
 | 
			
		||||
 
 | 
			
		||||
@@ -46,7 +46,7 @@ class PeerTab extends React.Component {
 | 
			
		||||
                <SortingState sorting={this.state.sorting} onSortingChange={this.changeSorting} />
 | 
			
		||||
                <LocalSorting />
 | 
			
		||||
                <DragDropContext />
 | 
			
		||||
                <TableView />
 | 
			
		||||
                <VirtualTableView height={350}/>
 | 
			
		||||
                <TableColumnResizing columnWidths={this.state.columnWidths} onColumnWidthsChange={this.changeColumnWidths}/>
 | 
			
		||||
                <TableColumnReordering order={this.state.columnOrder} onOrderChange={this.changeColumnOrder} />
 | 
			
		||||
                <TableHeaderRow allowSorting allowResizing allowDragging />
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										152
									
								
								torrent-project/src/TopMenu/Modals/addRSSModal.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										152
									
								
								torrent-project/src/TopMenu/Modals/addRSSModal.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,152 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import ReactDOM from 'react-dom';
 | 
			
		||||
import Button from 'material-ui/Button';
 | 
			
		||||
import TextField from 'material-ui/TextField';
 | 
			
		||||
import { withStyles } from 'material-ui/styles';
 | 
			
		||||
import PropTypes from 'prop-types';
 | 
			
		||||
import List, {
 | 
			
		||||
    ListItem,
 | 
			
		||||
    ListItemIcon,
 | 
			
		||||
    ListItemSecondaryAction,
 | 
			
		||||
    ListItemText,
 | 
			
		||||
  } from 'material-ui/List';
 | 
			
		||||
import Dialog, {
 | 
			
		||||
  DialogActions,
 | 
			
		||||
  DialogContent,
 | 
			
		||||
  DialogContentText,
 | 
			
		||||
  DialogTitle,
 | 
			
		||||
} from 'material-ui/Dialog';
 | 
			
		||||
import InsertLinkIcon from 'material-ui-icons/Link';
 | 
			
		||||
import ReactTooltip from 'react-tooltip'
 | 
			
		||||
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 RSSModalList from './addRSSModalList';
 | 
			
		||||
 | 
			
		||||
//Redux
 | 
			
		||||
import {connect} from 'react-redux';
 | 
			
		||||
import * as actionTypes from '../../store/actions';
 | 
			
		||||
 | 
			
		||||
const button = {
 | 
			
		||||
  fontSize: '60px',
 | 
			
		||||
  paddingRight: '20px',
 | 
			
		||||
  paddingLeft: '20px',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const smallButton = {
 | 
			
		||||
    width: '36px',
 | 
			
		||||
    height: '36px',
 | 
			
		||||
    padding: '5px',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const rssInput = {
 | 
			
		||||
    width: '90%',
 | 
			
		||||
    paddingRight: '10px',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const inlineStyle = {
 | 
			
		||||
  display: 'inline-block',
 | 
			
		||||
  backdrop: 'static',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 class AddRSSModal extends React.Component {
 | 
			
		||||
 | 
			
		||||
  state = {
 | 
			
		||||
    open: false,
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  componentWillMount () {
 | 
			
		||||
    let RSSRequest = {
 | 
			
		||||
      messageType: "rssFeedRequest",
 | 
			
		||||
    }
 | 
			
		||||
    ws.send(JSON.stringify(RSSRequest)) //Immediatly request an update of the feed when you add a new URL
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  handleClickOpen = () => {
 | 
			
		||||
    this.setState({ open: true });
 | 
			
		||||
  }
 | 
			
		||||
  handleRequestClose = () => {
 | 
			
		||||
    this.setState({ open: false });
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  handleSubmit = () => {
 | 
			
		||||
    this.setState({ open: false });
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  handleAddRSSFeed = () => {
 | 
			
		||||
    this.setState({ textValue: "Clear"}) //clearing out the text submitted
 | 
			
		||||
    let RSSURLSubmit = {
 | 
			
		||||
      messageType: "addRSSFeed",
 | 
			
		||||
      Payload: [this.state.textValue]
 | 
			
		||||
    }
 | 
			
		||||
    ws.send(JSON.stringify(RSSURLSubmit));
 | 
			
		||||
    let RSSRequest = {
 | 
			
		||||
      messageType: "rssFeedRequest",
 | 
			
		||||
    }
 | 
			
		||||
    ws.send(JSON.stringify(RSSRequest)) //Immediatly request an update of the feed when you add a new URL
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  setTextValue = (event) => {
 | 
			
		||||
    this.setState({ textValue: event.target.value });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //{this.props.RSSList.map(function(RSSFeed, i){ return (
 | 
			
		||||
  //  <ListItem key={i}><ListItemText primary="FEED" /></ListItem>
 | 
			
		||||
  //  )})}
 | 
			
		||||
 | 
			
		||||
  render() {
 | 
			
		||||
    const { classes, onRequestClose, handleRequestClose, handleSubmit } = this.props;
 | 
			
		||||
    return (
 | 
			
		||||
      <div style={inlineStyle}>
 | 
			
		||||
        <IconButton onClick={this.handleClickOpen} color="primary" data-tip="Add RSS URL" style={button} aria-label="RSS Feeds">
 | 
			
		||||
          <ReactTooltip place="top" type="light" effect="float" />
 | 
			
		||||
          <RSSTorrentIcon />
 | 
			
		||||
        </IconButton>
 | 
			
		||||
        <Dialog fullWidth open={this.state.open} onRequestClose={this.handleRequestClose}>
 | 
			
		||||
          <DialogTitle>Manage RSS Feeds</DialogTitle>
 | 
			
		||||
          <DialogContent>
 | 
			
		||||
            <TextField
 | 
			
		||||
              style={rssInput}
 | 
			
		||||
              autoFocus
 | 
			
		||||
              margin="dense"
 | 
			
		||||
              id="name"
 | 
			
		||||
              label="Add New RSS URL"
 | 
			
		||||
              type="text"
 | 
			
		||||
              placeholder="Enter RSS URL Here.."
 | 
			
		||||
              //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 &&
 | 
			
		||||
              <RSSModalList />
 | 
			
		||||
            }
 | 
			
		||||
          </DialogContent>
 | 
			
		||||
          <DialogActions>
 | 
			
		||||
            <Button onClick={this.handleRequestClose} color="primary">
 | 
			
		||||
              Close
 | 
			
		||||
            </Button>
 | 
			
		||||
          </DialogActions>
 | 
			
		||||
        </Dialog>
 | 
			
		||||
      </div>
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const mapStateToProps = state => {
 | 
			
		||||
  return {
 | 
			
		||||
    RSSList: state.RSSList,
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const mapDispatchToProps = dispatch => {
 | 
			
		||||
  return {
 | 
			
		||||
      newRSSFeedStore: (RSSList) => dispatch({type: actionTypes.NEW_RSS_FEED_STORE, RSSList}),
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default connect(mapStateToProps, mapDispatchToProps)(AddRSSModal)
 | 
			
		||||
							
								
								
									
										98
									
								
								torrent-project/src/TopMenu/Modals/addRSSModalList.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								torrent-project/src/TopMenu/Modals/addRSSModalList.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,98 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import ReactDOM from 'react-dom';
 | 
			
		||||
import Button from 'material-ui/Button';
 | 
			
		||||
import TextField from 'material-ui/TextField';
 | 
			
		||||
import { withStyles } from 'material-ui/styles';
 | 
			
		||||
import PropTypes from 'prop-types';
 | 
			
		||||
import List, {
 | 
			
		||||
    ListItem,
 | 
			
		||||
    ListItemIcon,
 | 
			
		||||
    ListItemSecondaryAction,
 | 
			
		||||
    ListItemText,
 | 
			
		||||
  } from 'material-ui/List';
 | 
			
		||||
import Dialog, {
 | 
			
		||||
  DialogActions,
 | 
			
		||||
  DialogContent,
 | 
			
		||||
  DialogContentText,
 | 
			
		||||
  DialogTitle,
 | 
			
		||||
} from 'material-ui/Dialog';
 | 
			
		||||
import InsertLinkIcon from 'material-ui-icons/Link';
 | 
			
		||||
import ReactTooltip from 'react-tooltip'
 | 
			
		||||
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';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//Redux
 | 
			
		||||
import {connect} from 'react-redux';
 | 
			
		||||
import * as actionTypes from '../../store/actions';
 | 
			
		||||
 | 
			
		||||
const button = {
 | 
			
		||||
  fontSize: '60px',
 | 
			
		||||
  paddingRight: '20px',
 | 
			
		||||
  paddingLeft: '20px',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const smallButton = {
 | 
			
		||||
    width: '36px',
 | 
			
		||||
    height: '36px',
 | 
			
		||||
    padding: '5px',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const rssInput = {
 | 
			
		||||
    width: '90%',
 | 
			
		||||
    paddingRight: '10px',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const inlineStyle = {
 | 
			
		||||
  display: 'inline-block',
 | 
			
		||||
  backdrop: 'static',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 class RSSModalList extends React.Component {
 | 
			
		||||
 | 
			
		||||
  state = {
 | 
			
		||||
    testRSSFeeds: [],
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  componentWillMount () {
 | 
			
		||||
    console.log("SECONDARY MOUNT", this.props.RSSFeed)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  showRSSFiles = (RSSFeed) => {
 | 
			
		||||
    console.log("RSSFEED", RSSFeed)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //{this.props.RSSList.map(function(RSSFeed, i){ return (
 | 
			
		||||
  //  <ListItem key={i}><ListItemText primary="FEED" /></ListItem>
 | 
			
		||||
  //  )})}
 | 
			
		||||
 | 
			
		||||
  render() {
 | 
			
		||||
    const { classes, onRequestClose, handleRequestClose, handleSubmit } = this.props;
 | 
			
		||||
    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>        
 | 
			
		||||
      </div>
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const mapStateToProps = state => {
 | 
			
		||||
  return {
 | 
			
		||||
    RSSList: state.RSSList,
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export default connect(mapStateToProps)(RSSModalList)
 | 
			
		||||
@@ -5,8 +5,9 @@ import { withStyles } from 'material-ui/styles';
 | 
			
		||||
import Icon from 'material-ui/Icon';
 | 
			
		||||
import IconButton from 'material-ui/IconButton';
 | 
			
		||||
 | 
			
		||||
import AddTorrentLinkPopup from './addTorrentLinkModal';
 | 
			
		||||
import AddTorrentFilePopup from './addTorrentFileModal';
 | 
			
		||||
import AddTorrentLinkPopup from './Modals/addTorrentLinkModal';
 | 
			
		||||
import AddTorrentFilePopup from './Modals/addTorrentFileModal';
 | 
			
		||||
import AddRSSModal from './Modals/addRSSModal';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import StartTorrentIcon from 'material-ui-icons/PlayArrow';
 | 
			
		||||
@@ -22,12 +23,12 @@ import ReactTooltip from 'react-tooltip'
 | 
			
		||||
import DeleteIcon from 'material-ui-icons/Delete';
 | 
			
		||||
import AddShoppingCartIcon from 'material-ui-icons/AddShoppingCart';
 | 
			
		||||
 | 
			
		||||
import BackendSocket from './BackendComm/backendWebsocket';
 | 
			
		||||
import BackendSocket from '../BackendComm/backendWebsocket';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//Redux
 | 
			
		||||
import {connect} from 'react-redux';
 | 
			
		||||
import * as actionTypes from './store/actions'
 | 
			
		||||
import * as actionTypes from '../store/actions'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const styles = theme => ({
 | 
			
		||||
@@ -68,7 +69,6 @@ class IconButtons extends React.Component {
 | 
			
		||||
    
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  startTorrent = () => {
 | 
			
		||||
    console.log("Starting Torrents", this.props.selectionHashes)
 | 
			
		||||
    let startTorrentHashes = {
 | 
			
		||||
@@ -77,6 +77,7 @@ class IconButtons extends React.Component {
 | 
			
		||||
    }
 | 
			
		||||
    //console.log("Peers tab information requested", peerListHashes)
 | 
			
		||||
    ws.send(JSON.stringify(startTorrentHashes))
 | 
			
		||||
    this.props.setButtonState(this.props.selection) //TODO this currently just forces a button refresh, should be a better way to do this
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
  stopTorrent = () => {
 | 
			
		||||
@@ -86,6 +87,7 @@ class IconButtons extends React.Component {
 | 
			
		||||
    }
 | 
			
		||||
    console.log("Stopping Torrents", stopTorrentHashes)
 | 
			
		||||
    ws.send(JSON.stringify(stopTorrentHashes))
 | 
			
		||||
    this.props.setButtonState(this.props.selection) //TODO this currently just forces a button refresh, should be a better way to do this
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  deleteTorrent = () => {
 | 
			
		||||
@@ -96,6 +98,7 @@ class IconButtons extends React.Component {
 | 
			
		||||
    }
 | 
			
		||||
    console.log("Deleting Torrents", deleteTorrentHashes)
 | 
			
		||||
    ws.send(JSON.stringify(deleteTorrentHashes))
 | 
			
		||||
    this.props.setButtonState(this.props.selection) //TODO this currently just forces a button refresh, should be a better way to do this
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -123,10 +126,7 @@ class IconButtons extends React.Component {
 | 
			
		||||
          <DeleteTorrentIcon />
 | 
			
		||||
        </IconButton>
 | 
			
		||||
        <div className={classes.verticalDivider}></div>
 | 
			
		||||
        <IconButton color="primary" data-tip="Manage RSS Feeds" className={classes.button} aria-label="RSS Feeds">
 | 
			
		||||
          <ReactTooltip place="top" type="light" effect="float" />
 | 
			
		||||
          <RSSTorrentIcon />
 | 
			
		||||
        </IconButton>
 | 
			
		||||
        <AddRSSModal />
 | 
			
		||||
        <IconButton color="primary" data-tip="Settings" className={classes.button} aria-label="Settings">
 | 
			
		||||
          <ReactTooltip place="top" type="light" effect="float" />
 | 
			
		||||
          <SettingsIcon />
 | 
			
		||||
@@ -153,7 +153,7 @@ const mapStateToProps = state => {
 | 
			
		||||
 | 
			
		||||
const mapDispatchToProps = dispatch => {
 | 
			
		||||
  return {
 | 
			
		||||
    //changeSelection: (selection) => dispatch({type: actionTypes.CHANGE_SELECTION, selection: selection})
 | 
			
		||||
      setButtonState: (buttonState) => dispatch({type: actionTypes.SET_BUTTON_STATE, buttonState}),
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -12,7 +12,7 @@ import {createStore} from 'redux';
 | 
			
		||||
import {Provider} from 'react-redux';
 | 
			
		||||
import reducer from './store/reducer';
 | 
			
		||||
//Menu and torrentlist imports
 | 
			
		||||
import TopMenu from './topMenu';
 | 
			
		||||
import TopMenu from './TopMenu/topMenu';
 | 
			
		||||
import BottomMenu from './BottomMenu/bottomMenu';
 | 
			
		||||
import LeftMenu from './leftMenu';
 | 
			
		||||
import TorrentList from './torrentlist';
 | 
			
		||||
@@ -47,10 +47,10 @@ class BasicLayout extends React.PureComponent {
 | 
			
		||||
    super(props);
 | 
			
		||||
 | 
			
		||||
    var layout =  [
 | 
			
		||||
      {i: 'a', x: 0, y: 0, w: 6, h: 1},
 | 
			
		||||
      {i: 'b', x: 0, y: 1, w: 1, h: 7},
 | 
			
		||||
      {i: 'c', x: 1, y: 1, w: 5, h: 3, minW: 5, minH: 3},
 | 
			
		||||
      {i: 'd', x: 1, y: 2, w: 5, h: 4, minW: 5, minH: 1}
 | 
			
		||||
      {i: 'a', x: 0, y: 0, w: 6, h: 1, static: true},
 | 
			
		||||
      {i: 'b', x: 0, y: 1, w: 1, h: 9, static: true},
 | 
			
		||||
      {i: 'c', x: 1, y: 1, w: 5, h: 5, minW: 5, minH: 3, static: true},
 | 
			
		||||
      {i: 'd', x: 1, y: 6, w: 5, h: 4, minW: 5, minH: 1, static: true}
 | 
			
		||||
    ];
 | 
			
		||||
    this.state = { layout };
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,4 +6,6 @@ export const SET_BUTTON_STATE = 'BUTTON_STATE';
 | 
			
		||||
export const SELECTION_HASHES = 'SELECTION_HASHES';
 | 
			
		||||
export const SELECTED_TAB = 'SELECTED_TAB';
 | 
			
		||||
export const PEER_LIST = 'PEER_LIST';
 | 
			
		||||
export const FILE_LIST = 'FILE_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';
 | 
			
		||||
@@ -15,8 +15,12 @@ const initialState = {
 | 
			
		||||
    fileList: [],
 | 
			
		||||
    torrentDetailInfo: [],
 | 
			
		||||
    selectedTab: 0,
 | 
			
		||||
    RSSList: [],
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const reducer = (state = initialState, action) => {
 | 
			
		||||
    switch(action.type){
 | 
			
		||||
 | 
			
		||||
@@ -25,10 +29,18 @@ const reducer = (state = initialState, action) => {
 | 
			
		||||
            return {
 | 
			
		||||
                ...state,
 | 
			
		||||
                peerList: [], //changing selection will purge out all of the old data
 | 
			
		||||
                fileList: [],
 | 
			
		||||
                selectionHashes: [],
 | 
			
		||||
                selection: action.selection,
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
        case actionTypes.NEW_RSS_FEED_STORE:
 | 
			
		||||
            console.log("New RSS Feed Store", action.RSSList)
 | 
			
		||||
            return {
 | 
			
		||||
                ...state,
 | 
			
		||||
                RSSList: action.RSSList,
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        case actionTypes.SELECTION_HASHES:
 | 
			
		||||
            console.log("Selection hashes REDUX", action.selectionHashes)
 | 
			
		||||
            return {
 | 
			
		||||
@@ -59,24 +71,72 @@ const reducer = (state = initialState, action) => {
 | 
			
		||||
            }
 | 
			
		||||
        
 | 
			
		||||
        case actionTypes.FILE_LIST:
 | 
			
		||||
        console.log("FILELIST REDUX......", action.fileList)
 | 
			
		||||
            return {
 | 
			
		||||
                ...state,
 | 
			
		||||
                fileList: action.fileList
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        case actionTypes.SET_BUTTON_STATE:
 | 
			
		||||
            return {
 | 
			
		||||
                ...state,
 | 
			
		||||
                buttonState: action.buttonState
 | 
			
		||||
            }; 
 | 
			
		||||
        
 | 
			
		||||
        case actionTypes.SELECTED_TAB:
 | 
			
		||||
            return {
 | 
			
		||||
                ...state,
 | 
			
		||||
                selectedTab: action.selectedTab
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
        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
 | 
			
		||||
                let buttonStateFinal = state.buttonStateDefault //if no selection dispatch that to redux
 | 
			
		||||
                return {
 | 
			
		||||
                    ...state,
 | 
			
		||||
                    buttonState: buttonStateFinal
 | 
			
		||||
                }; 
 | 
			
		||||
 | 
			
		||||
            } else { // if we have selection continue on with logic to determine button state
 | 
			
		||||
                const selectedRows = [] //array of all the selected Rows
 | 
			
		||||
                action.buttonState.forEach(element => {   
 | 
			
		||||
                    selectedRows.push(state.torrentList[element])   //pushing the selected rows out of torrentlist
 | 
			
		||||
                });
 | 
			
		||||
            
 | 
			
		||||
            
 | 
			
		||||
                let buttonStateTest = selectedRows.filter(element => { //TODO fix this bad mess... we literally just need to filter for stopped and go from there
 | 
			
		||||
                    let result = []
 | 
			
		||||
                    if (element.Status === "Downloading" || element.Status === "Awaiting Peers" || element.Status === "Seeding" || element.Status === "Completed"){
 | 
			
		||||
                        result.push(element.Status)
 | 
			
		||||
                        return result
 | 
			
		||||
                    }
 | 
			
		||||
                })
 | 
			
		||||
                let buttonStateTest2 = selectedRows.filter(element => element.Status === "Stopped")
 | 
			
		||||
            
 | 
			
		||||
                if (buttonStateTest.length > 0 && buttonStateTest2.length === 0){
 | 
			
		||||
 | 
			
		||||
                    let buttonStateFinal = [{startButton: "default", stopButton: "primary", deleteButton: "accent", fSeedButton: "default", fRecheckButton: "primary"}]
 | 
			
		||||
                    return {
 | 
			
		||||
                        ...state,
 | 
			
		||||
                        buttonState: buttonStateFinal
 | 
			
		||||
                    }; 
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                if (buttonStateTest.length === 0 && buttonStateTest2.length > 0){
 | 
			
		||||
                    let buttonStateFinal = [{startButton: "primary", stopButton: "default", deleteButton: "accent", fSeedButton: "default", fRecheckButton: "primary"}]
 | 
			
		||||
                    return {
 | 
			
		||||
                        ...state,
 | 
			
		||||
                        buttonState: buttonStateFinal
 | 
			
		||||
                    }; 
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                if (buttonStateTest.length > 0 && buttonStateTest2.length > 0){
 | 
			
		||||
                    let buttonStateFinal = [{startButton: "primary", stopButton: "primary", deleteButton: "accent", fSeedButton: "default", fRecheckButton: "primary"}]
 | 
			
		||||
                    return {
 | 
			
		||||
                        ...state,
 | 
			
		||||
                        buttonState: buttonStateFinal
 | 
			
		||||
                    }; 
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return {
 | 
			
		||||
                ...state,
 | 
			
		||||
                buttonState: buttonStateFinal
 | 
			
		||||
            }; 
 | 
			
		||||
        
 | 
			
		||||
        default:
 | 
			
		||||
            return state;
 | 
			
		||||
    };
 | 
			
		||||
 
 | 
			
		||||
@@ -2,17 +2,19 @@ import React from 'react';
 | 
			
		||||
import ReactDOM from 'react-dom';
 | 
			
		||||
import styles from '../node_modules/react-bootstrap-table/dist/react-bootstrap-table-all.min.css';
 | 
			
		||||
import {BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table';
 | 
			
		||||
import Paper from 'material-ui/Paper';
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
    SortingState, LocalSorting, PagingState, VirtualTableLayout, SelectionState, FilteringState,
 | 
			
		||||
    SortingState, LocalSorting, PagingState, VirtualTableLayout, SelectionState, FilteringState, LocalFiltering,
 | 
			
		||||
} from '@devexpress/dx-react-grid';
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
    Grid, TableView, TableHeaderRow, PagingPanel, VirtualTableView, TableSelection, TableColumnResizing,
 | 
			
		||||
    DragDropContext, TableColumnReordering,
 | 
			
		||||
    Grid, TableHeaderRow, PagingPanel, VirtualTableView, VirtualTable, TableSelection, TableColumnResizing,
 | 
			
		||||
    DragDropContext, TableColumnReordering, 
 | 
			
		||||
} from '@devexpress/dx-react-grid-material-ui';
 | 
			
		||||
 | 
			
		||||
import { ProgressBarCell } from './ProgressBarCell';
 | 
			
		||||
 | 
			
		||||
import { ProgressBarCell } from './CustomCells/progressBarCell';
 | 
			
		||||
//react redux
 | 
			
		||||
import {connect} from 'react-redux';
 | 
			
		||||
import * as actionTypes from './store/actions';
 | 
			
		||||
@@ -61,10 +63,14 @@ class TorrentListTable extends React.Component {
 | 
			
		||||
            columnOrder: ['TorrentName', 'DownloadedSize', 'Size', 'PercentDone', 'Status', 'DownloadSpeed', 'UploadSpeed','ActivePeers', 'ETA', 'Ratio', 'Availability'],
 | 
			
		||||
            columnWidths: {TorrentName: 250, DownloadedSize: 100, Size: 100, PercentDone: 175, Status: 150, DownloadSpeed: 100, UploadSpeed: 100, ActivePeers: 100, ETA: 100, Ratio: 75, Availability: 75},
 | 
			
		||||
            prevSelection: [], //just used to pull data from cell (temp Prevcell holder), real selection is in Redux
 | 
			
		||||
            pageSizes: [5, 10, 15, 0],
 | 
			
		||||
            currentPage: 0,
 | 
			
		||||
        };
 | 
			
		||||
 
 | 
			
		||||
        this.changeColumnOrder = columnOrder => this.setState({columnOrder});
 | 
			
		||||
        this.changeColumnWidths = columnWidths => this.setState({columnWidths});
 | 
			
		||||
        this.changePageSize = pageSize => this.setState({ pageSize });
 | 
			
		||||
        this.changeCurrentPage = currentPage => this.setState({ currentPage });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -73,11 +79,12 @@ class TorrentListTable extends React.Component {
 | 
			
		||||
        if (this.props.filter != nextProps.filter){
 | 
			
		||||
            this.filterHandler(nextProps.filter)
 | 
			
		||||
        }
 | 
			
		||||
        //console.log("Recieving new props", nextProps.selection)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    determineSelectionHashes = (selectedRows) => {
 | 
			
		||||
        console.log("CurrentSelectionHashes", this.props.selectionHashes)
 | 
			
		||||
        //console.log("CurrentSelectionHashes", this.props.selectionHashes)
 | 
			
		||||
        let selectionHashes = [] //rebuilding our selection hashes from our currently selected rows
 | 
			
		||||
        selectedRows.forEach(element => {
 | 
			
		||||
            selectionHashes.push(element.TorrentHashString) //push the selection hash to the temp array
 | 
			
		||||
@@ -86,40 +93,28 @@ class TorrentListTable extends React.Component {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    determineButtonState = (selectedRows) => { //TODO run a filter to corrently determing button status... currently broken
 | 
			
		||||
        selectedRows.forEach(element => {
 | 
			
		||||
            if (element.Status === "Downloading" || "Awaiting Peers" || "Seeding") {
 | 
			
		||||
                let buttonState = [{startButton: "default", stopButton: "primary", deleteButton: "accent", fSeedButton: "default", fRecheckButton: "primary"}]
 | 
			
		||||
                this.props.setButtonState(buttonState)
 | 
			
		||||
            } else if (element.Status === "Completed")  {
 | 
			
		||||
                let buttonState = [{startButton: "default", stopButton: "default", deleteButton: "accent", fSeedButton: "primary", fRecheckButton: "primary"}]
 | 
			
		||||
                this.props.setButtonState(buttonState)
 | 
			
		||||
            } else {
 | 
			
		||||
                this.props.setButtonState(this.props.buttonStateDefault)
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
   
 | 
			
		||||
 | 
			
		||||
    changeSelection = (selection) => {
 | 
			
		||||
        //console.log("TOrrentlist is changing selection now", selection)
 | 
			
		||||
        this.props.changeSelection(selection) //dispatch selection to redux, also clear out anything tied to the old selection (peerlists, filelists, etc)
 | 
			
		||||
 | 
			
		||||
        if (selection.length === 0) { //if selection is empty buttons will be default and selectionHashes will be blanked out and pushed to redux
 | 
			
		||||
            this.props.setButtonState(this.props.buttonStateDefault) //if no selection dispatch that to redux
 | 
			
		||||
            //let selectionHashes = []
 | 
			
		||||
            //this.props.sendSelectionHashes(selectionHashes) //clearning out selection hashes since we have nothing selected
 | 
			
		||||
         if (selection.length === 0) { //if selection is empty buttons will be default and selectionHashes will be blanked out and pushed to redux
 | 
			
		||||
            this.props.setButtonState(selection) //if no selection dispatch that to redux
 | 
			
		||||
        } else { // if we have selection continue on with logic to determine button state
 | 
			
		||||
            const selectedRows = [] //array of all the selected Rows
 | 
			
		||||
            selection.forEach(element => {   
 | 
			
		||||
                selectedRows.push(this.props.torrentList[element])   //pushing the selected rows out of torrentlist
 | 
			
		||||
            });
 | 
			
		||||
            this.determineButtonState(selectedRows) //running a filter on the rows to determing buttonState
 | 
			
		||||
            //console.log("Determining selection hashses")
 | 
			
		||||
            this.determineSelectionHashes(selectedRows) //pulling the torrent hashes for the selcted rows
 | 
			
		||||
        } 
 | 
			
		||||
            this.props.setButtonState(selection)
 | 
			
		||||
        }
 | 
			
		||||
       
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    filterHandler = (filter) => { //TODO, figure out how to do multiple filter
 | 
			
		||||
        console.log("Changing FIlter", filter)
 | 
			
		||||
        //console.log("Changing FIlter", filter)
 | 
			
		||||
        if (filter.value ==="Active"){
 | 
			
		||||
            console.log("This filter doesn't fucking work")
 | 
			
		||||
        }
 | 
			
		||||
@@ -127,26 +122,41 @@ class TorrentListTable extends React.Component {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    render() {
 | 
			
		||||
        return (   
 | 
			
		||||
            <Grid rows={this.props.torrentList} columns={this.state.columns}>
 | 
			
		||||
                <SortingState sorting={this.props.sorting} onSortingChange={this.props.changeSorting} />
 | 
			
		||||
                <LocalSorting />
 | 
			
		||||
                <FilteringState filters={this.props.filter} />
 | 
			
		||||
                <SelectionState onSelectionChange={this.changeSelection} selection={this.props.selection}/> 
 | 
			
		||||
                <TableView  tableCellTemplate={({ row, column, style }) => {
 | 
			
		||||
        return (
 | 
			
		||||
            <Paper>   
 | 
			
		||||
                <Grid rows={this.props.torrentList} columns={this.state.columns}>
 | 
			
		||||
                    <FilteringState filters={this.props.filter} />
 | 
			
		||||
                    
 | 
			
		||||
                    <SortingState sorting={this.props.sorting} onSortingChange={this.props.changeSorting} />
 | 
			
		||||
                    
 | 
			
		||||
                    <SelectionState onSelectionChange={this.changeSelection} selection={this.props.selection}/> 
 | 
			
		||||
 | 
			
		||||
                    <LocalFiltering />
 | 
			
		||||
                    <LocalSorting />
 | 
			
		||||
 | 
			
		||||
                    <VirtualTableView height={530} tableCellTemplate={({ row, column, style }) => {
 | 
			
		||||
                    if (column.name === 'PercentDone') {
 | 
			
		||||
                    return (
 | 
			
		||||
                        <ProgressBarCell value={row.PercentDone * 100} style={style} />
 | 
			
		||||
                    );
 | 
			
		||||
                    }
 | 
			
		||||
                    return undefined;
 | 
			
		||||
                }}/>
 | 
			
		||||
                <DragDropContext />
 | 
			
		||||
                <TableColumnResizing columnWidths={this.state.columnWidths} onColumnWidthsChange={this.changeColumnWidths}/>
 | 
			
		||||
                <TableColumnReordering order={this.state.columnOrder} onOrderChange={this.changeColumnOrder} />
 | 
			
		||||
                <TableSelection selectByRowClick highlightSelected />
 | 
			
		||||
                <TableHeaderRow allowSorting allowResizing allowDragging />
 | 
			
		||||
            </Grid>
 | 
			
		||||
                        return (
 | 
			
		||||
                            <ProgressBarCell value={row.PercentDone * 100} style={style} />
 | 
			
		||||
                        );
 | 
			
		||||
                        }
 | 
			
		||||
                        return undefined;
 | 
			
		||||
                    }}/>
 | 
			
		||||
 | 
			
		||||
                    <DragDropContext />
 | 
			
		||||
                    <TableColumnResizing columnWidths={this.state.columnWidths} onColumnWidthsChange={this.changeColumnWidths}/>
 | 
			
		||||
                    <TableColumnReordering order={this.state.columnOrder} onOrderChange={this.changeColumnOrder} />
 | 
			
		||||
                    <TableSelection selectByRowClick highlightSelected />
 | 
			
		||||
                    <TableHeaderRow allowSorting allowResizing allowDragging />
 | 
			
		||||
 | 
			
		||||
                    
 | 
			
		||||
                    
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                </Grid>
 | 
			
		||||
            </Paper>
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -158,6 +168,7 @@ const mapStateToProps = state => {
 | 
			
		||||
        buttonState: state.buttonState,
 | 
			
		||||
        buttonStateDefault: state.buttonStateDefault, //all default
 | 
			
		||||
        selectionHashes: state.selectionHashes,
 | 
			
		||||
        selection: state.selection,
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user