added configurable root directory in .env* files
parent
6bdb8b6174
commit
dc9c0d5e59
|
|
@ -0,0 +1,2 @@
|
|||
REACT_APP_API_HOST="http://localhost:5000/test/"
|
||||
REACT_APP_API_DIR="/test/"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
REACT_APP_API_HOST="http://localhost:3000/toast/"
|
||||
REACT_APP_API_DIR="/toast/"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
export const apiHost = process.env.REACT_APP_API_HOST
|
||||
export const apiDir = process.env.REACT_APP_API_DIR
|
||||
|
|
@ -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) => (
|
||||
<Link to={link}>{name}</Link>
|
||||
);
|
||||
|
||||
const RedirectCharts = () => (<Redirect to='/charts' />);
|
||||
const RedirectCharts = () => (<Redirect to={apiDir+'charts'} />);
|
||||
|
||||
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 = () => (<ChartLoader {...this.state}/>);
|
||||
const ConfiguredServerTab = () => (<ServerTabLoader {...this.state}/>);
|
||||
const ConfiguredChart = () => (<ChartLoader {...this.state} />);
|
||||
const ConfiguredServerTab = () => (<ServerTabLoader {...this.state} />);
|
||||
return (
|
||||
<Router>
|
||||
<div>
|
||||
<Container isFluid={true} isMarginless={true} isFullWidth={true}>
|
||||
<Navbar style={{ backgroundColor:'#00D1B2' }}>
|
||||
<Navbar style={{ backgroundColor: '#00D1B2' }}>
|
||||
<NavbarMenu isActive={true}>
|
||||
<NavbarItem >{navButton('Charts', '/charts')}</NavbarItem>
|
||||
<NavbarItem>{navButton('Tables', '/tables')}</NavbarItem>
|
||||
<NavbarItem >{navButton('Charts', apiDir + 'charts')}</NavbarItem>
|
||||
<NavbarItem>{navButton('Tables', apiDir + 'tables')}</NavbarItem>
|
||||
</NavbarMenu>
|
||||
</Navbar>
|
||||
</Container>
|
||||
<Section isPaddingless={true}>
|
||||
<Route exact={true} path="/" component={RedirectCharts} />
|
||||
<Route path="/charts" component={ConfiguredChart} />
|
||||
<Route path="/tables" component={ConfiguredServerTab} />
|
||||
<Route exact={true} path={apiDir} component={RedirectCharts} />
|
||||
<Route path={apiDir + "charts"} component={ConfiguredChart} />
|
||||
<Route path={apiDir + "tables"} component={ConfiguredServerTab} />
|
||||
</Section>
|
||||
</div>
|
||||
</Router>
|
||||
|
|
|
|||
|
|
@ -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<any, any> {
|
|||
colColorMap
|
||||
});
|
||||
}
|
||||
Papa.parse(this.props.csvFile, {
|
||||
Papa.parse(apiDir + this.props.csvFile, {
|
||||
header: true,
|
||||
download: true,
|
||||
skipEmptyLines: true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue