Browse Source

AGT-115, tab resize interval

v0.25
pbca26 7 years ago
parent
commit
f93ca218ca
  1. 27
      react/src/components/dashboard/settings/settings.appSettingsPanel.js
  2. 23
      react/src/components/dashboard/settings/settings.debugLogPanel.js
  3. 2
      react/src/components/dashboard/settings/settings.js
  4. 1
      react/src/components/dashboard/settings/settings.panel.js
  5. 23
      react/src/components/dashboard/settings/settings.panelBody.js

27
react/src/components/dashboard/settings/settings.appSettingsPanel.js

@ -60,7 +60,8 @@ class AppSettingsPanel extends React.Component {
if (key.indexOf('__') === -1) { if (key.indexOf('__') === -1) {
_appSettingsPristine[key] = this.state.appConfigSchema[key] && this.state.appConfigSchema[key].type === 'number' ? Number(_appSettings[key]) : _appSettings[key]; _appSettingsPristine[key] = this.state.appConfigSchema[key] && this.state.appConfigSchema[key].type === 'number' ? Number(_appSettings[key]) : _appSettings[key];
if (this.state.appConfigSchema[key] && this.state.appConfigSchema[key].type === 'folder' && if (this.state.appConfigSchema[key] &&
this.state.appConfigSchema[key].type === 'folder' &&
_appSettings[key] && _appSettings[key] &&
_appSettings[key].length) { _appSettings[key].length) {
const _testLocation = window.require('electron').remote.getCurrentWindow().testLocation; const _testLocation = window.require('electron').remote.getCurrentWindow().testLocation;
@ -72,18 +73,20 @@ class AppSettingsPanel extends React.Component {
isError = true; isError = true;
Store.dispatch( Store.dispatch(
triggerToaster( triggerToaster(
translate('TOASTR.KOMODO_DATADIR_INVALID'), this.renderLB('TOASTR.KOMODO_DATADIR_INVALID'),
translate('INDEX.SETTINGS'), translate('INDEX.SETTINGS'),
'error' 'error',
false
) )
); );
} else if (res === false) { } else if (res === false) {
isError = true; isError = true;
Store.dispatch( Store.dispatch(
triggerToaster( triggerToaster(
translate('TOASTR.KOMODO_DATADIR_NOT_DIR'), this.renderLB('TOASTR.KOMODO_DATADIR_NOT_DIR'),
translate('INDEX.SETTINGS'), translate('INDEX.SETTINGS'),
'error' 'error',
false
) )
); );
} else { } else {
@ -102,6 +105,17 @@ class AppSettingsPanel extends React.Component {
} }
} }
renderLB(_translationID) {
const _translationComponents = translate(_translationID).split('<br>');
return _translationComponents.map((_translation) =>
<span key={ `translate-${Math.random(0, 9) * 10}` }>
{_translation}
<br />
</span>
);
}
renderConfigEditForm() { renderConfigEditForm() {
let items = []; let items = [];
const _appConfig = this.state.appSettings; const _appConfig = this.state.appSettings;
@ -257,7 +271,8 @@ class AppSettingsPanel extends React.Component {
let _appSettings = this.state.appSettings; let _appSettings = this.state.appSettings;
let _appSettingsPrev = Object.assign({}, _appSettings); let _appSettingsPrev = Object.assign({}, _appSettings);
if (!childKey && this.state.appConfigSchema[parentKey].type === 'boolean') { if (!childKey &&
this.state.appConfigSchema[parentKey].type === 'boolean') {
_appSettings[parentKey] = typeof _appSettings[parentKey] !== undefined ? !_appSettings[parentKey] : !this.state.appSettings[parentKey]; _appSettings[parentKey] = typeof _appSettings[parentKey] !== undefined ? !_appSettings[parentKey] : !this.state.appSettings[parentKey];
} else if (childKey && this.state.appConfigSchema[parentKey][childKey].type === 'boolean') { } else if (childKey && this.state.appConfigSchema[parentKey][childKey].type === 'boolean') {
_appSettings[parentKey][childKey] = typeof _appSettings[parentKey][childKey] !== undefined ? !_appSettings[parentKey][childKey] : !this.state.appSettings[parentKey][childKey]; _appSettings[parentKey][childKey] = typeof _appSettings[parentKey][childKey] !== undefined ? !_appSettings[parentKey][childKey] : !this.state.appSettings[parentKey][childKey];

23
react/src/components/dashboard/settings/settings.debugLogPanel.js

@ -17,6 +17,7 @@ class DebugLogPanel extends React.Component {
debugTarget: 'iguana', debugTarget: 'iguana',
nativeOnly: Config.iguanaLessMode, nativeOnly: Config.iguanaLessMode,
toggleAppRuntimeLog: false, toggleAppRuntimeLog: false,
pristine: true,
}; };
this.readDebugLog = this.readDebugLog.bind(this); this.readDebugLog = this.readDebugLog.bind(this);
this.updateInput = this.updateInput.bind(this); this.updateInput = this.updateInput.bind(this);
@ -26,17 +27,21 @@ class DebugLogPanel extends React.Component {
} }
readDebugLog() { readDebugLog() {
this.setState(Object.assign({}, this.state, {
pristine: false,
}));
Store.dispatch( Store.dispatch(
getDebugLog( getDebugLog(
this.state.debugTarget, 'komodo',
this.state.debugLinesCount this.state.debugLinesCount
) )
); );
} }
renderAppRuntimeLog() { renderAppRuntimeLog() {
let _items = [];
const _appRuntimeLog = this.state.appRuntimeLog; const _appRuntimeLog = this.state.appRuntimeLog;
let _items = [];
for (let i = 0; i < _appRuntimeLog.length; i++) { for (let i = 0; i < _appRuntimeLog.length; i++) {
_items.push( _items.push(
@ -74,7 +79,8 @@ class DebugLogPanel extends React.Component {
} }
renderDebugLogData() { renderDebugLogData() {
if (this.props.Settings.debugLog) { if (this.props.Settings.debugLog &&
!this.state.pristine) {
const _debugLogDataRows = this.props.Settings.debugLog.split('\n'); const _debugLogDataRows = this.props.Settings.debugLog.split('\n');
if (_debugLogDataRows && if (_debugLogDataRows &&
@ -106,7 +112,9 @@ class DebugLogPanel extends React.Component {
return ( return (
<div className="row"> <div className="row">
<div className="col-sm-12"> <div className="col-sm-12">
{ this.props.Main.coins && this.props.Main.coins.native && Object.keys(this.props.Main.coins.native).length > 0 && { this.props.Main.coins &&
this.props.Main.coins.native &&
Object.keys(this.props.Main.coins.native).length > 0 &&
<p>{ translate('INDEX.DEBUG_LOG_DESC') }</p> <p>{ translate('INDEX.DEBUG_LOG_DESC') }</p>
} }
<div className="margin-top-30"> <div className="margin-top-30">
@ -123,10 +131,13 @@ class DebugLogPanel extends React.Component {
</label> </label>
<span <span
className="title" className="title"
onClick={ this.toggleAppRuntimeLog }>Show app runtime log</span> onClick={ this.toggleAppRuntimeLog }>{ translate('SETTINGS.SHOW_APP_RUNTIME_LOG') }</span>
</span> </span>
</div> </div>
{ !this.state.toggleAppRuntimeLog && this.props.Main.coins && this.props.Main.coins.native && Object.keys(this.props.Main.coins.native).length > 0 && { !this.state.toggleAppRuntimeLog &&
this.props.Main.coins &&
this.props.Main.coins.native &&
Object.keys(this.props.Main.coins.native).length > 0 &&
<form <form
className="read-debug-log-import-form" className="read-debug-log-import-form"
method="post" method="post"

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

@ -31,7 +31,7 @@ class Settings extends React.Component {
if (this.props.Main && if (this.props.Main &&
this.props.Main.coins && this.props.Main.coins &&
this.props.Main.coins.spv) { this.props.Main.coins.spv) {
for (let i = 0; this.props.Main.coins.spv.length; i++) { for (let i = 0; i < this.props.Main.coins.spv.length; i++) {
if (this.props.Dashboard.electrumCoins[this.props.Main.coins.spv[i]].serverList) { if (this.props.Dashboard.electrumCoins[this.props.Main.coins.spv[i]].serverList) {
return true; return true;
} }

1
react/src/components/dashboard/settings/settings.panel.js

@ -3,7 +3,6 @@ import className from 'classnames';
import * as Utils from './settings.panelUtils'; import * as Utils from './settings.panelUtils';
class Panel extends React.Component { class Panel extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.toggleSection = this.toggleSection.bind(this); this.toggleSection = this.toggleSection.bind(this);

23
react/src/components/dashboard/settings/settings.panelBody.js

@ -6,7 +6,8 @@ class PanelSection extends React.Component {
super(props); super(props);
this.state = { this.state = {
sectionHeight: 0, sectionHeight: 0,
} };
this.accordionResizeInterval = null;
this.toggleSection = this.toggleSection.bind(this); this.toggleSection = this.toggleSection.bind(this);
} }
@ -18,6 +19,18 @@ class PanelSection extends React.Component {
sectionHeight: this.accordionContent.scrollHeight, sectionHeight: this.accordionContent.scrollHeight,
}); });
} }
this.accordionResizeInterval = setInterval(() => {
if (this.props.active) {
this.setState({
sectionHeight: `${this.accordionContent.scrollHeight}px`,
});
}
}, 500);
}
componentWillUnmount() {
clearInterval(this.accordionResizeInterval);
} }
componentWillReceiveProps(props) { componentWillReceiveProps(props) {
@ -78,10 +91,10 @@ class PanelSection extends React.Component {
}); });
return( return(
<div <div className={triggerClasses}>
className={triggerClasses} <div
onClick={() => this.toggleSection()}> onClick={() => this.toggleSection()}
<div className="panel-heading"> className="panel-heading">
<a className="panel-title"> <a className="panel-title">
<i className={icon}></i> {title} <i className={icon}></i> {title}
</a> </a>

Loading…
Cancel
Save