diff --git a/.env b/.env new file mode 100644 index 0000000..194c3c2 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +REACT_APP_API_HOST="http://localhost:5000/test/" +REACT_APP_API_DIR="/test/" diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..c728da4 --- /dev/null +++ b/.env.development @@ -0,0 +1,2 @@ +REACT_APP_API_HOST="http://localhost:3000/toast/" +REACT_APP_API_DIR="/toast/" diff --git a/public/config.json b/public/toast/config.json similarity index 100% rename from public/config.json rename to public/toast/config.json diff --git a/public/data.csv b/public/toast/data.csv similarity index 100% rename from public/data.csv rename to public/toast/data.csv diff --git a/public/manifest.json b/public/toast/manifest.json similarity index 100% rename from public/manifest.json rename to public/toast/manifest.json diff --git a/src/Config.tsx b/src/Config.tsx new file mode 100644 index 0000000..5c98fed --- /dev/null +++ b/src/Config.tsx @@ -0,0 +1,2 @@ +export const apiHost = process.env.REACT_APP_API_HOST +export const apiDir = process.env.REACT_APP_API_DIR diff --git a/src/RouteMenu.tsx b/src/RouteMenu.tsx index 1196734..b4ab579 100644 --- a/src/RouteMenu.tsx +++ b/src/RouteMenu.tsx @@ -8,22 +8,23 @@ import { Container, Navbar, NavbarItem, NavbarMenu, Section } from 'bloomer'; import * as local from 'localforage'; import ServerTabLoader from './ServerTabLoader'; import ChartLoader from './ChartLoader'; +import { apiDir } from './Config'; const navButton = (name: string, link: string) => ( {name} ); -const RedirectCharts = () => (); +const RedirectCharts = () => (); class RouteMenu extends React.Component { constructor(props: any) { super(props); this.state = { - tabList:[], + tabList: [], chartList: [], - colorMaps:{} + colorMaps: {} } - fetch('/config.json') + fetch(apiDir+'config.json') .then((response) => response.text()) .then((jsonStr) => { const jsonObj = JSON.parse(jsonStr); @@ -38,23 +39,23 @@ class RouteMenu extends React.Component { } public render() { - const ConfiguredChart = () => (); - const ConfiguredServerTab = () => (); + const ConfiguredChart = () => (); + const ConfiguredServerTab = () => (); return (
- + - {navButton('Charts', '/charts')} - {navButton('Tables', '/tables')} + {navButton('Charts', apiDir + 'charts')} + {navButton('Tables', apiDir + 'tables')}
- - - + + +
diff --git a/src/ServerTable.tsx b/src/ServerTable.tsx index 6cfd771..c0f30e0 100644 --- a/src/ServerTable.tsx +++ b/src/ServerTable.tsx @@ -3,6 +3,7 @@ import { Tips } from "./Utils"; import * as _ from 'lodash'; import { Button } from 'bloomer'; // const randomColor = require('randomcolor'); +import { apiDir } from './Config'; const reactcsv = require('react-csv'); const CSVLink = reactcsv.CSVLink; import * as Papa from 'papaparse'; @@ -27,7 +28,7 @@ export default class ServerTable extends React.Component { colColorMap }); } - Papa.parse(this.props.csvFile, { + Papa.parse(apiDir + this.props.csvFile, { header: true, download: true, skipEmptyLines: true,