From 65d909bf76b8c29f20e733494fd4a0b1b2cd5afa Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Wed, 28 Oct 2020 00:54:00 +0100 Subject: Migrate popovers to Reactstrap --- .../app/sidebars/topology/machine/UnitComponent.js | 94 ++++++++++------------ .../app/sidebars/topology/machine/UnitContainer.js | 1 + 2 files changed, 45 insertions(+), 50 deletions(-) diff --git a/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js b/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js index 4816ca23..de55e506 100644 --- a/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js +++ b/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js @@ -1,58 +1,52 @@ import React from 'react' -import jQuery from '../../../../../util/jquery' +import { UncontrolledPopover, PopoverHeader, PopoverBody, Button } from 'reactstrap' -class UnitComponent extends React.Component { - componentDidMount() { - jQuery('.unit-info-popover').popover({ - trigger: 'focus', - }) +function UnitComponent({ index, unitType, unit, onDelete }) { + let unitInfo + if (unitType === 'cpu' || unitType === 'gpu') { + unitInfo = ( + <> + Clockrate: + {unit.clockRateMhz} +
+ Num. Cores: + {unit.numberOfCores} +
+ Energy Cons.: + {unit.energyConsumptionW} W +
+ + ) + } else if (unitType === 'memory' || unitType === 'storage') { + unitInfo = ( + <> + Speed: + {unit.speedMbPerS} Mb/s +
+ Size: + {unit.sizeMb} MB +
+ Energy Cons.: + {unit.energyConsumptionW} W +
+ + ) } - render() { - let unitInfo - if (this.props.unitType === 'cpu' || this.props.unitType === 'gpu') { - unitInfo = - 'Clockrate: ' + - this.props.unit.clockRateMhz + - ' MHz
' + - 'Num. Cores: ' + - this.props.unit.numberOfCores + - '
' + - 'Energy Cons.: ' + - this.props.unit.energyConsumptionW + - ' W' - } else if (this.props.unitType === 'memory' || this.props.unitType === 'storage') { - unitInfo = - 'Speed: ' + - this.props.unit.speedMbPerS + - ' Mb/s
' + - 'Size: ' + - this.props.unit.sizeMb + - ' MB
' + - 'Energy Cons.: ' + - this.props.unit.energyConsumptionW + - ' W' - } + return ( +
  • + {unit.name} + +
  • + ) } export default UnitComponent diff --git a/frontend/src/containers/app/sidebars/topology/machine/UnitContainer.js b/frontend/src/containers/app/sidebars/topology/machine/UnitContainer.js index a028ebce..f334f9f2 100644 --- a/frontend/src/containers/app/sidebars/topology/machine/UnitContainer.js +++ b/frontend/src/containers/app/sidebars/topology/machine/UnitContainer.js @@ -5,6 +5,7 @@ import UnitComponent from '../../../../../components/app/sidebars/topology/machi const mapStateToProps = (state, ownProps) => { return { unit: state.objects[ownProps.unitType][ownProps.unitId], + index: ownProps.unitId, } } -- cgit v1.2.3