From 790124d25a22d38385cb5633ed85da2e5f149e33 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Sun, 3 Apr 2016 08:45:33 -0400 Subject: [PATCH] First sorta-working draft of Settings page - Includes all fields except some I need to ask Jack about (layout details) - Loads current settings and saves one (run_on_startup) - Also made success callback in lbry.call() optional (don't need it for set_settings) --- dist/index.html | 1 + js/gui.js | 117 +++++++++++++++++++++++++++++++++++++++++++++--- js/lbry.js | 13 +++++- scss/_gui.scss | 4 ++ 4 files changed, 128 insertions(+), 7 deletions(-) diff --git a/dist/index.html b/dist/index.html index f6ae53ee0..b103d9121 100644 --- a/dist/index.html +++ b/dist/index.html @@ -20,6 +20,7 @@
+ diff --git a/js/gui.js b/js/gui.js index d731ed897..78292b383 100644 --- a/js/gui.js +++ b/js/gui.js @@ -362,23 +362,128 @@ var HomePage = React.createClass({ }); var settingsPageStyles = { - paddingTop: '80px' + paddingTop: '60px', + fontSize: '16px', }, settingsPageHeaderStyles = { textAlign: 'center' }, settingsBottomButtonsStyles = { textAlign: 'center' +}, settingsSectionStyles = { + paddingBottom: '15px', +}, settingsQuestionStyles = { + display: 'block', +}, settingsRadioOptionStyles = { + display: 'block', + marginLeft: '13px' +}, settingsCheckBoxOptionStyles = { + display: 'block', + marginLeft: '13px' +}, settingsNumberFieldStyles = { + width: '40px' }; var SettingsPage = React.createClass({ + storeSetting: function(setting, val) { + var settings = Object.assign({}, this.state.settings); + settings[setting] = val; + this.setState({ + 'settings': settings + }); + }, + onRunOnStartChange: function (event) { + this.storeSetting('run_on_startup', event.target.checked); + }, + onDownloadDirPrefChange: function(useCustom) { + this.setState({ + isCustomDownloadDirectory: useCustom + }); + }, + onMaxUploadPrefChange: function(isLimited) { + this.setState({ + isMaxUpload: isLimited + }); + }, + onMaxDownloadPrefChange: function(isLimited) { + this.setState({ + isMaxDownload: isLimited + }); + }, + getInitialState: function() { + return { + settings: null, + isCustomDownloadDirectory: false, + isBandwidthCap: false + } + }, + componentWillMount: function() { + lbry.getSettings(function(settings) { + this.setState({ + settings: settings + }); + }.bind(this)); + }, + onDone: function() { + lbry.setSettings(this.state.settings); + this.props.closeCallback(); + }, render: function() { + if (!this.state.settings) { // If the settings aren't loaded yet, don't render anything. + return null; + } + return (
-

Settings

-

Lots of settings and stuff

-

...

{/* Placeholder */} +

Settings

+
+

Run on startup

+ +
+
+

Download directory

+ Where would you like files you download from LBRY to be saved? + + + +
+ +
+

Bandwidth limits

+ How much of your upload bandwidth may LBRY use? + + + + How much of your download bandwidth may LBRY use? + + + +
+
+

Default payment rules

+ ... +
- +
); @@ -406,7 +511,7 @@ var App = React.createClass({ if (this.state.viewingPage == 'home') { var content = ; } else if (this.state.viewingPage == 'settings') { - var content = ; + var content = ; } return (
diff --git a/js/lbry.js b/js/lbry.js index 68c8fc175..1b0112693 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -15,7 +15,10 @@ lbry.call = function (method, params, callback, connectFailedCallback) if (response.error) { throw new Error('Call to method ' + method + ' failed with message: ' + response.error); } - callback(response.result); + + if (callback) { + callback(response.result); + } }); if (connectFailedCallback) { @@ -66,6 +69,14 @@ lbry.daemonRunningStatus = function (callback) { }); }; +lbry.getSettings = function(callback) { + lbry.call('get_settings', {}, callback); +}; + +lbry.setSettings = function(settings, callback) { + lbry.call('set_settings', settings, callback); +}; + lbry.getBalance = function(callback) { lbry.call("get_balance", {}, callback); diff --git a/scss/_gui.scss b/scss/_gui.scss index 559b8b43d..6069efb43 100644 --- a/scss/_gui.scss +++ b/scss/_gui.scss @@ -33,6 +33,10 @@ sub { top: 0.4em; } } } +.hidden { + display: none; +} + input[type="search"] { border: 0 none;