Skip to content

Commit

Permalink
feat(ui): add resources for analytics to show pagination
Browse files Browse the repository at this point in the history
* add links to pages in dash
  • Loading branch information
philwinder committed May 8, 2023
1 parent bd8c7f7 commit 2f6b1e9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
19 changes: 19 additions & 0 deletions ui/src/Analytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Datagrid, List, NumberField, TextField } from "react-admin";

export const ContentList = () => (
<List bulkActionButtons={false} actions={false} title={<div></div>} sort={{ field: 'meta.count', order: 'DESC' }}>
<Datagrid rowClick={false} bulkActionButtons={false} >
<TextField source="id" label="Content-Type" sortable={false} />
<NumberField source="meta.count" label="Count" />
</Datagrid>
</List>
);

export const RecentResultList = () => (
<List bulkActionButtons={false} actions={false} title={<div></div>} sort={{ field: 'meta.created_at', order: 'DESC' }}>
<Datagrid rowClick={false} bulkActionButtons={false} >
<NumberField source="meta.created_at" noWrap sortable={false} />
<TextField source="id" sortable={false} />
</Datagrid>
</List>
);
7 changes: 7 additions & 0 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import AccountTreeIcon from '@mui/icons-material/AccountTree';
import FindInPageIcon from '@mui/icons-material/FindInPage';
import ImageSearchIcon from '@mui/icons-material/ImageSearch';
import ShortTextIcon from '@mui/icons-material/ShortText';
import WorkIcon from '@mui/icons-material/Work';
import { Admin, Resource, ShowGuesser, defaultTheme } from "react-admin";
import { ContentList, RecentResultList } from './Analytics';
import Dashboard from './Dashboard';
import { GraphList } from './Graph';
import { JobList } from './Jobs';
Expand Down Expand Up @@ -28,6 +32,9 @@ const App = () => (
<Resource name="queue" list={QueueList} show={QueueItem} create={QueueCreate} options={{ label: 'Queue' }} />
<Resource name="graph" list={GraphList} options={{ label: 'Graph' }} icon={AccountTreeIcon} />
<Resource name="jobs" list={JobList} show={ShowGuesser} options={{ label: 'Jobs' }} icon={WorkIcon} />
<Resource name="analytics/results/content-type" list={ContentList} hasShow={false} hasCreate={false} hasEdit={false} options={{ label: 'Analytics: Content Types' }} icon={FindInPageIcon} />
<Resource name="analytics/results/content-classification" list={ContentList} hasShow={false} hasCreate={false} hasEdit={false} options={{ label: 'Analytics: Content Classifications' }} icon={ImageSearchIcon} />
<Resource name="analytics/recent-results/summary_text" list={RecentResultList} hasShow={false} hasCreate={false} hasEdit={false} options={{ label: 'Analytics: Text Summaries' }} icon={ShortTextIcon} />
</Admin >
);
export default App;
18 changes: 17 additions & 1 deletion ui/src/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import CardActions from '@mui/material/CardActions';
import CardContent from '@mui/material/CardContent';
import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import { Datagrid, List, NumberField, Resource, TextField, Title, useGetList } from 'react-admin';
import { Datagrid, List, NumberField, Resource, TextField, Title, useGetList , ReferenceField, UrlField} from 'react-admin';
import { ResponsiveLine } from '@nivo/line'
import logoUrl from './assets/amplify_logo_text.svg'
import Box from '@mui/material/Box';
Expand Down Expand Up @@ -77,6 +77,11 @@ export default () => {
</Typography>
<Resource name="analytics/results/content-type" list={ResultList} hasEdit={false} hasShow={false} hasCreate={false} options={{ label: 'Content-Type' }} />
</CardContent>
<CardActions>
<a href="/#/analytics/results/content-type">
<Button variant="outlined">Details</Button>
</a>
</CardActions>
</Card>
</Grid>
<Grid item sm={12} md={6} lg={4}>
Expand All @@ -90,6 +95,11 @@ export default () => {
</Typography>
<Resource name="analytics/results/content-classification" list={ResultList} hasEdit={false} hasShow={false} hasCreate={false} options={{ label: 'content-classification' }} />
</CardContent>
<CardActions>
<a href="/#/analytics/results/content-classification">
<Button variant="outlined">Details</Button>
</a>
</CardActions>
</Card>
</Grid>
<Grid item sm={12} md={6} lg={4}>
Expand Down Expand Up @@ -133,6 +143,12 @@ export default () => {
</Typography>
<Resource name="analytics/recent-results/summary_text" list={RecentResultList} hasEdit={false} hasShow={false} hasCreate={false} options={{ label: 'summary_text' }} />
</CardContent>

<CardActions>
<a href="/#/analytics/recent-results/summary_text">
<Button variant="outlined">Details</Button>
</a>
</CardActions>
</Card>
</Grid>
</Grid>
Expand Down

0 comments on commit 2f6b1e9

Please sign in to comment.