-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca0965b
commit 0bfebc7
Showing
3 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
ui/src/components/BeamlineActions/AnnotatedBeamlineActionForm.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import { Row, Col, Button } from 'react-bootstrap'; | ||
import JSForm from '@rjsf/core'; | ||
import validator from '@rjsf/validator-ajv8'; | ||
import styles from './BeamlineActions.module.css'; | ||
|
||
export default function AnnotatedBeamlineActionForm(props) { | ||
const { | ||
actionId, | ||
actionSchema, | ||
isActionRunning, | ||
handleStopAction, | ||
handleStartAction, | ||
} = props; | ||
|
||
return ( | ||
<Row className="py-2"> | ||
<Col className="col-md-4"> | ||
<div className={styles.formContainer}> | ||
<JSForm | ||
liveValidate | ||
validator={validator} | ||
schema={JSON.parse(actionSchema)} | ||
onSubmit={({ formData }) => { | ||
handleStartAction(actionId, formData); | ||
}} | ||
> | ||
{isActionRunning ? ( | ||
<Button | ||
className={styles.submitButton} | ||
variant="danger" | ||
onClick={() => { | ||
handleStopAction(actionId); | ||
}} | ||
> | ||
Abort | ||
</Button> | ||
) : ( | ||
<Button | ||
className={styles.submitButton} | ||
disabled={isActionRunning} | ||
variant="primary" | ||
type="submit" | ||
> | ||
Run | ||
</Button> | ||
)} | ||
</JSForm> | ||
</div> | ||
</Col> | ||
<Row className="py-2" /> | ||
</Row> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, { Fragment } from 'react'; | ||
import { Row, Col, Button, Form } from 'react-bootstrap'; | ||
|
||
export default function BeamlineActionForm(props) { | ||
const { | ||
actionId, | ||
isActionRunning, | ||
actionArguments, | ||
handleStopAction, | ||
handleStartAction, | ||
handleSetActionArgument, | ||
} = props; | ||
|
||
return ( | ||
<Row> | ||
{actionArguments.map((arg, i) => ( | ||
<Fragment key={arg.name}> | ||
<Col className="mt-2" xs={1} style={{ whiteSpace: 'nowrap' }}> | ||
{arg.name} | ||
</Col> | ||
<Col xs={1}> | ||
<Form.Control | ||
label={arg.name} | ||
type="text" | ||
value={arg.value} | ||
disabled={isActionRunning} | ||
onChange={(e) => { | ||
handleSetActionArgument(actionId, i, e.target.value); | ||
}} | ||
/> | ||
</Col> | ||
</Fragment> | ||
))} | ||
<Col> | ||
{isActionRunning ? ( | ||
<Button | ||
variant="danger" | ||
onClick={() => { | ||
handleStopAction(actionId); | ||
}} | ||
> | ||
Abort | ||
</Button> | ||
) : ( | ||
<Button | ||
disabled={isActionRunning} | ||
variant="primary" | ||
onClick={() => { | ||
handleStartAction(actionId); | ||
}} | ||
> | ||
Run | ||
</Button> | ||
)} | ||
</Col> | ||
</Row> | ||
); | ||
} |
16 changes: 16 additions & 0 deletions
16
ui/src/components/BeamlineActions/BeamlineActions.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.formContainer :global(.rjsf) legend { | ||
display: none; | ||
} | ||
|
||
.formContainer :global(.rjsf) :global(.control-label) { | ||
display: inline; | ||
} | ||
|
||
.formContainer :global(.rjsf) :global(.field-description) { | ||
display: inline; | ||
margin-left: 0.5em; | ||
} | ||
|
||
.submitButton { | ||
margin-top: 1em; | ||
} |