Browse Source

es6 string literals (wip)

all-modes
Petr Balashov 8 years ago
parent
commit
3b02924553
  1. 16
      react/src/actions/addCoin.js
  2. 14
      react/src/components/toaster/toaster-item.js
  3. 49
      react/src/components/toaster/toaster.js

16
react/src/actions/addCoin.js

@ -49,10 +49,10 @@ export function addCoin(coin, mode, syncOnly, port) {
};
return dispatch => {
startIguanaInstance(modeToValue[mode] + '/sync', coin)
startIguanaInstance(`${modeToValue[mode]}/sync`, coin)
.then(function(json) {
setTimeout(function() {
console.log('started ' + coin + ' / ' + modeToValue[mode] + ' fork', json);
console.log(`started ${coin} / ${modeToValue[mode]} fork`, json);
dispatch(iguanaAddCoin(coin, mode, _acData, json.result));
}, 2000);
});
@ -79,12 +79,12 @@ export function iguanaAddCoin(coin, mode, acData, port) {
'timestamp': _timestamp,
'function': 'iguanaAddCoin',
'type': 'post',
'url': 'http://127.0.0.1:' + (port ? port : Config.iguanaCorePort),
'url': `http://127.0.0.1:${(port ? port : Config.iguanaCorePort)}`,
'payload': acData,
'status': 'pending',
}));
return fetch('http://127.0.0.1:' + (port ? port : Config.iguanaCorePort), {
return fetch(`http://127.0.0.1:${(port ? port : Config.iguanaCorePort)}`, {
method: 'POST',
body: JSON.stringify(acData),
})
@ -160,12 +160,12 @@ export function shepherdHerd(coin, mode, path) {
if (checkCoinType(coin) === 'ac') {
acData = startAssetChain(path.result, coin, mode);
const supply = startAssetChain(path.result, coin, mode, true);
herdData.ac_options.push('-ac_supply=' + supply);
herdData.ac_options.push(`-ac_supply=${supply}`);
}
console.log('herdData', herdData);
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/herd', {
return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/herd`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@ -192,7 +192,7 @@ export function addCoinResult(coin, mode) {
};
return dispatch => {
dispatch(triggerToaster(true, coin + ' ' + translate('TOASTR.STARTED_IN') + ' ' + modeToValue[mode] + ' ' + translate('TOASTR.MODE'), translate('TOASTR.COIN_NOTIFICATION'), 'success'));
dispatch(triggerToaster(true, `${coin} ${translate('TOASTR.STARTED_IN')} ${modeToValue[mode]} ${translate('TOASTR.MODE')}`, translate('TOASTR.COIN_NOTIFICATION'), 'success'));
dispatch(toggleAddcoinModal(false, false));
dispatch(getDexCoins());
}
@ -200,7 +200,7 @@ export function addCoinResult(coin, mode) {
export function _shepherdGetConfig(coin, mode) {
return dispatch => {
return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', {
return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/getconf`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',

14
react/src/components/toaster/toaster-item.js

@ -1,6 +1,6 @@
import React from "react";
import {dismissToasterMessage} from "../../actions/actionCreators";
import Store from "../../store";
import React from 'react';
import { dismissToasterMessage } from '../../actions/actionCreators';
import Store from '../../store';
// each toast will be displayed for 5 seconds
const DISPLAY_LENGTH_MILLIS = 5000;
@ -10,7 +10,6 @@ const DISPLAY_LENGTH_MILLIS = 5000;
* each messages has a type, title and a content message
*/
class ToasterItem extends React.Component {
constructor(props) {
super(props);
this.state = {
@ -60,9 +59,10 @@ class ToasterItem extends React.Component {
}
return (
<div className={ 'toast toast-' + this.state.type }>
<button className="toast-close-button" role="button"
onClick={ () => this.dismissToast(this.state.toastId) }>×
<div className={ `toast toast-${this.state.type}` }>
<button
className="toast-close-button" role="button"
onClick={ () => this.dismissToast(this.state.toastId) }>×
</button>
<div className="toast-title">{ this.state.title }</div>
<div className="toast-message">{ this.state.message }</div>

49
react/src/components/toaster/toaster.js

@ -1,7 +1,7 @@
import React from "react";
import {dismissToasterMessage} from "../../actions/actionCreators";
import Store from "../../store";
import ToasterItem from "./toaster-item";
import React from 'react';
import { dismissToasterMessage } from '../../actions/actionCreators';
import Store from '../../store';
import ToasterItem from './toaster-item';
/**
* Container component used for creating multiple toasts
@ -17,7 +17,7 @@ class Toaster extends React.Component {
componentWillReceiveProps(props) {
if (props &&
props.toasts) {
props.toasts) {
this.setState({
toasts: props.toasts,
toastId: props.toasts.length
@ -34,24 +34,33 @@ class Toaster extends React.Component {
Store.dispatch(dismissToasterMessage(toastId));
}
renderToasts() {
if (this.state.toasts &&
this.state.toasts.length) {
this.state.toasts.map((toast) => {
// sets the toastId for all new toasts
if (!toast.toastId) {
toast.toastId = this.toastId++;
}
return (
<ToasterItem key={ toast.toastId } {...toast} />
);
});
} else {
return null;
}
}
// render all current toasts
render() {
return (
<div id="toast-container"
className="single-toast toast-bottom-right"
aria-live="polite"
role="alert">
{this.state.toasts
.map((toast) => {
// sets the toastId for all new toasts
if (!toast.toastId) {
toast.toastId = this.toastId++;
}
return (
<ToasterItem key={toast.toastId} {...toast} />
);
})}
<div
id="toast-container"
className="single-toast toast-bottom-right"
aria-live="polite"
role="alert">
{ this.renderToasts() }
</div>
);
}

Loading…
Cancel
Save