feat(filters): content type filters #49
This commit is contained in:
parent
a752a67370
commit
8792da82d5
@ -8,14 +8,31 @@ import Slider from 'material-ui/Slider'
|
||||
import SelectField from 'material-ui/SelectField';
|
||||
import MenuItem from 'material-ui/MenuItem';
|
||||
import InputSize from './input-size';
|
||||
|
||||
import fs from 'fs'
|
||||
import Checkbox from 'material-ui/Checkbox';
|
||||
|
||||
export default class ConfigPage extends Page {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.setTitle('Rats filters');
|
||||
this.options = {}
|
||||
this.basicTypes = ['video',
|
||||
'audio',
|
||||
'pictures',
|
||||
'books',
|
||||
'application',
|
||||
'archive',
|
||||
'disc']
|
||||
this.contentType = this.basicTypes.slice(0)
|
||||
this.descriptions = {
|
||||
main: __('All'),
|
||||
video: __('Video'),
|
||||
audio: __('Audio/Music'),
|
||||
books: __('Books'),
|
||||
pictures: __('Pictures/Images'),
|
||||
application: __('Apps/Games'),
|
||||
archive: __('Archives'),
|
||||
disc: __('Discs/ISO')
|
||||
}
|
||||
}
|
||||
componentDidMount() {
|
||||
this.loadSettings()
|
||||
@ -23,11 +40,19 @@ export default class ConfigPage extends Page {
|
||||
loadSettings() {
|
||||
window.torrentSocket.emit('config', window.customLoader((options) => {
|
||||
this.options = options;
|
||||
console.log(this.options)
|
||||
|
||||
if(this.options.filters && this.options.filters.contentType && this.options.filters.contentType.length > 0)
|
||||
this.contentType = this.options.filters.contentType
|
||||
|
||||
this.forceUpdate();
|
||||
}));
|
||||
}
|
||||
saveSettings() {
|
||||
if(this.options.filters && this.basicTypes.length === this.contentType.length)
|
||||
this.options.filters.contentType = null // обнуляем в случае если заданы все фильтры
|
||||
else
|
||||
this.options.filters.contentType = this.contentType
|
||||
|
||||
window.torrentSocket.emit('setConfig', this.options)
|
||||
this.settingsSavedMessage = true
|
||||
this.forceUpdate()
|
||||
@ -164,6 +189,31 @@ export default class ConfigPage extends Page {
|
||||
</div>
|
||||
}
|
||||
|
||||
<div className='column w100p'>
|
||||
<div style={{flex: 1, padding: '8px 0px'}}>{__('disable some categories')}:</div>
|
||||
{
|
||||
this.basicTypes.map(type => (<Checkbox
|
||||
label={this.descriptions[type]}
|
||||
checked={this.contentType && this.contentType.indexOf(type) >= 0}
|
||||
onCheck={e => {
|
||||
if(e.target.checked)
|
||||
{
|
||||
this.contentType.push(type)
|
||||
}
|
||||
else
|
||||
{
|
||||
const index = this.contentType.indexOf(type)
|
||||
this.contentType.splice(index, 1)
|
||||
}
|
||||
if(this.contentType.length == 0)
|
||||
this.contentType = this.basicTypes.slice(0)
|
||||
|
||||
this.forceUpdate()
|
||||
}}
|
||||
/>))
|
||||
}
|
||||
</div>
|
||||
|
||||
{
|
||||
this.toRemoveProbably && this.toRemoveProbably > 0
|
||||
?
|
||||
|
@ -433,6 +433,12 @@ app.get('*', function(req, res)
|
||||
return false
|
||||
}
|
||||
|
||||
if(config.filters.contentType && Array.isArray(config.filters.contentType) && !config.filters.contentType.includes(torrent.contentType))
|
||||
{
|
||||
console.log('ignore torrent', torrent.name, 'because type', torrent.contentType, 'not in:', config.filters.contentType)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -178,6 +178,8 @@
|
||||
"Pause torrent downloading": "Pause torrent downloading",
|
||||
"P2P torrents replication server": "P2P torrents replication server",
|
||||
"Enable torrents replication server for other rats clients (required for replication)": "Enable torrents replication server for other rats clients (required for replication)",
|
||||
"* - enabled means ignoring all adult content": "* - enabled means ignoring all adult content"
|
||||
"* - enabled means ignoring all adult content": "* - enabled means ignoring all adult content",
|
||||
"disable some categories": "disable some categories",
|
||||
"Discs/ISO": "Discs/ISO"
|
||||
}
|
||||
}
|
@ -178,6 +178,8 @@
|
||||
"Pause torrent downloading": "Пауза скачки торрента",
|
||||
"P2P torrents replication server": "Сервер репликация торрентов через p2p",
|
||||
"Enable torrents replication server for other rats clients (required for replication)": "Включить сервер репликации для остальных крысиных клиентов (необходим для репликации)",
|
||||
"* - enabled means ignoring all adult content": "* - означает игнорирование всего контента для взрослых"
|
||||
"* - enabled means ignoring all adult content": "* - означает игнорирование всего контента для взрослых",
|
||||
"disable some categories": "отключить некоторые категории",
|
||||
"Discs/ISO": "Диски/Образы"
|
||||
}
|
||||
}
|
@ -178,6 +178,8 @@
|
||||
"Pause torrent downloading": "Pause torrent downloading",
|
||||
"P2P torrents replication server": "P2P torrents replication server",
|
||||
"Enable torrents replication server for other rats clients (required for replication)": "Enable torrents replication server for other rats clients (required for replication)",
|
||||
"* - enabled means ignoring all adult content": "* - enabled means ignoring all adult content"
|
||||
"* - enabled means ignoring all adult content": "* - enabled means ignoring all adult content",
|
||||
"disable some categories": "disable some categories",
|
||||
"Discs/ISO": "Discs/ISO"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user