summaryrefslogtreecommitdiff
path: root/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2020-10-28 13:29:54 +0100
committerGitHub <noreply@github.com>2020-10-28 13:29:54 +0100
commit93fa55749c40ed1f1a7bee9157bce81708988656 (patch)
treec386e6f0cbac347d15cc10a64d044cb70a6df7f0 /frontend/src/components/app/sidebars/topology/machine/UnitComponent.js
parent44342c83b886c4d65ef8b74a3bea1d0e12b37f38 (diff)
parent34b45675b3de56c847818dbcc829f7ce02ddce56 (diff)
Merge pull request #52 from atlarge-research/refactor/jquery
Eliminate jQuery from frontend dependencies
Diffstat (limited to 'frontend/src/components/app/sidebars/topology/machine/UnitComponent.js')
-rw-r--r--frontend/src/components/app/sidebars/topology/machine/UnitComponent.js94
1 files changed, 44 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 = (
+ <>
+ <strong>Clockrate: </strong>
+ <code>{unit.clockRateMhz}</code>
+ <br />
+ <strong>Num. Cores: </strong>
+ <code>{unit.numberOfCores}</code>
+ <br />
+ <strong>Energy Cons.: </strong>
+ <code>{unit.energyConsumptionW} W</code>
+ <br />
+ </>
+ )
+ } else if (unitType === 'memory' || unitType === 'storage') {
+ unitInfo = (
+ <>
+ <strong>Speed:</strong>
+ <code>{unit.speedMbPerS} Mb/s</code>
+ <br />
+ <strong>Size:</strong>
+ <code>{unit.sizeMb} MB</code>
+ <br />
+ <strong>Energy Cons.:</strong>
+ <code>{unit.energyConsumptionW} W</code>
+ <br />
+ </>
+ )
}
- render() {
- let unitInfo
- if (this.props.unitType === 'cpu' || this.props.unitType === 'gpu') {
- unitInfo =
- '<strong>Clockrate:</strong> <code>' +
- this.props.unit.clockRateMhz +
- ' MHz</code><br/>' +
- '<strong>Num. Cores:</strong> <code>' +
- this.props.unit.numberOfCores +
- '</code><br/>' +
- '<strong>Energy Cons.:</strong> <code>' +
- this.props.unit.energyConsumptionW +
- ' W</code>'
- } else if (this.props.unitType === 'memory' || this.props.unitType === 'storage') {
- unitInfo =
- '<strong>Speed:</strong> <code>' +
- this.props.unit.speedMbPerS +
- ' Mb/s</code><br/>' +
- '<strong>Size:</strong> <code>' +
- this.props.unit.sizeMb +
- ' MB</code><br/>' +
- '<strong>Energy Cons.:</strong> <code> ' +
- this.props.unit.energyConsumptionW +
- ' W</code>'
- }
+ return (
+ <li className="d-flex list-group-item justify-content-between align-items-center">
+ <span style={{ maxWidth: '60%' }}>{unit.name}</span>
+ <span>
+ <Button outline={true} color="info" className="mr-1 fa fa-info-circle" id={`unit-${index}`} />
+ <UncontrolledPopover trigger="focus" placement="left" target={`unit-${index}`}>
+ <PopoverHeader>Unit Information</PopoverHeader>
+ <PopoverBody>{unitInfo}</PopoverBody>
+ </UncontrolledPopover>
- return (
- <li className="d-flex list-group-item justify-content-between align-items-center">
- <span style={{ maxWidth: '60%' }}>{this.props.unit.name}</span>
- <span>
- <span
- tabIndex="0"
- className="unit-info-popover btn btn-outline-info mr-1 fa fa-info-circle"
- role="button"
- data-toggle="popover"
- data-trigger="focus"
- title="Unit information"
- data-content={unitInfo}
- data-html="true"
- />
- <span className="btn btn-outline-danger fa fa-trash" onClick={this.props.onDelete} />
- </span>
- </li>
- )
- }
+ <span className="btn btn-outline-danger fa fa-trash" onClick={onDelete} />
+ </span>
+ </li>
+ )
}
export default UnitComponent