топ торрентов

This commit is contained in:
Alexey Kasyanchuk
2017-11-10 14:24:53 +03:00
parent 223863191f
commit 0717e4d94a
4 changed files with 110 additions and 4 deletions

View File

@ -423,10 +423,29 @@ io.on('connection', function(socket)
updateTorrentTrackers(hash); updateTorrentTrackers(hash);
}); });
/* socket.on('topTorrents', function(type, callback)
socket.on('topTorrents', function(params, callback)
{ {
mysqlPool.query('SELECT * FROM `torrents` ORDER BY seeders LIMIT 10', hash, function (error, rows) { let where = '';
let max = 20;
if(type && type.length > 0)
{
where += ' and contentType = ' + mysqlPool.escape(type) + ' ';
max = 15;
if(type == 'hours')
{
where = ' and `added` > DATE_SUB(NOW(), INTERVAL 24 HOUR) '
}
if(type == 'week')
{
where = ' and `added` > DATE_SUB(NOW(), INTERVAL 7 DAY) '
}
if(type == 'month')
{
where = ' and `added` > DATE_SUB(NOW(), INTERVAL 7 DAY) '
}
}
mysqlPool.query(`SELECT * FROM torrents WHERE seeders > 0 and (contentCategory is null or contentCategory != 'xxx') ${where} ORDER BY seeders + leechers DESC LIMIT ${max}`, function (error, rows) {
if(!rows || rows.length == 0) { if(!rows || rows.length == 0) {
callback(undefined) callback(undefined)
return; return;
@ -439,7 +458,6 @@ io.on('connection', function(socket)
callback(searchList); callback(searchList);
}); });
}); });
*/
socket.on('admin', function(callback) socket.on('admin', function(callback)
{ {

View File

@ -139,6 +139,9 @@ export default class RecentTorrents extends Component {
return ( return (
<List className='animated recent-torrents'> <List className='animated recent-torrents'>
<Subheader className='recent-title' inset={true}> <Subheader className='recent-title' inset={true}>
<FlatButton style={{marginRight: '8px'}} primary={true} label='top' labelStyle={{color: "#a4c639"}} onClick={() =>{
window.router('/top');
}} />
<FlatButton style={{marginRight: '8px'}} label={!this.state.pause ? 'running' : 'stoped'} secondary={this.state.pause} primary={!this.state.pause} onClick={() =>{ <FlatButton style={{marginRight: '8px'}} label={!this.state.pause ? 'running' : 'stoped'} secondary={this.state.pause} primary={!this.state.pause} onClick={() =>{
this.pauseAndContinue() this.pauseAndContinue()
}} /> }} />

View File

@ -6,6 +6,7 @@ import IndexPage from './index-page.js'
import TorrentPage from './torrent-page.js' import TorrentPage from './torrent-page.js'
import DMCAPage from './dmca-page.js' import DMCAPage from './dmca-page.js'
import AdminPage from './admin-page.js' import AdminPage from './admin-page.js'
import TopPage from './top-page.js'
router('/', () => { router('/', () => {
//singleton //singleton
@ -33,4 +34,10 @@ router('/admi5p', () => {
//singleton //singleton
let pie = new PagesPie; let pie = new PagesPie;
pie.open(AdminPage, {replace: 'all'}); pie.open(AdminPage, {replace: 'all'});
});
router('/top', () => {
//singleton
let pie = new PagesPie;
pie.open(TopPage, {replace: 'all'});
}); });

78
src/top-page.js Normal file
View File

@ -0,0 +1,78 @@
import React from 'react';
import Page from './page';
import Footer from './footer';
import { Header } from './index-page'
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 {
constructor(props) {
super(props)
this.setTitle('Rats On The Boat - Torrents top');
this.topTorrents = {};
this.types = ['main', 'week', 'hours', 'month', 'video', 'audio', 'books', 'pictures', 'application', 'archive']
this.descriptions = {
main: 'All',
video: 'Video',
audio: 'Audio/Music',
books: 'Books',
pictures: 'Pictures/Images',
application: 'Applications/Games',
archive: 'Archives',
week: 'Last week',
hours: 'Last 24 hours',
month: 'Last month'
}
}
componentDidMount()
{
super.componentDidMount();
for(const type of this.types)
{
window.torrentSocket.emit('topTorrents', type == 'main' ? null : type, window.customLoader((data) => {
this.topTorrents[type] = data;
this.forceUpdate()
}))
}
}
render() {
return (
<div>
<Header />
<div className='column center w100p pad0-75'>
<RaisedButton label="Back to main page" primary={true} onClick={() => {
window.router('/')
}} />
{
this.types.map((type) => {
const torrents = this.topTorrents[type];
if(!torrents)
return null;
return (
<List style={{paddingBottom: '70px'}} className='animated recent-torrents'>
<Subheader inset={true}>
{
this.descriptions[type]
}
</Subheader>
{
torrents.map((torrent, index) => {
return <TorrentLine key={index} torrent={torrent} />
})
}
</List>
)
})
}
<Footer />
</div>
</div>
);
}
}