|
| 1 | +import {Size} from "../../../util/vec2"; |
| 2 | +import * as React from "react"; |
| 3 | +import {numPointsX, numPointsY} from "../points"; |
| 4 | +import CpuUsageWidget from "../../cpu"; |
| 5 | +import {ProcessesInfoWidget} from "../../process"; |
| 6 | +import MemoryUsageWidget from "../../memory"; |
| 7 | +import {NetworkStatusWidget, NetworkUsageWidget} from "../../network"; |
| 8 | + |
| 9 | +interface PropType { |
| 10 | + windowSize: Size; |
| 11 | +} |
| 12 | + |
| 13 | +export default class RowLayoutEngine extends React.Component<PropType, {}> { |
| 14 | + |
| 15 | + render() { |
| 16 | + const totalWidth = numPointsX(this.props.windowSize) - 1; |
| 17 | + const totalHeight = numPointsY(this.props.windowSize) - 1; |
| 18 | + const padding = 1; |
| 19 | + let cpuSize = totalHeight; |
| 20 | + const fullCpuSize = cpuSize + padding; |
| 21 | + |
| 22 | + let networkFlowWidth = 10; |
| 23 | + const networkFlowTotalWidth = networkFlowWidth + padding; |
| 24 | + |
| 25 | + const pingWidth = 6; |
| 26 | + const totalPingWidth = pingWidth + padding; |
| 27 | + |
| 28 | + const memoryWidth = totalWidth - fullCpuSize - networkFlowTotalWidth - totalPingWidth; |
| 29 | + |
| 30 | + return ( |
| 31 | + <> |
| 32 | + <CpuUsageWidget |
| 33 | + topLeft={{x: 0, y: 0}} |
| 34 | + size={{width: cpuSize, height: cpuSize}} |
| 35 | + windowSize={this.props.windowSize} |
| 36 | + /> |
| 37 | + {memoryWidth > 0 && <MemoryUsageWidget |
| 38 | + topLeft={{x: fullCpuSize, y: 0}} |
| 39 | + size={{width: memoryWidth, height: cpuSize}} |
| 40 | + windowSize={this.props.windowSize} |
| 41 | + />} |
| 42 | + <NetworkUsageWidget |
| 43 | + topLeft={{x: fullCpuSize + memoryWidth + padding, y: 0}} |
| 44 | + size={{width: networkFlowWidth, height: totalHeight - padding * 4}} |
| 45 | + windowSize={this.props.windowSize} |
| 46 | + /> |
| 47 | + <NetworkStatusWidget |
| 48 | + topLeft={{x: fullCpuSize + memoryWidth + padding + networkFlowWidth + padding, y: 0}} |
| 49 | + size={{width: pingWidth, height: totalHeight - padding * 4}} |
| 50 | + windowSize={this.props.windowSize} |
| 51 | + /> |
| 52 | + <ProcessesInfoWidget |
| 53 | + topLeft={{x: fullCpuSize + memoryWidth + padding, y: totalHeight - padding * 3}} |
| 54 | + size={{width: networkFlowWidth + pingWidth + padding, height: padding * 3}} |
| 55 | + windowSize={this.props.windowSize} |
| 56 | + /> |
| 57 | + {/*{diskHeight > 0 && <PartitionWidget*/} |
| 58 | + {/* topLeft={{x: 0, y: fullCpuSize + networkFlowHeight + padding}}*/} |
| 59 | + {/* size={{width: networkFlowWidth + padding + pingWebWidth, height: diskHeight}}*/} |
| 60 | + {/* windowSize={this.props.windowSize}*/} |
| 61 | + {/*/>}*/} |
| 62 | + {/*{swapHeight !== 0 && <SwapUsageWidget*/} |
| 63 | + {/* topLeft={{x: fullCpuWidth + fullProcessWidth, y: memoryHeight}}*/} |
| 64 | + {/* size={{width: memoryNetworkWidth, height: swapHeight}}*/} |
| 65 | + {/* windowSize={this.props.windowSize}*/} |
| 66 | + {/*/>}*/} |
| 67 | + {/*{networkHeight !== 0 && <NetworkUsageWidget*/} |
| 68 | + {/* topLeft={{x: fullCpuWidth + fullProcessWidth, y: memoryHeight + swapHeight}}*/} |
| 69 | + {/* size={{width: memoryNetworkWidth, height: networkHeight}}*/} |
| 70 | + {/* windowSize={this.props.windowSize}*/} |
| 71 | + {/*/>}*/} |
| 72 | + {/*{detailsWidth !== 0 && <DetailsWidget*/} |
| 73 | + {/* topLeft={{x: fullCpuWidth + fullProcessWidth + fullMemoryNetworkWidth, y: 0}}*/} |
| 74 | + {/* size={{width: detailsWidth, height: totalHeight}}*/} |
| 75 | + {/* windowSize={this.props.windowSize}*/} |
| 76 | + {/*/>}*/} |
| 77 | + </> |
| 78 | + ); |
| 79 | + } |
| 80 | +} |
0 commit comments