"use strict"; const React = require("react"); const classnames = require("classnames"); const syncpipe = require("syncpipe"); const splitFilterN = require("split-filter-n"); const { B } = require("../../../packages/unit-bytes-iec"); const treecutter = require("../../../packages/treecutter"); const Layout = require("../layout"); function sum(values) { return values.reduce((total, value) => total + value, 0); } function sumDriveSizes(drives) { return syncpipe(drives, [ (_) => _.map((drive) => drive.size.toB().amount), (_) => sum(_), (_) => B(_) ]); } function Indented({ depth, children }) { return (
{children}
); } function MountEntry({ mount }) { return
{mount.mountpoint}
; } function PartitionEntry({partition, isLast}) { function PartitionIndent({ children }) { return ( {children} ); } return ( {partition.name} {partition.size.toDisplay(2).toString()} {(partition.mounts.length > 0) ? partition.mounts.map((mount) => ) : (not mounted) } ); } function DriveEntry({drive}) { let flattenedPartitions = treecutter.flatten(drive.partitions); let hasPartitions = (flattenedPartitions.length > 0); return (<> {drive.path} {drive.size.toDisplay(2).toString()} {(drive.rpm != null) ? `${drive.rpm} RPM` : null } {drive.serialNumber} {drive.model} {drive.modelFamily} {drive.firmwareVersion} {flattenedPartitions.map((partition, i) => { let isLast = (i === flattenedPartitions.length - 1); return ; })} ); } function TallyRow({ label, rowClass, labelClass, children }) { return ( {label} {children} ); } module.exports = { query: { hardware: { drives: { path: true, smartHealth: true, size: true, rpm: true, serialNumber: true, model: true, modelFamily: true, firmwareVersion: true, blockDevice: { name: true }, partitions: { $key: "allBlockDevices", name: true, size: true, mounts: { mountpoint: true }, children: { $recurse: true, $recurseLimit: Infinity, // 3 by default } } } } }, template: function StorageDeviceList({data}) { let drivesByStatus = splitFilterN(data.hardware.drives, [ "HEALTHY", "DETERIORATING", "FAILING", "UNKNOWN" ], (drive) => drive.smartHealth); let totalStorage = sumDriveSizes(data.hardware.drives); let totalHealthyStorage = sumDriveSizes(drivesByStatus.HEALTHY); let totalAtRiskStorage = sumDriveSizes(drivesByStatus.DETERIORATING); let totalFailingStorage = sumDriveSizes(drivesByStatus.FAILING); let totalUnknownStorage = sumDriveSizes(drivesByStatus.UNKNOWN); return ( {data.hardware.drives.map((drive) => )} {totalStorage.toDisplay(2).toString()} {totalHealthyStorage.toDisplay(2).toString()} {totalAtRiskStorage.toDisplay(2).toString()} {totalFailingStorage.toDisplay(2).toString()} {totalUnknownStorage.toDisplay(2).toString()}
SMART Device Total size RPM Serial number Model Family Firmware version
); } };