-
Notifications
You must be signed in to change notification settings - Fork 16
New features #1253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
joshunrau
merged 4 commits into
DouglasNeuroInformatics:main
from
joshunrau:new-features
Dec 10, 2025
+298
−20
Merged
New features #1253
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
69657a3
add qr-code to assignments and fix flashing with slider
joshunrau a13ba28
add instrument record summary page
joshunrau 6843f36
reorder subject page tabs in datahub
joshunrau 861d4c2
fix test failure caused by change by omitting __id__ from export
joshunrau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,32 @@ | ||
| import { useEffect, useRef } from 'react'; | ||
|
|
||
| import { useTheme } from '@douglasneuroinformatics/libui/hooks'; | ||
| import qrcode from 'qrcode'; | ||
|
|
||
| export const QRCode = ({ url }: { url: string }) => { | ||
| const ref = useRef<HTMLCanvasElement>(null); | ||
|
|
||
| const [theme] = useTheme(); | ||
|
|
||
| useEffect(() => { | ||
| qrcode.toCanvas( | ||
| ref.current, | ||
| url, | ||
| { | ||
| color: { | ||
| dark: theme === 'dark' ? '#f1f5f9' : '#0f172a', | ||
| light: '#0000' | ||
| }, | ||
| margin: 2, | ||
| scale: 6 | ||
| }, | ||
| (error) => { | ||
| if (error) { | ||
| console.error(error); | ||
| } | ||
| } | ||
| ); | ||
| }, [theme, url]); | ||
|
|
||
| return <canvas className="rounded-md border" ref={ref} />; | ||
| }; |
This file contains hidden or 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,17 @@ | ||
| import { $InstrumentRecord } from '@opendatacapture/schemas/instrument-records'; | ||
| import { queryOptions, useSuspenseQuery } from '@tanstack/react-query'; | ||
| import axios from 'axios'; | ||
|
|
||
| export const instrumentRecordQueryOptions = ({ params }: { params: { id: string } }) => { | ||
| return queryOptions({ | ||
| queryFn: async () => { | ||
| const response = await axios.get(`/v1/instrument-records/${params.id}`); | ||
| return $InstrumentRecord.parse(response.data); | ||
| }, | ||
| queryKey: ['instrument-records', `id-${params.id}`] | ||
| }); | ||
| }; | ||
|
|
||
| export function useInstrumentRecordQuery({ params }: { params: { id: string } }) { | ||
| return useSuspenseQuery(instrumentRecordQueryOptions({ params })); | ||
| } |
This file contains hidden or 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 hidden or 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,21 @@ | ||
| import { $Subject } from '@opendatacapture/schemas/subject'; | ||
| import { queryOptions, useSuspenseQuery } from '@tanstack/react-query'; | ||
| import axios from 'axios'; | ||
|
|
||
| type SubjectQueryParams = { | ||
| id: string; | ||
| }; | ||
|
|
||
| export const subjectQueryOptions = ({ params }: { params: SubjectQueryParams }) => { | ||
| return queryOptions({ | ||
| queryFn: async () => { | ||
| const response = await axios.get(`/v1/subjects/${params.id}`, { params }); | ||
| return $Subject.parseAsync(response.data); | ||
| }, | ||
| queryKey: ['subjects', `id-${params.id}`] | ||
| }); | ||
| }; | ||
|
|
||
| export function useSubjectQuery({ params }: { params: SubjectQueryParams }) { | ||
| return useSuspenseQuery(subjectQueryOptions({ params })); | ||
| } | ||
This file contains hidden or 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 hidden or 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,41 @@ | ||
| import { InstrumentSummary } from '@opendatacapture/react-core'; | ||
| import { createFileRoute } from '@tanstack/react-router'; | ||
|
|
||
| import { useInstrument } from '@/hooks/useInstrument'; | ||
| import { instrumentRecordQueryOptions, useInstrumentRecordQuery } from '@/hooks/useInstrumentRecordQuery'; | ||
| import { subjectQueryOptions, useSubjectQuery } from '@/hooks/useSubjectQuery'; | ||
|
|
||
| const RouteComponent = () => { | ||
| const recordId = Route.useParams({ select: (params) => params.recordId }); | ||
|
|
||
| const { data: instrumentRecord } = useInstrumentRecordQuery({ params: { id: recordId } }); | ||
| const { data: subject } = useSubjectQuery({ params: { id: instrumentRecord.subjectId } }); | ||
|
|
||
| const instrument = useInstrument(instrumentRecord.instrumentId); | ||
|
|
||
| if (!instrument) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <div className="container py-8"> | ||
| <InstrumentSummary | ||
| displayAllMeasures | ||
| data={instrumentRecord.data} | ||
| instrument={instrument} | ||
| subject={subject} | ||
| timeCollected={instrumentRecord.createdAt.getTime()} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export const Route = createFileRoute('/_app/datahub/$subjectId/$recordId')({ | ||
| component: RouteComponent, | ||
| loader: async ({ context, params }) => { | ||
| const record = await context.queryClient.ensureQueryData( | ||
| instrumentRecordQueryOptions({ params: { id: params.recordId } }) | ||
| ); | ||
| await context.queryClient.ensureQueryData(subjectQueryOptions({ params: { id: record.subjectId } })); | ||
| } | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Remove redundant params from axios config.
Line 12 passes
paramsas query parameters, resulting in/v1/subjects/123?id=123. The ID is already in the URL path and shouldn't be duplicated as a query parameter.Apply this diff:
export const subjectQueryOptions = ({ params }: { params: SubjectQueryParams }) => { return queryOptions({ queryFn: async () => { - const response = await axios.get(`/v1/subjects/${params.id}`, { params }); + const response = await axios.get(`/v1/subjects/${params.id}`); return $Subject.parseAsync(response.data); }, queryKey: ['subjects', `id-${params.id}`] }); };📝 Committable suggestion
🤖 Prompt for AI Agents