CEC-3577 Style tweak (#284)
This commit is contained in:
@@ -19,7 +19,7 @@ const MainForm = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx(classes.paper, classes.tableSize)}>
|
<div className={clsx(classes.paper, classes.tableSize)}>
|
||||||
<Typography variant="h6" className={classes.labelInline}>
|
<Typography variant="h6">
|
||||||
T.Rex Logs
|
T.Rex Logs
|
||||||
</Typography>
|
</Typography>
|
||||||
<TRexLogsTable vin={vin} token={token} classes={classes} />
|
<TRexLogsTable vin={vin} token={token} classes={classes} />
|
||||||
|
|||||||
@@ -1,47 +1,23 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
import api from "../../../services/vehiclesAPI";
|
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
TableCell,
|
TableCell,
|
||||||
TableFooter,
|
TableFooter,
|
||||||
TablePagination,
|
TablePagination,
|
||||||
TableRow,
|
TableRow
|
||||||
} from "@material-ui/core";
|
} from "@material-ui/core";
|
||||||
import {
|
import {
|
||||||
MuiPickersUtilsProvider,
|
KeyboardDatePicker, MuiPickersUtilsProvider
|
||||||
KeyboardDatePicker,
|
|
||||||
} from '@material-ui/pickers';
|
} from '@material-ui/pickers';
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
import api from "../../../services/vehiclesAPI";
|
||||||
|
|
||||||
import { useStatusContext } from "../../Contexts/StatusContext";
|
|
||||||
import { logger } from "../../../services/monitoring";
|
|
||||||
import { TableHead } from "@mui/material";
|
|
||||||
import DateFnsUtils from '@date-io/date-fns';
|
import DateFnsUtils from '@date-io/date-fns';
|
||||||
|
import { TableHead } from "@mui/material";
|
||||||
const transformLogs = (logs) =>
|
import { logger } from "../../../services/monitoring";
|
||||||
logs.map((log) => {
|
import { useStatusContext } from "../../Contexts/StatusContext";
|
||||||
const { level, timestamp, received_timestamp, line_number, filename, msg } = log;
|
|
||||||
//const trex_time = new Date(timestamp)
|
|
||||||
//const cloud_time = new Date(received_timestamp)
|
|
||||||
return {
|
|
||||||
level: level,
|
|
||||||
trex_timestamp: timestamp,
|
|
||||||
cloud_timestamp: received_timestamp,
|
|
||||||
line_number: line_number,
|
|
||||||
filename: filename,
|
|
||||||
msg: msg
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.flat()
|
|
||||||
|
|
||||||
const fromatDateForRequest = (date) => {
|
|
||||||
const getYear = date.toLocaleString("default", { year: "numeric" });
|
|
||||||
const getMonth = date.toLocaleString("default", { month: "2-digit" });
|
|
||||||
const getDay = date.toLocaleString("default", { day: "2-digit" });
|
|
||||||
return getYear + "-" + getMonth + "-" + getDay
|
|
||||||
};
|
|
||||||
|
|
||||||
const tableColumns = [
|
const tableColumns = [
|
||||||
{
|
{
|
||||||
@@ -75,9 +51,34 @@ const tableColumns = [
|
|||||||
width: "60%",
|
width: "60%",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const transformLogs = (logs) =>
|
||||||
|
logs.map((log) => {
|
||||||
|
const { level, timestamp, received_timestamp, line_number, filename, msg } = log;
|
||||||
|
//const trex_time = new Date(timestamp)
|
||||||
|
//const cloud_time = new Date(received_timestamp)
|
||||||
|
return {
|
||||||
|
level: level,
|
||||||
|
trex_timestamp: timestamp,
|
||||||
|
cloud_timestamp: received_timestamp,
|
||||||
|
line_number: line_number,
|
||||||
|
filename: filename,
|
||||||
|
msg: msg
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.flat()
|
||||||
|
|
||||||
|
const fromatDateForRequest = (date) => {
|
||||||
|
const getYear = date.toLocaleString("default", { year: "numeric" });
|
||||||
|
const getMonth = date.toLocaleString("default", { month: "2-digit" });
|
||||||
|
const getDay = date.toLocaleString("default", { day: "2-digit" });
|
||||||
|
return getYear + "-" + getMonth + "-" + getDay
|
||||||
|
};
|
||||||
|
|
||||||
//read at least 30000 bytes per one API request
|
//read at least 30000 bytes per one API request
|
||||||
const ONE_READ_SIZE = 30000
|
const ONE_READ_SIZE = 30000
|
||||||
const DEFAULT_PAGE_SIZE = 25
|
const DEFAULT_PAGE_SIZE = 25
|
||||||
|
|
||||||
const TRexLogsTable = ({ vin, token, classes }) => {
|
const TRexLogsTable = ({ vin, token, classes }) => {
|
||||||
const [allLogsFetched, setAllLogsFetched] = useState(false)
|
const [allLogsFetched, setAllLogsFetched] = useState(false)
|
||||||
const [blobSize, setBlobSize] = useState(0)
|
const [blobSize, setBlobSize] = useState(0)
|
||||||
@@ -134,7 +135,7 @@ const TRexLogsTable = ({ vin, token, classes }) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
setTotal(0)
|
setTotal(0)
|
||||||
const msg = `Can not fetch logs for ${fromatDateForRequest(selectedDate)}`
|
const msg = `Cannot fetch logs for ${fromatDateForRequest(selectedDate)}`
|
||||||
setMessage(msg)
|
setMessage(msg)
|
||||||
console.log(`${msg}, Cloud error:\n${fetched.error}`);
|
console.log(`${msg}, Cloud error:\n${fetched.error}`);
|
||||||
return
|
return
|
||||||
@@ -188,7 +189,7 @@ const TRexLogsTable = ({ vin, token, classes }) => {
|
|||||||
style={{ tableLayout: "fixed", minWidth: "1400px" }}
|
style={{ tableLayout: "fixed", minWidth: "1400px" }}
|
||||||
>
|
>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell>
|
<TableCell align="center">
|
||||||
<MuiPickersUtilsProvider utils={DateFnsUtils}>
|
<MuiPickersUtilsProvider utils={DateFnsUtils}>
|
||||||
<KeyboardDatePicker
|
<KeyboardDatePicker
|
||||||
disableToolbar
|
disableToolbar
|
||||||
@@ -205,7 +206,7 @@ const TRexLogsTable = ({ vin, token, classes }) => {
|
|||||||
/>
|
/>
|
||||||
</MuiPickersUtilsProvider>
|
</MuiPickersUtilsProvider>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="left">
|
<TableCell align="center">
|
||||||
{getReadPercentage()}
|
{getReadPercentage()}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@@ -213,13 +214,12 @@ const TRexLogsTable = ({ vin, token, classes }) => {
|
|||||||
<Table
|
<Table
|
||||||
style={{ tableLayout: "fixed", minWidth: "1400px" }}
|
style={{ tableLayout: "fixed", minWidth: "1400px" }}
|
||||||
>
|
>
|
||||||
<TableHead
|
<TableHead classes={classes}>
|
||||||
classes={classes}>
|
|
||||||
|
|
||||||
<TableRow>
|
<TableRow>
|
||||||
{tableColumns.map((column) => (
|
{tableColumns.map((column) => (
|
||||||
<TableCell style={{ width: column.width }} align="center" key={column.label || "none"}>{column.label}</TableCell>
|
<TableCell style={{ width: column.width }} align="center" key={column.label || "none"} className={classes.tableHeader} >{column.label}</TableCell>
|
||||||
))} </TableRow>
|
))}
|
||||||
|
</TableRow>
|
||||||
</TableHead >
|
</TableHead >
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{logs.slice(-getDesiredSize(), (pageIndex === 0 ? undefined : -(pageSize * pageIndex))).map((log, i) => (
|
{logs.slice(-getDesiredSize(), (pageIndex === 0 ? undefined : -(pageSize * pageIndex))).map((log, i) => (
|
||||||
|
|||||||
@@ -285,6 +285,10 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
color: "blue",
|
color: "blue",
|
||||||
textDecoration: "underline",
|
textDecoration: "underline",
|
||||||
},
|
},
|
||||||
|
tableHeader: {
|
||||||
|
textDecorationStyle: "solid",
|
||||||
|
fontWeight:500,
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export default useStyles;
|
export default useStyles;
|
||||||
|
|||||||
Reference in New Issue
Block a user