|
@@ -1,14 +1,34 @@
|
|
|
import gql from 'graphql-tag'
|
|
|
import { Query, Mutation } from 'react-apollo'
|
|
|
import InstrumentSubsystem from './InstrumentSubsystem'
|
|
|
+import Gallery from './Gallery'
|
|
|
|
|
|
-const CREATE_INSTRUMENT = gql`
|
|
|
- mutation CREATE_INSTRUMENT($name: String!, $description: String!, $interfaces: [String]!) {
|
|
|
- createInstrument(name: $name, description: $description, interfaces: $interfaces) {
|
|
|
- id
|
|
|
- }
|
|
|
- }
|
|
|
-`
|
|
|
+const instrumentSubsystems = [{
|
|
|
+ name: 'Source',
|
|
|
+ description: 'The commands in the SOURce subsystem are used to control the output of the power supply.',
|
|
|
+ commands: [{
|
|
|
+ id: '1',
|
|
|
+ tag: 'Apply',
|
|
|
+ name: 'Apply voltage and current',
|
|
|
+ description: 'This command sets voltage and current levels on a specified channel with a single command message.',
|
|
|
+ instrument: null,
|
|
|
+ readString: null,
|
|
|
+ writeString: '[SOURce:]APPLy {CH1|CH2|CH3}, <NRf+>, <NRf+>',
|
|
|
+ parameters: ['channel']
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: '1',
|
|
|
+ tag: 'Output',
|
|
|
+ name: 'Channel output state',
|
|
|
+ description: 'This command sets the output state of the presently selected channel. The query form of this command returns the output state of the presently selected channel.',
|
|
|
+ instrument: null,
|
|
|
+ readString: '[SOURce:]CHANnel:OUTPut[:STATe]?',
|
|
|
+ writeString: '[SOURce:]CHANnel:OUTPut[:STATe] <BOOL>',
|
|
|
+ parameters: ['channel']
|
|
|
+ }],
|
|
|
+ parameters: [{ channel: ['CH1', 'CH2', 'CH3'] }],
|
|
|
+ subsystems: []
|
|
|
+}]
|
|
|
|
|
|
class Instrument extends React.Component {
|
|
|
state = {
|
|
@@ -24,53 +44,16 @@ class Instrument extends React.Component {
|
|
|
this.setState({ [event.target.name]: event.target.value })
|
|
|
}
|
|
|
|
|
|
- addComment = event => {
|
|
|
- event.preventDefault()
|
|
|
- const newState = { ...this.state }
|
|
|
- newState.changes.push(this.state.change)
|
|
|
- newState.change = ''
|
|
|
- this.setState(newState)
|
|
|
- }
|
|
|
-
|
|
|
render() {
|
|
|
return (
|
|
|
- <Mutation mutation={CREATE_PROJECT_VERSION} variables={this.state}>
|
|
|
- {(createProjectVersion, { data, error, loading }) => (
|
|
|
- <form onSubmit={async event => {
|
|
|
- event.preventDefault()
|
|
|
- const { data } = await createProjectVersion()
|
|
|
- this.state.id = data.createProjectVersion.id
|
|
|
- }}>
|
|
|
- {!this.props.title && <h1>Project Version</h1>}
|
|
|
- <fieldset id='project-generic'>
|
|
|
- <label htmlFor='name'>Project name</label>
|
|
|
- <input type='text' name='name' id='name' placeholder='Project version name' value={this.state.name} onChange={this.toState} />
|
|
|
- <label htmlFor='description'>Date</label>
|
|
|
- <input type='text' name='description' id='description' placeholder='Project description' value={this.state.description} onChange={this.toState} />
|
|
|
- {this.props.project || (
|
|
|
- <Query query={QUERY_PROJECTS}>
|
|
|
- {({ data, error, loading }) => {
|
|
|
- if (loading) return <p>Loading projects...</p>
|
|
|
- if (error) return <p>Error: {error.message}</p>
|
|
|
- if (!data || !data.projects.length) return <p>No projects found.</p>
|
|
|
- if (!this.state.project) this.setState({ project: data.projects[0].id })
|
|
|
- return (
|
|
|
- <label htmlFor="version">
|
|
|
- <select name="version" id="version">onChange={this.toState}>
|
|
|
- {data.projects.map(project =>
|
|
|
- <option key={project.id} value={project.id}>{project.name}</option>)
|
|
|
- }
|
|
|
- </select>
|
|
|
- </label>
|
|
|
- )
|
|
|
- }}
|
|
|
- </Query>
|
|
|
- )}
|
|
|
- </fieldset>
|
|
|
- <button type='submit'>Save</button>
|
|
|
- </form>
|
|
|
- )}
|
|
|
- </Mutation>
|
|
|
+ <div>
|
|
|
+ <h1>{this.state.name || 'Keithley 2230-3'}</h1>
|
|
|
+ <p>{this.state.description || 'A really nice 3 output multimeter'}</p>
|
|
|
+ <Gallery title='Documents' items={['Hallo']} />
|
|
|
+ <Gallery title='Interfaces' items={['serial', 'usbtmc'].map(item => <div>{item}</div>)} />
|
|
|
+ <Gallery title='Subsystems' items={instrumentSubsystems.map(instrumentSubsystem =>
|
|
|
+ <InstrumentSubsystem instrumentSubsystem={instrumentSubsystem} />)} />
|
|
|
+ </div>
|
|
|
)
|
|
|
}
|
|
|
}
|