blob: 4854456c7316d45517768192e06415bed767ec99 (
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
|
import React from "react";
import Shapes from "../../../../shapes";
const UnitIcon = ({id, type}) => (
<div>
<img
src={"/img/topology/" + id + "-icon.png"}
alt={"Machine contains " + type + " units"}
className="img-fluid ml-1"
style={{maxHeight: "35px"}}
/>
</div>
);
const MachineComponent = ({position, machine, onClick}) => (
<li
className="d-flex list-group-item list-group-item-action justify-content-between align-items-center"
onClick={onClick}
>
<span className="badge badge-default badge-info mr-1">
{position}
</span>
<div className="d-inline-flex">
{machine.cpuIds.length > 0 ?
<UnitIcon id="cpu" type="CPU"/> :
undefined
}
{machine.gpuIds.length > 0 ?
<UnitIcon id="gpu" type="GPU"/> :
undefined
}
{machine.memoryIds.length > 0 ?
<UnitIcon id="memory" type="memory"/> :
undefined
}
{machine.storageIds.length > 0 ?
<UnitIcon id="storage" type="storage"/> :
undefined
}
{machine.cpuIds.length + machine.gpuIds.length + machine.memoryIds.length
+ machine.storageIds.length === 0 ?
<span className="badge badge-default badge-warning">
Machine with no units
</span> :
undefined
}
</div>
</li>
);
MachineComponent.propTypes = {
machine: Shapes.Machine
};
export default MachineComponent;
|