feat: Add White Labelling, Hanging Protocols, and tons of Extensions / Mode fixes

* modified

* new files in existing extensions/libraries/modes

* fixed bugs and tests

* Clean up

* fix: viewport display fixed

* Fixed configs for deployment

* Removed unnecessary files and functions

* Fixed default HP module

* Added white labelling

* Fixed hash routing

* Removed unnecessary routers

Co-authored-by: Alireza Sedghi <ar.sedghi@gmail.com>
This commit is contained in:
Erik ZieglerandAlireza Sedghi authored and GitHub committed 2021-05-28 14:32:48 -04:00
1 parent 0db81b30f3
commit 99b8dc4759
93 files changed
+3825 -1293

No files matched your search

@@ -1,153 +0,0 @@
import React, {
createContext,
useCallback,
useContext,
useEffect,
useReducer,
} from 'react';
import PropTypes from 'prop-types';
const DEFAULT_STATE = {
hangingProtocol: null,
hpAlreadyApplied: {},
};
export const HangingProtocolContext = createContext(DEFAULT_STATE);
export function HangingProtocolProvider({ children, service }) {
const hangingProtocolReducer = (state, action) => {
switch (action.type) {
case 'SET_HANGING_PROTOCOL': {
return {
...state,
...{ hangingProtocol: action.payload.hangingProtocol },
};
}
case 'SET_HANGING_PROTOCOL_APPLIED_FOR_VIEWPORT': {
const index = action.payload.index;
const newHPAlreadyApplied = Object.assign({}, state.hpAlreadyApplied);
newHPAlreadyApplied[index] = true;
return {
...state,
...{ hpAlreadyApplied: newHPAlreadyApplied },
};
}
case 'RESET': {
return {
hangingProtocol: null,
hpAlreadyApplied: {},
};
}
case 'SET': {
return {
...state,
...action.payload,
};
}
default:
return action.payload;
}
};
const [hangingProtocolState, dispatch] = useReducer(
hangingProtocolReducer,
DEFAULT_STATE
);
console.log('hangingProtocolState', hangingProtocolState);
const getState = useCallback(() => hangingProtocolState, [
hangingProtocolState,
]);
const setHangingProtocol = useCallback(
hangingProtocol =>
dispatch({
type: 'SET_HANGING_PROTOCOL',
payload: {
hangingProtocol,
},
}),
[dispatch]
);
const setHangingProtocolAppliedForViewport = useCallback(
index =>
dispatch({
type: 'SET_HANGING_PROTOCOL_APPLIED_FOR_VIEWPORT',
payload: {
index,
},
}),
[dispatch]
);
const reset = useCallback(
() =>
dispatch({
type: 'RESET',
payload: {},
}),
[dispatch]
);
const set = useCallback(
payload =>
dispatch({
type: 'SET',
payload,
}),
[dispatch]
);
/**
* Sets the implementation of the HangingProtocolService that can be used by extensions.
*
* @returns void
*/
useEffect(() => {
if (service) {
service.setServiceImplementation({
getState,
setHangingProtocol,
setHangingProtocolAppliedForViewport,
reset,
set,
});
}
}, [
getState,
service,
setHangingProtocol,
setHangingProtocolAppliedForViewport,
reset,
set,
]);
const api = {
// getState,
setHangingProtocol,
setHangingProtocolAppliedForViewport,
reset,
set,
};
return (
<HangingProtocolContext.Provider value={[hangingProtocolState, api]}>
{children}
</HangingProtocolContext.Provider>
);
}
HangingProtocolProvider.propTypes = {
children: PropTypes.any,
service: PropTypes.shape({
setServiceImplementation: PropTypes.func,
}).isRequired,
};
export const useHangingProtocol = () => useContext(HangingProtocolContext);
@@ -1,4 +1,4 @@
import React, { createContext, useContext, useReducer } from 'react';
import React, { createContext, useContext, useReducer, useMemo } from 'react';
// export const IMAGE_VIEWER_DEFAULT_VALUE = {
// StudyInstanceUIDs: [],
@@ -7,9 +7,18 @@ import React, { createContext, useContext, useReducer } from 'react';
export const ImageViewerContext = createContext();
export function ImageViewerProvider({ reducer, initialState, children }) {
export function ImageViewerProvider({
StudyInstanceUIDs,
reducer,
initialState,
children,
}) {
const value = useMemo(() => {
return { StudyInstanceUIDs };
}, [StudyInstanceUIDs]);
return (
<ImageViewerContext.Provider value={useReducer(reducer, initialState)}>
<ImageViewerContext.Provider value={value}>
{children}
</ImageViewerContext.Provider>
);
@@ -8,8 +8,10 @@ import React, {
import PropTypes from 'prop-types';
const DEFAULT_STATE = {
numRows: 1,
numCols: 1,
// starting from null, hanging
// protocol will defined number of rows and cols
numRows: null,
numCols: null,
viewports: [
/*
* {
@@ -58,12 +60,14 @@ export function ViewportGridProvider({ children, service }) {
}
case 'RESET': {
return {
numCols: 1,
numRows: 1,
numCols: null,
numRows: null,
activeViewportIndex: 0,
viewports: [{
displaySetInstanceUID: null,
}],
viewports: [
{
displaySetInstanceUID: null,
},
],
cachedLayout: null,
};
}
@@ -41,9 +41,3 @@ export {
ViewportGridProvider,
useViewportGrid,
} from './ViewportGridProvider';
export {
HangingProtocolContext,
HangingProtocolProvider,
useHangingProtocol,
} from './HangingProtocolProvider';