Skip to content

Commit db93d2c

Browse files
authored
Merge pull request #36 from igoroctaviano/feat/enhancers
Feature: Add request hooks
2 parents 4799d1e + 3eb39eb commit db93d2c

File tree

7 files changed

+203
-170
lines changed

7 files changed

+203
-170
lines changed

examples/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ <h1>
99
Example
1010
</h1>
1111
<hr>
12+
<a href='/retry'>Request hooks</a>
13+
<hr>
1214
<div class="row">
1315
<div id='contents' class="col-xs-12">
1416
</div>
@@ -17,7 +19,7 @@ <h1>
1719
</body>
1820

1921
<!-- include the cornerstone library -->
20-
<script src="../../build/dicomweb-client.js"></script>
22+
<script src="../build/dicomweb-client.js"></script>
2123
<script>
2224
if (!window.DICOMwebClient) {
2325
console.warn('Failed to load dicomweb-client from build directory. Using unpkg instead.');
@@ -28,11 +30,11 @@ <h1>
2830
<script>
2931
const dwc = DICOMwebClient.api.DICOMwebClient;
3032
const options = {
31-
url: "https://dicomcloud.azurewebsites.net/wadors"
33+
url: "https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs"
3234
};
3335

3436
const dicomweb = new dwc(options)
35-
const studyInstanceUID = '1.2.826.0.1.3680043.8.1055.1.20111103111148288.98361414.79379639'
37+
const studyInstanceUID = '1.2.392.200140.2.1.1.1.2.799008771.2156.1519721160.421'
3638
const promise = dicomweb.retrieveStudyMetadata({studyInstanceUID});
3739

3840
promise.then(studyMetadata => {

examples/retry.html

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
5+
</head>
6+
<body>
7+
<div class="container">
8+
<h1>
9+
Example: Request Hooks
10+
</h1>
11+
<hr>
12+
<pre>
13+
const options = {
14+
url: "https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs",
15+
requestHooks: [
16+
(request, metadata) => {
17+
const requestMetadata = document.createElement('div');
18+
requestMetadata.innerHTML = `Method: ${metadata.method} URL: ${metadata.url}`;
19+
document.getElementById('requests').append(requestMetadata);
20+
return request;
21+
}
22+
],
23+
};
24+
</pre>
25+
<hr>
26+
<h3>Requests:</h3>
27+
<h5>(Logged using request hooks)</h5>
28+
<pre id='requests'></pre>
29+
<hr>
30+
<div class="row">
31+
<div id='contents' class="col-xs-12">
32+
</div>
33+
</div>
34+
</div>
35+
</body>
36+
37+
<!-- include the cornerstone library -->
38+
<script src="../build/dicomweb-client.js"></script>
39+
<script>
40+
if (!window.DICOMwebClient) {
41+
console.warn('Failed to load dicomweb-client from build directory. Using unpkg instead.');
42+
document.write('<script src="https://unpkg.com/dicomweb-client">\x3C/script>')
43+
}
44+
</script>
45+
46+
<script>
47+
const dwc = DICOMwebClient.api.DICOMwebClient;
48+
const options = {
49+
url: "https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs",
50+
requestHooks: [
51+
(request, metadata) => {
52+
const requestMetadata = document.createElement('div');
53+
requestMetadata.innerHTML = `Method: ${metadata.method} URL: ${metadata.url}`;
54+
document.getElementById('requests').append(requestMetadata);
55+
return request;
56+
}
57+
],
58+
};
59+
60+
const dicomweb = new dwc(options)
61+
const studyInstanceUID = '1.2.392.200140.2.1.1.1.2.799008771.2156.1519721160.421'
62+
const promise = dicomweb.retrieveStudyMetadata({studyInstanceUID});
63+
64+
promise.then(studyMetadata => {
65+
const div = document.getElementById('contents');
66+
div.innerText = JSON.stringify(studyMetadata, null, 2);
67+
console.log(studyMetadata);
68+
}, error => {
69+
throw new Error(error);
70+
});
71+
</script>
72+
</html>

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = function(config) {
1111

1212
// frameworks to use
1313
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
14-
frameworks: ['mocha', 'chai'],
14+
frameworks: ['jasmine'],
1515

1616

1717
// list of files / patterns to load in the browser

package-lock.json

Lines changed: 11 additions & 126 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,17 @@
3434
"devDependencies": {
3535
"@babel/core": "^7.1.0",
3636
"@babel/preset-env": "^7.1.0",
37-
"chai": "^4.1.2",
3837
"eslint": "^5.16.0",
3938
"eslint-config-airbnb-base": "^13.1.0",
4039
"eslint-plugin-import": "^2.16.0",
4140
"karma": "^4.2.0",
4241
"karma-chai": "^0.1.0",
4342
"karma-chrome-launcher": "^2.2.0",
44-
"karma-mocha": "^1.3.0",
45-
"mocha": "^5.2.0",
43+
"karma-jasmine": "^4.0.1",
4644
"prettier": "^1.16.4",
4745
"puppeteer": "^1.18.1",
4846
"rollup": "^0.63.2",
4947
"rollup-plugin-babel": "^4.0.3"
50-
}
48+
},
49+
"dependencies": {}
5150
}

0 commit comments

Comments
 (0)