небольшие исправления
This commit is contained in:
parent
ed7a3dc685
commit
c13534fe68
16
index.js
16
index.js
@ -91,6 +91,9 @@ io.on('connection', function(socket)
|
|||||||
|
|
||||||
socket.on('recentTorrents', function(callback)
|
socket.on('recentTorrents', function(callback)
|
||||||
{
|
{
|
||||||
|
if(typeof callback != 'function')
|
||||||
|
return;
|
||||||
|
|
||||||
socketMysql.query('SELECT * FROM `torrents` ORDER BY added DESC LIMIT 0,10', function (error, rows, fields) {
|
socketMysql.query('SELECT * FROM `torrents` ORDER BY added DESC LIMIT 0,10', function (error, rows, fields) {
|
||||||
let torrents = [];
|
let torrents = [];
|
||||||
rows.forEach((row) => {
|
rows.forEach((row) => {
|
||||||
@ -103,6 +106,9 @@ io.on('connection', function(socket)
|
|||||||
|
|
||||||
socket.on('statistic', function(callback)
|
socket.on('statistic', function(callback)
|
||||||
{
|
{
|
||||||
|
if(typeof callback != 'function')
|
||||||
|
return;
|
||||||
|
|
||||||
let stats = {};
|
let stats = {};
|
||||||
socketMysql.query('SELECT COUNT(*) as tornum FROM `torrents`', function (error, rows, fields) {
|
socketMysql.query('SELECT COUNT(*) as tornum FROM `torrents`', function (error, rows, fields) {
|
||||||
stats.torrents = rows[0].tornum;
|
stats.torrents = rows[0].tornum;
|
||||||
@ -118,6 +124,9 @@ io.on('connection', function(socket)
|
|||||||
if(hash.length != 40)
|
if(hash.length != 40)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(typeof callback != 'function')
|
||||||
|
return;
|
||||||
|
|
||||||
socketMysql.query('SELECT * FROM `torrents` WHERE `hash` = ?', hash, function (error, rows, fields) {
|
socketMysql.query('SELECT * FROM `torrents` WHERE `hash` = ?', hash, function (error, rows, fields) {
|
||||||
if(rows.length == 0) {
|
if(rows.length == 0) {
|
||||||
callback(undefined);
|
callback(undefined);
|
||||||
@ -141,9 +150,14 @@ io.on('connection', function(socket)
|
|||||||
|
|
||||||
socket.on('search', function(text, callback)
|
socket.on('search', function(text, callback)
|
||||||
{
|
{
|
||||||
if(!text || text.length <= 2)
|
if(typeof callback != 'function')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(!text || text.length <= 2) {
|
||||||
|
callback(undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let search = {};
|
let search = {};
|
||||||
|
|
||||||
console.log(text);
|
console.log(text);
|
||||||
|
@ -14,16 +14,16 @@ return (
|
|||||||
onClick={() => window.router('/torrent/' + torrent.hash)}
|
onClick={() => window.router('/torrent/' + torrent.hash)}
|
||||||
primaryText={<span className='break-word'>{torrent.name}</span>}
|
primaryText={<span className='break-word'>{torrent.name}</span>}
|
||||||
secondaryText={
|
secondaryText={
|
||||||
<div className='column'>
|
<div className='column' style={{height: 'auto', whiteSpace: 'normal'}}>
|
||||||
<div>
|
<div>
|
||||||
{
|
{
|
||||||
formatBytes(torrent.size, 1)
|
formatBytes(torrent.size, 1) + ' (' + torrent.files + ' files)'
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
torrent.path && torrent.path.length > 0
|
torrent.path && torrent.path.length > 0
|
||||||
?
|
?
|
||||||
<div>{torrent.path}</div>
|
<div className='break-word fs0-75' style={{paddingTop: '0.3em'}}>{torrent.path}</div>
|
||||||
:
|
:
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,14 @@ const TorrentInformation = (props) => {
|
|||||||
rightIcon={<ActionInfo />}
|
rightIcon={<ActionInfo />}
|
||||||
primaryText="Torrent contains files"
|
primaryText="Torrent contains files"
|
||||||
secondaryText={torrent.files}
|
secondaryText={torrent.files}
|
||||||
|
onClick={() => {
|
||||||
|
if(!props.parent)
|
||||||
|
return
|
||||||
|
|
||||||
|
props.parent.setState({
|
||||||
|
value: 'files'
|
||||||
|
})
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<ListItem
|
<ListItem
|
||||||
// leftAvatar={<Avatar icon={<EditorInsertChart />} backgroundColor={yellow600} />}
|
// leftAvatar={<Avatar icon={<EditorInsertChart />} backgroundColor={yellow600} />}
|
||||||
@ -144,7 +152,7 @@ export default class TorrentPage extends Component {
|
|||||||
<div className='column w100p'>
|
<div className='column w100p'>
|
||||||
<div className='row w100p torrent-information-row'>
|
<div className='row w100p torrent-information-row'>
|
||||||
<div style={{flexBasis: '60%'}}>
|
<div style={{flexBasis: '60%'}}>
|
||||||
<TorrentInformation torrent={this.torrent} />
|
<TorrentInformation torrent={this.torrent} parent={this} />
|
||||||
</div>
|
</div>
|
||||||
<div style={{flexBasis: '40%'}} className='column center w100p'>
|
<div style={{flexBasis: '40%'}} className='column center w100p'>
|
||||||
<img src={NoImage} className='pad0-75' style={{height: '200px'}} />
|
<img src={NoImage} className='pad0-75' style={{height: '200px'}} />
|
||||||
|
Loading…
Reference in New Issue
Block a user