From 804c96d041aaeb20afd97a8565612e1ab47b797e Mon Sep 17 00:00:00 2001 From: Thomas Nordquist Date: Sun, 17 Feb 2019 10:36:56 +0100 Subject: [PATCH] Preview connection URI --- .../ConnectionSetup/ConnectionSetup.tsx | 18 +++++++++-- .../ConnectionSetup/ProfileList.tsx | 32 ++++++++++++++++--- app/src/components/Tree/TreeNodeSubnodes.tsx | 3 -- app/src/model/ConnectionOptions.ts | 2 +- 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/app/src/components/ConnectionSetup/ConnectionSetup.tsx b/app/src/components/ConnectionSetup/ConnectionSetup.tsx index dd1d9b1..e9ac5f2 100644 --- a/app/src/components/ConnectionSetup/ConnectionSetup.tsx +++ b/app/src/components/ConnectionSetup/ConnectionSetup.tsx @@ -5,7 +5,7 @@ import { AppState } from '../../reducers' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import { connectionManagerActions } from '../../actions' -import { ConnectionOptions } from '../../model/ConnectionOptions' +import { ConnectionOptions, toMqttConnection } from '../../model/ConnectionOptions' import { Theme, withStyles } from '@material-ui/core/styles' import { Modal, @@ -34,7 +34,8 @@ class ConnectionSetup extends React.Component { } public render() { - const { classes, visible } = this.props + const { classes, visible, connection } = this.props + const mqttConnection = connection && toMqttConnection(connection) return (
@@ -43,6 +44,9 @@ class ConnectionSetup extends React.Component {
MQTT Connection + + {mqttConnection && mqttConnection.url} + {this.renderSettings()}
@@ -70,6 +74,7 @@ class ConnectionSetup extends React.Component { const styles = (theme: Theme) => ({ title: { color: theme.palette.text.primary, + whiteSpace: 'nowrap' as 'nowrap', }, root: { margin: '13vw auto 0 auto', @@ -94,6 +99,15 @@ const styles = (theme: Theme) => ({ padding: `${2 * theme.spacing.unit}px`, flex: 10, }, + connectionUri: { + width: '27em', + textOverflow: 'ellipsis' as 'ellipsis', + whiteSpace: 'nowrap' as 'nowrap', + overflow: 'hidden' as 'hidden', + color: theme.palette.text.hint, + fontSize: '0.9em', + marginLeft: '24px', + }, }) const mapStateToProps = (state: AppState) => { diff --git a/app/src/components/ConnectionSetup/ProfileList.tsx b/app/src/components/ConnectionSetup/ProfileList.tsx index 223158e..ebcde9a 100644 --- a/app/src/components/ConnectionSetup/ProfileList.tsx +++ b/app/src/components/ConnectionSetup/ProfileList.tsx @@ -4,12 +4,11 @@ import { AppState } from '../../reducers' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import { connectionManagerActions } from '../../actions' -import { ConnectionOptions } from '../../model/ConnectionOptions' +import { ConnectionOptions, toMqttConnection } from '../../model/ConnectionOptions' import { Theme, withStyles } from '@material-ui/core/styles' import { List, ListItem, - ListItemText, ListSubheader, Typography, } from '@material-ui/core' @@ -63,21 +62,44 @@ interface ConnectionItemProps { connection: ConnectionOptions, actions: any, selected: boolean, + classes: any } -const connectionItemRenderer = (props: ConnectionItemProps) => { +const connectionItemStyle = (theme: Theme) => ({ + name: { + width: '100%', + textOverflow: 'ellipsis' as 'ellipsis', + whiteSpace: 'nowrap' as 'nowrap', + overflow: 'hidden' as 'hidden', + }, + details: { + width: '100%', + textOverflow: 'ellipsis' as 'ellipsis', + whiteSpace: 'nowrap' as 'nowrap', + overflow: 'hidden' as 'hidden', + color: theme.palette.text.hint, + fontSize: '0.7em', + }, +}) + +const connectionItemRenderer = withStyles(connectionItemStyle)((props: ConnectionItemProps) => { + const connection = props.connection.host && toMqttConnection(props.connection) return ( props.actions.selectConnection(props.connection.id)} > - + {props.connection.name || 'mqtt broker'} + + { connection && connection.url } + ) -} +}) const ConnectionItem = connect(null, mapDispatchToProps)(connectionItemRenderer) diff --git a/app/src/components/Tree/TreeNodeSubnodes.tsx b/app/src/components/Tree/TreeNodeSubnodes.tsx index 18496a9..3ae947d 100644 --- a/app/src/components/Tree/TreeNodeSubnodes.tsx +++ b/app/src/components/Tree/TreeNodeSubnodes.tsx @@ -1,10 +1,7 @@ import * as React from 'react' import * as q from '../../../../backend/src/Model' -import { AppState } from '../../reducers' - import TreeNode from './TreeNode' -import { connect } from 'react-redux' import { TopicOrder } from '../../reducers/Settings' import { Theme, withStyles } from '@material-ui/core' import { TopicViewModel } from '../../TopicViewModel' diff --git a/app/src/model/ConnectionOptions.ts b/app/src/model/ConnectionOptions.ts index 3582c1c..925425e 100644 --- a/app/src/model/ConnectionOptions.ts +++ b/app/src/model/ConnectionOptions.ts @@ -6,7 +6,7 @@ export interface ConnectionOptions { type: 'mqtt' id: string host: string - protocol: 'mqtt' | 'ws' | 'wss' + protocol: 'mqtt' | 'ws' basePath?: string port: number name: string