-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(download): torrent downloads manager
- Loading branch information
Showing
8 changed files
with
119 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
import Page from './page'; | ||
import Footer from './footer'; | ||
|
||
import TorrentLine from './torrent' | ||
import {List} from 'material-ui/List'; | ||
import Subheader from 'material-ui/Subheader'; | ||
import RaisedButton from 'material-ui/RaisedButton'; | ||
|
||
export default class TopPage extends Page { | ||
downloads = [] | ||
|
||
constructor(props) { | ||
super(props) | ||
this.setTitle('Current Downloads'); | ||
} | ||
getDownloads() | ||
{ | ||
window.torrentSocket.emit('downloads', window.customLoader((downloads) => { | ||
this.downloads = downloads | ||
this.forceUpdate() | ||
})) | ||
} | ||
componentDidMount() | ||
{ | ||
super.componentDidMount(); | ||
this.getDownloads() | ||
this.downloading = () => this.getDownloads() | ||
window.torrentSocket.on('downloading', this.downloading); | ||
this.downloadDone = () => this.getDownloads() | ||
window.torrentSocket.on('downloadDone', this.downloadDone); | ||
} | ||
componentWillUnmount() | ||
{ | ||
if(this.downloading) | ||
window.torrentSocket.off('downloading', this.downloading); | ||
if(this.downloadDone) | ||
window.torrentSocket.off('downloadDone', this.downloadDone); | ||
} | ||
render() { | ||
return ( | ||
<div> | ||
<div className='column center w100p pad0-75'> | ||
<RaisedButton label="Back to main page" primary={true} onClick={() => { | ||
window.router('/') | ||
}} /> | ||
<List style={{paddingBottom: '70px'}} className='animated recent-torrents'> | ||
{ | ||
this.downloads.map((download, index) => { | ||
return <TorrentLine key={index} torrent={download.torrentObject} download={download} /> | ||
}) | ||
} | ||
</List> | ||
<Footer /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { app, BrowserWindow, shell } from "electron"; | ||
import path from "path"; | ||
import url from "url"; | ||
|
||
export const manageMenuTemplate = { | ||
label: "Manage", | ||
submenu: [ | ||
{ | ||
label: "Downloads", | ||
accelerator: "CmdOrCtrl+d", | ||
click: () => { | ||
BrowserWindow.getFocusedWindow().webContents.send('url', '/downloads') | ||
}, | ||
}, | ||
{ | ||
label: "Search", | ||
accelerator: "CmdOrCtrl+n", | ||
click: () => { | ||
BrowserWindow.getFocusedWindow().webContents.send('url', '/') | ||
}, | ||
} | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters