Browse Source

reset settings to default

all-modes
pbca26 7 years ago
parent
commit
6d1bb7d236
  1. 43
      react/src/actions/actions/settings.js
  2. 12
      react/src/components/dashboard/settings/settings.js
  3. 6
      react/src/components/dashboard/settings/settings.render.js

43
react/src/actions/actions/settings.js

@ -376,7 +376,16 @@ export function saveAppConfig(_payload) {
);
})
.then(response => response.json())
.then(json => dispatch(getAppConfig()))
.then(json => {
dispatch(getAppConfig());
dispatch(
triggerToaster(
'Settings are saved',
translate('TOASTR.SETTINGS_NOTIFICATION'),
'success'
)
);
})
}
}
@ -408,4 +417,36 @@ export function getAppConfig() {
.then(response => response.json())
.then(json => dispatch(getAppConfigState(json)))
}
}
export function resetAppConfig() {
return dispatch => {
return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/appconf/reset`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(
triggerToaster(
'resetAppConfig',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => {
dispatch(getAppConfig());
dispatch(
triggerToaster(
'Settings are reset to default',
translate('TOASTR.SETTINGS_NOTIFICATION'),
'success'
)
);
})
}
}

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

@ -11,10 +11,11 @@ import {
addPeerNode,
getAppConfig,
saveAppConfig,
resetAppConfig,
getAppInfo,
shepherdCli,
checkForUpdateUIPromise,
updateUIPromise
updateUIPromise,
} from '../../../actions/actionCreators';
import Store from '../../../store';
@ -72,6 +73,7 @@ class Settings extends React.Component {
this.renderPeersList = this.renderPeersList.bind(this);
this.renderSNPeersList = this.renderSNPeersList.bind(this);
this._saveAppConfig = this._saveAppConfig.bind(this);
this._resetAppConfig = this._resetAppConfig.bind(this);
this.exportWifKeysRaw = this.exportWifKeysRaw.bind(this);
this.toggleSeedInputVisibility = this.toggleSeedInputVisibility.bind(this);
this._checkForUpdateUIPromise = this._checkForUpdateUIPromise.bind(this);
@ -97,12 +99,16 @@ class Settings extends React.Component {
}
}
_resetAppConfig() {
Store.dispatch(resetAppConfig());
}
resizeLoginTextarea() {
// auto-size textarea
setTimeout(() => {
if (this.state.seedInputVisibility) {
document.querySelector('#wifkeysPassphraseTextarea').style.height = '1px';
document.querySelector('#wifkeysPassphraseTextarea').style.height = `${(15 + document.querySelector('#wifkeysPassphraseTextarea').scrollHeight)}px`;
document.querySelector('#wifkeysPassphraseTextarea').style.height = '1px';
document.querySelector('#wifkeysPassphraseTextarea').style.height = `${(15 + document.querySelector('#wifkeysPassphraseTextarea').scrollHeight)}px`;
}
}, 100);
}

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

@ -538,6 +538,10 @@ export const SettingsRender = function() {
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this._saveAppConfig }>{ translate('SETTINGS.SAVE_APP_CONFIG') }</button>
<button
type="button"
className="btn btn-primary waves-effect waves-light margin-left-30"
onClick={ this._resetAppConfig }>Reset to default</button>
</div>
</div>
</div>
@ -570,7 +574,7 @@ export const SettingsRender = function() {
name="cliCoin"
id="settingsCliOptions"
onChange={ this.updateInput }>
<option value="">{ translate('INDEX.CLI_NATIVE_COIN') }</option>
<option>{ translate('INDEX.CLI_NATIVE_COIN') }</option>
{ this.renderActiveCoinsList('native') }
</select>
<label

Loading…
Cancel
Save