diff --git a/ui/src/index.js b/ui/src/index.js index 2ace658d7..ffc5c51f1 100644 --- a/ui/src/index.js +++ b/ui/src/index.js @@ -1,7 +1,7 @@ import React, {PropTypes} from 'react'; import {render} from 'react-dom'; import {Provider} from 'react-redux'; -import {Router, Route, browserHistory} from 'react-router'; +import {Router, Route, browserHistory, IndexRoute} from 'react-router'; import App from 'src/App'; import CheckDataNodes from 'src/CheckDataNodes'; @@ -13,6 +13,7 @@ import RetentionPoliciesPage from 'src/retention_policies'; import DataExplorer from 'src/chronograf'; import DatabaseManager from 'src/database_manager'; import SignUp from 'src/sign_up'; +import SelectSourcePage from 'src/select_source'; import {UsersPage, UserEditPage} from 'src/web_users'; import {ClusterAccountsPage, ClusterAccountPage} from 'src/cluster_accounts'; import {RolesPageContainer, RolePageContainer} from 'src/access_control'; @@ -121,6 +122,7 @@ const Root = React.createClass({ + diff --git a/ui/src/select_source/containers/SelectSourcePage.js b/ui/src/select_source/containers/SelectSourcePage.js new file mode 100644 index 000000000..083b076a0 --- /dev/null +++ b/ui/src/select_source/containers/SelectSourcePage.js @@ -0,0 +1,93 @@ +import React from 'react'; +import FlashMessages from 'shared/components/FlashMessages'; +import {createSource, getSources} from 'shared/apis'; + +export const SelectSourcePage = React.createClass({ + getInitialState() { + return { + sources: [], + }; + }, + + componentDidMount() { + getSources().then(({data: {sources}}) => { + this.setState({ + sources, + }); + }); + }, + + handleSelectSource(e) { + e.preventDefault(); + // const source = this.state.sources.find((s) => s.name === this.selectedSource.value); + // redirect to /hosts?sourceId=source.id + }, + + handleNewSource(e) { + e.preventDefault(); + const source = { + url: this.sourceURL.value, + name: this.sourceName.value, + username: this.sourceUser.value, + password: this.sourcePassword.value, + }; + createSource(source).then(() => { + // redirect to /hosts?sourceId=123 + }); + }, + + render() { + return ( +
+
+
+
+
+
+

Welcome to Chronograf

+
+
+
+
+

Select an InfluxDB server to connect to

+ + +
+ +
+ +
+
+ +
+
+

Or connect to a new server

+ + this.sourceURL = r} id="connect-string" placeholder="http://localhost:8086"> + + this.sourceName = r} id="name" placeholder="Influx 1"> + + this.sourceUser = r} id="username"> + + this.sourcePassword = r} id="password" type="password"> +
+ +
+ +
+
+
+
+
+
+
+
+ ); + }, +}); + +export default FlashMessages(SelectSourcePage); diff --git a/ui/src/select_source/index.js b/ui/src/select_source/index.js new file mode 100644 index 000000000..a172a2b31 --- /dev/null +++ b/ui/src/select_source/index.js @@ -0,0 +1,2 @@ +import SelectSourcePage from './containers/SelectSourcePage'; +export default SelectSourcePage; diff --git a/ui/src/shared/apis/index.js b/ui/src/shared/apis/index.js index c3ed9407b..0ae16a222 100644 --- a/ui/src/shared/apis/index.js +++ b/ui/src/shared/apis/index.js @@ -6,6 +6,19 @@ export function getSources() { }); } +export function createSource({url, name, username, password}) { + return AJAX({ + url: '/chronograf/v1/sources', + method: 'POST', + data: { + url, + name, + username, + password, + }, + }); +} + export function updateCluster(clusterID, displayName) { return AJAX({ url: `/api/int/v1/clusters/${clusterID}`, diff --git a/ui/webpack/devConfig.js b/ui/webpack/devConfig.js index 0d7234d7a..a5452352a 100644 --- a/ui/webpack/devConfig.js +++ b/ui/webpack/devConfig.js @@ -4,7 +4,7 @@ var ExtractTextPlugin = require("extract-text-webpack-plugin"); var HtmlWebpackPlugin = require("html-webpack-plugin"); module.exports = { - devtool: 'cheap-eval-source-map', + devtool: 'source-map', entry: { app: path.resolve(__dirname, '..', 'src', 'index.js'), },