// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import * as React from "react"; import { compose } from 'redux'; import { withStyles, Dialog, DialogTitle, DialogContent, DialogActions, Button, StyleRulesCallback, WithStyles, Grid } from '@material-ui/core'; import { WithDialogProps, withDialog } from "~/store/dialog/with-dialog"; import { COMPUTE_NODE_ATTRIBUTES_DIALOG } from '~/store/compute-nodes/compute-nodes-actions'; import { ArvadosTheme } from '~/common/custom-theme'; import { NodeResource, NodeProperties, NodeInfo } from '~/models/node'; import classnames from "classnames"; type CssRules = 'root' | 'grid'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ root: { fontSize: '0.875rem', '& div:nth-child(odd):not(.nestedRoot)': { textAlign: 'right', color: theme.palette.grey["500"] }, '& div:nth-child(even)': { overflowWrap: 'break-word' } }, grid: { padding: '8px 0 0 0' } }); interface AttributesComputeNodeDialogDataProps { computeNode: NodeResource; } export const AttributesComputeNodeDialog = compose( withDialog(COMPUTE_NODE_ATTRIBUTES_DIALOG), withStyles(styles))( ({ open, closeDialog, data, classes }: WithDialogProps & WithStyles) => Attributes {data.computeNode &&
{renderPrimaryInfo(data.computeNode, classes)} {renderInfo(data.computeNode.info, classes)} {renderProperties(data.computeNode.properties, classes)}
}
); const renderPrimaryInfo = (computeNode: NodeResource, classes: any) => { const { uuid, ownerUuid, createdAt, modifiedAt, modifiedByClientUuid, modifiedByUserUuid } = computeNode; return ( UUID {uuid} Owner uuid {ownerUuid} Created at {createdAt} Modified at {modifiedAt} Modified by user uuid {modifiedByUserUuid} Modified by client uuid {modifiedByClientUuid || '(none)'} ); }; const renderInfo = (info: NodeInfo, classes: any) => { const { last_action, ping_secret, ec2_instance_id, slurm_state } = info; return ( Info - Last action {last_action || '(none)'} Info - Ping secret {ping_secret || '(none)'} Info - ec2 instance id {ec2_instance_id || '(none)'} Info - Slurm state {slurm_state || '(none)'} ); }; const renderProperties = (properties: NodeProperties, classes: any) => { const { total_ram_mb, total_cpu_cores, total_scratch_mb, cloud_node } = properties; return ( Properties - Total ram mb {total_ram_mb || '(none)'} Properties - Total scratch mb {total_scratch_mb || '(none)'} Properties - Total cpu cores {total_cpu_cores || '(none)'} Properties - Cloud node size {cloud_node ? cloud_node.size : '(none)'} Properties - Cloud node price {cloud_node ? cloud_node.price : '(none)'} ); };