Browse Source

updated app settings tab

all-modes
pbca26 8 years ago
parent
commit
7366f93604
  1. 99
      react/src/components/dashboard/settings/settings.js
  2. 2
      react/src/components/dashboard/settings/settings.render.js
  3. 18
      react/src/components/overrides.scss
  4. 1
      react/src/translate/en.js

99
react/src/components/dashboard/settings/settings.js

@ -49,7 +49,7 @@ class Settings extends React.Component {
debugTarget: 'iguana', debugTarget: 'iguana',
activeTabHeight: '0', activeTabHeight: '0',
appSettings: {}, appSettings: {},
appSettingsTypes: {}, appConfigSchema: {},
tabElId: null, tabElId: null,
cliCmdString: '', cliCmdString: '',
cliCoin: null, cliCoin: null,
@ -67,7 +67,7 @@ class Settings extends React.Component {
}; };
this.exportWifKeys = this.exportWifKeys.bind(this); this.exportWifKeys = this.exportWifKeys.bind(this);
this.updateInput = this.updateInput.bind(this); this.updateInput = this.updateInput.bind(this);
this.updateInputSettings = this.updateInputSettings.bind(this); // this.updateInputSettings = this.updateInputSettings.bind(this);
this.importWifKey = this.importWifKey.bind(this); this.importWifKey = this.importWifKey.bind(this);
this.readDebugLog = this.readDebugLog.bind(this); this.readDebugLog = this.readDebugLog.bind(this);
this.checkNodes = this.checkNodes.bind(this); this.checkNodes = this.checkNodes.bind(this);
@ -97,13 +97,17 @@ class Settings extends React.Component {
socket.on('patch', msg => this.updateSocketsData(msg)); socket.on('patch', msg => this.updateSocketsData(msg));
window.addEventListener('resize', this.updateTabDimensions); window.addEventListener('resize', this.updateTabDimensions);
/*try { try {
const _window.require('electron').remote.getCurrentWindow().appBasicInfo; const _appConfigSchema = window.require('electron').remote.getCurrentWindow().appConfigSchema;
const _appSettings = this.props.Settings.appSettings ? this.props.Settings.appSettings : window.require('electron').remote.getCurrentWindow().appConfig;
this.setState(Object.assign({}, this.state, { this.setState(Object.assign({}, this.state, {
activeTabHeight: _height, appConfigSchema: _appConfigSchema,
appSettings: _appSettings,
})); }));
} catch(e) {}*/
console.warn(_appSettings);
} catch(e) {}
} }
componentWillUnmount() { componentWillUnmount() {
@ -120,6 +124,7 @@ class Settings extends React.Component {
if (!this.props.disableWalletSpecificUI) { if (!this.props.disableWalletSpecificUI) {
Store.dispatch(iguanaActiveHandle()); Store.dispatch(iguanaActiveHandle());
} }
Store.dispatch(getAppConfig()); Store.dispatch(getAppConfig());
Store.dispatch(getAppInfo()); Store.dispatch(getAppInfo());
} }
@ -268,7 +273,7 @@ class Settings extends React.Component {
return ( return (
<div style={{ minHeight: '200px' }}> <div style={{ minHeight: '200px' }}>
<hr /> <hr />
<h5>Progress:</h5> <h5>{ translate('SETTINGS.PROGRESS') }:</h5>
<div className="padding-bottom-15">{ items }</div> <div className="padding-bottom-15">{ items }</div>
<div className={ updateProgressBar.patch > -1 ? 'progress progress-sm' : 'hide' }> <div className={ updateProgressBar.patch > -1 ? 'progress progress-sm' : 'hide' }>
<div <div
@ -416,9 +421,18 @@ class Settings extends React.Component {
} }
} }
updateInputSettings(e) { updateInputSettings(e, parentKey, childKey) {
console.warn(parentKey + ' | ' + childKey);
let _appSettings = this.state.appSettings; let _appSettings = this.state.appSettings;
console.warn(this.state.appSettings);
if (!childKey && this.state.appConfigSchema[parentKey].type === 'boolean') {
_appSettings[parentKey] = typeof _appSettings[parentKey] !== undefined ? !_appSettings[parentKey] : !this.state.appSettings[parentKey];
} else if (childKey && this.state.appConfigSchema[parentKey].type === 'boolean') {
_appSettings[parentKey][childKey] = typeof _appSettings[parentKey][childKey] !== undefined ? !_appSettings[parentKey][childKey] : !this.state.appSettings[parentKey][childKey];
} else {
_appSettings[e.target.name] = e.target.value; _appSettings[e.target.name] = e.target.value;
}
this.setState({ this.setState({
appSettings: _appSettings, appSettings: _appSettings,
@ -443,14 +457,20 @@ class Settings extends React.Component {
renderConfigEditForm() { renderConfigEditForm() {
let items = []; let items = [];
const _appConfig = this.props.Settings.appSettings; const _appConfig = this.state.appSettings;
for (let key in _appConfig) { for (let key in _appConfig) {
if (typeof _appConfig[key] === 'object') { if (typeof _appConfig[key] === 'object') {
if (this.state.appConfigSchema[key].display) {
items.push( items.push(
<tr key={ `app-settings-${key}` }> <tr key={ `app-settings-${key}` }>
<td className="padding-15"> <td className="padding-15">
{ key } { this.state.appConfigSchema[key].displayName ? this.state.appConfigSchema[key].displayName : key }
{ this.state.appConfigSchema[key].info &&
<i
className="icon fa-question-circle settings-help"
title={ this.state.appConfigSchema[key].info }></i>
}
</td> </td>
<td className="padding-15"></td> <td className="padding-15"></td>
</tr> </tr>
@ -460,35 +480,90 @@ class Settings extends React.Component {
items.push( items.push(
<tr key={ `app-settings-${key}-${_key}` }> <tr key={ `app-settings-${key}-${_key}` }>
<td className="padding-15 padding-left-30"> <td className="padding-15 padding-left-30">
{ _key } { this.state.appConfigSchema[key][_key].displayName ? this.state.appConfigSchema[key][_key].displayName : _key }
{ this.state.appConfigSchema[key][_key].info &&
<i
className="icon fa-question-circle settings-help"
title={ this.state.appConfigSchema[key][_key].info }></i>
}
</td> </td>
<td className="padding-15"> <td className="padding-15">
{ this.state.appConfigSchema[key][_key].type === 'number' &&
<input <input
type="number"
pattern="[0-9]*"
type="text" type="text"
name={ `${key}__${_key}` } name={ `${key}__${_key}` }
defaultValue={ _appConfig[key][_key] } defaultValue={ _appConfig[key][_key] }
onChange={ this.updateInputSettings } /> onChange={ this.updateInputSettings } />
}
{ this.state.appConfigSchema[key][_key].type === 'boolean' &&
<span className="pointer toggle">
<label className="switch">
<input
type="checkbox"
name={ `${key}__${_key}` }
value={ _appConfig[key] }
checked={ _appConfig[key][_key] } />
<div
className="slider"
onClick={ (event) => this.updateInputSettings(event, key, _key) }></div>
</label>
</span>
}
</td> </td>
</tr> </tr>
); );
} }
}
} else { } else {
if (this.state.appConfigSchema[key].display) {
items.push( items.push(
<tr key={ `app-settings-${key}` }> <tr key={ `app-settings-${key}` }>
<td className="padding-15"> <td className="padding-15">
{ key } { this.state.appConfigSchema[key].displayName ? this.state.appConfigSchema[key].displayName : key }
{ this.state.appConfigSchema[key].info &&
<i
className="icon fa-question-circle settings-help"
title={ this.state.appConfigSchema[key].info }></i>
}
</td> </td>
<td className="padding-15"> <td className="padding-15">
{ this.state.appConfigSchema[key].type === 'number' &&
<input
type="number"
pattern="[0-9]*"
name={ `${key}` }
defaultValue={ _appConfig[key] }
onChange={ this.updateInputSettings } />
}
{ this.state.appConfigSchema[key].type === 'string' &&
<input <input
type="text" type="text"
name={ `${key}` } name={ `${key}` }
defaultValue={ _appConfig[key] } defaultValue={ _appConfig[key] }
onChange={ this.updateInputSettings } /> onChange={ this.updateInputSettings } />
}
{ this.state.appConfigSchema[key].type === 'boolean' &&
<span className="pointer toggle">
<label className="switch">
<input
type="checkbox"
name={ `${key}` }
value={ _appConfig[key] }
checked={ _appConfig[key] } />
<div
className="slider"
onClick={ (event) => this.updateInputSettings(event, key) }></div>
</label>
</span>
}
</td> </td>
</tr> </tr>
); );
} }
} }
}
return items; return items;
} }

2
react/src/components/dashboard/settings/settings.render.js

@ -540,7 +540,7 @@ export const SettingsRender = function() {
</tbody> </tbody>
</table> </table>
</div> </div>
<div className="col-sm-12 col-xs-12 text-align-center padding-top-25 padding-bottom-25"> <div className="col-sm-12 col-xs-12 text-align-center padding-top-35 padding-bottom-30">
<button <button
type="button" type="button"
className="btn btn-primary waves-effect waves-light" className="btn btn-primary waves-effect waves-light"

18
react/src/components/overrides.scss

@ -1056,3 +1056,21 @@ select{
} }
} }
} }
.settings-help {
font-size: 20px;
position: relative;
top: 2px;
left: 10px;
color: #5683ad;
}
#SettingsAccordion {
.toggle {
position: relative;
top: 4px;
}
table {
width: 80%;
}
}

1
react/src/translate/en.js

@ -574,6 +574,7 @@ export const _lang = {
'JUMBLR_MOTTO': 'Secure, Native and Decentralised Coin Anonymizer', 'JUMBLR_MOTTO': 'Secure, Native and Decentralised Coin Anonymizer',
}, },
'SETTINGS': { 'SETTINGS': {
'PROGRESS': 'Progress',
'SUPPORT_TICKETS': 'Support tickets', 'SUPPORT_TICKETS': 'Support tickets',
'GET_SLACK_INVITE': 'Get Slack invite', 'GET_SLACK_INVITE': 'Get Slack invite',
'ADDRESS_LIST': 'Address list', 'ADDRESS_LIST': 'Address list',

Loading…
Cancel
Save