-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from TurtIeSocks/new-filtering
Better Filtering for Admin Panel
- Loading branch information
Showing
14 changed files
with
417 additions
and
140 deletions.
There are no files selected for viewing
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,43 @@ | ||
import * as React from 'react' | ||
import { DeleteWithUndoButton } from 'react-admin' | ||
import { IconButton, Menu, MenuItem } from '@mui/material' | ||
import MoreVertIcon from '@mui/icons-material/MoreVert' | ||
|
||
import { ExportButton } from './Export' | ||
import { PushToProd } from './PushToApi' | ||
|
||
export function ExtraMenuActions({ resource }: { resource: string }) { | ||
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null) | ||
|
||
const handleClose = (e: React.MouseEvent) => { | ||
e.stopPropagation() | ||
setAnchorEl(null) | ||
} | ||
|
||
return ( | ||
<> | ||
<IconButton | ||
onClick={(e) => { | ||
e.stopPropagation() | ||
setAnchorEl(e.currentTarget) | ||
}} | ||
> | ||
<MoreVertIcon /> | ||
</IconButton> | ||
<Menu open={!!anchorEl} anchorEl={anchorEl} onClose={handleClose}> | ||
<MenuItem onClick={handleClose}> | ||
<DeleteWithUndoButton /> | ||
</MenuItem> | ||
<MenuItem onClick={handleClose}> | ||
<ExportButton resource={resource} /> | ||
</MenuItem> | ||
<MenuItem | ||
onClick={handleClose} | ||
sx={{ display: { xs: 'flex', sm: 'none' } }} | ||
> | ||
<PushToProd resource={resource} /> | ||
</MenuItem> | ||
</Menu> | ||
</> | ||
) | ||
} |
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
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,69 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import * as React from 'react' | ||
import { | ||
// SavedQueriesList, | ||
FilterLiveSearch, | ||
FilterList, | ||
FilterListItem, | ||
useGetList, | ||
} from 'react-admin' | ||
import { useQuery } from 'react-query' | ||
import { Card, CardContent } from '@mui/material' | ||
import AutoModeIcon from '@mui/icons-material/AutoMode' | ||
import AccountTree from '@mui/icons-material/AccountTree' | ||
import MapIcon from '@mui/icons-material/Map' | ||
import SupervisedUserCircleIcon from '@mui/icons-material/SupervisedUserCircle' | ||
|
||
import { useStatic } from '@hooks/useStatic' | ||
import { RDM_FENCES, UNOWN_FENCES } from '@assets/constants' | ||
import { KojiGeofence, KojiProject, KojiResponse } from '@assets/types' | ||
import { fetchWrapper } from '@services/fetches' | ||
|
||
export function GeofenceFilter() { | ||
const { scannerType } = useStatic.getState() | ||
const projectData = useGetList<KojiProject>('project') | ||
const { data } = useQuery('parents', () => | ||
fetchWrapper<KojiResponse<KojiGeofence[]>>( | ||
'/internal/admin/geofence/parent', | ||
), | ||
) | ||
return ( | ||
<Card sx={{ order: -1, width: 200 }}> | ||
<CardContent> | ||
{/* <SavedQueriesList /> */} | ||
<FilterLiveSearch /> | ||
<FilterList label="Project" icon={<AccountTree />}> | ||
{(projectData?.data || []).map((project) => ( | ||
<FilterListItem | ||
key={project.id} | ||
label={project.name} | ||
value={{ project: project.id }} | ||
/> | ||
))} | ||
</FilterList> | ||
<FilterList label="Parent" icon={<SupervisedUserCircleIcon />}> | ||
{(data?.data || []).map((parent) => ( | ||
<FilterListItem | ||
key={parent.id} | ||
label={parent.name} | ||
value={{ parent: parent.id }} | ||
/> | ||
))} | ||
</FilterList> | ||
<FilterList label="Geography Type" icon={<MapIcon />}> | ||
{['Polygon', 'MultiPolygon'].map((geotype) => ( | ||
<FilterListItem key={geotype} label={geotype} value={{ geotype }} /> | ||
))} | ||
</FilterList> | ||
<FilterList label="Mode" icon={<AutoModeIcon />}> | ||
{[ | ||
...(scannerType === 'rdm' ? RDM_FENCES : UNOWN_FENCES), | ||
'unset', | ||
].map((mode) => ( | ||
<FilterListItem key={mode} label={mode} value={{ mode }} /> | ||
))} | ||
</FilterList> | ||
</CardContent> | ||
</Card> | ||
) | ||
} |
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
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,53 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import * as React from 'react' | ||
import { | ||
// SavedQueriesList, | ||
FilterLiveSearch, | ||
FilterList, | ||
FilterListItem, | ||
} from 'react-admin' | ||
import { useQuery } from 'react-query' | ||
import { Card, CardContent } from '@mui/material' | ||
import AutoModeIcon from '@mui/icons-material/AutoMode' | ||
import SupervisedUserCircleIcon from '@mui/icons-material/SupervisedUserCircle' | ||
|
||
import { useStatic } from '@hooks/useStatic' | ||
import { RDM_ROUTES, UNOWN_ROUTES } from '@assets/constants' | ||
import { BasicKojiEntry, KojiResponse } from '@assets/types' | ||
import { fetchWrapper } from '@services/fetches' | ||
|
||
export function RouteFilter() { | ||
const { scannerType } = useStatic.getState() | ||
const { data } = useQuery('unique_geofences', () => | ||
fetchWrapper<KojiResponse<BasicKojiEntry[]>>( | ||
'/internal/admin/route/parent', | ||
), | ||
) | ||
return ( | ||
<Card sx={{ order: -1, width: 225 }}> | ||
<CardContent> | ||
{/* <SavedQueriesList /> */} | ||
<FilterLiveSearch /> | ||
<FilterList label="Mode" icon={<AutoModeIcon />}> | ||
{[ | ||
...(scannerType === 'rdm' ? RDM_ROUTES : UNOWN_ROUTES), | ||
'unset', | ||
].map((mode) => ( | ||
<FilterListItem key={mode} label={mode} value={{ mode }} /> | ||
))} | ||
</FilterList> | ||
<FilterList label="Geofence" icon={<SupervisedUserCircleIcon />}> | ||
<div style={{ maxHeight: 400, overflow: 'auto' }}> | ||
{(data?.data || []).map((fence) => ( | ||
<FilterListItem | ||
key={fence.id} | ||
label={fence.name} | ||
value={{ geofenceid: fence.id }} | ||
/> | ||
))} | ||
</div> | ||
</FilterList> | ||
</CardContent> | ||
</Card> | ||
) | ||
} |
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
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
Oops, something went wrong.
3ed922a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
koji – ./
koji-git-main-turtiesocks.vercel.app
koji-turtiesocks.vercel.app
koji.vercel.app