conflict in api
This commit is contained in:
parent
4b4f0c1d57
commit
56e5990b1e
|
@ -1,9 +1,10 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import constants from '../constants';
|
||||||
|
|
||||||
const BASE_URL = 'http://localhost:8000/embark-api';
|
const BASE_URL = 'http://localhost:8000/embark-api';
|
||||||
|
|
||||||
export function fetchAccounts() {
|
export function fetchAccounts() {
|
||||||
return axios.get(`${BASE_URL}/blockchain/accounts`);
|
return axios.get(constants.httpEndpoint + 'blockchain/accounts');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchBlocks(from) {
|
export function fetchBlocks(from) {
|
||||||
|
@ -15,5 +16,5 @@ export function fetchTransactions(blockFrom) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchProcesses() {
|
export function fetchProcesses() {
|
||||||
return axios.get(`${BASE_URL}/processes`);
|
return axios.get(constants.httpEndpoint + 'processes');
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
import {Tab} from "tabler-react";
|
||||||
|
import constants from '../constants';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
class Process extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
logs: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
const self = this;
|
||||||
|
this.ws = new WebSocket(constants.wsEndpoint + 'process-logs/' + self.props.processName);
|
||||||
|
|
||||||
|
this.ws.onmessage = function(evt) {
|
||||||
|
const log = JSON.parse(evt.data);
|
||||||
|
const logs = self.state.logs;
|
||||||
|
logs.push(log);
|
||||||
|
self.setState({
|
||||||
|
logs
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
this.ws.onclose = function() {
|
||||||
|
console.log(self.props.processName + "Log process connection is closed");
|
||||||
|
};
|
||||||
|
|
||||||
|
window.onbeforeunload = function(_event) {
|
||||||
|
this.ws.close();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.ws.close();
|
||||||
|
this.ws = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
State: {this.props.state}
|
||||||
|
<div className="logs">
|
||||||
|
{
|
||||||
|
this.state.logs.map((item, i) => <p key={i} className={item.logLevel}>{item.msg}</p>)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process.propTypes = {
|
||||||
|
processName: PropTypes.string,
|
||||||
|
state: PropTypes.string
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Process;
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"httpEndpoint": "http://localhost:8000/embark-api/",
|
||||||
|
"wsEndpoint": "ws://localhost:8000/embark-api/"
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import {fetchProcesses} from '../actions';
|
||||||
import Loading from '../components/Loading';
|
import Loading from '../components/Loading';
|
||||||
|
|
||||||
import "./css/processContainer.css";
|
import "./css/processContainer.css";
|
||||||
|
import Process from "../components/Process";
|
||||||
|
|
||||||
class ProcessesContainer extends Component {
|
class ProcessesContainer extends Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -32,7 +33,9 @@ class ProcessesContainer extends Component {
|
||||||
<div className="processes-container">
|
<div className="processes-container">
|
||||||
<Tabs initialTab={processNames[0]}>
|
<Tabs initialTab={processNames[0]}>
|
||||||
{processNames.map(processName => {
|
{processNames.map(processName => {
|
||||||
return (<Tab key={processName} title={processName}>State: {processes.data[processName].state}</Tab>);
|
return (<Tab key={processName} title={processName}>
|
||||||
|
<Process processName={processName} state={processes.data[processName].state}/>
|
||||||
|
</Tab>);
|
||||||
})}
|
})}
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,3 +2,26 @@
|
||||||
.processes-container .nav-link {
|
.processes-container .nav-link {
|
||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.processes-container .logs {
|
||||||
|
margin: 10px 0;
|
||||||
|
background-color: #333333;
|
||||||
|
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
||||||
|
font-size: 14px;
|
||||||
|
color: white;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.processes-container .logs .error {
|
||||||
|
color: #dc3546;
|
||||||
|
}
|
||||||
|
.processes-container .logs .warn {
|
||||||
|
color: #fec107;
|
||||||
|
}
|
||||||
|
.processes-container .logs .debug {
|
||||||
|
color: #b7c1cc;
|
||||||
|
}
|
||||||
|
.processes-container .logs .trace {
|
||||||
|
color: #8f98a2;
|
||||||
|
}
|
||||||
|
|
|
@ -223,8 +223,9 @@ Plugin.prototype.registerActionForEvent = function(eventName, cb) {
|
||||||
|
|
||||||
Plugin.prototype.registerAPICall = function(method, endpoint, cb) {
|
Plugin.prototype.registerAPICall = function(method, endpoint, cb) {
|
||||||
console.dir("registerAPICall " + method + " " + endpoint);
|
console.dir("registerAPICall " + method + " " + endpoint);
|
||||||
this.apiCalls.push({method: method, endpoint: endpoint, cb: cb});
|
this.apiCalls.push({method, endpoint, cb});
|
||||||
this.addPluginType('apiCalls');
|
this.addPluginType('apiCalls');
|
||||||
|
this.events.emit('plugins:register:api', {method, endpoint, cb});
|
||||||
};
|
};
|
||||||
|
|
||||||
Plugin.prototype.runFilePipeline = function() {
|
Plugin.prototype.runFilePipeline = function() {
|
||||||
|
|
|
@ -11,6 +11,7 @@ class BlockchainProcessLauncher {
|
||||||
this.blockchainConfig = options.blockchainConfig;
|
this.blockchainConfig = options.blockchainConfig;
|
||||||
this.locale = options.locale;
|
this.locale = options.locale;
|
||||||
this.isDev = options.isDev;
|
this.isDev = options.isDev;
|
||||||
|
this.embark = options.embark;
|
||||||
}
|
}
|
||||||
|
|
||||||
processEnded(code) {
|
processEnded(code) {
|
||||||
|
@ -21,16 +22,17 @@ class BlockchainProcessLauncher {
|
||||||
this.logger.info(__('Starting Blockchain node in another process').cyan);
|
this.logger.info(__('Starting Blockchain node in another process').cyan);
|
||||||
|
|
||||||
this.blockchainProcess = new ProcessLauncher({
|
this.blockchainProcess = new ProcessLauncher({
|
||||||
|
name: 'blockchain',
|
||||||
modulePath: utils.joinPath(__dirname, './blockchainProcess.js'),
|
modulePath: utils.joinPath(__dirname, './blockchainProcess.js'),
|
||||||
logger: this.logger,
|
logger: this.logger,
|
||||||
events: this.events,
|
events: this.events,
|
||||||
|
embark: this.embark,
|
||||||
silent: this.logger.logLevel !== 'trace',
|
silent: this.logger.logLevel !== 'trace',
|
||||||
exitCallback: this.processEnded.bind(this)
|
exitCallback: this.processEnded.bind(this)
|
||||||
});
|
});
|
||||||
this.blockchainProcess.send({
|
this.blockchainProcess.send({
|
||||||
action: constants.blockchain.init, options: {
|
action: constants.blockchain.init, options: {
|
||||||
blockchainConfig: this.blockchainConfig,
|
blockchainConfig: this.blockchainConfig,
|
||||||
//client: this.client,
|
|
||||||
// TODO: assume for now it's geth
|
// TODO: assume for now it's geth
|
||||||
client: 'geth',
|
client: 'geth',
|
||||||
env: this.env,
|
env: this.env,
|
||||||
|
@ -45,7 +47,7 @@ class BlockchainProcessLauncher {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.blockchainProcess.once('result', constants.blockchain.blockchainExit, () => {
|
this.blockchainProcess.once('result', constants.blockchain.blockchainExit, () => {
|
||||||
// telle everyone that our blockchain process (ie geth) died
|
// tell everyone that our blockchain process (ie geth) died
|
||||||
this.events.emit(constants.blockchain.blockchainExit);
|
this.events.emit(constants.blockchain.blockchainExit);
|
||||||
|
|
||||||
// then kill off the blockchain process
|
// then kill off the blockchain process
|
||||||
|
|
|
@ -72,7 +72,8 @@ class BlockchainModule {
|
||||||
normalizeInput: utils.normalizeInput,
|
normalizeInput: utils.normalizeInput,
|
||||||
blockchainConfig: self.blockchainConfig,
|
blockchainConfig: self.blockchainConfig,
|
||||||
locale: self.locale,
|
locale: self.locale,
|
||||||
isDev: self.isDev
|
isDev: self.isDev,
|
||||||
|
embark: this.embark
|
||||||
});
|
});
|
||||||
|
|
||||||
blockchainProcess.startBlockchainNode();
|
blockchainProcess.startBlockchainNode();
|
||||||
|
|
|
@ -79,6 +79,8 @@ class Server {
|
||||||
ws.addEventListener('open', _event => {
|
ws.addEventListener('open', _event => {
|
||||||
ws.send('outputDone');
|
ws.send('outputDone');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.app.get('/embark/*', function (req, res) {
|
this.app.get('/embark/*', function (req, res) {
|
||||||
self.logger.trace('webserver> GET ' + req.path);
|
self.logger.trace('webserver> GET ' + req.path);
|
||||||
|
|
Loading…
Reference in New Issue