MachineCollapsedContent component

master
Tudor Stanciu 2023-04-18 02:22:42 +03:00
parent feab019df1
commit 4dff02b87f
7 changed files with 78 additions and 6 deletions

View File

@ -4,3 +4,9 @@ https://v4.mui.com/components/material-icons/
Theming: Theming:
https://v4.mui.com/customization/palette/ (Dark theme) https://v4.mui.com/customization/palette/ (Dark theme)
Add in settings:
- reset cache
- ping interval
- notifications
- test notification mechanism

View File

@ -67,6 +67,7 @@
"Name": "Machine name", "Name": "Machine name",
"IP": "IP", "IP": "IP",
"MAC": "MAC address", "MAC": "MAC address",
"Description": "Description",
"PoweredOn": "Powered on", "PoweredOn": "Powered on",
"Actions": { "Actions": {
"Wake": "Wake", "Wake": "Wake",

View File

@ -58,6 +58,7 @@
"Name": "Nume masina", "Name": "Nume masina",
"IP": "IP", "IP": "IP",
"MAC": "Adresa MAC", "MAC": "Adresa MAC",
"Description": "Descriere",
"PoweredOn": "Pornit", "PoweredOn": "Pornit",
"Actions": { "Actions": {
"Wake": "Pornește", "Wake": "Pornește",

View File

@ -8,7 +8,7 @@ import {
} from "@material-ui/core"; } from "@material-ui/core";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore"; import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
import withStyles from "@material-ui/core/styles/withStyles"; import withStyles from "@material-ui/core/styles/withStyles";
import MachineLog from "./common/MachineLog"; import MachineCollapsedContent from "./common/MachineCollapsedContent";
import { DataLabel } from "../../../components/common"; import { DataLabel } from "../../../components/common";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useSensitiveInfo } from "../../../hooks"; import { useSensitiveInfo } from "../../../hooks";
@ -87,7 +87,11 @@ const MachineAccordion = ({ machine, actions, logs, addLog }) => {
</Grid> </Grid>
</IconLeftAccordionSummary> </IconLeftAccordionSummary>
<AccordionDetails> <AccordionDetails>
<MachineLog logs={logs} /> <MachineCollapsedContent
description={machine.description}
logs={logs}
style={{ width: "100%" }}
/>
</AccordionDetails> </AccordionDetails>
</Accordion> </Accordion>
); );

View File

@ -3,7 +3,7 @@ import PropTypes from "prop-types";
import { TableCell, TableRow, IconButton, Collapse } from "@material-ui/core"; import { TableCell, TableRow, IconButton, Collapse } from "@material-ui/core";
import { KeyboardArrowDown, KeyboardArrowUp } from "@material-ui/icons"; import { KeyboardArrowDown, KeyboardArrowUp } from "@material-ui/icons";
import { makeStyles } from "@material-ui/core/styles"; import { makeStyles } from "@material-ui/core/styles";
import MachineLog from "./common/MachineLog"; import MachineCollapsedContent from "./common/MachineCollapsedContent";
import { useSensitiveInfo } from "../../../hooks"; import { useSensitiveInfo } from "../../../hooks";
import ActionsGroup from "./common/ActionsGroup"; import ActionsGroup from "./common/ActionsGroup";
@ -45,7 +45,11 @@ const MachineTableRow = ({ machine, actions, logs, addLog }) => {
<TableRow> <TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}> <TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}>
<Collapse in={open} timeout="auto" unmountOnExit> <Collapse in={open} timeout="auto" unmountOnExit>
<MachineLog logs={logs} /> <MachineCollapsedContent
description={machine.description}
logs={logs}
style={{ paddingBottom: "10px" }}
/>
</Collapse> </Collapse>
</TableCell> </TableCell>
</TableRow> </TableRow>

View File

@ -0,0 +1,56 @@
import React from "react";
import PropTypes from "prop-types";
import MachineLog from "./MachineLog";
import Typography from "@material-ui/core/Typography";
import { useSensitiveInfo } from "../../../../hooks";
import { makeStyles } from "@material-ui/core/styles";
const useStyles = makeStyles(_theme => ({
panel: {
display: "flex"
},
label: {
marginRight: "4px"
}
}));
const MachineDescription = ({ description }) => {
const classes = useStyles();
return (
<div className={classes.panel}>
<Typography
variant="body2"
className={classes.label}
color="textSecondary"
>
{"Description:"}
</Typography>
<Typography variant="body2" color="textSecondary">
{description}
</Typography>
</div>
);
};
MachineDescription.propTypes = {
description: PropTypes.string
};
const MachineCollapsedContent = ({ description, logs, style }) => {
const { mask } = useSensitiveInfo();
return (
<div style={style}>
<MachineLog logs={logs} />
{description && <MachineDescription description={mask(description)} />}
</div>
);
};
MachineCollapsedContent.propTypes = {
logs: PropTypes.array.isRequired,
description: PropTypes.string,
style: PropTypes.object
};
export default MachineCollapsedContent;

View File

@ -13,7 +13,7 @@ const MachineLog = ({ logs }) => {
); );
return ( return (
<Box width="100%"> <Box>
<div style={{ height: 200 }}> <div style={{ height: 200 }}>
<ScrollFollow <ScrollFollow
startFollowing={true} startFollowing={true}