Browse Source

app config (wip)

all-modes
pbca26 8 years ago
parent
commit
0792bf86bd
  1. 54
      react/src/actions/actionCreators.js
  2. 2
      react/src/components/dashboard/navbar.js
  3. 3
      react/src/components/dashboard/sendCoin.js
  4. 96
      react/src/components/dashboard/settings.js
  5. 18
      react/src/reducers/settings.js
  6. 4
      react/src/util/cacheFormat.js

54
react/src/actions/actionCreators.js

@ -53,6 +53,7 @@ export const LOAD_APP_CONFIG = 'LOAD_APP_CONFIG';
export const SAVE_APP_CONFIG = 'SAVE_APP_CONFIG'; export const SAVE_APP_CONFIG = 'SAVE_APP_CONFIG';
export const SERVICE_ERROR = 'SERVICE_ERROR'; export const SERVICE_ERROR = 'SERVICE_ERROR';
export const DASHBOARD_ACTIVE_ADDRESS = 'DASHBOARD_ACTIVE_ADDRESS'; export const DASHBOARD_ACTIVE_ADDRESS = 'DASHBOARD_ACTIVE_ADDRESS';
export const LOAD_APP_INFO = 'LOAD_APP_INFO';
var iguanaForks = {}; // forks in mem array var iguanaForks = {}; // forks in mem array
@ -2493,28 +2494,23 @@ export function edexGetTransaction(data) {
}); });
} }
/*export function saveAppConfig() { export function saveAppConfig(_payload) {
const payload = {
'herdname': target,
'lastLines': linesCount
};
return dispatch => { return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/debuglog', { return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appconf', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify(payload), body: JSON.stringify(_payload),
}) })
.catch(function(error) { .catch(function(error) {
console.log(error); console.log(error);
dispatch(triggerToaster(true, 'getDebugLog', 'Error', 'error')); dispatch(triggerToaster(true, 'saveAppConfig', 'Error', 'error'));
}) })
.then(response => response.json()) .then(response => response.json())
.then(json => dispatch(getDebugLogState(json))) .then(json => dispatch(getAppConfigState(json)))
} }
}*/ }
function getAppConfigState(json) { function getAppConfigState(json) {
return { return {
@ -2622,16 +2618,26 @@ export function shepherdPostCoinList(data) {
}); });
} }
/*function Shepherd_SendPendValue() { function getAppInfoState(json) {
Shepherd_SysInfo().then(function(result){ return {
var ram_data = formatBytes(result.totalmem_bytes) type: LOAD_APP_INFO,
var pend_val = null; info: json,
if (ram_data.size === 'GB') { }
if (ram_data.ramsize >= '63' ) { pend_val = 16; } }
if (ram_data.ramsize >= '31' ) { pend_val = 8; }
if (ram_data.ramsize >= '15' ) { pend_val = 4; } export function getAppInfo() {
if (ram_data.ramsize <= '15' ) { pend_val = 1; } return dispatch => {
} else { pend_val = 1; } return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appinfo', {
sessionStorage.setItem('IguanaPendValue', pend_val); method: 'GET',
}) headers: {
}*/ 'Content-Type': 'application/json',
},
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'getAppInfo', 'Error', 'error'));
})
.then(response => response.json())
.then(json => dispatch(getAppInfoState(json)))
}
}

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

@ -76,7 +76,7 @@ class Navbar extends React.Component {
<i className="site-menu-icon" aria-hidden="true"></i> EasyDEX <i className="site-menu-icon" aria-hidden="true"></i> EasyDEX
</a> </a>
</li> </li>
<li className={this.props.Dashboard.activeSection === 'jumblr' ? 'active nav-top-menu' : 'nav-top-menu'}> <li className={this.props.Dashboard.activeSection === 'jumblr' ? 'active nav-top-menu' : 'nav-top-menu'} style={{display: 'none'}}>
<a href="javascript:void(0)" id="nav-jumblr" onClick={() => this.dashboardChangeSection('jumblr')}> <a href="javascript:void(0)" id="nav-jumblr" onClick={() => this.dashboardChangeSection('jumblr')}>
<i className="site-menu-icon" aria-hidden="true"></i> Jumblr <i className="site-menu-icon" aria-hidden="true"></i> Jumblr
</a> </a>

3
react/src/components/dashboard/sendCoin.js

@ -288,6 +288,7 @@ class SendCoin extends React.Component {
const utxoSet = (refreshData && refreshData.data) || (listunspentData && listunspentData.data); const utxoSet = (refreshData && refreshData.data) || (listunspentData && listunspentData.data);
const _pubkey = this.props.Dashboard.activeHandle.pubkey; const _pubkey = this.props.Dashboard.activeHandle.pubkey;
const forceUpdateCache = this._fetchNewUTXOData; const forceUpdateCache = this._fetchNewUTXOData;
const _sendFrom = this.state.sendFrom;
const sendData = { const sendData = {
'coin': this.props.ActiveCoin.coin, 'coin': this.props.ActiveCoin.coin,
'sendfrom': this.state.sendFrom, 'sendfrom': this.state.sendFrom,
@ -356,7 +357,7 @@ class SendCoin extends React.Component {
getCacheFile(_pubkey) getCacheFile(_pubkey)
.then(function(result) { .then(function(result) {
console.log('got cache file', result); console.log('got cache file', result);
let saveThisData = edexRemoveTXID(result.result, txidListToRemove); let saveThisData = edexRemoveTXID(result.result, _sendFrom, txidListToRemove);
console.log('saveThisData', saveThisData); console.log('saveThisData', saveThisData);
resolve(saveThisData); resolve(saveThisData);
}); });

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

@ -8,7 +8,9 @@ import {
getDebugLog, getDebugLog,
getPeersList, getPeersList,
addPeerNode, addPeerNode,
getAppConfig getAppConfig,
saveAppConfig,
getAppInfo
} from '../../actions/actionCreators'; } from '../../actions/actionCreators';
import Store from '../../store'; import Store from '../../store';
import AddCoinOptionsCrypto from '../addcoin/addcoinOptionsCrypto'; import AddCoinOptionsCrypto from '../addcoin/addcoinOptionsCrypto';
@ -30,6 +32,7 @@ class Settings extends React.Component {
debugLinesCount: 10, debugLinesCount: 10,
debugTarget: 'iguana', debugTarget: 'iguana',
activeTabHeight: '10px', activeTabHeight: '10px',
appSettings: [],
}; };
this.exportWifKeys = this.exportWifKeys.bind(this); this.exportWifKeys = this.exportWifKeys.bind(this);
this.updateInput = this.updateInput.bind(this); this.updateInput = this.updateInput.bind(this);
@ -44,12 +47,16 @@ class Settings extends React.Component {
componentDidMount() { componentDidMount() {
Store.dispatch(iguanaActiveHandle()); Store.dispatch(iguanaActiveHandle());
Store.dispatch(getAppConfig()); Store.dispatch(getAppConfig());
Store.dispatch(getAppInfo());
}
_saveAppConfig() {
Store.dispatch(saveAppConfig);
} }
openTab(elemId, tab) { openTab(elemId, tab) {
console.log(elemId);
const _height = document.querySelector('#' + elemId + ' .panel-collapse .panel-body').clientHeight; const _height = document.querySelector('#' + elemId + ' .panel-collapse .panel-body').clientHeight;
console.log(_height);
this.setState(Object.assign({}, this.state, { this.setState(Object.assign({}, this.state, {
activeTab: tab, activeTab: tab,
activeTabHeight: _height, activeTabHeight: _height,
@ -112,6 +119,51 @@ class Settings extends React.Component {
} }
} }
renderConfigEditForm() {
console.log(this.props.Settings.appSettings);
let items = [];
const _appConfig = this.props.Settings.appSettings;
for (let key in this.props.Settings.appSettings) {
if (Object.keys(this.props.Settings.appSettings[key]).length && key !== 'host') {
items.push(
<tr key={`app-settings-${key}`}>
<td style={{padding: '15px'}}>
{key}
</td>
<td style={{padding: '15px'}}></td>
</tr>
);
for (let _key in this.props.Settings.appSettings[key]) {
items.push(
<tr key={`app-settings-${key}-${_key}`}>
<td style={{padding: '15px', paddingLeft: '30px'}}>
{_key}
</td>
<td style={{padding: '15px'}}>
<input type="text" name={`app-settings-${_key}-edit`} defaultValue={_appConfig[key][_key]} />
</td>
</tr>
);
}
} else {
items.push(
<tr key={`app-settings-${key}`}>
<td style={{padding: '15px'}}>
{key}
</td>
<td style={{padding: '15px'}}>
<input type="text" name={`app-settings-${key}-edit`} defaultValue={_appConfig[key]} />
</td>
</tr>
);
}
}
return items;
}
updateInput(e) { updateInput(e) {
this.setState({ this.setState({
[e.target.name]: e.target.value, [e.target.name]: e.target.value,
@ -393,13 +445,45 @@ class Settings extends React.Component {
<div className="panel" id="AppSettings"> <div className="panel" id="AppSettings">
<div className="panel-heading" role="tab" onClick={() => this.openTab('AppSettings', 7)}> <div className="panel-heading" role="tab" onClick={() => this.openTab('AppSettings', 7)}>
<a className={this.state.activeTab === 6 ? 'panel-title' : 'panel-title collapsed'} data-toggle="collapse" data-parent="#AppSettings"> <a className={this.state.activeTab === 7 ? 'panel-title' : 'panel-title collapsed'} data-toggle="collapse" data-parent="#AppSettings">
<i className="icon md-info" aria-hidden="true"></i>App Settings (config.json) <i className="icon md-info" aria-hidden="true"></i>App Config (config.json)
</a> </a>
</div> </div>
<div className={this.state.activeTab === 7 ? 'panel-collapse collapse in' : 'panel-collapse collapse'} style={{height: this.state.activeTab === 7 ? this.state.activeTabHeight + 'px' : '10px'}} id="DebugLogTab" aria-labelledby="DebugLog" role="tabpanel"> <div className={this.state.activeTab === 7 ? 'panel-collapse collapse in' : 'panel-collapse collapse'} style={{height: this.state.activeTab === 7 ? this.state.activeTabHeight + 'px' : '10px'}} id="DebugLogTab" aria-labelledby="DebugLog" role="tabpanel">
<div className="panel-body"> <div className="panel-body">
<p>Manage app settings</p> <p>Manage app config</p>
<p>
<strong>Most changes to app config require wallet restart!</strong>
</p>
<div className="col-sm-12"></div>
<form className="read-debug-log-import-form" method="post" action="javascript:" autoComplete="off">
<div className="col-sm-12" style={{paddingTop: '15px'}}>
<div className="row" data-plugin="masonry"></div>
</div>
<div className="col-sm-12" style={{paddingTop: '15px'}}>
<table>
<tbody>
{this.renderConfigEditForm()}
</tbody>
</table>
</div>
<div className="col-sm-12 col-xs-12" style={{textAlign: 'center'}}>
<button type="button" className="btn btn-primary waves-effect waves-light" data-toggle="modal" data-dismiss="modal" id="read_debug_log_btn" onClick={this._saveAppConfig}>Save app config</button>
</div>
</form>
</div>
</div>
</div>
<div className="panel" id="AppInfo">
<div className="panel-heading" role="tab" onClick={() => this.openTab('AppInfo', 8)}>
<a className={this.state.activeTab === 8 ? 'panel-title' : 'panel-title collapsed'} data-toggle="collapse" data-parent="#AppInfoAccordion">
<i className="icon md-info" aria-hidden="true"></i>App Info
</a>
</div>
<div className={this.state.activeTab === 8 ? 'panel-collapse collapse in' : 'panel-collapse collapse'} style={{height: this.state.activeTab === 8 ? this.state.activeTabHeight + 'px' : '10px'}} aria-labelledby="DebugLog" role="tabpanel">
<div className="panel-body">
<p>{translate('INDEX.DEBUG_LOG_DESC')}</p>
<div className="col-sm-12"></div> <div className="col-sm-12"></div>
<form className="read-debug-log-import-form" method="post" action="javascript:" autoComplete="off"> <form className="read-debug-log-import-form" method="post" action="javascript:" autoComplete="off">
<div className="form-group form-material floating"> <div className="form-group form-material floating">

18
react/src/reducers/settings.js

@ -1,9 +1,17 @@
import { GET_WIF_KEY, GET_PEERS_LIST, GET_DEBUG_LOG } from '../actions/actionCreators'; import {
GET_WIF_KEY,
GET_PEERS_LIST,
GET_DEBUG_LOG,
LOAD_APP_CONFIG,
LOAD_APP_INFO
} from '../actions/actionCreators';
export function Settings(state = { export function Settings(state = {
wifkey: null, wifkey: null,
address: null, address: null,
debugLog: null, debugLog: null,
appSettings: null,
appInfo: null,
}, action) { }, action) {
switch (action.type) { switch (action.type) {
case GET_WIF_KEY: case GET_WIF_KEY:
@ -20,6 +28,14 @@ export function Settings(state = {
return Object.assign({}, state, { return Object.assign({}, state, {
debugLog: action.data, debugLog: action.data,
}); });
case LOAD_APP_CONFIG:
return Object.assign({}, state, {
appSettings: action.config,
});
case LOAD_APP_INFO:
return Object.assign({}, state, {
appInfo: action.info,
});
default: default:
return state; return state;
} }

4
react/src/util/cacheFormat.js

@ -10,7 +10,7 @@ export function edexGetTxIDList(getTxData) {
return getTxidList; return getTxidList;
} }
export function edexRemoveTXID(_obj, txidArray) { export function edexRemoveTXID(_obj, address, txidArray) {
let txidToStr = ':' + txidArray.join(':') + ':'; let txidToStr = ':' + txidArray.join(':') + ':';
console.log(txidToStr); console.log(txidToStr);
@ -21,7 +21,7 @@ export function edexRemoveTXID(_obj, txidArray) {
} else { } else {
for (let key in _obj.basilisk) { for (let key in _obj.basilisk) {
for (let coinAddr in _obj.basilisk[key]) { for (let coinAddr in _obj.basilisk[key]) {
if (_obj.basilisk[key][coinAddr] !== 'addresses') { if (_obj.basilisk[key][coinAddr] !== 'addresses' && coinAddr === address) {
if (_obj.basilisk[key][coinAddr].refresh && if (_obj.basilisk[key][coinAddr].refresh &&
_obj.basilisk[key][coinAddr].refresh.data && _obj.basilisk[key][coinAddr].refresh.data &&
_obj.basilisk[key][coinAddr].refresh.data.length > 0) { _obj.basilisk[key][coinAddr].refresh.data.length > 0) {

Loading…
Cancel
Save