-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Added comment column * Added enabled column * Added is helper column * Added modified column * Added metrics grid with data example * Created actions component with 'Show SQL', 'Edit' and 'Delete' buttons. Changed spaces indents from 4 to 2 * changed spaces indent * created grid toolbar component with 'columns', 'filter' and 'new' buttons * changed location of columns definition * removed sample data
- Loading branch information
1 parent
847bf04
commit 75f25c6
Showing
5 changed files
with
149 additions
and
22 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/webui/src/layout/MetricDefinitions/MetricsTable/ActionsComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import DeleteIcon from '@mui/icons-material/Delete'; | ||
import EditIcon from '@mui/icons-material/Edit'; | ||
import VisibilityIcon from '@mui/icons-material/Visibility'; | ||
import { Box, Button } from "@mui/material"; | ||
|
||
|
||
export const ActionsComponent = () => { | ||
|
||
|
||
return ( | ||
<Box sx={{ display: "flex", justifyContent: "space-around", width: "100%" }}> | ||
<Button | ||
size="small" | ||
variant="outlined" | ||
startIcon={<VisibilityIcon />} | ||
> | ||
Show SQL | ||
</Button> | ||
<Button | ||
size="small" | ||
variant="outlined" | ||
startIcon={<EditIcon />} | ||
> | ||
Edit | ||
</Button> | ||
<Button | ||
size="small" | ||
variant="contained" | ||
startIcon={<DeleteIcon />} | ||
> | ||
Delete | ||
</Button> | ||
</Box> | ||
); | ||
}; |
16 changes: 16 additions & 0 deletions
16
src/webui/src/layout/MetricDefinitions/MetricsTable/GridToolbarComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import AddIcon from '@mui/icons-material/Add'; | ||
import { Button } from "@mui/material"; | ||
import { GridToolbarColumnsButton, GridToolbarContainer, GridToolbarFilterButton } from "@mui/x-data-grid"; | ||
|
||
|
||
export const GridToolbarComponent = () => { | ||
|
||
|
||
return ( | ||
<GridToolbarContainer> | ||
<GridToolbarColumnsButton size="small" sx={{ height: 32 }} /> | ||
<GridToolbarFilterButton componentsProps={{ button: { size: "small" } }} sx={{ height: 32 }} /> | ||
<Button size="small" startIcon={<AddIcon />} sx={{ height: 32 }}>New</Button> | ||
</GridToolbarContainer> | ||
); | ||
}; |
92 changes: 92 additions & 0 deletions
92
src/webui/src/layout/MetricDefinitions/MetricsTable/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import CheckIcon from '@mui/icons-material/Check'; | ||
import CloseIcon from '@mui/icons-material/Close'; | ||
import { Box, Typography } from "@mui/material"; | ||
import { DataGrid, GridColDef, GridRenderCellParams } from "@mui/x-data-grid"; | ||
import moment from 'moment'; | ||
import { ActionsComponent } from './ActionsComponent'; | ||
import { GridToolbarComponent } from "./GridToolbarComponent"; | ||
|
||
export const MetricsTable = () => { | ||
|
||
const columns: GridColDef[] = [ | ||
{ | ||
field: "m_name", | ||
headerName: "Metric name", | ||
width: 150, | ||
align: "center", | ||
headerAlign: "center" | ||
}, | ||
{ | ||
field: "m_versions", | ||
headerName: "PG versions", | ||
width: 150, | ||
align: "center", | ||
headerAlign: "center", | ||
valueGetter(params) { | ||
return (Object.keys(params.value)); | ||
}, | ||
}, | ||
{ | ||
field: "m_comment", | ||
headerName: "Comment", | ||
width: 150, | ||
align: "center", | ||
headerAlign: "center" | ||
}, | ||
{ | ||
field: "m_is_active", | ||
headerName: "Enabled?", | ||
width: 120, | ||
renderCell: (params: GridRenderCellParams<boolean>) => params.value ? <CheckIcon /> : <CloseIcon />, | ||
align: "center", | ||
headerAlign: "center" | ||
}, | ||
{ | ||
field: "m_is_helper", | ||
headerName: "Helpers?", | ||
width: 120, | ||
renderCell: (params: GridRenderCellParams<boolean>) => params.value ? <CheckIcon /> : <CloseIcon />, | ||
align: "center", | ||
headerAlign: "center" | ||
}, | ||
{ | ||
field: "m_last_modified_on", | ||
headerName: "Last modified", | ||
width: 150, | ||
renderCell: (params) => | ||
<Box sx={{ display: "flex", alignItems: "center", textAlign: "center" }}> | ||
{moment(params.value).format("MMMM Do YYYY HH:mm:ss")} | ||
</Box>, | ||
align: "center", | ||
headerAlign: "center" | ||
}, | ||
{ | ||
field: "actions", | ||
headerName: "Actions", | ||
type: "actions", | ||
width: 350, | ||
renderCell: () => ( | ||
<ActionsComponent /> | ||
), | ||
headerAlign: "center" | ||
} | ||
]; | ||
|
||
return ( | ||
<Box display="flex" flexDirection="column" gap={1}> | ||
<Typography variant="h5"> | ||
Metrics | ||
</Typography> | ||
<DataGrid | ||
getRowHeight={() => "auto"} | ||
getRowId={(row) => row.m_name} | ||
columns={columns} | ||
rows={[]} | ||
autoHeight | ||
pageSize={5} | ||
components={{ Toolbar: () => GridToolbarComponent() }} | ||
disableColumnMenu | ||
/> | ||
</Box> | ||
); | ||
}; |
21 changes: 0 additions & 21 deletions
21
src/webui/src/layout/MetricDefinitions/MetricsTable/metricsTableColumns.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
import { Box } from "@mui/material"; | ||
import { MetricsTable } from "./MetricsTable"; | ||
|
||
export const MetricDefinitions = () => { | ||
return <Box>Metric Definitions</Box>; | ||
return ( | ||
<Box> | ||
<MetricsTable /> | ||
</Box> | ||
); | ||
}; |