feat(config): new settings for application (port, cpu usage eth.)
This commit is contained in:
@ -5,11 +5,13 @@ import {Header} from './index-page'
|
|||||||
|
|
||||||
import Toggle from 'material-ui/Toggle';
|
import Toggle from 'material-ui/Toggle';
|
||||||
import RaisedButton from 'material-ui/RaisedButton';
|
import RaisedButton from 'material-ui/RaisedButton';
|
||||||
|
import TextField from 'material-ui/TextField'
|
||||||
|
import Slider from 'material-ui/Slider'
|
||||||
|
|
||||||
export default class AdminPage extends Page {
|
export default class AdminPage extends Page {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.setTitle('-=-= Some page =-=-');
|
this.setTitle('Rats settings');
|
||||||
this.options = {}
|
this.options = {}
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -44,9 +46,70 @@ export default class AdminPage extends Page {
|
|||||||
trackSwitchedStyle={{backgroundColor: '#ff9d9d'}}
|
trackSwitchedStyle={{backgroundColor: '#ff9d9d'}}
|
||||||
onToggle={(e, checked) => {
|
onToggle={(e, checked) => {
|
||||||
this.options.indexer = checked
|
this.options.indexer = checked
|
||||||
this.saveSettings()
|
this.forceUpdate()
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<div className='row inline w100p'>
|
||||||
|
<div style={{flex: 1}}>Scanning port</div>
|
||||||
|
<TextField
|
||||||
|
style={{width: 65}}
|
||||||
|
hintText="Port"
|
||||||
|
errorText={this.options.spiderPort > 0 ? undefined : "This field is required"}
|
||||||
|
value={this.options.spiderPort}
|
||||||
|
onChange={(e, value) => {
|
||||||
|
if(!value)
|
||||||
|
value = 0
|
||||||
|
if(value > 65535)
|
||||||
|
value = 65535
|
||||||
|
|
||||||
|
this.options.spiderPort = parseInt(value)
|
||||||
|
this.forceUpdate()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='row inline w100p'>
|
||||||
|
<div style={{flex: 1}}>Trackers responce port</div>
|
||||||
|
<TextField
|
||||||
|
style={{width: 65}}
|
||||||
|
hintText="Port"
|
||||||
|
errorText={this.options.udpTrackersPort > 0 ? undefined : "This field is required"}
|
||||||
|
value={this.options.udpTrackersPort}
|
||||||
|
onChange={(e, value) => {
|
||||||
|
if(!value)
|
||||||
|
value = 0
|
||||||
|
if(value > 65535)
|
||||||
|
value = 65535
|
||||||
|
|
||||||
|
this.options.udpTrackersPort = parseInt(value)
|
||||||
|
this.forceUpdate()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='row inline w100p'>
|
||||||
|
<div style={{flex: 1}}>CPU usage limitation</div>
|
||||||
|
<Slider
|
||||||
|
min={0}
|
||||||
|
max={100}
|
||||||
|
step={1}
|
||||||
|
style={{width: 300}}
|
||||||
|
value={this.options.spider && this.options.spider.cpuLimit === 0 ? 100 : this.options.spider && this.options.spider.cpuLimit}
|
||||||
|
onChange={(event, value) => {
|
||||||
|
if(value === 100)
|
||||||
|
value = 0
|
||||||
|
|
||||||
|
this.options.spider.cpuLimit = value
|
||||||
|
this.forceUpdate()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='row center pad0-75'>
|
||||||
|
<RaisedButton label="Save Sttings" primary={true} onClick={() => {
|
||||||
|
this.saveSettings()
|
||||||
|
}} />
|
||||||
|
</div>
|
||||||
<Footer />
|
<Footer />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -546,12 +546,19 @@ setInterval(() => {
|
|||||||
|
|
||||||
if(typeof options.indexer !== 'undefined')
|
if(typeof options.indexer !== 'undefined')
|
||||||
{
|
{
|
||||||
|
const upSpider = () => {
|
||||||
if(options.indexer)
|
if(options.indexer)
|
||||||
spider.listen(config.spiderPort)
|
spider.listen(config.spiderPort)
|
||||||
else
|
else
|
||||||
spider.close()
|
spider.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(options.spiderPort !== config.spiderPort)
|
||||||
|
spider.close(upSpider)
|
||||||
|
else
|
||||||
|
upSpider()
|
||||||
|
}
|
||||||
|
|
||||||
for(const option in options)
|
for(const option in options)
|
||||||
{
|
{
|
||||||
if(option in config)
|
if(option in config)
|
||||||
|
Reference in New Issue
Block a user