feat: Notification provider and service (#1703)
* Create basic structure for Viewport dialog provier and Dialog component * Implementation of a UIViewportDialogService * Update viewportDialogProvider docz * Create example of use of UIViewportDialogService
This commit is contained in:
1 parent
cee09fcf8d
commit
e633eb80eb
11 files changed
+395
-23
No files matched your search
@@ -22,10 +22,11 @@ import errorHandler from './errorHandler.js';
|
||||
import utils, { hotkeys } from './utils/';
|
||||
|
||||
import {
|
||||
UINotificationService,
|
||||
UIModalService,
|
||||
UIDialogService,
|
||||
MeasurementService,
|
||||
UIDialogService,
|
||||
UIModalService,
|
||||
UINotificationService,
|
||||
UIViewportDialogService,
|
||||
} from './services';
|
||||
|
||||
const OHIF = {
|
||||
@@ -56,9 +57,10 @@ const OHIF = {
|
||||
measurements,
|
||||
hangingProtocols,
|
||||
//
|
||||
UINotificationService,
|
||||
UIModalService,
|
||||
UIDialogService,
|
||||
UIModalService,
|
||||
UINotificationService,
|
||||
UIViewportDialogService,
|
||||
MeasurementService,
|
||||
};
|
||||
|
||||
@@ -89,9 +91,10 @@ export {
|
||||
measurements,
|
||||
hangingProtocols,
|
||||
//
|
||||
UINotificationService,
|
||||
UIModalService,
|
||||
UIDialogService,
|
||||
UIModalService,
|
||||
UINotificationService,
|
||||
UIViewportDialogService,
|
||||
MeasurementService,
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* Viewport Dialog
|
||||
*
|
||||
* @typedef {Object} ViewportDialogProps
|
||||
* @property {ReactElement|HTMLElement} [content=null] Modal content.
|
||||
* @property {Object} [contentProps=null] Modal content props.
|
||||
* @property {boolean} [viewportIndex=false] Modal is dismissible via the esc key.
|
||||
*/
|
||||
|
||||
const name = 'UIViewportDialogService';
|
||||
|
||||
const publicAPI = {
|
||||
name,
|
||||
hide: _hide,
|
||||
show: _show,
|
||||
setServiceImplementation,
|
||||
};
|
||||
|
||||
const serviceImplementation = {
|
||||
_viewports: [],
|
||||
};
|
||||
|
||||
/**
|
||||
* Show a new UI viewport dialog on the specified viewportIndex;
|
||||
*
|
||||
* @param {ViewportDialogProps} props { content, contentProps, viewportIndex }
|
||||
*/
|
||||
function _show({ content = null, contentProps = null, viewportIndex }) {
|
||||
const viewportIndexImplementation =
|
||||
(viewportIndex !== undefined &&
|
||||
serviceImplementation._viewports[viewportIndex]) ||
|
||||
{};
|
||||
|
||||
if (!viewportIndexImplementation._show) {
|
||||
console.warn('show() NOT IMPLEMENTED');
|
||||
return;
|
||||
}
|
||||
|
||||
return viewportIndexImplementation._show({
|
||||
content,
|
||||
contentProps,
|
||||
viewportIndex,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides/dismisses the viewport dialog, if currently shown
|
||||
*
|
||||
* @param {*} { viewportIndex }
|
||||
*/
|
||||
function _hide({ viewportIndex }) {
|
||||
const viewportIndexImplementation =
|
||||
(viewportIndex && serviceImplementation._viewports[viewportIndex]) || {};
|
||||
|
||||
if (!viewportIndexImplementation._hide) {
|
||||
console.warn('hide() NOT IMPLEMENTED');
|
||||
return;
|
||||
}
|
||||
|
||||
return viewportIndexImplementation._hide();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param {*} {
|
||||
* hide: hideImplementation,
|
||||
* show: showImplementation,
|
||||
* viewportIndex,
|
||||
* }
|
||||
*/
|
||||
function setServiceImplementation({
|
||||
hide: hideImplementation,
|
||||
show: showImplementation,
|
||||
viewportIndex,
|
||||
}) {
|
||||
if (viewportIndex !== undefined) {
|
||||
const newImplementations = {};
|
||||
if (hideImplementation) {
|
||||
newImplementations._hide = hideImplementation;
|
||||
}
|
||||
if (showImplementation) {
|
||||
newImplementations._show = showImplementation;
|
||||
}
|
||||
|
||||
serviceImplementation._viewports[viewportIndex] = Object.assign(
|
||||
{},
|
||||
serviceImplementation._viewports[viewportIndex],
|
||||
newImplementations
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
name,
|
||||
create: ({ configuration = {} }) => {
|
||||
return publicAPI;
|
||||
},
|
||||
};
|
||||
@@ -1,13 +1,15 @@
|
||||
import ServicesManager from './ServicesManager.js';
|
||||
import UINotificationService from './UINotificationService';
|
||||
import UIModalService from './UIModalService';
|
||||
import UIDialogService from './UIDialogService';
|
||||
import MeasurementService from './MeasurementService';
|
||||
import ServicesManager from './ServicesManager.js';
|
||||
import UIDialogService from './UIDialogService';
|
||||
import UIModalService from './UIModalService';
|
||||
import UINotificationService from './UINotificationService';
|
||||
import UIViewportDialogService from './UIViewportDialogService';
|
||||
|
||||
export {
|
||||
UINotificationService,
|
||||
UIModalService,
|
||||
UIDialogService,
|
||||
ServicesManager,
|
||||
MeasurementService,
|
||||
ServicesManager,
|
||||
UIDialogService,
|
||||
UIModalService,
|
||||
UINotificationService,
|
||||
UIViewportDialogService,
|
||||
};
|
||||
Reference in new issue
Block a user