@ohif/extension-default 3.14.0-beta.10 → 3.14.0-beta.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/dist/ohif-extension-default.css +1 -1
  2. package/dist/ohif-extension-default.umd.js +1 -1
  3. package/package.json +14 -10
  4. package/src/Actions/createReportAsync.tsx +45 -0
  5. package/src/Components/DataSourceConfigurationComponent.tsx +142 -0
  6. package/src/Components/DataSourceConfigurationModalComponent.tsx +200 -0
  7. package/src/Components/ItemListComponent.tsx +95 -0
  8. package/src/Components/LineChartViewport/LineChartViewport.tsx +31 -0
  9. package/src/Components/LineChartViewport/index.ts +1 -0
  10. package/src/Components/MoreDropdownMenu.tsx +112 -0
  11. package/src/Components/ProgressDropdownWithService.tsx +101 -0
  12. package/src/Components/SidePanelWithServices.tsx +122 -0
  13. package/src/CustomizableContextMenu/ContextMenuController.tsx +216 -0
  14. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.test.js +29 -0
  15. package/src/CustomizableContextMenu/ContextMenuItemsBuilder.ts +176 -0
  16. package/src/CustomizableContextMenu/index.ts +5 -0
  17. package/src/CustomizableContextMenu/types.ts +126 -0
  18. package/src/DataSourceConfigurationAPI/GoogleCloudDataSourceConfigurationAPI.ts +236 -0
  19. package/src/DicomJSONDataSource/index.js +326 -0
  20. package/src/DicomLocalDataSource/index.js +273 -0
  21. package/src/DicomTagBrowser/DicomTagBrowser.css +49 -0
  22. package/src/DicomTagBrowser/DicomTagBrowser.tsx +454 -0
  23. package/src/DicomTagBrowser/DicomTagTable.tsx +311 -0
  24. package/src/DicomWebDataSource/dcm4cheeReject.js +45 -0
  25. package/src/DicomWebDataSource/exampleInstances.js +280 -0
  26. package/src/DicomWebDataSource/index.ts +808 -0
  27. package/src/DicomWebDataSource/qido.js +215 -0
  28. package/src/DicomWebDataSource/retrieveBulkData.test.ts +35 -0
  29. package/src/DicomWebDataSource/retrieveBulkData.ts +31 -0
  30. package/src/DicomWebDataSource/retrieveRendered.test.ts +147 -0
  31. package/src/DicomWebDataSource/retrieveRendered.ts +141 -0
  32. package/src/DicomWebDataSource/retrieveStudyMetadata.js +108 -0
  33. package/src/DicomWebDataSource/retrieveStudyMetadata.test.js +75 -0
  34. package/src/DicomWebDataSource/retrieveThumbnail.ts +346 -0
  35. package/src/DicomWebDataSource/serviceUrls.test.ts +143 -0
  36. package/src/DicomWebDataSource/utils/StaticWadoClient.ts +272 -0
  37. package/src/DicomWebDataSource/utils/cleanDenaturalizedDataset.ts +78 -0
  38. package/src/DicomWebDataSource/utils/findIndexOfString.ts +47 -0
  39. package/src/DicomWebDataSource/utils/fixBulkDataURI.test.ts +68 -0
  40. package/src/DicomWebDataSource/utils/fixBulkDataURI.ts +78 -0
  41. package/src/DicomWebDataSource/utils/fixMultiValueKeys.ts +12 -0
  42. package/src/DicomWebDataSource/utils/fixMultipart.ts +70 -0
  43. package/src/DicomWebDataSource/utils/getImageId.js +54 -0
  44. package/src/DicomWebDataSource/utils/getWADORSImageId.js +51 -0
  45. package/src/DicomWebDataSource/utils/index.ts +9 -0
  46. package/src/DicomWebDataSource/utils/retrieveMetadataFiltered.js +61 -0
  47. package/src/DicomWebDataSource/wado/retrieveMetadata.js +41 -0
  48. package/src/DicomWebDataSource/wado/retrieveMetadataLoader.js +64 -0
  49. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js +159 -0
  50. package/src/DicomWebDataSource/wado/retrieveMetadataLoaderSync.js +58 -0
  51. package/src/DicomWebProxyDataSource/index.ts +90 -0
  52. package/src/MergeDataSource/index.test.ts +212 -0
  53. package/src/MergeDataSource/index.ts +319 -0
  54. package/src/MergeDataSource/types.ts +46 -0
  55. package/src/Panels/DataSourceSelector.tsx +55 -0
  56. package/src/Panels/StudyBrowser/PanelStudyBrowser.tsx +612 -0
  57. package/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx +88 -0
  58. package/src/Panels/StudyBrowser/constants/actionIcons.ts +12 -0
  59. package/src/Panels/StudyBrowser/constants/index.ts +4 -0
  60. package/src/Panels/StudyBrowser/constants/viewPresets.ts +16 -0
  61. package/src/Panels/StudyBrowser/resolveThumbnailDetails.test.ts +197 -0
  62. package/src/Panels/StudyBrowser/resolveThumbnailDetails.ts +132 -0
  63. package/src/Panels/StudyBrowser/types/actionIcon.ts +9 -0
  64. package/src/Panels/StudyBrowser/types/index.ts +4 -0
  65. package/src/Panels/StudyBrowser/types/viewPreset.ts +7 -0
  66. package/src/Panels/WrappedPanelStudyBrowser.tsx +61 -0
  67. package/src/Panels/createReportDialogPrompt.tsx +128 -0
  68. package/src/Panels/debounce.js +25 -0
  69. package/src/Panels/getImageSrcFromImageId.js +16 -0
  70. package/src/Panels/getStudiesForPatientByMRN.js +19 -0
  71. package/src/Panels/index.js +5 -0
  72. package/src/Panels/requestDisplaySetCreationForStudy.js +19 -0
  73. package/src/SOPClassHandlers/chartSOPClassHandler.test.ts +81 -0
  74. package/src/SOPClassHandlers/chartSOPClassHandler.ts +127 -0
  75. package/src/Toolbar/ToolBoxWrapper.tsx +64 -0
  76. package/src/Toolbar/ToolButtonListWrapper.tsx +77 -0
  77. package/src/Toolbar/ToolButtonWrapper.tsx +32 -0
  78. package/src/Toolbar/ToolRowWrapper.tsx +41 -0
  79. package/src/Toolbar/Toolbar.tsx +98 -0
  80. package/src/Toolbar/ToolbarDivider.tsx +5 -0
  81. package/src/Toolbar/ToolbarLayoutSelector.tsx +195 -0
  82. package/src/Toolbar/index.ts +7 -0
  83. package/src/ViewerLayout/HeaderPatientInfo/HeaderPatientInfo.tsx +96 -0
  84. package/src/ViewerLayout/HeaderPatientInfo/index.js +3 -0
  85. package/src/ViewerLayout/HeaderUndoRedo.tsx +47 -0
  86. package/src/ViewerLayout/ResizablePanelsHook.tsx +334 -0
  87. package/src/ViewerLayout/ViewerHeader.tsx +124 -0
  88. package/src/ViewerLayout/constants/panels.ts +42 -0
  89. package/src/ViewerLayout/index.tsx +227 -0
  90. package/src/ViewerLayout/useUndoRedoState.ts +75 -0
  91. package/src/__tests__/commandsModuleToggleOneUp.test.ts +147 -0
  92. package/src/commandsModule.ts +970 -0
  93. package/src/customizations/aboutModalCustomization.tsx +42 -0
  94. package/src/customizations/appearanceModalCustomization.tsx +143 -0
  95. package/src/customizations/contextMenuCustomization.ts +25 -0
  96. package/src/customizations/contextMenuUICustomization.ts +5 -0
  97. package/src/customizations/customRoutesCustomization.ts +6 -0
  98. package/src/customizations/dataSourceConfigurationCustomization.ts +19 -0
  99. package/src/customizations/datasourcesCustomization.tsx +14 -0
  100. package/src/customizations/defaultContextMenuCustomization.ts +22 -0
  101. package/src/customizations/hangingProtocolsCustomization.ts +15 -0
  102. package/src/customizations/headerRightSideCustomization.ts +19 -0
  103. package/src/customizations/helloPageCustomization.tsx +14 -0
  104. package/src/customizations/hideHeaderUndoRedoCustomization.ts +22 -0
  105. package/src/customizations/hotkeyBindingsCustomization.ts +5 -0
  106. package/src/customizations/instanceSortingCriteriaCustomization.ts +6 -0
  107. package/src/customizations/labellingFlowCustomization.tsx +5 -0
  108. package/src/customizations/loadingIndicatorProgressCustomization.tsx +5 -0
  109. package/src/customizations/loadingIndicatorTotalPercentCustomization.tsx +5 -0
  110. package/src/customizations/menuContentCustomization.tsx +67 -0
  111. package/src/customizations/metadataContextCustomization.test.ts +22 -0
  112. package/src/customizations/metadataContextCustomization.ts +28 -0
  113. package/src/customizations/metadataDisplaySetCustomization.ts +55 -0
  114. package/src/customizations/missingReferenceDisplaySetHandler.ts +5 -0
  115. package/src/customizations/multimonitorCustomization.ts +63 -0
  116. package/src/customizations/notificationCustomization.ts +29 -0
  117. package/src/customizations/onDropHandlerCustomization.ts +5 -0
  118. package/src/customizations/onboardingCustomization.ts +200 -0
  119. package/src/customizations/overlayItemCustomization.tsx +33 -0
  120. package/src/customizations/progressDropdownCustomization.ts +5 -0
  121. package/src/customizations/progressLoadingBarCustomization.tsx +5 -0
  122. package/src/customizations/reportDialogCustomization.test.ts +701 -0
  123. package/src/customizations/reportDialogCustomization.tsx +661 -0
  124. package/src/customizations/sortingCriteriaCustomization.ts +14 -0
  125. package/src/customizations/studyBrowserCustomization.test.ts +69 -0
  126. package/src/customizations/studyBrowserCustomization.ts +95 -0
  127. package/src/customizations/thumbnailDetailsCustomization.ts +91 -0
  128. package/src/customizations/userPreferencesCustomization.tsx +342 -0
  129. package/src/customizations/workListCustomization.ts +107 -0
  130. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.test.ts +181 -0
  131. package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.ts +240 -0
  132. package/src/displaySetSplitting/makeImageSetDisplaySet.ts +276 -0
  133. package/src/displaySetSplitting/stackSopClassUids.ts +60 -0
  134. package/src/displaySetSplitting/urlSplitModules.test.ts +333 -0
  135. package/src/findViewportsByPosition.ts +102 -0
  136. package/src/getCustomizationModule.tsx +109 -0
  137. package/src/getDataSourcesModule.js +44 -0
  138. package/src/getDisplaySetMessages.ts +54 -0
  139. package/src/getDisplaySetsFromUnsupportedSeries.js +63 -0
  140. package/src/getDisplaySetsFromUnsupportedSeries.test.js +14 -0
  141. package/src/getHangingProtocolModule.js +155 -0
  142. package/src/getLayoutTemplateModule.js +28 -0
  143. package/src/getPTImageIdInstanceMetadata.test.ts +102 -0
  144. package/src/getPTImageIdInstanceMetadata.ts +124 -0
  145. package/src/getPanelModule.tsx +29 -0
  146. package/src/getSopClassHandlerModule.js +152 -0
  147. package/src/getSopClassHandlerModule.test.js +78 -0
  148. package/src/getToolbarModule.tsx +63 -0
  149. package/src/getViewportModule.tsx +12 -0
  150. package/src/hangingprotocols/hpCompare.ts +189 -0
  151. package/src/hangingprotocols/hpEcgCustomization.test.ts +104 -0
  152. package/src/hangingprotocols/hpMNGrid.test.ts +120 -0
  153. package/src/hangingprotocols/hpMNGrid.ts +419 -0
  154. package/src/hangingprotocols/hpMammo.ts +202 -0
  155. package/src/hangingprotocols/hpScale.ts +132 -0
  156. package/src/hangingprotocols/index.ts +16 -0
  157. package/src/hangingprotocols/protocolMatchChanges.test.ts +73 -0
  158. package/src/hangingprotocols/utils/isNewestOfModality.ts +19 -0
  159. package/src/hangingprotocols/utils/laterality.ts +9 -0
  160. package/src/hangingprotocols/utils/mammoDisplaySetSelector.ts +214 -0
  161. package/src/hangingprotocols/utils/registerHangingProtocolAttributes.ts +14 -0
  162. package/src/hangingprotocols/utils/seriesSelectors.ts +62 -0
  163. package/src/hangingprotocols/utils/studySelectors.ts +14 -0
  164. package/src/hangingprotocols/utils/viewCode.test.js +25 -0
  165. package/src/hangingprotocols/utils/viewCode.ts +17 -0
  166. package/src/hangingprotocols/utils/viewportOptions.ts +18 -0
  167. package/src/hooks/usePatientInfo.tsx +63 -0
  168. package/src/id.js +5 -0
  169. package/src/index.ts +113 -0
  170. package/src/init.ts +169 -0
  171. package/src/stores/index.ts +7 -0
  172. package/src/stores/useDisplaySetSelectorStore.ts +83 -0
  173. package/src/stores/useHangingProtocolStageIndexStore.ts +76 -0
  174. package/src/stores/useToggleHangingProtocolStore.ts +76 -0
  175. package/src/stores/useToggleOneUpViewportGridStore.ts +19 -0
  176. package/src/stores/useUIStateStore.ts +87 -0
  177. package/src/stores/useViewportGridStore.ts +89 -0
  178. package/src/stores/useViewportsByPositionStore.ts +100 -0
  179. package/src/types/AppTypes.ts +20 -0
  180. package/src/types/commandModuleTypes.tsx +6 -0
  181. package/src/utils/Toolbox.tsx +123 -0
  182. package/src/utils/_shared/PROMPT_RESPONSES.ts +10 -0
  183. package/src/utils/addIcon.ts +6 -0
  184. package/src/utils/appendFrameQueryToImageId.js +9 -0
  185. package/src/utils/callInputDialog.tsx +126 -0
  186. package/src/utils/colorPickerDialog.css +4 -0
  187. package/src/utils/colorPickerDialog.tsx +45 -0
  188. package/src/utils/createRenderedRetrieve.js +32 -0
  189. package/src/utils/createRenderedRetrieve.test.js +46 -0
  190. package/src/utils/dicomWriter.test.ts +228 -0
  191. package/src/utils/dicomWriter.ts +110 -0
  192. package/src/utils/getBulkdataValue.js +45 -0
  193. package/src/utils/getBulkdataValue.test.js +105 -0
  194. package/src/utils/getDirectURL.test.ts +207 -0
  195. package/src/utils/getDirectURL.ts +65 -0
  196. package/src/utils/getSRSeriesAndInstanceNumber.js +48 -0
  197. package/src/utils/index.ts +2 -0
  198. package/src/utils/layerConfigurationUtils.ts +202 -0
  199. package/src/utils/promptLabelAnnotation.js +47 -0
  200. package/src/utils/promptSaveReport.test.ts +106 -0
  201. package/src/utils/promptSaveReport.tsx +117 -0
  202. package/src/utils/registerNaturalizedDatasetForLocalWadouri.js +146 -0
  203. package/src/utils/registerNaturalizedDatasetForLocalWadouri.test.js +177 -0
  204. package/src/utils/registerStoredInstanceImageId.test.ts +73 -0
  205. package/src/utils/registerStoredInstanceImageId.ts +66 -0
  206. package/src/utils/reuseCachedLayouts.ts +92 -0
  207. package/src/utils/secureConfigFetch.js +115 -0
  208. package/src/utils/secureConfigFetch.test.js +163 -0
  209. package/src/utils/seriesDescriptionHistory.ts +83 -0
  210. package/src/utils/validations/areAllImageComponentsEqual.ts +24 -0
  211. package/src/utils/validations/areAllImageDimensionsEqual.test.ts +41 -0
  212. package/src/utils/validations/areAllImageDimensionsEqual.ts +27 -0
  213. package/src/utils/validations/areAllImagePositionsEqual.ts +75 -0
  214. package/src/utils/validations/areAllImageSpacingEqual.ts +66 -0
  215. package/src/utils/validations/checkMultiframe.ts +25 -0
  216. package/src/utils/validations/checkSingleFrames.ts +36 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohif/extension-default",
3
- "version": "3.14.0-beta.10",
3
+ "version": "3.14.0-beta.101",
4
4
  "description": "Common/default features and functionality for basic image viewing",
5
5
  "author": "OHIF Core Team",
6
6
  "license": "MIT",
@@ -9,34 +9,38 @@
9
9
  "url": "OHIF/Viewers"
10
10
  },
11
11
  "main": "dist/ohif-extension-default.umd.js",
12
- "module": "src/index.ts",
12
+ "module": "dist/ohif-extension-default.umd.js",
13
13
  "engines": {
14
14
  "node": ">=24"
15
15
  },
16
16
  "files": [
17
17
  "dist",
18
+ "src",
19
+ "public",
18
20
  "README.md"
19
21
  ],
20
22
  "publishConfig": {
21
23
  "access": "public"
22
24
  },
23
25
  "peerDependencies": {
26
+ "@cornerstonejs/metadata": "5.18.3",
27
+ "@ohif/core": "3.14.0-beta.101",
28
+ "@ohif/i18n": "3.14.0-beta.101",
29
+ "@ohif/ui-next": "3.14.0-beta.101",
24
30
  "dcmjs": "0.52.0",
25
31
  "dicomweb-client": "0.10.4",
26
- "prop-types": "15.8.1",
27
- "react": "18.3.1",
28
- "react-dom": "18.3.1",
32
+ "react": "19.2.7",
33
+ "react-dom": "19.2.7",
29
34
  "react-i18next": "12.3.1",
30
35
  "react-window": "1.8.11",
31
- "webpack-merge": "5.10.0",
32
- "@ohif/core": "3.14.0-beta.10",
33
- "@ohif/i18n": "3.14.0-beta.10"
36
+ "webpack-merge": "5.10.0"
34
37
  },
35
38
  "dependencies": {
36
39
  "@babel/runtime": "7.29.7",
37
40
  "@cornerstonejs/calculate-suv": "1.1.0",
38
41
  "lodash.get": "4.4.2",
39
42
  "lodash.uniqby": "4.7.0",
43
+ "query-string": "10.0.0",
40
44
  "react-color": "2.19.3"
41
45
  },
42
46
  "devDependencies": {
@@ -49,9 +53,9 @@
49
53
  "scripts": {
50
54
  "clean": "shx rm -rf dist",
51
55
  "clean:deep": "pnpm run clean && shx rm -rf node_modules",
52
- "dev": "cross-env NODE_ENV=development rspack build --config .webpack/webpack.dev.js --watch",
56
+ "dev": "cross-env NODE_ENV=development rspack build --config .rspack/rspack.dev.js --watch",
53
57
  "dev:dicom-pdf": "pnpm run dev",
54
- "build": "cross-env NODE_ENV=production rspack build --config .webpack/webpack.prod.js",
58
+ "build": "cross-env NODE_ENV=production rspack build --config .rspack/rspack.prod.js",
55
59
  "build:package-1": "pnpm run build",
56
60
  "start": "pnpm run dev",
57
61
  "test:unit": "jest --watchAll",
@@ -0,0 +1,45 @@
1
+ /**
2
+ *
3
+ * @param {*} servicesManager
4
+ */
5
+ async function createReportAsync({
6
+ servicesManager,
7
+ getReport,
8
+ reportType = 'Measurements',
9
+ successMessage,
10
+ }: withAppTypes) {
11
+ const { displaySetService, uiNotificationService, uiDialogService } = servicesManager.services;
12
+
13
+ try {
14
+ const naturalizedReport = await getReport();
15
+
16
+ if (!naturalizedReport) {
17
+ return;
18
+ }
19
+
20
+ // addInstances is called by the store command (storeMeasurements/storeSegmentation),
21
+ // so the display set should already exist at this point.
22
+ const displaySet = displaySetService.getMostRecentDisplaySet();
23
+
24
+ const displaySetInstanceUID = displaySet.displaySetInstanceUID;
25
+
26
+ uiNotificationService.show({
27
+ title: 'Create Report',
28
+ message: successMessage ?? `${reportType} saved successfully`,
29
+ type: 'success',
30
+ });
31
+
32
+ return [displaySetInstanceUID];
33
+ } catch (error) {
34
+ uiNotificationService.show({
35
+ title: 'Create Report',
36
+ message: error.message || `Failed to store ${reportType}`,
37
+ type: 'error',
38
+ });
39
+ throw new Error(`Failed to store ${reportType}. Error: ${error.message || 'Unknown error'}`);
40
+ } finally {
41
+ uiDialogService.hide('loading-dialog');
42
+ }
43
+ }
44
+
45
+ export default createReportAsync;
@@ -0,0 +1,142 @@
1
+ import React, { ReactElement, useCallback, useEffect, useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import {
4
+ Icons,
5
+ useModal,
6
+ Button,
7
+ HoverCard,
8
+ HoverCardTrigger,
9
+ HoverCardContent,
10
+ Card,
11
+ CardHeader,
12
+ CardDescription,
13
+ CardContent,
14
+ } from '@ohif/ui-next';
15
+ import { Types } from '@ohif/core';
16
+ import DataSourceConfigurationModalComponent from './DataSourceConfigurationModalComponent';
17
+
18
+ function DataSourceConfigurationComponent({
19
+ servicesManager,
20
+ extensionManager,
21
+ }: withAppTypes): ReactElement<any> {
22
+ const { t } = useTranslation('DataSourceConfiguration');
23
+ const { show, hide } = useModal();
24
+
25
+ const { customizationService } = servicesManager.services;
26
+
27
+ const [configurationAPI, setConfigurationAPI] = useState<Types.BaseDataSourceConfigurationAPI>();
28
+
29
+ const [configuredItems, setConfiguredItems] =
30
+ useState<Array<Types.BaseDataSourceConfigurationAPIItem>>();
31
+
32
+ const [itemLabels, setItemLabels] = useState<Array<string>>([]);
33
+
34
+ useEffect(() => {
35
+ let shouldUpdate = true;
36
+
37
+ const dataSourceChangedCallback = async () => {
38
+ const activeDataSourceDef = extensionManager.getActiveDataSourceDefinition();
39
+
40
+ if (!activeDataSourceDef?.configuration?.configurationAPI) {
41
+ return;
42
+ }
43
+
44
+ const configurationAPIFactory =
45
+ customizationService.getCustomization(activeDataSourceDef.configuration.configurationAPI) ??
46
+ (() => null);
47
+
48
+ if (!configurationAPIFactory) {
49
+ return;
50
+ }
51
+
52
+ const configAPI = configurationAPIFactory(activeDataSourceDef.sourceName);
53
+ setConfigurationAPI(configAPI);
54
+ setItemLabels(configAPI.getItemLabels());
55
+
56
+ // New configuration API means that the existing configured items must be cleared.
57
+ setConfiguredItems(null);
58
+
59
+ configAPI.getConfiguredItems().then(list => {
60
+ if (shouldUpdate) {
61
+ setConfiguredItems(list);
62
+ }
63
+ });
64
+ };
65
+
66
+ const sub = extensionManager.subscribe(
67
+ extensionManager.EVENTS.ACTIVE_DATA_SOURCE_CHANGED,
68
+ dataSourceChangedCallback
69
+ );
70
+
71
+ dataSourceChangedCallback();
72
+
73
+ return () => {
74
+ shouldUpdate = false;
75
+ sub.unsubscribe();
76
+ };
77
+ }, []);
78
+
79
+ const showConfigurationModal = useCallback(() => {
80
+ show({
81
+ content: DataSourceConfigurationModalComponent,
82
+ title: t('Configure Data Source'),
83
+ containerClassName: 'max-w-3xl',
84
+ contentProps: {
85
+ configurationAPI,
86
+ configuredItems,
87
+ onHide: hide,
88
+ },
89
+ });
90
+ }, [configurationAPI, configuredItems, show, t, hide]);
91
+
92
+ useEffect(() => {
93
+ if (!configurationAPI || !configuredItems) {
94
+ return;
95
+ }
96
+
97
+ if (configuredItems.length !== configurationAPI.getItemLabels().length) {
98
+ // Not the correct number of configured items, so show the modal to configure the data source.
99
+ showConfigurationModal();
100
+ }
101
+ }, [configurationAPI, configuredItems, showConfigurationModal]);
102
+
103
+ return configuredItems ? (
104
+ <HoverCard>
105
+ <HoverCardTrigger asChild>
106
+ <Button
107
+ variant="ghost"
108
+ size="sm"
109
+ className="gap-1 text-sm"
110
+ onClick={showConfigurationModal}
111
+ >
112
+ <Icons.CloudSettings className="h-5 w-5" />
113
+ Source
114
+ </Button>
115
+ </HoverCardTrigger>
116
+ <HoverCardContent
117
+ align="center"
118
+ className="w-72 p-0"
119
+ >
120
+ <Card className="border-0 shadow-none">
121
+ <CardHeader className="p-3 pb-1">
122
+ <CardDescription className="text-sm">
123
+ <span className="text-foreground font-semibold">{t('Data Source')}:</span>{' '}
124
+ {t('Configure the server connection and storage settings')}
125
+ </CardDescription>
126
+ </CardHeader>
127
+ <CardContent className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 p-3 pt-0 text-sm">
128
+ <div className="bg-input col-span-2 my-2 h-px" />
129
+ {itemLabels.map((label, index) => (
130
+ <React.Fragment key={label}>
131
+ <span className="text-muted-foreground">{t(label)}</span>
132
+ <span>{configuredItems[index]?.name ?? '—'}</span>
133
+ </React.Fragment>
134
+ ))}
135
+ </CardContent>
136
+ </Card>
137
+ </HoverCardContent>
138
+ </HoverCard>
139
+ ) : null;
140
+ }
141
+
142
+ export default DataSourceConfigurationComponent;
@@ -0,0 +1,200 @@
1
+ import classNames from 'classnames';
2
+ import React, { ReactElement, useEffect, useState } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { Icons } from '@ohif/ui-next';
5
+ import { Types } from '@ohif/core';
6
+ import ItemListComponent from './ItemListComponent';
7
+
8
+ const NO_WRAP_ELLIPSIS_CLASS_NAMES = 'text-ellipsis whitespace-nowrap overflow-hidden';
9
+
10
+ type DataSourceConfigurationModalComponentProps = {
11
+ configurationAPI: Types.BaseDataSourceConfigurationAPI;
12
+ configuredItems: Array<Types.BaseDataSourceConfigurationAPIItem>;
13
+ onHide: () => void;
14
+ };
15
+
16
+ function DataSourceConfigurationModalComponent({
17
+ configurationAPI,
18
+ configuredItems,
19
+ onHide,
20
+ }: DataSourceConfigurationModalComponentProps) {
21
+ const { t } = useTranslation('DataSourceConfiguration');
22
+
23
+ const [itemList, setItemList] = useState<Array<Types.BaseDataSourceConfigurationAPIItem>>();
24
+
25
+ const [selectedItems, setSelectedItems] = useState(configuredItems);
26
+
27
+ const [errorMessage, setErrorMessage] = useState<string>();
28
+
29
+ const [itemLabels] = useState(configurationAPI.getItemLabels());
30
+
31
+ // Determines whether to show the full/existing configuration for the data source.
32
+ // A full or complete configuration is one where the data source (path) has the
33
+ // maximum/required number of path items. Anything less is considered not complete and
34
+ // the configuration starts from scratch (i.e. as if no items are configured at all).
35
+ // TODO: consider configuration starting from a partial (i.e. non-empty) configuration
36
+ const [showFullConfig, setShowFullConfig] = useState(
37
+ itemLabels.length === configuredItems.length
38
+ );
39
+
40
+ /**
41
+ * The index of the selected item that is considered current and for which
42
+ * its sub-items should be displayed in the items list component. When the
43
+ * full/existing configuration for a data source is to be shown, the current
44
+ * selected item is the second to last in the `selectedItems` list.
45
+ */
46
+ const currentSelectedItemIndex = showFullConfig
47
+ ? selectedItems.length - 2
48
+ : selectedItems.length - 1;
49
+
50
+ useEffect(() => {
51
+ let shouldUpdate = true;
52
+
53
+ setErrorMessage(null);
54
+
55
+ // Clear out the former/old list while we fetch the next sub item list.
56
+ setItemList(null);
57
+
58
+ if (selectedItems.length === 0) {
59
+ configurationAPI
60
+ .initialize()
61
+ .then(items => {
62
+ if (shouldUpdate) {
63
+ setItemList(items);
64
+ }
65
+ })
66
+ .catch(error => setErrorMessage(error.message));
67
+ } else if (!showFullConfig && selectedItems.length === itemLabels.length) {
68
+ // The last item to configure the data source (path) has been selected.
69
+ configurationAPI.setCurrentItem(selectedItems[selectedItems.length - 1]);
70
+ // We can hide the modal dialog now.
71
+ onHide();
72
+ } else {
73
+ configurationAPI
74
+ .setCurrentItem(selectedItems[currentSelectedItemIndex])
75
+ .then(items => {
76
+ if (shouldUpdate) {
77
+ setItemList(items);
78
+ }
79
+ })
80
+ .catch(error => setErrorMessage(error.message));
81
+ }
82
+
83
+ return () => {
84
+ shouldUpdate = false;
85
+ };
86
+ }, [
87
+ selectedItems,
88
+ configurationAPI,
89
+ onHide,
90
+ itemLabels,
91
+ showFullConfig,
92
+ currentSelectedItemIndex,
93
+ ]);
94
+
95
+ const getSelectedItemCursorClasses = itemIndex =>
96
+ itemIndex !== itemLabels.length - 1 && itemIndex < selectedItems.length
97
+ ? 'cursor-pointer'
98
+ : 'cursor-auto';
99
+
100
+ const getSelectedItemBackgroundClasses = itemIndex =>
101
+ itemIndex < selectedItems.length
102
+ ? classNames(
103
+ 'bg-background/[.4]',
104
+ itemIndex !== itemLabels.length - 1 ? 'hover:bg-transparent active:bg-popover' : ''
105
+ )
106
+ : 'bg-transparent';
107
+
108
+ const getSelectedItemBorderClasses = itemIndex =>
109
+ itemIndex === currentSelectedItemIndex + 1
110
+ ? classNames('border-2', 'border-solid', 'border-highlight')
111
+ : itemIndex < selectedItems.length
112
+ ? 'border border-solid border-primary hover:border-highlight active:border-white'
113
+ : 'border border-dashed border-input';
114
+
115
+ const getSelectedItemTextClasses = itemIndex =>
116
+ itemIndex <= selectedItems.length ? 'text-highlight' : 'text-primary';
117
+
118
+ const getErrorComponent = (): ReactElement<any> => {
119
+ return (
120
+ <div className="flex min-h-[1px] grow flex-col gap-4">
121
+ <div className="text-highlight text-[20px]">
122
+ {t(`Error fetching ${itemLabels[selectedItems.length]} list`)}
123
+ </div>
124
+ <div className="grow bg-background p-4 text-[14px]">{errorMessage}</div>
125
+ </div>
126
+ );
127
+ };
128
+
129
+ const getSelectedItemsComponent = (): ReactElement<any> => {
130
+ return (
131
+ <div className="flex gap-4">
132
+ {itemLabels.map((itemLabel, itemLabelIndex) => {
133
+ return (
134
+ <div
135
+ key={itemLabel}
136
+ className={classNames(
137
+ 'flex min-w-[1px] shrink basis-[200px] flex-col gap-1 rounded-md p-3.5',
138
+ getSelectedItemCursorClasses(itemLabelIndex),
139
+ getSelectedItemBackgroundClasses(itemLabelIndex),
140
+ getSelectedItemBorderClasses(itemLabelIndex),
141
+ getSelectedItemTextClasses(itemLabelIndex)
142
+ )}
143
+ onClick={
144
+ (showFullConfig && itemLabelIndex < currentSelectedItemIndex) ||
145
+ itemLabelIndex <= currentSelectedItemIndex
146
+ ? () => {
147
+ setShowFullConfig(false);
148
+ setSelectedItems(theList => theList.slice(0, itemLabelIndex));
149
+ }
150
+ : undefined
151
+ }
152
+ >
153
+ <div className="text- flex items-center gap-2">
154
+ {itemLabelIndex < selectedItems.length ? (
155
+ <Icons.ByName name="status-tracked" className="text-highlight" />
156
+ ) : (
157
+ <Icons.ByName name="status-untracked" />
158
+ )}
159
+ <div className={classNames(NO_WRAP_ELLIPSIS_CLASS_NAMES)}>{t(itemLabel)}</div>
160
+ </div>
161
+ {itemLabelIndex < selectedItems.length ? (
162
+ <div
163
+ className={classNames(
164
+ 'text-foreground text-[14px]',
165
+ NO_WRAP_ELLIPSIS_CLASS_NAMES
166
+ )}
167
+ >
168
+ {selectedItems[itemLabelIndex].name}
169
+ </div>
170
+ ) : (
171
+ <br></br>
172
+ )}
173
+ </div>
174
+ );
175
+ })}
176
+ </div>
177
+ );
178
+ };
179
+
180
+ return (
181
+ <div className="flex h-[calc(100vh-300px)] select-none flex-col gap-4 pt-0.5">
182
+ {getSelectedItemsComponent()}
183
+ <div className="h-0.5 w-full shrink-0 bg-background"></div>
184
+ {errorMessage ? (
185
+ getErrorComponent()
186
+ ) : (
187
+ <ItemListComponent
188
+ itemLabel={itemLabels[currentSelectedItemIndex + 1]}
189
+ itemList={itemList}
190
+ onItemClicked={item => {
191
+ setShowFullConfig(false);
192
+ setSelectedItems(theList => [...theList.slice(0, currentSelectedItemIndex + 1), item]);
193
+ }}
194
+ ></ItemListComponent>
195
+ )}
196
+ </div>
197
+ );
198
+ }
199
+
200
+ export default DataSourceConfigurationModalComponent;
@@ -0,0 +1,95 @@
1
+ import classNames from 'classnames';
2
+ import React, { ReactElement, useEffect, useState } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { useSystem } from '@ohif/core';
5
+ import { Button, Icons, InputFilter } from '@ohif/ui-next';
6
+ import { Types } from '@ohif/core';
7
+
8
+ type ItemListComponentProps = {
9
+ itemLabel: string;
10
+ itemList: Array<Types.BaseDataSourceConfigurationAPIItem>;
11
+ onItemClicked: (item: Types.BaseDataSourceConfigurationAPIItem) => void;
12
+ };
13
+
14
+ function ItemListComponent({
15
+ itemLabel,
16
+ itemList,
17
+ onItemClicked,
18
+ }: ItemListComponentProps): ReactElement<any> {
19
+ const { servicesManager } = useSystem();
20
+ const { t } = useTranslation('DataSourceConfiguration');
21
+ const [filterValue, setFilterValue] = useState('');
22
+
23
+ useEffect(() => {
24
+ setFilterValue('');
25
+ }, [itemList]);
26
+
27
+ const LoadingIndicatorProgress = servicesManager.services.customizationService.getCustomization(
28
+ 'ui.loadingIndicatorProgress'
29
+ );
30
+
31
+ return (
32
+ <div className="flex min-h-[1px] grow flex-col gap-4">
33
+ <div className="flex items-center justify-between">
34
+ <div className="text-highlight text-xl">{t(`Select ${itemLabel}`)}</div>
35
+ <InputFilter
36
+ className="max-w-[40%] grow"
37
+ onChange={setFilterValue}
38
+ >
39
+ <InputFilter.SearchIcon />
40
+ <InputFilter.Input
41
+ placeholder={t(`Search ${itemLabel} list`)}
42
+ className="pl-8 pr-9"
43
+ />
44
+ <InputFilter.ClearButton className="text-primary mr-0.5 p-0.5" />
45
+ </InputFilter>
46
+ </div>
47
+ <div className="relative flex min-h-[1px] grow flex-col bg-background text-[14px]">
48
+ {itemList == null ? (
49
+ <LoadingIndicatorProgress className={'h-full w-full'} />
50
+ ) : itemList.length === 0 ? (
51
+ <div className="text-highlight flex h-full flex-col items-center justify-center px-6 py-4">
52
+ <Icons.ToolMagnify className="mb-4" />
53
+ <span>{t(`No ${itemLabel} available`)}</span>
54
+ </div>
55
+ ) : (
56
+ <>
57
+ <div className="bg-popover text-foreground px-3 py-1.5">{t(itemLabel)}</div>
58
+ <div className="ohif-scrollbar overflow-auto">
59
+ {itemList
60
+ .filter(
61
+ item =>
62
+ !filterValue || item.name.toLowerCase().includes(filterValue.toLowerCase())
63
+ )
64
+ .map(item => {
65
+ const border = 'rounded border-transparent border-b-input border-[1px]';
66
+ return (
67
+ <div
68
+ className={classNames(
69
+ 'hover:text-highlight hover:bg-muted group mx-2 flex items-center justify-between px-6 py-2',
70
+ border
71
+ )}
72
+ key={item.id}
73
+ >
74
+ <div className="text-muted-foreground">{item.name}</div>
75
+ <Button
76
+ onClick={() => onItemClicked(item)}
77
+ className="invisible group-hover:visible"
78
+ variant="default"
79
+ size="sm"
80
+ >
81
+ {t('Select')}
82
+ <Icons.ChevronRight className="ml-2 h-3 w-3" />
83
+ </Button>
84
+ </div>
85
+ );
86
+ })}
87
+ </div>
88
+ </>
89
+ )}
90
+ </div>
91
+ </div>
92
+ );
93
+ }
94
+
95
+ export default ItemListComponent;
@@ -0,0 +1,31 @@
1
+ import { LineChart } from '@ohif/ui-next';
2
+
3
+ const LineChartViewport = ({ displaySets }) => {
4
+ const displaySet = displaySets[0];
5
+ const { axis: chartAxis, series: chartSeries } = displaySet.instance.chartData;
6
+
7
+ return (
8
+ <LineChart
9
+ showLegend={true}
10
+ legendWidth={150}
11
+ axis={{
12
+ x: {
13
+ label: chartAxis.x.label,
14
+ indexRef: 0,
15
+ type: 'x',
16
+ range: {
17
+ min: 0,
18
+ },
19
+ },
20
+ y: {
21
+ label: chartAxis.y.label,
22
+ indexRef: 1,
23
+ type: 'y',
24
+ },
25
+ }}
26
+ series={chartSeries}
27
+ />
28
+ );
29
+ };
30
+
31
+ export { LineChartViewport as default };
@@ -0,0 +1 @@
1
+ export { default } from './LineChartViewport';
@@ -0,0 +1,112 @@
1
+ import React from 'react';
2
+ import {
3
+ DropdownMenu,
4
+ DropdownMenuContent,
5
+ DropdownMenuTrigger,
6
+ DropdownMenuItem,
7
+ Icons,
8
+ Button,
9
+ } from '@ohif/ui-next';
10
+ import { useSystem } from '@ohif/core';
11
+
12
+ /**
13
+ * The default sub-menu appearance and setup is defined here, but this can be
14
+ * replaced by
15
+ */
16
+ const getMenuItemsDefault = ({ commandsManager, items, ...props }: withAppTypes) => {
17
+ const { servicesManager } = useSystem();
18
+ const { customizationService } = servicesManager.services;
19
+
20
+ // This allows replacing the default child item for menus, whereas the entire
21
+ // getMenuItems can also be replaced by providing it to the MoreDropdownMenu
22
+ const menuContent = customizationService.getCustomization('ohif.menuContent');
23
+
24
+ // Default menu item component if none is provided through customization
25
+
26
+ const DefaultMenuItem = ({
27
+ item,
28
+ }: {
29
+ item: {
30
+ id: string;
31
+ label: string;
32
+ iconName: string;
33
+ onClick: ({ commandsManager, ...props }: withAppTypes) => () => void;
34
+ };
35
+ }) => (
36
+ <DropdownMenuItem onClick={() => item.onClick({ commandsManager, servicesManager, ...props })}>
37
+ <div className="flex items-center gap-2">
38
+ {item.iconName && <Icons.ByName name={item.iconName} />}
39
+ <span>{item.label}</span>
40
+ </div>
41
+ </DropdownMenuItem>
42
+ );
43
+
44
+ const MenuItemComponent = menuContent ?? DefaultMenuItem;
45
+
46
+ return (
47
+ <DropdownMenuContent
48
+ hideWhenDetached
49
+ align="start"
50
+ onClick={e => {
51
+ e.stopPropagation();
52
+ e.preventDefault();
53
+ }}
54
+ >
55
+ {items?.map((item, index) => (
56
+ <MenuItemComponent
57
+ key={item.id || `menu-item-${index}`}
58
+ item={item}
59
+ commandsManager={commandsManager}
60
+ servicesManager={servicesManager}
61
+ {...props}
62
+ />
63
+ ))}
64
+ </DropdownMenuContent>
65
+ );
66
+ };
67
+
68
+ /**
69
+ * The component provides a ... sub-menu for various components which appears
70
+ * on hover over the main component.
71
+ *
72
+ * @param bindProps - properties to define the sub-menu
73
+ * @returns Component bound to the bindProps
74
+ */
75
+ export default function MoreDropdownMenu(bindProps) {
76
+ const { menuItemsKey, getMenuItems = getMenuItemsDefault, commandsManager } = bindProps;
77
+ const { servicesManager } = useSystem();
78
+ const { customizationService } = servicesManager.services;
79
+
80
+ const items = customizationService.getCustomization(menuItemsKey);
81
+
82
+ if (!items?.length) {
83
+ return null;
84
+ }
85
+
86
+ function BoundMoreDropdownMenu(props) {
87
+ return (
88
+ <DropdownMenu>
89
+ <DropdownMenuTrigger asChild>
90
+ <Button
91
+ variant="ghost"
92
+ size="icon"
93
+ className="hidden group-hover:inline-flex data-[state=open]:inline-flex"
94
+ onClick={e => {
95
+ e.preventDefault();
96
+ e.stopPropagation();
97
+ }}
98
+ >
99
+ <Icons.More />
100
+ </Button>
101
+ </DropdownMenuTrigger>
102
+ {getMenuItems({
103
+ ...props,
104
+ commandsManager: commandsManager,
105
+ servicesManager: servicesManager,
106
+ items,
107
+ })}
108
+ </DropdownMenu>
109
+ );
110
+ }
111
+ return BoundMoreDropdownMenu;
112
+ }