небольшие исправления

This commit is contained in:
Alexey Kasyanchuk 2017-01-03 05:44:24 +03:00
parent ed7a3dc685
commit c13534fe68
3 changed files with 27 additions and 5 deletions

View File

@ -91,6 +91,9 @@ io.on('connection', function(socket)
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) {
let torrents = [];
rows.forEach((row) => {
@ -103,6 +106,9 @@ io.on('connection', function(socket)
socket.on('statistic', function(callback)
{
if(typeof callback != 'function')
return;
let stats = {};
socketMysql.query('SELECT COUNT(*) as tornum FROM `torrents`', function (error, rows, fields) {
stats.torrents = rows[0].tornum;
@ -118,6 +124,9 @@ io.on('connection', function(socket)
if(hash.length != 40)
return;
if(typeof callback != 'function')
return;
socketMysql.query('SELECT * FROM `torrents` WHERE `hash` = ?', hash, function (error, rows, fields) {
if(rows.length == 0) {
callback(undefined);
@ -141,9 +150,14 @@ io.on('connection', function(socket)
socket.on('search', function(text, callback)
{
if(!text || text.length <= 2)
if(typeof callback != 'function')
return;
if(!text || text.length <= 2) {
callback(undefined);
return;
}
let search = {};
console.log(text);

View File

@ -14,16 +14,16 @@ return (
onClick={() => window.router('/torrent/' + torrent.hash)}
primaryText={<span className='break-word'>{torrent.name}</span>}
secondaryText={
<div className='column'>
<div className='column' style={{height: 'auto', whiteSpace: 'normal'}}>
<div>
{
formatBytes(torrent.size, 1)
formatBytes(torrent.size, 1) + ' (' + torrent.files + ' files)'
}
</div>
{
torrent.path && torrent.path.length > 0
?
<div>{torrent.path}</div>
<div className='break-word fs0-75' style={{paddingTop: '0.3em'}}>{torrent.path}</div>
:
null
}

View File

@ -87,6 +87,14 @@ const TorrentInformation = (props) => {
rightIcon={<ActionInfo />}
primaryText="Torrent contains files"
secondaryText={torrent.files}
onClick={() => {
if(!props.parent)
return
props.parent.setState({
value: 'files'
})
}}
/>
<ListItem
// leftAvatar={<Avatar icon={<EditorInsertChart />} backgroundColor={yellow600} />}
@ -144,7 +152,7 @@ export default class TorrentPage extends Component {
<div className='column w100p'>
<div className='row w100p torrent-information-row'>
<div style={{flexBasis: '60%'}}>
<TorrentInformation torrent={this.torrent} />
<TorrentInformation torrent={this.torrent} parent={this} />
</div>
<div style={{flexBasis: '40%'}} className='column center w100p'>
<img src={NoImage} className='pad0-75' style={{height: '200px'}} />