Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for displaying current controller state
- Loading branch information
Showing
21 changed files
with
477 additions
and
184 deletions.
There are no files selected for viewing
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,51 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import shallowCompare from 'react-addons-shallow-compare'; | ||
import Modal from '../../components/Modal'; | ||
import i18n from '../../lib/i18n'; | ||
import { | ||
MODAL_CONTROLLER_STATE | ||
} from './constants'; | ||
//import styles from './index.styl'; | ||
|
||
class ControllerState extends Component { | ||
static propTypes = { | ||
state: PropTypes.object, | ||
actions: PropTypes.object | ||
}; | ||
|
||
shouldComponentUpdate(nextProps, nextState) { | ||
return shallowCompare(this, nextProps, nextState); | ||
} | ||
render() { | ||
const { state, actions } = this.props; | ||
const { modal } = state; | ||
const show = (modal.name === MODAL_CONTROLLER_STATE); | ||
const maxHeight = Math.max(window.innerHeight / 2, 200); | ||
|
||
return ( | ||
<Modal | ||
onClose={actions.closeModal} | ||
show={show} | ||
size="lg" | ||
> | ||
<Modal.Header> | ||
<Modal.Title>{i18n._('Controller State')}</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body style={{ maxHeight: maxHeight }}> | ||
<pre><code>{JSON.stringify(state.controller.state, null, 2)}</code></pre> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<button | ||
type="button" | ||
className="btn btn-default" | ||
onClick={actions.closeModal} | ||
> | ||
{i18n._('Close')} | ||
</button> | ||
</Modal.Footer> | ||
</Modal> | ||
); | ||
} | ||
} | ||
|
||
export default ControllerState; |
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
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
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,6 @@ | ||
import constants from 'namespace-constants'; | ||
|
||
module.exports = constants('widgets/Grbl', [ | ||
'MODAL_NONE', | ||
'MODAL_CONTROLLER_STATE' | ||
]); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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,51 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import shallowCompare from 'react-addons-shallow-compare'; | ||
import Modal from '../../components/Modal'; | ||
import i18n from '../../lib/i18n'; | ||
import { | ||
MODAL_CONTROLLER_STATE | ||
} from './constants'; | ||
//import styles from './index.styl'; | ||
|
||
class ControllerState extends Component { | ||
static propTypes = { | ||
state: PropTypes.object, | ||
actions: PropTypes.object | ||
}; | ||
|
||
shouldComponentUpdate(nextProps, nextState) { | ||
return shallowCompare(this, nextProps, nextState); | ||
} | ||
render() { | ||
const { state, actions } = this.props; | ||
const { modal } = state; | ||
const show = (modal.name === MODAL_CONTROLLER_STATE); | ||
const maxHeight = Math.max(window.innerHeight / 2, 200); | ||
|
||
return ( | ||
<Modal | ||
onClose={actions.closeModal} | ||
show={show} | ||
size="lg" | ||
> | ||
<Modal.Header> | ||
<Modal.Title>{i18n._('Controller State')}</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body style={{ maxHeight: maxHeight }}> | ||
<pre><code>{JSON.stringify(state.controller.state, null, 2)}</code></pre> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<button | ||
type="button" | ||
className="btn btn-default" | ||
onClick={actions.closeModal} | ||
> | ||
{i18n._('Close')} | ||
</button> | ||
</Modal.Footer> | ||
</Modal> | ||
); | ||
} | ||
} | ||
|
||
export default ControllerState; |
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
Oops, something went wrong.