fix(client-only): Fix client-only Server & CurrentServer usage (#276)

This commit is contained in:
Erik Ziegler 2018-09-21 20:02:29 +02:00 committed by GitHub
parent c4b1086097
commit 18a3bcba30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 86 additions and 37 deletions

View File

@ -30,3 +30,9 @@ Meteor.startup(function() {
} }
}); });
}); });
if (Meteor.settings &&
Meteor.settings.public &&
Meteor.settings.public.clientOnly === true) {
Meteor.disconnect();
}

View File

@ -1,3 +1,4 @@
import { Meteor } from "meteor/meteor";
import { Router } from 'meteor/clinical:router'; import { Router } from 'meteor/clinical:router';
import { OHIF } from 'meteor/ohif:core'; import { OHIF } from 'meteor/ohif:core';
@ -12,7 +13,9 @@ Router.configure({
// //
// In this case, the developer is required to add Servers and specify // In this case, the developer is required to add Servers and specify
// a CurrentServer with some other approach (e.g. a separate script). // a CurrentServer with some other approach (e.g. a separate script).
if (Meteor.settings.public && Meteor.settings.public.clientOnly !== true) { if (Meteor.settings &&
Meteor.settings.public &&
Meteor.settings.public.clientOnly !== true) {
Router.waitOn(function() { Router.waitOn(function() {
return [ return [
Meteor.subscribe('servers'), Meteor.subscribe('servers'),

View File

@ -1,3 +1,4 @@
import { Meteor } from "meteor/meteor";
// The ProtocolStore default strategy is used to persist hanging protocols in // The ProtocolStore default strategy is used to persist hanging protocols in
// the MongoDB collection 'HangingProtocols' in the application server. // the MongoDB collection 'HangingProtocols' in the application server.
@ -9,11 +10,6 @@ var defaultStrategy = (function () {
console.log('Inserting default protocols'); console.log('Inserting default protocols');
addProtocol(HP.defaultProtocol); addProtocol(HP.defaultProtocol);
//addProtocol(HP.testProtocol);
/* HP.demoProtocols.forEach(protocol => {
addProtocol(protocol);
});*/
} }
function getDatabaseIdByProtocolId(protocolId) { function getDatabaseIdByProtocolId(protocolId) {
@ -303,7 +299,9 @@ var clientOnlyStrategy = (function () {
// If we are running a disconnect client similar to the StandaloneViewer // If we are running a disconnect client similar to the StandaloneViewer
// (see https://docs.ohif.org/standalone-viewer/usage.html) we don't want // (see https://docs.ohif.org/standalone-viewer/usage.html) we don't want
// our HangingProtocol strategy to try to use Meteor methods or Pub / Sub // our HangingProtocol strategy to try to use Meteor methods or Pub / Sub
if (Meteor.settings.public && Meteor.settings.public.clientOnly === true) { if (Meteor.settings &&
Meteor.settings.public &&
Meteor.settings.public.clientOnly === true) {
HP.ProtocolStore.setStrategy(clientOnlyStrategy); HP.ProtocolStore.setStrategy(clientOnlyStrategy);
} else { } else {
HP.ProtocolStore.setStrategy(defaultStrategy); HP.ProtocolStore.setStrategy(defaultStrategy);

View File

@ -2,7 +2,12 @@ import { Mongo } from 'meteor/mongo';
import { OHIF } from 'meteor/ohif:core'; import { OHIF } from 'meteor/ohif:core';
// CurrentServer is a single document collection to describe which of the Servers is being used // CurrentServer is a single document collection to describe which of the Servers is being used
const CurrentServer = new Mongo.Collection('currentServer'); let collectionName = 'currentServer';
if (Meteor.settings && Meteor.settings.public && Meteor.settings.public.clientOnly === true) {
collectionName = null;
}
const CurrentServer = new Mongo.Collection(collectionName);
CurrentServer._debugName = 'CurrentServer'; CurrentServer._debugName = 'CurrentServer';
OHIF.servers.collections.currentServer = CurrentServer; OHIF.servers.collections.currentServer = CurrentServer;

View File

@ -2,8 +2,13 @@ import { Mongo } from 'meteor/mongo';
import { OHIF } from 'meteor/ohif:core'; import { OHIF } from 'meteor/ohif:core';
// import { Servers as ServerSchema } from 'meteor/ohif:servers/both/schema/servers.js'; // import { Servers as ServerSchema } from 'meteor/ohif:servers/both/schema/servers.js';
let collectionName = 'servers';
if (Meteor.settings && Meteor.settings.public && Meteor.settings.public.clientOnly === true) {
collectionName = null;
}
// Servers describe the DICOM servers configurations // Servers describe the DICOM servers configurations
const Servers = new Mongo.Collection('servers'); const Servers = new Mongo.Collection(collectionName);
// TODO: Make the Schema match what we are currently sticking into the Collection // TODO: Make the Schema match what we are currently sticking into the Collection
//Servers.attachSchema(ServerSchema); //Servers.attachSchema(ServerSchema);
Servers._debugName = 'Servers'; Servers._debugName = 'Servers';

View File

@ -1 +0,0 @@
import './subscriptions.js';

View File

@ -1,4 +0,0 @@
import { Meteor } from 'meteor/meteor';
Meteor.subscribe('servers');
Meteor.subscribe('currentServer');

View File

@ -1,2 +1,2 @@
import './collections'; import './startup.js';
import './components'; import './components';

View File

@ -0,0 +1,32 @@
// Check the servers on meteor startup
import { Meteor } from "meteor/meteor";
import { Servers, CurrentServer } from 'meteor/ohif:servers/both/collections';
if (Meteor.settings &&
Meteor.settings.public &&
Meteor.settings.public.clientOnly === true &&
Meteor.settings.public.servers) {
OHIF.log.info('Updating servers information from JSON configuration');
const servers = Meteor.settings.public.servers;
Object.keys(servers).forEach((serverType) => {
const endpoints = servers[serverType];
endpoints.forEach((endpoint) => {
const server = Object.assign({}, endpoint);
server.origin = 'json';
server.type = serverType;
Servers.insert(server);
});
});
const newServer = Servers.findOne();
CurrentServer.insert({
serverId: newServer._id
});
console.log('test');
}

View File

@ -5,7 +5,11 @@ import { Servers } from 'meteor/ohif:servers/both/collections';
import { ServerConfiguration } from 'meteor/ohif:servers/both/schema/servers.js'; import { ServerConfiguration } from 'meteor/ohif:servers/both/schema/servers.js';
// Check the servers on meteor startup // Check the servers on meteor startup
Meteor.startup(function() { if (Meteor.settings &&
Meteor.settings.public &&
Meteor.settings.public.clientOnly !== true) {
Meteor.startup(function() {
OHIF.log.info('Updating servers information from JSON configuration'); OHIF.log.info('Updating servers information from JSON configuration');
_.each(Meteor.settings.servers, function(endpoints, serverType) { _.each(Meteor.settings.servers, function(endpoints, serverType) {
@ -31,4 +35,5 @@ Meteor.startup(function() {
}); });
OHIF.servers.control.resetCurrentServer(); OHIF.servers.control.resetCurrentServer();
}); });
}