forked from bioinformatics-ua/dicoogle-client-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 903196e
Showing
14 changed files
with
913 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,89 @@ | ||
module.exports = function(grunt) { | ||
|
||
var globals = { | ||
"console": false, | ||
"define": false, | ||
"module": false, | ||
"exports": true, | ||
"XMLHttpRequest": false, | ||
"XDomainRequest": false | ||
}; | ||
|
||
// Project configuration. | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
replace: { | ||
browser: { | ||
src: ['<%= pkg.name %>.js'], // source files array (supports minimatch) | ||
dest: 'browser/<%= pkg.name %>.js', // destination directory or file | ||
replacements: [{ | ||
from: /var\s+service_request\s*;?\s*(\/\/.*)?/, // regex replacement | ||
to: '<%= grunt.file.read("servicerequest-browser.js") %>' | ||
}] | ||
}, | ||
node: { | ||
src: ['<%= pkg.name %>.js'], // source files array (supports minimatch) | ||
dest: 'node/<%= pkg.name %>.js', // destination directory or file | ||
replacements: [{ | ||
from: /var\s+service_request\s*;?\s*(\/\/.*)?/, // regex replacement | ||
to: '<%= grunt.file.read("servicerequest-node.js") %>' | ||
}] | ||
} | ||
}, | ||
jshint: { | ||
all: ['Gruntfile.js', '<%= pkg.name %>.js', 'browser/<%= pkg.name %>.js', 'node/<%= pkg.name %>.js'], | ||
options: { | ||
globals: globals | ||
} | ||
}, | ||
browserify: { | ||
standalone: { | ||
src: [ './browser/<%= pkg.name %>.js' ], | ||
dest: './browser/build/<%= pkg.name %>.js', | ||
options: { | ||
browserifyOptions: { | ||
standalone: '<%= pkg.name %>' | ||
} | ||
} | ||
}, | ||
}, | ||
uglify: { | ||
options: { | ||
banner: '<%= grunt.file.read("license-header.txt") %>' | ||
}, | ||
minimize: { | ||
options: { | ||
compress: true, | ||
preserveComments: false, | ||
mangle: true | ||
}, | ||
src: './browser/build/<%= pkg.name %>.js', | ||
dest: './browser/build/<%= pkg.name %>.min.js' | ||
}, | ||
pretty: { | ||
options: { | ||
compress: false, | ||
mangle: false, | ||
preserveComments: true, | ||
sourceMap: true | ||
}, | ||
src: 'browser/build/<%= pkg.name %>.js', | ||
dest: 'browser/build/<%= pkg.name %>.js' | ||
} | ||
} | ||
}); | ||
|
||
// Load plugin tasks. | ||
grunt.loadNpmTasks('grunt-text-replace'); | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-browserify'); | ||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
|
||
// Default task(s). | ||
grunt.registerTask('default', [ | ||
'replace', | ||
'jshint', | ||
'browserify', | ||
'uglify:minimize','uglify:pretty']); | ||
|
||
}; |
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,62 @@ | ||
# dicoogle-client | ||
|
||
This is a web service client API to [Dicoogle](http://www.dicoogle.com), the open-source P2P PACS, for use in JavaScript applications. Both browser JavaScript and Node.js are supported. | ||
|
||
## How to use | ||
|
||
In Node.js, install "dicoogle-client" with `npm` and `require` the "dicoogle-client" module. | ||
|
||
```JavaScript | ||
var dicoogleClient = require("dicoogle-client"); | ||
``` | ||
|
||
In a browser, include the "dicoogle-client.js" file in the browser/build folder as a script. The module also supports AMD. | ||
|
||
```HTML | ||
<script src='./dicoogle-client.js'></script> | ||
``` | ||
|
||
Afterwards, invoke the module to obtain an access object. The object may be used multiple times. | ||
|
||
```JavaScript | ||
var Dicoogle = dicoogleClient("localhost:8080"); | ||
|
||
... | ||
|
||
Dicoogle.queryFreeText("(PatientName:Pinho^Eduardo)", function(error, result) { | ||
if (error) { | ||
console.log(error); | ||
return; | ||
} | ||
// use result | ||
}); | ||
``` | ||
|
||
The repository includes two examples of dicoogle-client for simple querying: | ||
|
||
- "app.js" is a stand-alone Node.js application that outputs the result to the standard output. | ||
- "app.html" is a browser application that prints the result to the web page. | ||
|
||
## Further Notice | ||
|
||
This library is using the latest Dicoogle web service API, which is not fully stable. This client wrapper will be developed as the API matures. | ||
|
||
## License | ||
|
||
Copyright (C) 2015 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ | ||
|
||
This software is part of Dicoogle. | ||
|
||
Dicoogle/dicoogle-client is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
Dicoogle/dicoogle-client is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. | ||
|
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,42 @@ | ||
<!DOCTYPE html> | ||
<!-- Here is an example of using the wrapper in a browser environment --> | ||
<html> | ||
<head> | ||
<style> | ||
span { | ||
font-family: "Courier New", monospace; | ||
} | ||
</style> | ||
<script src='./browser/build/dicoogle-client.js'></script> | ||
<script> | ||
var server = "http://localhost:8080"; | ||
var Dicoogle = dicoogleClient(server); | ||
|
||
function doQuery() { | ||
var query = document.getElementById('txt').value; | ||
var res_span = document.getElementById('res'); | ||
res_span.innerHTML = "Querying ..."; | ||
|
||
Dicoogle.queryFreeText(query, | ||
function cb(error, result) { | ||
if (error) { console.log(error); | ||
res_span.innerHTML = "An error occurred: \n" | ||
+ JSON.stringify(error); | ||
} | ||
else { | ||
var j = JSON.stringify(result); | ||
console.log(j); | ||
res_span.innerHTML = j; | ||
} | ||
}); | ||
|
||
} | ||
</script> | ||
</head> | ||
<body> | ||
<input id='txt'></input> | ||
<button onclick='doQuery()'>Query</button> | ||
<hr/> | ||
<span id='res'></span> | ||
</body> | ||
</html> |
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,37 @@ | ||
/** Dicoogle DIM query request application in Node.js | ||
* | ||
* Usage: | ||
* node app.js [-s server_location] QUERY | ||
* | ||
* @author Eduardo Pinho ([email protected]) | ||
*/ | ||
|
||
var server = null; | ||
var query; | ||
var keyword = false; | ||
|
||
for (var i = 2 ; i < process.argv.length ; i++) { | ||
if (process.argv[i] === '--keyword' || process.argv[i] === '-k') { | ||
keyword = true; | ||
} else if (process.argv[i] === '-s') { | ||
server = process.argv[++i]; | ||
} else { | ||
query = process.argv[i]; | ||
} | ||
} | ||
|
||
if (!query) { | ||
console.log("Usage:\n\tnode app.js [-k] [-s server_location] QUERY"); | ||
process.exit(-1); | ||
} | ||
|
||
console.log("Querying:", query); | ||
var dicoogleClient = require("./node/dicoogle-client"); | ||
|
||
var Dicoogle = dicoogleClient(server); | ||
var queryFn = keyword ? Dicoogle.queryAdvanced : Dicoogle.queryFreeText; | ||
queryFn(query, | ||
function cb(error, result) { | ||
if (error) { console.log(error); } | ||
else console.log(JSON.stringify(result)); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.