Skip to content

Commit 9f6d3ee

Browse files
committed
PACS: PACS with sse
1 parent 46e42b1 commit 9f6d3ee

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

src/components/Pacs/PacsApp.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@
66

77
import { PageSection } from "@patternfly/react-core";
88
import config from "config";
9-
import { access } from "fs";
109
import { useEffect, useState } from "react";
1110
import {
1211
genUUID,
13-
getRoot,
14-
getRootID,
1512
getState,
1613
type ModuleToFunc,
1714
StateType,
@@ -26,8 +23,7 @@ import PacsLoadingScreen from "./components/PacsLoadingScreen.tsx";
2623
import { DEFAULT_PREFERENCES } from "./defaultPreferences.ts";
2724
import styles from "./PacsApp.module.css";
2825
import PacsView from "./PacsView.tsx";
29-
import { type PacsState, QUERY_PROMPT, SearchMode } from "./types.ts";
30-
import { createFeedWithSeriesInstanceUID, errorCodeIsNot4xx } from "./utils.ts";
26+
import type { PacsState } from "./types.ts";
3127

3228
type TDoPacs = ModuleToFunc<typeof DoPacs>;
3329

@@ -189,7 +185,7 @@ export default () => {
189185
]);
190186

191187
// Subscribe to all expanded series
192-
// biome-ignore lint/correctness/useExhaustiveDependencies: updateReceiveState
188+
console.info("PacsApp: isExpandedAllDone:", isExpandedAllDone, "pacs:", pacs);
193189
useEffect(() => {
194190
if (wsError) {
195191
return;
@@ -209,6 +205,7 @@ export default () => {
209205

210206
const url = `${config.API_ROOT}/pacs/sse/?pacs_name=${service}&series_uids=${series_uids}`;
211207
const eventSource = new EventSource(url);
208+
console.info("PacsApp.eventSource: new eventSource");
212209

213210
eventSource.onmessage = (event) => {
214211
const data: Lonk<LonkMessageData> = JSON.parse(event.data);
@@ -217,7 +214,11 @@ export default () => {
217214

218215
eventSource.onerror = (err) => {
219216
console.error("PacsApp.eventSource.onerror: err:", err);
220-
setWsError(`event error: ${err}`);
217+
// XXX TODO: error handling.
218+
// It's possible that the error happens when isExpandedAllDone is already done.
219+
// but the useEffect is not refreshed yet.
220+
// However, it seems like we cannot detect this here because it's a function
221+
// created in the past.
221222
};
222223

223224
return () => {
@@ -226,7 +227,7 @@ export default () => {
226227
};
227228
// Note: we are subscribing to series, but never unsubscribing.
228229
// This is mostly harmless.
229-
}, [expandedSeries, wsError, isExpandedAllDone]);
230+
}, [pacsID, service, expandedSeries, wsError, isExpandedAllDone, doPacs]);
230231

231232
// ========================================
232233
// RENDER

src/components/Pacs/components/SeriesRow.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ const SeriesRow: React.FC<SeriesRowProps> = ({
128128
const showModal = () => {
129129
if (!hasMultipleSelected) {
130130
setFeedName(
131+
// @ts-expect-error no need the SeriesReceiveState in generateFeedName
131132
generateFeedName({
132133
info,
133134
errors,
@@ -189,6 +190,7 @@ const SeriesRow: React.FC<SeriesRowProps> = ({
189190
};
190191

191192
const contextMenuItems = getSeriesContextMenuItems(
193+
// @ts-expect-error no need the SeriesReceiveState in PacsSeriesState
192194
{ info, errors, pullState, inCube, receivedCount: receivedCount },
193195
selected,
194196
selectedSeries.length,
@@ -255,6 +257,7 @@ const SeriesRow: React.FC<SeriesRowProps> = ({
255257
onClick={(e) => {
256258
e.stopPropagation();
257259
if (inCube) {
260+
// @ts-expect-error no need to include SeriesReceiveState in PacsSeriesState
258261
toggleSelection(seriesId, {
259262
info,
260263
errors,

src/components/Pacs/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ export type SeriesReceiveStateMap = { [key: string]: SeriesReceiveState };
131131
* The combined state of a DICOM series in PFDCM, CUBE, and LONK.
132132
*/
133133
export type PacsSeriesState = SeriesReceiveState & {
134-
errors: ReadonlyArray<string>;
135134
info: Series;
136135
inCube: { data: PACSSeries } | null;
137136
pullState: SeriesPullState;

src/reducers/pacs.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,13 @@ export const processLonkMsgDone = (
919919
return;
920920
}
921921

922+
if (!pacsName && !seriesUID) {
923+
// all-done
924+
console.info("processLonkMsgDone: all done");
925+
dispatch(setData<Partial<State>>(myID, { isExpandedAllDone: true }));
926+
return;
927+
}
928+
922929
const seriesKey = seriesUIDToSeriesMapKey(pacsName, seriesUID);
923930
const series = me.seriesMap[seriesKey];
924931
if (!series) {

testing/miniChRIS

0 commit comments

Comments
 (0)