Browse Source

missing cli.js

all-modes
Petr Balashov 8 years ago
parent
commit
a3dcbcc306
  1. 65
      react/src/actions/actions/cli.js

65
react/src/actions/actions/cli.js

@ -0,0 +1,65 @@
import {
triggerToaster,
Config
} from '../actionCreators';
import { CLI } from '../storeType';
import {
logGuiHttp,
guiLogState
} from './log';
export function shepherdCliPromise(mode, chain, cmd) {
const _payload = {
mode,
chain,
cmd
};
return new Promise((resolve, reject) => {
fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/cli`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'payload': _payload }),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'shepherdCli', 'Error', 'error'));
})
.then(response => response.json())
.then(json => resolve(json))
});
}
export function shepherdCli(mode, chain, cmd) {
const _payload = {
mode,
chain,
cmd
};
return dispatch => {
return fetch(`http://127.0.0.1:${Config.agamaPort}/shepherd/cli`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'payload': _payload }),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'shepherdCli', 'Error', 'error'));
})
.then(response => response.json())
.then(json => cliResponseState(json))
}
}
export function cliResponseState(json) {
console.log('cliResponseState', json);
return {
type: CLI,
data: json,
}
}
Loading…
Cancel
Save