Skip to content

Commit

Permalink
Release dicoogle-client-js 0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Enet4 committed Apr 8, 2015
0 parents commit 903196e
Show file tree
Hide file tree
Showing 14 changed files with 913 additions and 0 deletions.
89 changes: 89 additions & 0 deletions Gruntfile.js
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']);

};
62 changes: 62 additions & 0 deletions README.md
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/>.

42 changes: 42 additions & 0 deletions app.html
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>
37 changes: 37 additions & 0 deletions app.js
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));
});
62 changes: 62 additions & 0 deletions browser/build/dicoogle-client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions browser/build/dicoogle-client.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions browser/build/dicoogle-client.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 903196e

Please sign in to comment.