summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-05-26 23:58:46 +0200
committerJules Laplace <julescarbon@gmail.com>2018-05-26 23:58:46 +0200
commit66dfb9e5ca6b3e2990d9b70314d404074b1be0cb (patch)
tree0944916eb1d89f145a4fe67ea11fe2bc6afe116f /app
parent1d4fca365ae76f193c05da6eb1d58b41b171e359 (diff)
streaming script output to the browser
Diffstat (limited to 'app')
-rw-r--r--app/client/socket/socket.task.js4
-rw-r--r--app/client/system/system.component.js9
-rw-r--r--app/client/system/system.reducer.js16
-rw-r--r--app/client/types.js2
4 files changed, 26 insertions, 5 deletions
diff --git a/app/client/socket/socket.task.js b/app/client/socket/socket.task.js
index 938c533..00b310f 100644
--- a/app/client/socket/socket.task.js
+++ b/app/client/socket/socket.task.js
@@ -18,10 +18,10 @@ socket.on('task_res', (data) => {
case 'kill':
break
case 'stdout':
- console.log(data.data)
+ return dispatch({ type: types.system.stdout, data: data.data })
break
case 'stderr':
- console.log(data.data)
+ return dispatch({ type: types.system.stderr, data: data.data })
break
case 'add':
break
diff --git a/app/client/system/system.component.js b/app/client/system/system.component.js
index f8cf139..07428e5 100644
--- a/app/client/system/system.component.js
+++ b/app/client/system/system.component.js
@@ -90,7 +90,7 @@ class System extends Component {
)
}
renderCommandOutput(){
- const { cmd } = this.props
+ const { cmd, stdout, stderr } = this.props
let output
if (cmd.loading) {
output = 'Loading: ' + cmd.name
@@ -106,6 +106,13 @@ class System extends Component {
}
}
}
+ else {
+ output = stdout
+ if (cmd.stderr) {
+ output += '\n\n_________________________________\n\n'
+ output += stderr
+ }
+ }
return (
<div>
<div className='screen'>{output}</div>
diff --git a/app/client/system/system.reducer.js b/app/client/system/system.reducer.js
index ac7b20e..2a58cd7 100644
--- a/app/client/system/system.reducer.js
+++ b/app/client/system/system.reducer.js
@@ -31,9 +31,11 @@ const systemInitialState = {
loaded: false,
name: null,
error: null,
- stdout: null,
- stderr: null,
+ stdout: "",
+ stderr: "",
},
+ stdout: "",
+ stderr: "",
}
const systemReducer = (state = systemInitialState, action) => {
@@ -142,6 +144,16 @@ const systemReducer = (state = systemInitialState, action) => {
stderr: action.data.stderr,
}
}
+ case types.system.stdout:
+ return {
+ ...state,
+ stdout: state.stdout + action.data,
+ }
+ case types.system.stderr:
+ return {
+ ...state,
+ stderr: state.stderr + action.data,
+ }
default:
return state
}
diff --git a/app/client/types.js b/app/client/types.js
index f78265f..5598e63 100644
--- a/app/client/types.js
+++ b/app/client/types.js
@@ -6,6 +6,8 @@ export default {
relay_disconnected: 'SYSTEM_RELAY_DISCONNECTED',
rpc_connected: 'SYSTEM_RPC_CONNECTED',
rpc_disconnected: 'SYSTEM_RPC_DISCONNECTED',
+ stdout: 'SYSTEM_STDOUT',
+ stderr: 'SYSTEM_STDERR',
},
task: {
starting_task: 'TASK_STARTING_TASK',