summaryrefslogtreecommitdiff
path: root/frontend/src/components/app/sidebars/topology/machine/UnitComponent.js
blob: 647c8e5c1659f764bf2a1f60ac01018d94eb9f73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React from 'react'
import jQuery from '../../../../../util/jquery'

class UnitComponent extends React.Component {
    componentDidMount() {
        jQuery('.unit-info-popover').popover({
            trigger: 'focus',
        })
    }

    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%' }}>
          {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"
          />
                    {this.props.inSimulation ? (
                        undefined
                    ) : (
                        <span
                            className="btn btn-outline-danger"
                            onClick={this.props.onDelete}
                        >
              <span className="fa fa-trash"/>
            </span>
                    )}
        </span>
            </li>
        )
    }
}

export default UnitComponent