restore functionality of the table
This commit is contained in:
parent
43226717c1
commit
47d50194c5
1 changed files with 39 additions and 68 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import { List } from "@mui/material";
|
import { List, Typography } from "@mui/material";
|
||||||
import DeviceLinkDrawer from "common/DeviceLinkDrawer";
|
import DeviceLinkDrawer from "common/DeviceLinkDrawer";
|
||||||
import ResponsiveTable from "common/ResponsiveTable";
|
import ResponsiveTable, { Column } from "common/ResponsiveTable";
|
||||||
//import { getTableIcons } from "common/ResponsiveTable";
|
//import { getTableIcons } from "common/ResponsiveTable";
|
||||||
import { useMobile } from "hooks";
|
import { useMobile } from "hooks";
|
||||||
//import MaterialTable from "material-table";
|
//import MaterialTable from "material-table";
|
||||||
|
|
@ -51,78 +51,49 @@ export default function Heaters() {
|
||||||
navigate(path, {state: { heater: heater, devices: devices}})
|
navigate(path, {state: { heater: heater, devices: devices}})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const columns = (): Column<pond.ObjectHeaterData>[] => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title: "Heater",
|
||||||
|
render: row => (<Typography>{row.heater?.name}</Typography>)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Site",
|
||||||
|
render: row => (<Typography>{row.site?.settings?.siteName}</Typography>)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Make",
|
||||||
|
render: row => (<Typography>{row.heater?.settings?.make}</Typography>)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Model",
|
||||||
|
render: row => (<Typography>{row.heater?.settings?.model}</Typography>)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Device",
|
||||||
|
render: row => {
|
||||||
|
let display: string | number | undefined = "No Device Found"
|
||||||
|
if (row.devices.length > 0) {
|
||||||
|
if (row.devices[0].device?.settings?.name) {
|
||||||
|
display = row.devices[0].device?.settings?.name;
|
||||||
|
} else {
|
||||||
|
display = row.devices[0].device?.settings?.deviceId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (<Typography>{display}</Typography>)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
const desktopTable = () => {
|
const desktopTable = () => {
|
||||||
// return (
|
|
||||||
// <MaterialTable
|
|
||||||
// columns={[
|
|
||||||
// {
|
|
||||||
// title: "Heater",
|
|
||||||
// field: "heater.name",
|
|
||||||
// headerStyle: {
|
|
||||||
// fontWeight: 650,
|
|
||||||
// fontSize: 20
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// title: "Site",
|
|
||||||
// field: "site.settings.siteName",
|
|
||||||
// headerStyle: {
|
|
||||||
// fontWeight: 650,
|
|
||||||
// fontSize: 20
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// title: "Make",
|
|
||||||
// field: "heater.settings.make",
|
|
||||||
// headerStyle: {
|
|
||||||
// fontWeight: 650,
|
|
||||||
// fontSize: 20
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// title: "Model",
|
|
||||||
// field: "heater.settings.model",
|
|
||||||
// headerStyle: {
|
|
||||||
// fontWeight: 650,
|
|
||||||
// fontSize: 20
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// title: "Device",
|
|
||||||
// headerStyle: {
|
|
||||||
// fontWeight: 650,
|
|
||||||
// fontSize: 20
|
|
||||||
// },
|
|
||||||
// render: rowData => {
|
|
||||||
// if (rowData.devices.length > 0) {
|
|
||||||
// if (rowData.devices[0].device?.settings?.name) {
|
|
||||||
// return rowData.devices[0].device?.settings?.name;
|
|
||||||
// } else {
|
|
||||||
// return rowData.devices[0].device?.settings?.deviceId;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// return "No Device Found";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// ]}
|
|
||||||
// data={heaters}
|
|
||||||
// icons={getTableIcons()}
|
|
||||||
// onRowClick={(_, heaterData) => {
|
|
||||||
// heaterData && goToHeater(ObjectHeater.any(heaterData.heater), heaterData.devices);
|
|
||||||
// }}
|
|
||||||
// title={"Heaters"}
|
|
||||||
// options={{
|
|
||||||
// pageSize: 10
|
|
||||||
// }}
|
|
||||||
// />
|
|
||||||
// );
|
|
||||||
return (
|
return (
|
||||||
<ResponsiveTable
|
<ResponsiveTable<pond.ObjectHeaterData>
|
||||||
page={tablePage}
|
page={tablePage}
|
||||||
pageSize={pageSize}
|
pageSize={pageSize}
|
||||||
total={total}
|
total={total}
|
||||||
rows={heaters}
|
rows={heaters}
|
||||||
|
columns={columns}
|
||||||
setPage={(page)=>{setTablePage(page)}}
|
setPage={(page)=>{setTablePage(page)}}
|
||||||
handleRowsPerPageChange={()=>{}}
|
handleRowsPerPageChange={()=>{}}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue