listen for url changes on start

This commit is contained in:
Colin Megill
2017-10-09 22:18:07 -07:00
parent ec8dc69112
commit 089b89a1e5
+19 -12
View File
@@ -9,7 +9,9 @@ import Categorical from "./categorical/categorical";
import Continuous from "./continuous/continuous"; import Continuous from "./continuous/continuous";
import Joy from "./joy/joy"; import Joy from "./joy/joy";
import Graph from "./graph/graph"; import Graph from "./graph/graph";
import Heatmap from "./heatmap/heatmap"; import * as globals from "../globals";
import SectionHeader from "./framework/sectionHeader";
@connect((state) => { @connect((state) => {
return { return {
@@ -26,12 +28,17 @@ class Home extends React.Component {
metadata: null, metadata: null,
}; };
} }
_onURLChanged () {
this.props.dispatch({type: 'url changed', url: document.location.href});
};
componentDidMount() { componentDidMount() {
const prefix = "http://api.clustering.czi.technology/api/"; /* listen for url changes, fire one when we start the app up */
const version = "v0.1/"; window.addEventListener('popstate', this._onURLChanged);
this._onURLChanged();
const expressions = fetch(`${prefix}${version}expression`, { /* fire an initialize action */
const expressions = fetch(`${globals.API.prefix}${globals.API.version}expression`, {
method: "post", method: "post",
headers: new Headers({ headers: new Headers({
'Content-Type': 'application/json' 'Content-Type': 'application/json'
@@ -45,17 +52,18 @@ class Home extends React.Component {
.then((res) => res.json()) .then((res) => res.json())
.then((data) => { this.setState({expressions: data}) }) .then((data) => { this.setState({expressions: data}) })
const initialize = fetch(`${prefix}${version}initialize`) const initialize = fetch(`${globals.API.prefix}${globals.API.version}initialize`)
.then((res) => res.json()) .then((res) => res.json())
.then((data) => { this.setState({initialize: data}) }) .then((data) => { this.setState({initialize: data}) })
const graph = fetch(`${prefix}${version}graph`) const graph = fetch(`${globals.API.prefix}${globals.API.version}graph`)
.then((res) => res.json()) .then((res) => res.json())
.then((data) => { this.setState({vertices: data}) }) .then((data) => { this.setState({vertices: data}) })
const metadata = d3.csv(`${prefix}${version}metadata`, (data) => { }
this.setState({metadata: data})
}) componentWillUpdate() {
this.props.dispatch({type: "initialize app", data: "kitty! :D"})
} }
createExpressionsCountsMap () { createExpressionsCountsMap () {
@@ -85,13 +93,12 @@ class Home extends React.Component {
} }
render() { render() {
console.log('app:', this.props, this.state) // console.log('app:', this.props, this.state)
return ( return (
<Container> <Container>
<Helmet title="cellxgene" /> <Helmet title="cellxgene" />
{/* <Heatmap/> */} <SectionHeader text="Gene Selection Criteria"/>
<h3 style={{marginTop: 50}}> Gene selection criteria </h3>
{false ? <Joy data={this.state.expressions && this.state.expressions.data}/> : ""} {false ? <Joy data={this.state.expressions && this.state.expressions.data}/> : ""}
<Categorical/> <Categorical/>