Adjusting Standalone Viewer to the new structure
This commit is contained in:
1 parent
718fd30feb
commit
bb9d04d569
21 files changed
+129
-175
No files matched your search
@@ -1,6 +1,10 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Router } from 'meteor/iron:router';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
if (Meteor.isClient) {
|
||||
// Disconnect from the Meteor Server since we don't need it
|
||||
console.log('Disconnecting from the Meteor server');
|
||||
OHIF.log.info('Disconnecting from the Meteor server');
|
||||
Meteor.disconnect();
|
||||
|
||||
Router.configure({
|
||||
@@ -15,31 +19,31 @@ if (Meteor.isClient) {
|
||||
let id = this.params.id;
|
||||
|
||||
if (!id) {
|
||||
id = 'testId';
|
||||
id = 'testId';
|
||||
}
|
||||
|
||||
// Define a request to the server to retrieve the study data
|
||||
// as JSON, given an ID that was in the Route
|
||||
var oReq = new XMLHttpRequest();
|
||||
const oReq = new XMLHttpRequest();
|
||||
|
||||
// Add event listeners for request failure
|
||||
oReq.addEventListener("error", () => {
|
||||
console.warn("An error occurred while retrieving the JSON data");
|
||||
oReq.addEventListener('error', () => {
|
||||
OHIF.log.warn('An error occurred while retrieving the JSON data');
|
||||
});
|
||||
|
||||
const self = this;
|
||||
|
||||
// When the JSON has been returned, parse it into a JavaScript Object
|
||||
// and render the OHIF Viewer with this data
|
||||
oReq.addEventListener("load", function() {
|
||||
oReq.addEventListener('load', function() {
|
||||
// Parse the response content
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseText
|
||||
if (!this.responseText) {
|
||||
console.warn('Response was undefined');
|
||||
OHIF.log.warn('Response was undefined');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(JSON.stringify(this.responseText, null, 2));
|
||||
OHIF.log.info(JSON.stringify(this.responseText, null, 2));
|
||||
|
||||
const parsed = JSON.parse(this.responseText);
|
||||
|
||||
@@ -60,8 +64,8 @@ if (Meteor.isClient) {
|
||||
// Open the Request to the server for the JSON data
|
||||
// In this case we have a server-side route called /api/
|
||||
// which responds to GET requests with the study data
|
||||
console.log('Sending Request to: ' + "/api/" + id);
|
||||
oReq.open("GET", "/api/" + id);
|
||||
OHIF.log.info(`Sending Request to: /api/${id}`);
|
||||
oReq.open('GET', `/api/${id}`);
|
||||
|
||||
// Fire the request the server
|
||||
oReq.send();
|
||||
@@ -70,7 +74,6 @@ if (Meteor.isClient) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// This is ONLY for demo purposes.
|
||||
if (Meteor.isServer) {
|
||||
// You can test this with:
|
||||
@@ -79,19 +82,19 @@ if (Meteor.isServer) {
|
||||
// Or by going to:
|
||||
// http://localhost:3000/api/testId
|
||||
|
||||
Router.route('/api/:id', {where: 'server'}).get(function () {
|
||||
Router.route('/api/:id', { where: 'server' }).get(function() {
|
||||
// "this" is the RouteController instance.
|
||||
// "this.response" is the Connect response object
|
||||
// "this.request" is the Connect request object
|
||||
const id = this.params.id;
|
||||
|
||||
// Find the relevant study data from the Collection given the ID
|
||||
var data = RequestStudies.findOne({transactionId: id});
|
||||
const data = RequestStudies.findOne({ transactionId: id });
|
||||
|
||||
// Set the response headers to return JSON to any server
|
||||
this.response.setHeader("Content-Type", "application/json");
|
||||
this.response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
this.response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||
this.response.setHeader('Content-Type', 'application/json');
|
||||
this.response.setHeader('Access-Control-Allow-Origin', '*');
|
||||
this.response.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
|
||||
|
||||
// Change the response text depending on the available study data
|
||||
if (!data) {
|
||||
@@ -104,4 +107,4 @@ if (Meteor.isServer) {
|
||||
// Finalize the response
|
||||
this.response.end();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user