Select Git revision
InstanceHomePage.js
InstanceHomePage.js 7.69 KiB
import React from 'react'
import PropTypes from 'prop-types'
import { withStyles } from '@material-ui/core/styles'
import Paper from '@material-ui/core/Paper'
import Typography from '@material-ui/core/Typography'
import CircularProgress from '@material-ui/core/CircularProgress'
import purple from '@material-ui/core/colors/purple'
import PerspectiveTabs from '../../main_layout/PerspectiveTabs'
import InstanceHomePageTable from '../../main_layout/InstanceHomePageTable'
import Network from '../../facet_results/Network'
import LeafletMap from '../../facet_results/LeafletMap'
import Export from '../../facet_results/Export'
import { coseLayout, cytoscapeStyle } from '../../../configs/sampo/Cytoscape.js/NetworkConfig'
import { Route, Redirect } from 'react-router-dom'
import { has } from 'lodash'
const styles = () => ({
root: {
width: '100%',
height: '100%'
},
content: {
width: '100%',
height: 'calc(100% - 72px)',
overflow: 'auto'
},
spinnerContainer: {
display: 'flex',
width: '100%',
height: '100%',
alignItems: 'center',
justifyContent: 'center'
}
})
/**
* A component for generating a landing page for a single entity.
* Customized for MMM data
*/
class InstanceHomePage extends React.Component {
constructor (props) {
super(props)
this.state = {
localID: null
}
}
componentDidMount = () => this.fetchData()
componentDidUpdate = prevProps => {
if (prevProps.routeProps.location !== this.props.routeProps.location) {
this.fetchData()
}
}
fetchData = () => {
let uri = ''
const base = 'http://ldf.fi/mmm'
const locationArr = this.props.routeProps.location.pathname.split('/')
let localID = locationArr.pop()
this.props.tabs.map(tab => {
if (localID === tab.id) {
localID = locationArr.pop() // pop again if tab id
}
})
this.setState({ localID: localID })
switch (this.props.resultClass) {
case 'perspective1':
uri = `${base}/manifestation_singleton/${localID}`
break