// 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 * as 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 { lastAction, pingSecret, ec2InstanceId, slurmState } = info; return ( Info - Last action {lastAction || '(none)'} Info - Ping secret {pingSecret || '(none)'} Info - ec2 instance id {ec2InstanceId || '(none)'} Info - Slurm state {slurmState || '(none)'} ); }; const renderProperties = (properties: NodeProperties, classes: any) => { const { totalRamMb, totalCpuCores, totalScratchMb, cloudNode } = properties; return ( Properties - Total ram mb {totalRamMb || '(none)'} Properties - Total scratch mb {totalScratchMb || '(none)'} Properties - Total cpu cores {totalCpuCores || '(none)'} Properties - Cloud node size {cloudNode ? cloudNode.size : '(none)'} Properties - Cloud node price {cloudNode ? cloudNode.price : '(none)'} ); };