import React from 'react'; import {FormField, FormRow} from '../component/form.js'; import lbry from '../lbry.js'; var SettingsPage = React.createClass({ _onSettingSaveSuccess: function() { // This is bad. // document.dispatchEvent(new CustomEvent('globalNotice', { // detail: { // message: "Settings saved", // }, // })) }, setDaemonSetting: function(name, value) { lbry.setDaemonSetting(name, value, this._onSettingSaveSuccess) }, setClientSetting: function(name, value) { lbry.setClientSetting(name, value) this._onSettingSaveSuccess() }, onRunOnStartChange: function (event) { this.setDaemonSetting('run_on_startup', event.target.checked); }, onShareDataChange: function (event) { this.setDaemonSetting('share_debug_info', event.target.checked); }, onDownloadDirChange: function(event) { this.setDaemonSetting('download_directory', event.target.value); }, onMaxUploadPrefChange: function(isLimited) { if (!isLimited) { this.setDaemonSetting('max_upload', 0.0); } this.setState({ isMaxUpload: isLimited }); }, onMaxUploadFieldChange: function(event) { this.setDaemonSetting('max_upload', Number(event.target.value)); }, onMaxDownloadPrefChange: function(isLimited) { if (!isLimited) { this.setDaemonSetting('max_download', 0.0); } this.setState({ isMaxDownload: isLimited }); }, onMaxDownloadFieldChange: function(event) { this.setDaemonSetting('max_download', Number(event.target.value)); }, getInitialState: function() { return { settings: null, showNsfw: lbry.getClientSetting('showNsfw'), showUnavailable: lbry.getClientSetting('showUnavailable'), } }, componentDidMount: function() { document.title = "Settings"; }, componentWillMount: function() { lbry.getDaemonSettings(function(settings) { this.setState({ daemonSettings: settings, isMaxUpload: settings.max_upload != 0, isMaxDownload: settings.max_download != 0 }); }.bind(this)); }, onShowNsfwChange: function(event) { lbry.setClientSetting('showNsfw', event.target.checked); }, onShowUnavailableChange: function(event) { }, render: function() { if (!this.state.daemonSettings) { return null; } /*

Run on Startup

*/ return (

Download Directory

Bandwidth Limits

Max Upload
{ this.state.isMaxUpload ? : '' } { this.state.isMaxUpload ? MB/s : '' }
Max Download
{ this.state.isMaxDownload ? : '' } { this.state.isMaxDownload ? MB/s : '' }

Content

Share Diagnostic Data

); } }); export default SettingsPage;