UNPKG

@openshift-assisted/ui-lib

Version:

React component library for the Assisted Installer UI

51 lines 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const react_table_1 = require("@patternfly/react-table"); const hosts_1 = require("../hosts"); const hardwareInfo_1 = require("../hosts/hardwareInfo"); const utils_1 = require("../../utils"); const ui_1 = require("../ui"); const ReviewHostsInventory = ({ hosts = [] }) => { const rows = React.useMemo(() => { const summary = (0, hosts_1.getEnabledHosts)(hosts).reduce((summary, host) => { summary.count++; const inventory = (0, utils_1.stringToJSON)(host.inventory); if (inventory) { const hwInfo = (0, hardwareInfo_1.getSimpleHardwareInfo)(inventory); summary.cores += hwInfo.cores; summary.memory += hwInfo.memory; summary.fs += hwInfo.disks; } return summary; }, { count: 0, cores: 0, memory: 0, fs: 0, }); return [ { cells: [{ title: 'Hosts' }, { title: summary.count }], rowId: 'hosts', }, { cells: [{ title: 'Total cores' }, { title: summary.cores }], rowId: 'total-cores', }, { cells: [{ title: 'Total memory' }, { title: (0, utils_1.fileSize)(summary.memory, 2, 'iec') }], rowId: 'total-memory', }, { cells: [{ title: 'Total storage' }, { title: (0, utils_1.fileSize)(summary.fs, 2, 'si') }], rowId: 'total-storage', }, ]; }, [hosts]); return (React.createElement(react_table_1.Table, { "data-testid": "review-host-inventory-table", variant: react_table_1.TableVariant.compact, borders: false, "aria-label": "Cluster summary table", className: "review-table" }, React.createElement(react_table_1.Tbody, null, rows.map((row, i) => (React.createElement(react_table_1.Tr, { key: (0, ui_1.genericTableRowKey)(row.rowId) }, row.cells.map((cell, j) => (React.createElement(react_table_1.Td, { key: `cell-${i}-${j}` }, cell.title))))))))); }; exports.default = ReviewHostsInventory; //# sourceMappingURL=ReviewHostsInventory.js.map