From ad7794b30df757dac0139a2be12a23e5ce10e344 Mon Sep 17 00:00:00 2001 From: Thomas Nordquist Date: Fri, 4 Jan 2019 02:33:32 +0100 Subject: [PATCH] Add connection setup form --- app/src/App.tsx | 2 + .../components/ConnectionSetup/Connection.tsx | 207 ++++++++++++++++++ 2 files changed, 209 insertions(+) create mode 100644 app/src/components/ConnectionSetup/Connection.tsx diff --git a/app/src/App.tsx b/app/src/App.tsx index 41ebba5..16c9d6a 100644 --- a/app/src/App.tsx +++ b/app/src/App.tsx @@ -4,6 +4,7 @@ import * as q from '../../backend/src/Model' import { Tree } from './components/Tree/Tree' import TitleBar from './components/TitleBar' import Sidebar from './components/Sidebar/Sidebar' +import Connection from './components/ConnectionSetup/Connection' import { withTheme, Theme } from '@material-ui/core/styles' @@ -62,6 +63,7 @@ class App extends React.Component { + } } diff --git a/app/src/components/ConnectionSetup/Connection.tsx b/app/src/components/ConnectionSetup/Connection.tsx new file mode 100644 index 0000000..5bbf9b6 --- /dev/null +++ b/app/src/components/ConnectionSetup/Connection.tsx @@ -0,0 +1,207 @@ +import * as React from 'react' + +import { Typography, Toolbar, Modal, MenuItem, Button, Grid, Paper, TextField, Switch, FormControlLabel } from '@material-ui/core' +import { withStyles, Theme, StyleRulesCallback } from '@material-ui/core/styles' + +interface Props { + classes: {[s: string]: string} + theme: Theme + onAbort: () => void +} + +const protocols = [ + 'tcp://', + 'ws://', +] + +interface State { + visible: boolean + name: string + host: string + protocol: string + port: number + ssl: boolean + sslValidation: boolean + clientId: string + username: string + password: string +} + +class Connection extends React.Component { + constructor(props: any) { + super(props) + this.state = { + visible: true, + name: '', + host: '', + protocol: protocols[0], + port: 1883, + ssl: false, + sslValidation: true, + clientId: '', + username: '', + password: '', + } + } + + public static styles: StyleRulesCallback = (theme: Theme) => { + return { + root: { + minWidth: 550, + maxWidth: 650, + backgroundColor: theme.palette.background.default, + margin: '20vh auto auto auto', + padding: `${2 * theme.spacing.unit}px`, + outline: 'none', + }, + title: { + color: theme.palette.text.primary, + }, + paper: { + padding: theme.spacing.unit * 2, + textAlign: 'center', + color: theme.palette.text.secondary, + }, + textField: { + width: '100%', + }, + switch: { + marginTop: `${1 * theme.spacing.unit}px`, + }, + button: { + margin: theme.spacing.unit, + }, + } + } + + private handleChange = (name: string) => (event: any) => { + const state: any = { + [name]: event.target.value, + } + this.setState(state) + } + + public render() { + const { classes } = this.props + return { console.log('close') }}> + + + MQTT Connection + +
+ + + + + + + +
+ this.setState({ sslValidation: !this.state.sslValidation })} + color="primary" + /> + )} + label="Validate certificate" + labelPlacement="bottom" + /> +
+
+ +
+ this.setState({ ssl: !this.state.ssl })} + color="primary" + /> + )} + label="Encryption" + labelPlacement="bottom" + /> +
+
+ + + {protocols.map((value: string) => ( + + {value} + + ))} + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+
+ } +} + +export default withStyles(Connection.styles, { withTheme: true })(Connection)