This commit is contained in:
Thomas Nordquist
2019-04-04 19:51:44 +02:00
parent c20c075bcf
commit 09dcce97b7
55 changed files with 775 additions and 1415 deletions

View File

@@ -56,6 +56,11 @@ interface State {
}
class Publish extends React.Component<Props, State> {
private editorOptions = {
showLineNumbers: false,
tabSize: 2,
}
constructor(props: any) {
super(props)
this.state = { history: [] }
@@ -88,7 +93,7 @@ class Publish extends React.Component<Props, State> {
}
}
private addMessageToHistory(topic: string, payload?: string) {
private addMessageToHistory(topic: string, payload?: string) {
// Remove duplicates
let filteredHistory = this.state.history.filter(e => e.payload !== payload || e.topic !== topic)
filteredHistory = filteredHistory.slice(-7)
@@ -96,16 +101,6 @@ class Publish extends React.Component<Props, State> {
this.setState({ history })
}
public render() {
return (
<div style={{ flexGrow: 1, marginLeft: '8px' }}>
{this.topic()}
{this.editor()}
{this.history()}
</div>
)
}
private clearTopic = () => {
this.props.actions.setTopic('')
}
@@ -138,11 +133,6 @@ class Publish extends React.Component<Props, State> {
}
}
private editorOptions = {
showLineNumbers: false,
tabSize: 2,
}
private publishButton() {
return (
<Button
@@ -232,7 +222,7 @@ class Publish extends React.Component<Props, State> {
private onChangeQoS = (event: React.ChangeEvent<HTMLInputElement>) => {
const value = parseInt(event.target.value, 10)
if (value !== 0 && value !== 1 && value !== 2) {
if (value !== 0 && value !== 1 && value !== 2) {
return
}
@@ -326,6 +316,16 @@ class Publish extends React.Component<Props, State> {
/>
)
}
public render() {
return (
<div style={{ flexGrow: 1, marginLeft: '8px' }}>
{this.topic()}
{this.editor()}
{this.history()}
</div>
)
}
}
const mapDispatchToProps = (dispatch: any) => {