-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) * Feat #1130 Adding support for downloading and zipping files @ This is a combination of 12 commits. - Feat #1130 Initial Commit - Feat #1130 Adding support for hierachical lists - Feat #1130 [WIP] Adding support for downloading and zipping files - Feat #1130 Adding support for hierarchical folder structure study, series, instances on generated zip file - Feat #1130 Adding unit tests and addressing code review feedbacks - Feat #1130 POC (adding module to support on progress handling) - Feat #1130 Improving logic from progress tracking utils - Feat #1130 Renaming module with progress tracking utils - Feat #1130 Beta version of Progress Tracking utils - Feat #1130 Adding unit tests for Progress Tracking Utils - Feat #1130 Documenting public methods from progress tracking utils module - Feat #1130 Adding support for download and zip progress reporting * Feat #1130 Addressing code review feedback * Feat #1130 Preventing multiple downloads from executing at once * Feat #1130 Improving error message for concurrent downloads * Remove downloadAndZipSeriesOnViewports Co-authored-by: James Petts <[email protected]>
- Loading branch information
1 parent
2412c08
commit 29d4955
Showing
26 changed files
with
1,665 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 'OHIFExtDicomP10Downloader', | ||
libraryTarget: 'umd', | ||
libraryExport: 'default', | ||
filename: pkg.main, | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. See | ||
[Conventional Commits](https://conventionalcommits.org) for commit guidelines. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @ohif/extension-dicom-p10-downloader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "@ohif/extension-dicom-p10-downloader", | ||
"version": "0.0.1", | ||
"description": "OHIF extension for downloading DICOM P10 files", | ||
"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", | ||
"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": "^2.6.0", | ||
"dicom-parser": "^1.8.3", | ||
"dicomweb-client": "^0.5.2" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.5.5", | ||
"file-saver": "^2.0.2", | ||
"jszip": "^3.2.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import OHIF from '@ohif/core'; | ||
import { | ||
save, | ||
getDicomWebClientFromContext, | ||
getSOPInstanceReferenceFromActiveViewport, | ||
getSOPInstanceReferencesFromViewports, | ||
} from './utils'; | ||
import _downloadAndZip from './downloadAndZip'; | ||
|
||
const { | ||
utils: { | ||
Queue, | ||
}, | ||
} = OHIF; | ||
|
||
export function getCommands(context) { | ||
const queue = new Queue(1); | ||
const actions = { | ||
/** | ||
* @example Running this command using Commands Manager | ||
* commandsManager.runCommand( | ||
* 'downloadAndZip', | ||
* { | ||
* listOfUIDs: [...], | ||
* options: { | ||
* progress(status) { | ||
* console.info('Progress:', (status.progress * 100).toFixed(2) + '%'); | ||
* } | ||
* } | ||
* }, | ||
* 'VIEWER' | ||
* ); | ||
*/ | ||
downloadAndZip({ servers, dicomWebClient, listOfUIDs, options }) { | ||
return save( | ||
_downloadAndZip( | ||
dicomWebClient || getDicomWebClientFromContext(context, servers), | ||
listOfUIDs, | ||
options | ||
), | ||
listOfUIDs | ||
); | ||
}, | ||
downloadAndZipSeriesOnViewports({ servers, viewports, progress }) { | ||
const dicomWebClient = getDicomWebClientFromContext(context, servers); | ||
const listOfUIDs = getSOPInstanceReferencesFromViewports(viewports); | ||
return save( | ||
_downloadAndZip(dicomWebClient, listOfUIDs, { progress }), | ||
listOfUIDs | ||
); | ||
}, | ||
downloadAndZipSeriesOnActiveViewport({ servers, viewports, progress }) { | ||
const dicomWebClient = getDicomWebClientFromContext(context, servers); | ||
const listOfUIDs = getSOPInstanceReferenceFromActiveViewport(viewports); | ||
return save( | ||
_downloadAndZip(dicomWebClient, listOfUIDs, { progress }), | ||
listOfUIDs | ||
); | ||
}, | ||
}; | ||
|
||
const definitions = { | ||
downloadAndZip: { | ||
commandFn: queue.bindSafe(actions.downloadAndZip, error), | ||
storeContexts: ['servers'], | ||
}, | ||
downloadAndZipSeriesOnViewports: { | ||
commandFn: queue.bindSafe(actions.downloadAndZipSeriesOnViewports, error), | ||
storeContexts: ['servers', 'viewports'], | ||
options: { progress }, | ||
}, | ||
downloadAndZipSeriesOnActiveViewport: { | ||
commandFn: queue.bindSafe( | ||
actions.downloadAndZipSeriesOnActiveViewport, | ||
error | ||
), | ||
storeContexts: ['servers', 'viewports'], | ||
options: { progress }, | ||
}, | ||
}; | ||
|
||
return { | ||
actions, | ||
definitions, | ||
}; | ||
} | ||
|
||
/** | ||
* Utils | ||
*/ | ||
|
||
function progress(status) { | ||
OHIF.log.info( | ||
'Download and Zip Progress:', | ||
(status.progress * 100.0).toFixed(2) + '%' | ||
); | ||
} | ||
|
||
function error(e) { | ||
if (e.message === 'Queue limit reached') { | ||
OHIF.log.warn('A download is already in progress, please wait.'); | ||
} else { | ||
OHIF.log.error(e); | ||
} | ||
} |
Oops, something went wrong.