Path: blob/trunk/javascript/grid-ui/src/components/Node/NodeDetailsDialog.tsx
3987 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the5// "License"); you may not use this file except in compliance6// with the License. You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing,11// software distributed under the License is distributed on an12// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13// KIND, either express or implied. See the License for the14// specific language governing permissions and limitations15// under the License.1617import {18Box,19Button,20Chip,21Dialog,22DialogActions,23DialogContent,24DialogTitle,25IconButton,26Typography27} from '@mui/material'28import React, { useState } from 'react'29import {Info as InfoIcon } from '@mui/icons-material'30import OsLogo from '../common/OsLogo'31import NodeInfo from '../../models/node-info'3233function NodeDetailsDialog (props) {34const [open, setOpen] = useState(false)35const { node } = props36const nodeInfo: NodeInfo = node3738const getStatusColor = (status: string) => {39if (status === 'DOWN') return 'error'40if (status === 'DRAINING') return 'warning'41return 'success'42}4344return (45<Box component='span'>46<IconButton47sx={{ bm: 1 }}48onClick={() => setOpen(true)}49data-testid={`node-info-${nodeInfo.id}`}50size='large'51>52<InfoIcon />53</IconButton>54<Dialog55onClose={() => setOpen(false)}56aria-labelledby='node-info-dialog' open={open}57>58<DialogTitle id='node-info-dialog'>59<Box display='flex' alignItems='center' gap={1} flexWrap='wrap'>60<OsLogo osName={nodeInfo.osInfo.name} />61<Box fontWeight='fontWeightBold' display='inline'>62URI:63</Box>64<Box display='inline'>{nodeInfo.uri}</Box>65<Chip66label={nodeInfo.status}67color={getStatusColor(nodeInfo.status)}68size='small'69sx={{ ml: 'auto' }}70/>71</Box>72</DialogTitle>73<DialogContent dividers>74<Typography gutterBottom>75Node Id: {nodeInfo.id}76</Typography>77<Typography gutterBottom>78Status: {nodeInfo.status}79</Typography>80<Typography gutterBottom>81OS Arch: {nodeInfo.osInfo.arch}82</Typography>83<Typography gutterBottom>84OS Name: {nodeInfo.osInfo.name}85</Typography>86<Typography gutterBottom>87OS Version: {nodeInfo.osInfo.version}88</Typography>89<Typography gutterBottom>90Total slots: {nodeInfo.slotCount}91</Typography>92<Typography gutterBottom>93Grid version: {nodeInfo.version}94</Typography>95</DialogContent>96<DialogActions>97<Button98onClick={() => setOpen(false)}99color='primary'100variant='contained'101>102Close103</Button>104</DialogActions>105</Dialog>106</Box>107)108}109110export default NodeDetailsDialog111112113