summaryrefslogtreecommitdiff
path: root/app/client/system/system.actions.js
blob: 73cea28f59fb1849b00efc2ad69f0c0c166860c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import socket from '../socket'
import types from '../types'

// import actions from '../actions'

export const run = (cmd) => (dispatch) => {
  dispatch({ type: types.system.running_command, cmd })
  socket.actions.run_system_command({ cmd })
  .then(data => {
    dispatch({
      type: types.system.command_output,
      data: data,
    })
  })
}

export const listDirectory = (opt) => (dispatch) => {
  dispatch({ type: types.system.listing_directory, opt })
  socket.actions.list_directory(opt)
  .then(data => {
    dispatch({
      type: types.system.list_directory,
      data: data,
    })
  })
}

export const countDirectory = (opt) => (dispatch) => {
  dispatch({ type: types.system.counting_directory, opt })
  socket.actions.count_directory(opt)
  .then(data => {
    dispatch({
      type: types.system.count_directory,
      data: data,
    })
  })
}

export const changeTool = (tool) => {
  localStorage.setItem('system.last_tool', tool)
  return { type: types.app.change_tool, tool }
}

export const changeLanguage = (language) => {
  localStorage.setItem('cortex.i18n.language', language)
  return { type: types.system.change_language, language }
}

export const enqueue_test_task = (dataset) => dispatch => {
  const task = {
    module: 'test',
    activity: 'cpu',
    dataset: dataset,
  }
  // return actions.queue.add_task(task)
}

window.addEventListener('keyDown', e => {
  if (e.altKey) {
    switch (e.keyCode) {
      case 192: // tilde - switch tool
        break
      case 49: // 1
        break
      case 50: // 2
        break
      case 51: // 3
        break
      case 52: // 4
        break
      case 53: // 5
        break
      case 54: // 6
        break
      case 55: // 7
        break
      case 56: // 8
        break
      case 57: // 9
        break
      case 48: // 0
        break
    }
  }
})