diff options
Diffstat (limited to 'app/client')
| -rw-r--r-- | app/client/socket/socket.actions.js | 10 | ||||
| -rw-r--r-- | app/client/socket/socket.system.js | 31 | ||||
| -rw-r--r-- | app/client/system/system.actions.js | 22 | ||||
| -rw-r--r-- | app/client/system/system.component.js | 12 |
4 files changed, 28 insertions, 47 deletions
diff --git a/app/client/socket/socket.actions.js b/app/client/socket/socket.actions.js index b1f13ef..dc8d6fc 100644 --- a/app/client/socket/socket.actions.js +++ b/app/client/socket/socket.actions.js @@ -1,9 +1,3 @@ -import { - list_directory_async, - run_system_command_async, - run_script_async, -} from './socket.system' +import * as socketActions from './socket.system' -export const list_directory = list_directory_async -export const run_system_command = run_system_command_async -export const run_script = run_script_async
\ No newline at end of file +export default socketActions diff --git a/app/client/socket/socket.system.js b/app/client/socket/socket.system.js index 5c1e294..5279d21 100644 --- a/app/client/socket/socket.system.js +++ b/app/client/socket/socket.system.js @@ -28,43 +28,18 @@ socket.on('system_res', (data) => { type: data.rpc_connected ? types.system.rpc_connected : types.system.rpc_disconnected, runner: data.runner, }) - // case 'run_system_command': - // return dispatch({ - // type: types.system.command_output, - // data: data, - // }) - // case 'list_directory': - // return dispatch({ - // type: types.system.list_directory, - // data: data, - // }) - // break default: break } }) -export function run_system_command(cmd) { - socket.emit('system', { - cmd: 'run_system_command', - payload: cmd, - }) -} - -export function list_directory(opt) { - socket.emit('system', { - cmd: 'list_directory', - payload: opt, - }) -} - -export function run_system_command_async(opt) { +export function run_system_command(opt) { return syscall_async('run_system_command', opt) } -export function list_directory_async(opt) { +export function list_directory(opt) { return syscall_async('list_directory', opt).then(res => res.files) } -export function run_script_async(opt) { +export function run_script(opt) { return syscall_async('run_script', opt) } export const syscall_async = (tag, payload, ttl=10000) => { diff --git a/app/client/system/system.actions.js b/app/client/system/system.actions.js index a318d68..2e5f783 100644 --- a/app/client/system/system.actions.js +++ b/app/client/system/system.actions.js @@ -1,16 +1,28 @@ import socket from '../socket' import types from '../types' -export const run = (cmd) => { +export const run = (cmd) => (dispatch) => { + dispatch({ type: types.system.running_command, cmd }) socket.system.run_system_command(cmd) - return { type: types.system.running_command, cmd } + .then(data => { + dispatch({ + type: types.system.command_output, + data: data, + }) + }) } -export const listDirectory = (opt) => { +export const listDirectory = (opt) => (dispatch) => { + dispatch({ type: types.system.listing_directory, opt }) socket.system.list_directory(opt) - return { type: types.system.listing_directory, opt } + .then(data => { + dispatch({ + type: types.system.list_directory, + data: data, + }) + }) } export const changeTool = (tool) => { return { type: types.app.change_tool, tool } -}
\ No newline at end of file +} diff --git a/app/client/system/system.component.js b/app/client/system/system.component.js index a4be0c9..d0e6d48 100644 --- a/app/client/system/system.component.js +++ b/app/client/system/system.component.js @@ -78,16 +78,16 @@ class System extends Component { </Group> <Group title="Test"> <Param title='CPU Test Task'> - <button onClick={() => actions.task.start_task(cpu_test_task, { preempt: true, watch: true })}>Start</button> - <button onClick={() => actions.task.stop_task(runner.cpu.task)}>Stop</button> + <button onClick={() => actions.queue.start_task(cpu_test_task, { preempt: true, watch: true })}>Start</button> + <button onClick={() => actions.queue.stop_task(runner.cpu.task)}>Stop</button> </Param> <Param title='GPU Test Task'> - <button onClick={() => actions.task.start_task(gpu_test_task, { preempt: true, watch: true })}>Start</button> - <button onClick={() => actions.task.stop_task(runner.gpu.task)}>Stop</button> + <button onClick={() => actions.queue.start_task(gpu_test_task, { preempt: true, watch: true })}>Start</button> + <button onClick={() => actions.queue.stop_task(runner.gpu.task)}>Stop</button> </Param> <Param title='Live Test Task'> - <button onClick={() => actions.task.start_task(live_test_task, { preempt: true, watch: true })}>Start</button> - <button onClick={() => actions.task.stop_task(runner.cpu.task)}>Stop</button> + <button onClick={() => actions.queue.start_task(live_test_task, { preempt: true, watch: true })}>Start</button> + <button onClick={() => actions.queue.stop_task(runner.cpu.task)}>Stop</button> </Param> <Param title='Test Live RPC'> <button onClick={() => actions.live.get_params()}>Get</button> |
