network-resurrector/src/features/machines/components/MachineItem.js

106 lines
2.7 KiB
JavaScript
Raw Normal View History

2021-04-17 02:21:49 +03:00
import React from "react";
import PropTypes from "prop-types";
2021-04-17 02:39:05 +03:00
import {
TableCell,
TableRow,
IconButton,
Collapse,
Tooltip
} from "@material-ui/core";
import {
KeyboardArrowDown,
KeyboardArrowUp,
PowerSettingsNew,
LastPage
} from "@material-ui/icons";
2021-04-17 02:21:49 +03:00
import { makeStyles } from "@material-ui/core/styles";
import MachineLog from "./MachineLog";
2021-04-17 02:39:05 +03:00
import { useTranslation } from "react-i18next";
2021-04-17 02:21:49 +03:00
const useRowStyles = makeStyles({
root: {
"& > *": {
borderBottom: "unset"
}
}
});
const MachineItem = ({ machine }) => {
const [open, setOpen] = React.useState(false);
const classes = useRowStyles();
2021-04-17 02:39:05 +03:00
const { t } = useTranslation();
const handleClick = event => {
alert("asdasd");
};
2021-04-17 02:21:49 +03:00
return (
<React.Fragment>
<TableRow className={classes.root}>
<TableCell>
<IconButton
aria-label="expand row"
size="small"
onClick={() => setOpen(!open)}
>
2021-04-17 02:39:05 +03:00
{open ? <KeyboardArrowUp /> : <KeyboardArrowDown />}
2021-04-17 02:21:49 +03:00
</IconButton>
</TableCell>
<TableCell component="th" scope="row">
{machine.fullMachineName}
</TableCell>
<TableCell>{machine.machineName}</TableCell>
<TableCell>{machine.iPv4Address}</TableCell>
2021-04-17 02:39:05 +03:00
<TableCell align="right">
<>
<Tooltip title={t("General.Actions")}>
<span>
<IconButton
id={`machine-item-${machine.machineId}-wake`}
size={"small"}
disabled={false}
onClick={handleClick}
>
<PowerSettingsNew />
</IconButton>
</span>
</Tooltip>
<Tooltip title={t("General.Actions")}>
<span>
<IconButton
id={`machine-item-${machine.machineId}-ping`}
size={"small"}
disabled={false}
onClick={handleClick}
>
<LastPage />
</IconButton>
</span>
</Tooltip>
</>
</TableCell>
2021-04-17 02:21:49 +03:00
</TableRow>
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}>
<Collapse in={open} timeout="auto" unmountOnExit>
<MachineLog />
</Collapse>
</TableCell>
</TableRow>
</React.Fragment>
);
};
MachineItem.propTypes = {
machine: PropTypes.shape({
machineId: PropTypes.number.isRequired,
machineName: PropTypes.string.isRequired,
fullMachineName: PropTypes.string.isRequired,
macAddress: PropTypes.string.isRequired,
iPv4Address: PropTypes.string,
description: PropTypes.string
}).isRequired
};
export default MachineItem;