InstrumentCommand.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. const InstrumentCommandFields = {
  2. id: null,
  3. tag: '',
  4. name: '',
  5. description: '',
  6. readString: '',
  7. writeString: '',
  8. subsystem: '',
  9. parameters: []
  10. }
  11. const InstrumentCommandFormFields = props => {
  12. const { state, onChange } = props
  13. const toState = event => {
  14. const newState = {
  15. ...state,
  16. [event.target.name]: event.target.value
  17. }
  18. onChange(newState)
  19. }
  20. return (
  21. <fieldset>
  22. <label htmlFor='tag'>Tag</label>
  23. <input
  24. type='text'
  25. name='tag'
  26. id='tag'
  27. placeholder='Tag'
  28. value={state.tag}
  29. onChange={toState}
  30. />
  31. <label htmlFor='name'>Name</label>
  32. <input
  33. type='text'
  34. name='name'
  35. id='name'
  36. placeholder='Name'
  37. value={state.name}
  38. onChange={toState}
  39. />
  40. <label htmlFor='description'>Description</label>
  41. <textarea
  42. name='description'
  43. id='description'
  44. placeholder='Description'
  45. value={state.description}
  46. onChange={toState}
  47. />
  48. <label htmlFor='readString'>Read string</label>
  49. <input
  50. type='text'
  51. name='readString'
  52. id='readString'
  53. placeholder='Read string'
  54. value={state.readString}
  55. onChange={toState}
  56. />
  57. <label htmlFor='writeString'>Write string</label>
  58. <input
  59. type='text'
  60. name='writeString'
  61. id='writeString'
  62. placeholder='Write string'
  63. value={state.writeString}
  64. onChange={toState}
  65. />
  66. </fieldset>
  67. )
  68. }
  69. const InstrumentCommand = props => {
  70. const { command } = props
  71. return (
  72. <div>
  73. <h1>{command.name}</h1>
  74. <p>{command.description}</p>
  75. <p>Tag: {command.tag}</p>
  76. <pre>{command.readString}</pre>
  77. <pre>{command.writeString}</pre>
  78. <div>Here go the parameters</div>
  79. </div>
  80. )
  81. }
  82. export default InstrumentCommand
  83. export { InstrumentCommandFields, InstrumentCommandFormFields }