Skip to content

Commit

Permalink
feat: lesion-tracker extension (OHIF#1420)
Browse files Browse the repository at this point in the history
* chore: init lesion-tracker extension

* chore: dev build for lesion-tracker extension

* fix: a more appropriate library name

* chore: fix script naming
  • Loading branch information
dannyrb authored Feb 6, 2020
1 parent 3f7eb8a commit 73e4409
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 84 deletions.
8 changes: 8 additions & 0 deletions extensions/lesion-tracker/.webpack/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const path = require('path');
const webpackCommon = require('./../../../.webpack/webpack.commonjs.js');
const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist');

module.exports = (env, argv) => {
return webpackCommon(env, argv, { SRC_DIR, DIST_DIR });
};
38 changes: 38 additions & 0 deletions extensions/lesion-tracker/.webpack/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const merge = require('webpack-merge');
const path = require('path');
const webpackCommon = require('./../../../.webpack/webpack.commonjs.js');
const pkg = require('./../package.json');

const ROOT_DIR = path.join(__dirname, './..');
const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist');

module.exports = (env, argv) => {
const commonConfig = webpackCommon(env, argv, { SRC_DIR, DIST_DIR });

return merge(commonConfig, {
devtool: 'source-map',
stats: {
colors: true,
hash: true,
timings: true,
assets: true,
chunks: false,
chunkModules: false,
modules: false,
children: false,
warnings: true,
},
optimization: {
minimize: true,
sideEffects: true,
},
output: {
path: ROOT_DIR,
library: 'OHIFExtLesionTracker',
libraryTarget: 'umd',
libraryExport: 'default',
filename: pkg.main,
},
});
};
21 changes: 21 additions & 0 deletions extensions/lesion-tracker/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Open Health Imaging Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
38 changes: 38 additions & 0 deletions extensions/lesion-tracker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# @ohif/extension-lesion-tracker

This project is an OHIF extension that can be used with the Core OHIF Platform,
either at runtime, or as an ES6 dependency, to create a medical image viewing
application similar to that of the [legacy Lesion
Tracker][legacy-lesion-tracker] viewer.

## About

...

## Scope

...

### Configuration

...

### Extensions

...

## Build & Deploy

...

## Funding/Support

...

<!--
LINKS
-->

<!-- prettier-ignore-start -->
[legacy-lesion-tracker]: http://lesiontracker.ohif.org/studylist
<!-- prettier-ignore-end -->
40 changes: 40 additions & 0 deletions extensions/lesion-tracker/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@ohif/extension-lesion-tracker",
"version": "0.0.1",
"description": "OHIF extension for Lesion Tracker",
"author": "OHIF",
"license": "MIT",
"repository": "OHIF/Viewers",
"main": "dist/index.umd.js",
"module": "src/index.js",
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">=10",
"npm": ">=6",
"yarn": ">=1.16.0"
},
"files": [
"dist",
"README.md"
],
"scripts": {
"dev": "cross-env NODE_ENV=development webpack --config .webpack/webpack.dev.js --watch --debug --output-pathinfo",
"dev:lesion-tracker": "yarn run dev",
"build": "cross-env NODE_ENV=production webpack --config .webpack/webpack.prod.js",
"build:package": "yarn run build",
"prepublishOnly": "yarn run build",
"start": "yarn run dev"
},
"peerDependencies": {
"@ohif/core": "^0.50.0",
"prop-types": "^15.6.2",
"react": "^16.8.6",
"react-dom": "^16.8.6"
},
"dependencies": {
"@babel/runtime": "^7.5.5",
"classnames": "^2.2.6"
}
}
101 changes: 101 additions & 0 deletions extensions/lesion-tracker/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// SEE: Async imports (code-splitting)
// import asyncComponent from './asyncComponent.js';
// import OHIFDicomPDFSopClassHandler from './OHIFDicomPDFSopClassHandler.js';

// const ConnectedOHIFDicomPDFViewer = asyncComponent(() =>
// import(
// /* webpackChunkName: "ConnectedOHIFDicomPDFViewer" */ './ConnectedOHIFDicomPDFViewer'
// )
// );

export default {
/**
* Only required property. Should be a unique value across all extensions.
*/
id: 'lesion-tracker',

/**
* @param {object} params
* @param {ServicesManager} params.servicesManager
* @param {CommandsManager} params.commandsManager
*/
getPanelModule({ servicesManager, commandsManager }) {
return undefined;
// {
// TODO:
// - Right, alternative StudyBrowser
// - Left, alternative Measurements Table
// menuOptions: [
// {
// // A suggested icon
// // Available icons determined by consuming app
// icon: 'list',
// // A suggested label
// label: 'Magic',
// // 'right' or 'left'
// from: 'right',
// // The target component to toggle open/close
// target: 'target-component-id',
// // Overrides `defaultContext`, if specified
// context: ['ACTIVE_VIEWPORT:MAGIC'],
// },
// ],
// components: [
// {
// id: 'target-component-id',
// component: MyComponent,
// },
// ],
// defaultContext: ['ROUTE:VIEWER'],
// };
},

/**
* @param {object} params
* @param {ServicesManager} params.servicesManager
* @param {CommandsManager} params.commandsManager
* @returns Object
*/
getToolbarModule({ servicesManager, commandsManager }) {
// TODO: Zoom, Levels, Pan, More (see lesiontracker.ohif.org)
// These may be driven through configuration of `cornerstone` extension instead of defined here
return {
definitions: [
{
id: 'say-hell-world',
label: '🎉 HELLO WORLD 🎉',
icon: 'exclamation-triangle',
type: 'command',
commandName: 'sayHelloWorld',
},
],
defaultContext: 'VIEWER',
};
},

/**
* @param {object} params
* @param {ServicesManager} params.servicesManager
* @param {CommandsManager} params.commandsManager
* @returns Object
*/
getCommandsModule({ servicesManager }) {
const { UINotificationService } = servicesManager.services;
return {
definitions: {
sayHelloWorld: {
commandFn: function() {
console.log(UINotificationService);
UINotificationService.show({
title: 'What does a nosey pepper do?',
message: 'Gets jalapeno business!',
});
},
storeContexts: [],
options: {},
},
},
defaultContext: ['VIEWER'],
};
},
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"scripts": {
"cm": "npx git-cz",
"build": "lerna run build:viewer --stream",
"build:lt": "lerna run build:viewer:lesion-tracker --stream",
"build:ci": "lerna run build:viewer:ci --stream",
"build:demo": "lerna run build:viewer:demo --stream",
"build:package": "lerna run build:viewer:package --stream",
"build:package-all": "lerna run build:package --parallel --stream",
"dev": "lerna run dev:viewer --stream",
"dev:lt": "lerna run dev:viewer:lesion-tracker --stream",
"dev:project": ".scripts/dev.sh",
"dev:orthanc": "lerna run dev:orthanc --stream",
"orthanc:up": "docker-compose -f .docker/Nginx-Orthanc/docker-compose.yml up",
Expand Down
4 changes: 4 additions & 0 deletions platform/viewer/.webpack/webpack.pwa.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ const PUBLIC_URL = process.env.PUBLIC_URL || '/';
const APP_CONFIG = process.env.APP_CONFIG || 'config/default.js';
const PROXY_TARGET = process.env.PROXY_TARGET;
const PROXY_DOMAIN = process.env.PROXY_DOMAIN;
const ENTRY_TARGET = process.env.ENTRY_TARGET || `${SRC_DIR}/index.js`;

module.exports = (env, argv) => {
const baseConfig = webpackBase(env, argv, { SRC_DIR, DIST_DIR });
const isProdBuild = process.env.NODE_ENV === 'production';
const hasProxy = PROXY_TARGET && PROXY_DOMAIN;

const mergedConfig = merge(baseConfig, {
entry: {
app: ENTRY_TARGET,
},
output: {
path: DIST_DIR,
filename: isProdBuild ? '[name].bundle.[chunkhash].js' : '[name].js',
Expand Down
3 changes: 3 additions & 0 deletions platform/viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
"scripts": {
"build:package": "cross-env NODE_ENV=production node --max_old_space_size=4096 ./../../node_modules/webpack/bin/webpack.js --config .webpack/webpack.commonjs.js --progress",
"build:viewer": "cross-env NODE_ENV=production node --max_old_space_size=4096 ./../../node_modules/webpack/bin/webpack.js --config .webpack/webpack.pwa.js --progress",
"build:viewer:lesion-tracker": "cross-env ENTRY_TARGET=index-lesion-tracker.js NODE_ENV=production node --max_old_space_size=4096 ./../../node_modules/webpack/bin/webpack.js --config .webpack/webpack.pwa.js --progress",
"build:viewer:ci": "cross-env NODE_ENV=production PUBLIC_URL=/pwa/ APP_CONFIG=config/netlify.js QUICK_BUILD=true node --max_old_space_size=4096 ./../../node_modules/webpack/bin/webpack.js --config .webpack/webpack.pwa.js",
"build:viewer:demo": "cross-env NODE_ENV=production APP_CONFIG=config/demo.js HTML_TEMPLATE=rollbar.html QUICK_BUILD=true node --max_old_space_size=4096 ./../../node_modules/webpack/bin/webpack.js --progress --config .webpack/webpack.pwa.js",
"build:viewer:package": "yarn run build:package",
"dev": "cross-env NODE_ENV=development webpack-dev-server --config .webpack/webpack.pwa.js --watch",
"dev:orthanc": "cross-env NODE_ENV=development PROXY_TARGET=/dicom-web PROXY_DOMAIN=http://localhost:8042 APP_CONFIG=config/docker_nginx-orthanc.js webpack-dev-server --config .webpack/webpack.pwa.js --watch",
"dev:viewer": "yarn run dev",
"dev:viewer:lesion-tracker": "cross-env ENTRY_TARGET=index-lesion-tracker.js NODE_ENV=development webpack-dev-server --config .webpack/webpack.pwa.js --watch",
"start": "yarn run dev",
"test:e2e": "cypress open",
"test:e2e:ci": "percy exec -- cypress run --config video=false --record --browser chrome --spec 'cypress/integration/visual-regression/**/*'",
Expand All @@ -50,6 +52,7 @@
"@ohif/extension-dicom-html": "^1.1.0",
"@ohif/extension-dicom-microscopy": "^0.50.6",
"@ohif/extension-dicom-pdf": "^1.0.1",
"@ohif/extension-lesion-tracker": "^0.0.1",
"@ohif/extension-vtk": "^1.2.14",
"@ohif/i18n": "^0.52.5",
"@ohif/ui": "^1.1.9",
Expand Down
46 changes: 46 additions & 0 deletions platform/viewer/src/index-lesion-tracker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Entry point for development and production PWA builds.
* Packaged (NPM) builds go through `index-umd.js`
*/

import 'regenerator-runtime/runtime';

import App from './App.js';
import React from 'react';
import ReactDOM from 'react-dom';

/**
* EXTENSIONS
* =================
*
* Importing and modifying the extensions our app uses HERE allows us to leverage
* tree shaking and a few other niceties. However, by including them here they become
* "baked in" to the published application.
*
* Depending on your use case/needs, you may want to consider not adding any extensions
* by default HERE, and instead provide them via the extensions configuration key or
* by using the exported `App` component, and passing in your extensions as props using
* the defaultExtensions property.
*/
import OHIFLesionTrackerExtension from '@ohif/extension-lesion-tracker';
import OHIFDicomPDFExtension from '@ohif/extension-dicom-pdf';

/*
* Default Settings
*/
let config = {};

if (window) {
config = window.config || {};
}

const appProps = {
config,
defaultExtensions: [OHIFLesionTrackerExtension, OHIFDicomPDFExtension],
};

/** Create App */
const app = React.createElement(App, appProps, null);

/** Render */
ReactDOM.render(app, document.getElementById('root'));
Loading

0 comments on commit 73e4409

Please sign in to comment.