import React from 'react' import PropTypes from 'prop-types' import { fetchMeasures } from '../utils/FetchUtils' import DtoStation from '../dto/DtoStation' import ExpandLessIcon from '@material-ui/icons/ExpandLess' import ExpandMoreIcon from '@material-ui/icons/ExpandMore' // ListStation component class ListStation extends React.Component { constructor(props) { super(props) this.state = { isOpen: false, color: ['#80FFA5', '#00DDFF', '#37A2FF', '#FF0087', '#FFBF00'], } } // loads all measurements from a station loadMeasures(evt, station) { if (!this.props.addOnChart[station.name]) { const color = this.state.color[(this.props.colorId % this.state.color.length)] evt.target.style.color = color fetchMeasures(station.id, this.props.stationType, this.props.days, 0, false) .then(measures => { this.props.addMeasures({ stationsMeasures: { [station.name]: { id: station.id, name: station.name, measures: measures, type: this.props.stationType, color: color } }, addOnChart: { ...this.props.addOnChart, [station.name]: true } }) }) this.props.changeColorId({ colorId: this.props.colorId+1 }) } else { evt.target.classList.remove('default-selected') evt.target.style.color = 'black' this.props.deleteMeasures({ name: station.name, addOnChart: { ...this.props.addOnChart, [station.name]: false } }) } } render() { return (