diff --git a/src/content/series/EditSeries.tsx b/src/content/series/EditSeries.tsx index e3f00c1a..a42ef190 100644 --- a/src/content/series/EditSeries.tsx +++ b/src/content/series/EditSeries.tsx @@ -57,7 +57,6 @@ const EditSeries: React.FC = ({ series, onEditSeries, onClose, diff --git a/src/content/series/PreviewSeries.tsx b/src/content/series/PreviewSeries.tsx index 115dada2..af4a84d4 100644 --- a/src/content/series/PreviewSeries.tsx +++ b/src/content/series/PreviewSeries.tsx @@ -7,17 +7,15 @@ import React, { ChangeEvent, useMemo, useState } from "react"; import { getInstancesOfSeries } from "../../services/orthanc"; import { useCustomQuery } from "../../utils"; -import { Input, Modal, Spinner } from "../../ui"; +import { Input, Spinner } from "../../ui"; import PreviewInstance from "./PreviewInstance"; import { Instances } from "../../utils/types"; type PreviewSeriesProps = { seriesId: string; - onClose: () => void; - show: boolean; } -const PreviewSeries: React.FC = ({ seriesId, onClose, show }) => { +const PreviewSeries: React.FC = ({ seriesId}) => { const [rows, setRows] = useState(1) const [columns, setColumns] = useState(3) @@ -63,45 +61,40 @@ const PreviewSeries: React.FC = ({ seriesId, onClose, show } }; return ( - - - Preview Series - - -
- { - selectedInstanceUIDs?.map((instance: Instances) => { - return - }) - } + <> +
+ { + selectedInstanceUIDs?.map((instance: Instances) => { + return + }) + } +
+ ) => setImageIndex(Number(event.target.value))} /> +
+
+ +
- ) => setImageIndex(Number(event.target.value))} /> -
-
- - -
-
- - +
+ ); }; diff --git a/src/content/series/SeriesEditForm.tsx b/src/content/series/SeriesEditForm.tsx index cff6777f..b5e45f85 100644 --- a/src/content/series/SeriesEditForm.tsx +++ b/src/content/series/SeriesEditForm.tsx @@ -1,8 +1,9 @@ import React, { ChangeEvent, useState } from "react"; import { Series, SeriesPayload, SeriesMainDicomTags } from '../../utils/types'; -import { InputWithDelete, CheckBox } from "../../ui"; +import { InputWithDelete, CheckBox, Button } from "../../ui"; import ProgressJobs from "../../query/ProgressJobs"; +import { Colors } from "../../utils"; type SeriesEditFormProps = { data: Series; @@ -120,6 +121,9 @@ const SeriesEditForm = ({ data, onSubmit, jobId, onJobCompleted }: SeriesEditFor bordered={false} />
+
+ +
{ jobId && (
diff --git a/src/content/series/SeriesRoot.tsx b/src/content/series/SeriesRoot.tsx index 72faaf19..fbcc834b 100644 --- a/src/content/series/SeriesRoot.tsx +++ b/src/content/series/SeriesRoot.tsx @@ -11,7 +11,7 @@ import EditSeries from './EditSeries'; import PreviewSeries from './PreviewSeries'; import { useConfirm } from '../../services/ConfirmContextProvider'; import { useCustomToast } from '../../utils/toastify'; -import { Spinner } from '../../ui'; +import { Modal, Spinner } from '../../ui'; interface SeriesRootProps { studyId: string; @@ -23,11 +23,11 @@ const SeriesRoot: React.FC = ({ studyId }) => { const { confirm } = useConfirm(); const { toastSuccess, toastError } = useCustomToast(); - + const { data: seriesList, isLoading, refetch: refetchSeries } = useCustomQuery( ['series', studyId], () => getSeriesOfStudy(studyId), - { + { onError: (error) => { console.error(`No series for this study or an error occured: ${error}`); } @@ -58,13 +58,13 @@ const SeriesRoot: React.FC = ({ studyId }) => { const handleDeleteSeries = async (seriesId: string) => { const confirmContent = (
- Are you sure you want to delete this Series: - {seriesId} ? + Are you sure you want to delete this Series: + {seriesId} ?
- ); - if (await confirm({content: confirmContent})) { - mutateDeleteSeries(seriesId); -} + ); + if (await confirm({ content: confirmContent })) { + mutateDeleteSeries(seriesId); + } }; @@ -110,11 +110,14 @@ const SeriesRoot: React.FC = ({ studyId }) => { /> )} {previewSeries && ( - setPreviewSeries(null)} - show={!!previewSeries} - /> + + setPreviewSeries(null)} > + Preview Series + + + + + )}
); diff --git a/src/content/studies/PreviewStudy.tsx b/src/content/studies/PreviewStudy.tsx index e69de29b..eecd6ca3 100644 --- a/src/content/studies/PreviewStudy.tsx +++ b/src/content/studies/PreviewStudy.tsx @@ -0,0 +1,57 @@ +/** + * Component for a modal to preview a study + * @name PreviewStudy + */ + +import React from "react"; +import { getSeriesOfStudy } from "../../services/orthanc"; +import { useCustomQuery } from "../../utils"; + +import { Accordion, Modal, Spinner } from "../../ui"; +import { Series } from "../../utils/types"; +import { AccordionHeader } from "../../ui/Accordion"; +import PreviewSeries from "../series/PreviewSeries"; + +type PreviewStudyProps = { + studyId: string; + onClose: () => void; + show: boolean; +} + +const PreviewStudy: React.FC = ({ studyId, onClose, show }) => { + + const { data: series, isLoading } = useCustomQuery( + ['study', studyId, 'series'], + () => getSeriesOfStudy(studyId), + { + select: (instances: Series[]) => { + return instances.sort((a, b) => a.mainDicomTags?.seriesDescription?.localeCompare(b.mainDicomTags?.seriesDescription ?? "") ?? 0) + } + } + ) + + if (isLoading) return + + return ( + + + Preview Study + + +
+ { + series?.map((series: Series) => { + return ( + {(series.mainDicomTags?.seriesDescription?.length ?? 0) > 0 ? series.mainDicomTags?.seriesDescription : "N/A"}}> + + + ) + }) + } +
+
+
+ ); +}; + +export default PreviewStudy; diff --git a/src/content/studies/StudyRoot.tsx b/src/content/studies/StudyRoot.tsx index 4fd799b6..3a8d561e 100644 --- a/src/content/studies/StudyRoot.tsx +++ b/src/content/studies/StudyRoot.tsx @@ -3,7 +3,7 @@ import { useCustomMutation } from '../../utils/reactQuery'; import { deleteStudy } from '../../services/orthanc'; import StudyTable from './StudyTable'; import EditStudy from './EditStudy'; -// import PreviewStudy from './PreviewStudy'; +import PreviewStudy from './PreviewStudy'; import { useConfirm } from '../../services/ConfirmContextProvider'; import { useCustomToast } from '../../utils/toastify'; import Patient from '../../model/Patient'; @@ -16,6 +16,7 @@ type StudyRootProps = { const StudyRoot: React.FC = ({ patient, onStudyUpdated, onStudySelected }) => { const [editingStudy, setEditingStudy] = useState(null); + const [previewStudyId, setPreviewStudyId] = useState(null); const { confirm } = useConfirm(); const { toastSuccess, toastError } = useCustomToast(); @@ -55,6 +56,10 @@ const StudyRoot: React.FC = ({ patient, onStudyUpdated, onStudyS } }; + const handlePreviewStudy = (studyId: string) => { + setPreviewStudyId(studyId); + } + const handleStudyAction = (action: string, studyId: string) => { switch (action) { case 'edit': @@ -64,7 +69,7 @@ const StudyRoot: React.FC = ({ patient, onStudyUpdated, onStudyS handleDeleteStudy(studyId); break; case 'preview': - // handlePreviewStudy(studyId); + handlePreviewStudy(studyId); break; default: break; @@ -91,13 +96,13 @@ const StudyRoot: React.FC = ({ patient, onStudyUpdated, onStudyS show={!!editingStudy} /> )} - {/* {previewStudy && ( + {previewStudyId && ( setPreviewStudy(null)} - show={!!previewStudy} + studyId={previewStudyId} + onClose={() => setPreviewStudyId(null)} + show={!!previewStudyId} /> - )} */} + )} ); }; diff --git a/src/ui/Accordion.tsx b/src/ui/Accordion.tsx index d65645b5..24b25dc1 100644 --- a/src/ui/Accordion.tsx +++ b/src/ui/Accordion.tsx @@ -43,7 +43,7 @@ const Accordion: React.FC = ({ return (
{header} @@ -56,25 +56,25 @@ const Accordion: React.FC = ({ type AccordionHeaderProps = { children?: React.ReactNode; variant?: string - className? : string + className?: string } -const AccordionHeader = ({ children, className="", variant="default" }: AccordionHeaderProps) => { +const AccordionHeader = ({ children, className = "", variant = "default" }: AccordionHeaderProps) => { const getVariantClasses = () => { switch (variant) { case "secondary": - return "cursor-pointer flex justify-between items-center p-4 bg-secondary text-white" + return "bg-secondary text-white" case "primary": - return "cursor-pointer flex justify-between items-center p-4 bg-primary-active text-white" + return "bg-primary-active text-white" case "default": default: - return "cursor-pointer flex justify-between items-center p-4 bg-gray-100" + return "bg-gray-100" }; } return ( -
+
{children}
)