Browse Source

coind down modal fetch daemon stdout by default

v0.25
pbca26 7 years ago
parent
commit
fc5c0007d4
  1. 29
      react/src/actions/actions/settings.js
  2. 2
      react/src/components/dashboard/coinTile/coinTileItem.js
  3. 47
      react/src/components/dashboard/coindDownModal/coindDownModal.js
  4. 28
      react/src/components/dashboard/coindDownModal/coindDownModal.render.js
  5. 7
      react/src/components/overrides.scss

29
react/src/actions/actions/settings.js

@ -386,4 +386,31 @@ export function resetAppConfig() {
);
})
}
}
}
export function coindGetStdout(chain) {
const _chain = chain === 'KMD' ? 'komodod' : chain;
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/coind/stdout?chain=${chain}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
}
})
.catch((error) => {
console.log(error);
dispatch(
triggerToaster(
'coindGetStdout',
'Error',
'error'
)
);
})
.then(response => response.json())
.then(json => {
resolve(json);
});
});
}

2
react/src/components/dashboard/coinTile/coinTileItem.js

@ -33,7 +33,7 @@ import CoinTileItemRender from './coinTileItem.render';
const SPV_DASHBOARD_UPDATE_TIMEOUT = 60000;
const ACTIVE_HANDLE_TIMEOUT_COIND_NATIVE = 15000;
const COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD = 2; //window.require('electron').remote.getCurrentWindow().appConfig.failedRPCAttemptsThreshold || 10;
const COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD = window.require('electron').remote.getCurrentWindow().appConfig.failedRPCAttemptsThreshold || 10;
class CoinTileItem extends React.Component {
constructor() {

47
react/src/components/dashboard/coindDownModal/coindDownModal.js

@ -1,21 +1,58 @@
import React from 'react';
import { connect } from 'react-redux';
import { toggleCoindDownModal } from '../../../actions/actionCreators';
import {
toggleCoindDownModal,
coindGetStdout,
getDebugLog,
} from '../../../actions/actionCreators';
import Store from '../../../store';
import CoindDownModalRender from './coindDownModal.render';
const COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD = 2; //window.require('electron').remote.getCurrentWindow().appConfig.failedRPCAttemptsThreshold || 10;
const COIND_DOWN_MODAL_FETCH_FAILURES_THRESHOLD = window.require('electron').remote.getCurrentWindow().appConfig.failedRPCAttemptsThreshold || 10;
class CoindDownModal extends React.Component {
constructor() {
super();
this.state = {
display: false,
debugLogCrash: null,
kmdMainPassiveMode: false,
coindStdOut: 'Loading...',
toggleDebugLog: true,
};
this.dismiss = this.dismiss.bind(this);
this.getCoindGetStdout = this.getCoindGetStdout.bind(this);
this.toggleDebugLog = this.toggleDebugLog.bind(this);
this.refreshDebugLog = this.refreshDebugLog.bind(this);
}
refreshDebugLog() {
const _coin = this.props.ActiveCoin.coin;
if (!this.state.toggleDebugLog) {
if (_coin === 'KMD') {
Store.dispatch(getDebugLog('komodo', 50));
} else {
Store.dispatch(getDebugLog('komodo', 50, _coin));
}
} else {
this.getCoindGetStdout();
}
}
toggleDebugLog() {
this.setState({
toggleDebugLog: !this.state.toggleDebugLog,
});
}
getCoindGetStdout() {
coindGetStdout(this.props.ActiveCoin.coin)
.then((res) => {
this.setState({
coindStdOut: res.msg === 'success' ? res.result : `Error reading ${this.props.ActiveCoin.coin} stdout`,
});
});
}
dismiss() {
@ -39,6 +76,10 @@ class CoindDownModal extends React.Component {
this.setState(Object.assign({}, this.state, {
display: nextProps.displayCoindDownModal,
}));
if (nextProps.displayCoindDownModal) {
this.getCoindGetStdout();
}
}
}

28
react/src/components/dashboard/coindDownModal/coindDownModal.render.js

@ -27,12 +27,36 @@ const CoindDownModalRender = function() {
<div className="modal-body">
<div className="vertical-align text-center">
<div className="page-content vertical-align-middle">
<strong>Debug.log ({ translate('INDEX.LAST_50_LINES') })</strong>
<i
className="icon fa-refresh manual-debuglog-refresh pointer"
onClick={ this.refreshDebugLog }></i>
<div className="text-left">
<label className="switch">
<input
type="checkbox"
value="on"
checked={ this.state.toggleDebugLog } />
<div
className="slider"
onClick={ this.toggleDebugLog }></div>
</label>
<div
className="toggle-label margin-right-15 pointer"
onClick={ this.toggleDebugLog }>
Show debug.log
</div>
</div>
{ !this.state.toggleDebugLog &&
<strong>Debug.log ({ translate('INDEX.LAST_50_LINES') })</strong>
}
{ this.state.toggleDebugLog &&
<strong>{ this.props.ActiveCoin.coin === 'KMD' ? 'Komodod' : `Komodod / ${this.props.ActiveCoin.coin} stdout` }</strong>
}
<div className="form-group form-material floating">
<textarea
readOnly
className="form-control"
value={ _debuglog }></textarea>
value={ !this.state.toggleDebugLog ? _debuglog : this.state.coindStdOut }></textarea>
</div>
<button
type="button"

7
react/src/components/overrides.scss

@ -529,4 +529,11 @@ select{
tbody > tr > td {
border: none;
}
}
.manual-debuglog-refresh {
position: absolute;
top: 40px;
right: 40px;
font-size: 20px;
}
Loading…
Cancel
Save