Skip to content
Snippets Groups Projects
Commit d1f36129 authored by Mattia Mancini's avatar Mattia Mancini
Browse files

OSB-31: replaced popover component with tooltip

parent 092889a4
No related branches found
No related tags found
2 merge requests!89Monitoring maintenance Epic branch merge,!1Resolve OSB-13 "Monitoringmaintenance "
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Table, Popover, PopoverHeader, PopoverBody } from 'reactstrap'; import { Table, Popover, PopoverHeader, PopoverBody, Tooltip } from 'reactstrap';
import { unique_id } from '../utils/utils.js' import { unique_id } from '../utils/utils.js'
import AutoLoadWrapper from '../utils/autoLoader.js' import AutoLoadWrapper from '../utils/autoLoader.js'
import * as moment from 'moment'; import * as moment from 'moment';
...@@ -10,40 +10,11 @@ import './LatestObservations.css' ...@@ -10,40 +10,11 @@ import './LatestObservations.css'
class SORow extends Component { class SORow extends Component {
constructor(props){ constructor(props){
super(props); super(props);
this.state = {mouseOverRow:false, mouseOverPopover:false, popoverOpen: false}; this.state = {popoverOpen: false};
this.id = unique_id(); this.id = unique_id();
this.togglePopover = this.togglePopover.bind(this); this.togglePopover = this.togglePopover.bind(this);
} }
onMouseOverPopover(e){
this.setState({mouseOverPopover: true});
}
onMouseOutPopover(e){
setTimeout(
function () {
if(this.state.mouseOverRow === false && this.state.mouseOverPopover === false){
this.setState({popoverOpen: false})
}
this.setState({mouseOverPopover: false});
}.bind(this), 100)
}
onMouseOverRow(){
this.setState({mouseOverRow: true, popoverOpen: true})
}
onMouseOutRow(){
this.setState({mouseOverRow: false})
setTimeout(
function () {
if(this.state.mouseOverPopover === false){
this.setState({popoverOpen: false})
}
}.bind(this), 100)
}
renderObservationID() { renderObservationID() {
return this.props.data.observation_id; return this.props.data.observation_id;
...@@ -67,9 +38,7 @@ class SORow extends Component { ...@@ -67,9 +38,7 @@ class SORow extends Component {
} }
togglePopover(){ togglePopover(){
if(this.state.mouseOverPopup === false){ this.setState({popoverOpen: !this.state.popoverOpen});
this.setState({popoverOpen: !this.state.popoverOpen});
}
} }
render() { render() {
const data = this.props.data; const data = this.props.data;
...@@ -82,29 +51,31 @@ class SORow extends Component { ...@@ -82,29 +51,31 @@ class SORow extends Component {
<td>{station.n_errors}</td> <td>{station.n_errors}</td>
</tr>); </tr>);
return ( return (
<tr id={this.id} onMouseOver={()=> this.onMouseOverRow()} onMouseLeave={()=>this.onMouseOutRow()} <tr id={this.id} className="hoverable">
className="hoverable">
<th scope="row">{ this.renderObservationID() }</th> <th scope="row">{ this.renderObservationID() }</th>
<td>{ moment(start_datetime).format('lll') }</td> <td>{ moment(start_datetime).format('lll') }</td>
<td>{ station_involved_list.length }</td> <td>{ station_involved_list.length }</td>
<td>{ this.renderStationsWithProblems(station_involved_list) }</td> <td>{ this.renderStationsWithProblems(station_involved_list) }</td>
<td>{ total_component_errors }</td> <td>{ total_component_errors }</td>
<Popover placement="auto-start" isOpen={this.state.popoverOpen} target={ this.id }> <Tooltip placement="auto" isOpen={this.state.popoverOpen}
<div onMouseOver={(e)=> this.onMouseOverPopover(e)} onMouseOut={(e)=>this.onMouseOutPopover(e)}> target={ this.id }
<PopoverHeader>{data.observation_id}</PopoverHeader> toggle={this.togglePopover}
<PopoverBody> style={{backgroundColor: "white", color:"black", opacity: "1"}}
autohide={false}>
<div className='popover-header'>{data.observation_id}</div>
<div>
<strong>Start:</strong> { start_datetime}<br/> <strong>Start:</strong> { start_datetime}<br/>
<strong>End:</strong> { end_datetime }<br/> <strong>End:</strong> { end_datetime }<br/>
<strong>Mode:</strong> { mode.join(',') }<br/> <strong>Mode:</strong> { mode.join(',') }<br/>
<Table size="sm" className="so-table table-wrapper"> <Table size="sm" className="so-table table-wrapper">
<thead><tr><th>Station name</th><th>errors</th></tr></thead> <thead><tr><th>Station name</th><th>errors</th></tr></thead>
<tbody>{stations_and_errors}</tbody> <tbody>{stations_and_errors}</tbody>
</Table> </Table>
</PopoverBody>
</div> </div>
</Popover>
</Tooltip>
</tr> </tr>
); );
} }
......
...@@ -119,7 +119,7 @@ class GenericStatus extends Component { ...@@ -119,7 +119,7 @@ class GenericStatus extends Component {
const jsx = ( const jsx = (
<Tooltip isOpen={this.state.isPopOverOpen} <Tooltip isOpen={this.state.isPopOverOpen}
target={this.id} style={{backgroundColor: "white", color: "black"}} target={this.id} style={{backgroundColor: "white", color: "black"}}
autohide='false' autohide={false}
placement='auto' toggle={this.togglePopOver}> placement='auto' toggle={this.togglePopOver}>
<h5>Errors details</h5> <h5>Errors details</h5>
<Table size='sm'> <Table size='sm'>
...@@ -410,7 +410,7 @@ class StationTestViewC extends Component { ...@@ -410,7 +410,7 @@ class StationTestViewC extends Component {
const firstComponent = Object.keys(this.props.data)[0] const firstComponent = Object.keys(this.props.data)[0]
if(this.state !== undefined && this.state.activeTab === undefined && firstComponent !== undefined){ if(this.state !== undefined && this.state.activeTab === undefined && firstComponent !== undefined){
this.setState({ this.setState({
activeTab: Object.keys(this.props.data)[0] activeTab: firstComponent
}) })
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment