added bin history, fixed some column stuff in the DiffHistory
This commit is contained in:
parent
41131dee26
commit
c397b86524
3 changed files with 24 additions and 19 deletions
|
|
@ -1,14 +1,14 @@
|
||||||
import { Box, Card, Typography } from "@material-ui/core";
|
import { Box, Card, Typography, Theme } from "@mui/material";
|
||||||
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles";
|
import { createStyles, makeStyles } from "@mui/styles";
|
||||||
import { MatchParams } from "navigation/Routes";
|
//import { MatchParams } from "navigation/Routes";
|
||||||
import DiffHistory, { ListResult, Record } from "common/DiffHistory";
|
import DiffHistory, { ListResult, Record } from "common/DiffHistory";
|
||||||
import { useSnackbar, useMobile } from "hooks";
|
import { useSnackbar, useMobile } from "hooks";
|
||||||
import { useBinAPI } from "providers";
|
import { useBinAPI } from "providers";
|
||||||
import { Bin } from "models";
|
import { Bin } from "models";
|
||||||
import { TranslateKey, TranslateValue } from "pbHelpers/Bin";
|
import { TranslateKey, TranslateValue } from "pbHelpers/Bin";
|
||||||
import { pond } from "protobuf-ts/pond";
|
import { pond } from "protobuf-ts/pond";
|
||||||
import React, { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useParams } from "react-router";
|
//import { useParams } from "react-router";
|
||||||
import { or } from "utils/types";
|
import { or } from "utils/types";
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) =>
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
|
|
@ -29,16 +29,17 @@ const useStyles = makeStyles((theme: Theme) =>
|
||||||
);
|
);
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
binID?: string;
|
binID: string;
|
||||||
drawer?: boolean;
|
drawer?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function BinHistory(props: Props) {
|
export default function BinHistory(props: Props) {
|
||||||
const params = useParams<MatchParams>();
|
//const params = useParams<MatchParams>();
|
||||||
|
const {binID, drawer} = props
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const { openSnack } = useSnackbar();
|
const { openSnack } = useSnackbar();
|
||||||
const binAPI = useBinAPI();
|
const binAPI = useBinAPI();
|
||||||
const binID = props.binID ?? params.binID;
|
//const binID = props.binID ?? params.binID;
|
||||||
const [bin, setBin] = useState(Bin.any({ settings: { binId: binID } }));
|
const [bin, setBin] = useState(Bin.any({ settings: { binId: binID } }));
|
||||||
const binName = bin.name();
|
const binName = bin.name();
|
||||||
const isMobile = useMobile();
|
const isMobile = useMobile();
|
||||||
|
|
@ -92,7 +93,7 @@ export default function BinHistory(props: Props) {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className={isMobile || props.drawer ? classes.gutterMobile : classes.gutter}>
|
<Card className={isMobile || drawer ? classes.gutterMobile : classes.gutter}>
|
||||||
<Typography variant="subtitle2" color="textPrimary" className={classes.title}>
|
<Typography variant="subtitle2" color="textPrimary" className={classes.title}>
|
||||||
{binName} History
|
{binName} History
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
@ -103,10 +104,10 @@ export default function BinHistory(props: Props) {
|
||||||
list={list}
|
list={list}
|
||||||
translateKey={translateKey}
|
translateKey={translateKey}
|
||||||
translateValue={translateValue}
|
translateValue={translateValue}
|
||||||
cellStyle={{ margin: "0px", padding: "0.5rem" }}
|
cellStyle={{ margin: "0px", padding: 1 }}
|
||||||
showTitle={false}
|
showTitle={false}
|
||||||
headerStyle={{ margin: "0px" }}
|
headerStyle={{ margin: "0px" }}
|
||||||
drawer={props.drawer}
|
drawer={drawer}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ import {
|
||||||
ListItemIcon,
|
ListItemIcon,
|
||||||
Chip,
|
Chip,
|
||||||
Avatar,
|
Avatar,
|
||||||
Grid2 as Grid
|
Grid2 as Grid,
|
||||||
|
SxProps
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { Add, ChangeHistory, Remove, Face, Sync } from "@mui/icons-material";
|
import { Add, ChangeHistory, Remove, Face, Sync } from "@mui/icons-material";
|
||||||
import { amber, red, blue, green } from "@mui/material/colors";
|
import { amber, red, blue, green } from "@mui/material/colors";
|
||||||
|
|
@ -258,7 +259,7 @@ interface Props {
|
||||||
translateKey: (key: keyof any, type?: pond.ObjectType) => string;
|
translateKey: (key: keyof any, type?: pond.ObjectType) => string;
|
||||||
translateValue: (key: keyof any, obj: any, type?: pond.ObjectType) => string;
|
translateValue: (key: keyof any, obj: any, type?: pond.ObjectType) => string;
|
||||||
headerStyle?: React.CSSProperties;
|
headerStyle?: React.CSSProperties;
|
||||||
cellStyle?: React.CSSProperties | ((data: RowData[], rowData: RowData) => React.CSSProperties);
|
cellStyle?: SxProps<Theme>;
|
||||||
noPaging?: boolean;
|
noPaging?: boolean;
|
||||||
sortingEnabled?: boolean;
|
sortingEnabled?: boolean;
|
||||||
filteringEnabled?: boolean;
|
filteringEnabled?: boolean;
|
||||||
|
|
@ -391,6 +392,7 @@ export default function DiffHistory(props: Props) {
|
||||||
const columns = (): Column<RowData>[] => {
|
const columns = (): Column<RowData>[] => {
|
||||||
return [{
|
return [{
|
||||||
title: "Time",
|
title: "Time",
|
||||||
|
cellStyle: cellStyle,
|
||||||
render: (row: RowData) => (
|
render: (row: RowData) => (
|
||||||
<div style={isMobile || drawer ? { minWidth: "4rem" } : {}}>
|
<div style={isMobile || drawer ? { minWidth: "4rem" } : {}}>
|
||||||
{moment(row.timestamp).calendar()}
|
{moment(row.timestamp).calendar()}
|
||||||
|
|
@ -402,16 +404,17 @@ export default function DiffHistory(props: Props) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Object Type",
|
title: "Object Type",
|
||||||
|
cellStyle: cellStyle,
|
||||||
render: row => {
|
render: row => {
|
||||||
if (row.type) {
|
if (row.type) {
|
||||||
return (<div>ObjectDescriber(row.type).name</div>)
|
return (<div>{ObjectDescriber(row.type).name}</div>)
|
||||||
}
|
}
|
||||||
return <div></div>
|
return <div></div>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "User",
|
title: "User",
|
||||||
// cellStyle: cellStyle,
|
cellStyle: cellStyle,
|
||||||
// field: "user",
|
// field: "user",
|
||||||
render: row => {
|
render: row => {
|
||||||
const profile = getProfile(row.user);
|
const profile = getProfile(row.user);
|
||||||
|
|
@ -435,11 +438,12 @@ export default function DiffHistory(props: Props) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Status",
|
title: "Status",
|
||||||
render: row => <div>row.status</div>
|
cellStyle: cellStyle,
|
||||||
|
render: row => <div>{row.status}</div>
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Summary",
|
title: "Summary",
|
||||||
// cellStyle: cellStyle,
|
cellStyle: cellStyle,
|
||||||
// hidden: isMobile || drawer,
|
// hidden: isMobile || drawer,
|
||||||
render: row => (
|
render: row => (
|
||||||
<Summary
|
<Summary
|
||||||
|
|
@ -467,7 +471,7 @@ export default function DiffHistory(props: Props) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResponsiveTable<RowData>
|
<ResponsiveTable<RowData>
|
||||||
title={name + " History"}
|
title={showTitle ? name + " History" : undefined}
|
||||||
rows={data}
|
rows={data}
|
||||||
columns={columns()}
|
columns={columns()}
|
||||||
total={0}
|
total={0}
|
||||||
|
|
|
||||||
|
|
@ -542,7 +542,7 @@ export default function Bin(props: Props) {
|
||||||
</Box>
|
</Box>
|
||||||
</TabPanelMine>
|
</TabPanelMine>
|
||||||
<TabPanelMine value={value} index={1}>
|
<TabPanelMine value={value} index={1}>
|
||||||
{/* <BinHistory drawer={drawer} binID={binID} /> */}
|
<BinHistory drawer={drawer} binID={binID} />
|
||||||
</TabPanelMine>
|
</TabPanelMine>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue