From 4bcca2e9883b0f26f95c9abb921627b06c863bb0 Mon Sep 17 00:00:00 2001 From: Tim Raymond Date: Tue, 13 Dec 2016 17:01:34 -0500 Subject: [PATCH] Build dashboard table from API This pulls the table data into a fetch from the mocked-out API. A subsequent commit will remove the commented-out sections to actually hit the backend. --- ui/src/dashboards/apis/index.js | 17 ++++++++ .../dashboards/containers/DashboardsPage.js | 43 +++++++++++-------- 2 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 ui/src/dashboards/apis/index.js diff --git a/ui/src/dashboards/apis/index.js b/ui/src/dashboards/apis/index.js new file mode 100644 index 0000000000..3e6aa691d4 --- /dev/null +++ b/ui/src/dashboards/apis/index.js @@ -0,0 +1,17 @@ +// import AJAX from 'utils/ajax'; + +export function getDashboards() { + // return AJAX({ + // method: 'GET', + // url: `/chronograf/v1/dashboards`, + // }); + return { + then(cb) { + cb([ + {name: "Goldeneye System Status"}, + {name: "Carver Media Group Broadcast System Status"}, + {name: "Icarus Space Program Status"}, + ]); + }, + }; +} diff --git a/ui/src/dashboards/containers/DashboardsPage.js b/ui/src/dashboards/containers/DashboardsPage.js index dbc58ed399..e36d2cca59 100644 --- a/ui/src/dashboards/containers/DashboardsPage.js +++ b/ui/src/dashboards/containers/DashboardsPage.js @@ -1,5 +1,7 @@ import React from 'react'; +import {getDashboards} from '../apis'; + const DashboardsPage = React.createClass({ getInitialState() { return { @@ -8,22 +10,28 @@ const DashboardsPage = React.createClass({ }, componentDidMount() { - // getDashboards().then((dashboards) => { - const dashboards = []; - this.state({ - dashboards, + getDashboards().then((dashboards) => { + this.setState({ + dashboards, + }); }); - // }); }, render() { + let tableHeader; + if (this.state.dashboards.length === 0) { + tableHeader = "Loading Dashboards..."; + } else { + tableHeader = `${this.state.dashboards.length} Dashboards`; + } + return (

- Bond Villain Dashboards + Dashboards

@@ -34,7 +42,7 @@ const DashboardsPage = React.createClass({
-

4 Doomsday Devices

+

{tableHeader}

@@ -44,18 +52,15 @@ const DashboardsPage = React.createClass({ - - - - - - - - - - - - + { + this.state.dashboards.map((dashboard) => { + return ( + + + + ); + }) + }
Goldeneye System Status
Carver Media Group Broadcast System Status
King Oil Pipeline Status
Icarus Space Program Status
{dashboard.name}