diff --git a/Packages/lesiontracker/client/components/serverInformationModal/serverInformationForm.html b/Packages/lesiontracker/client/components/serverInformationModal/serverInformationForm.html new file mode 100644 index 000000000..eeab6f6be --- /dev/null +++ b/Packages/lesiontracker/client/components/serverInformationModal/serverInformationForm.html @@ -0,0 +1,19 @@ + + + + + Server Name + + + + + + Server Type + + DICOM Web + DIMSE + + + + + diff --git a/Packages/lesiontracker/client/components/serverInformationModal/serverInformationList.html b/Packages/lesiontracker/client/components/serverInformationModal/serverInformationList.html new file mode 100644 index 000000000..a52f62309 --- /dev/null +++ b/Packages/lesiontracker/client/components/serverInformationModal/serverInformationList.html @@ -0,0 +1,36 @@ + + + + + Name + Type + Actions + + + + {{#each server in servers}} + + {{server.name}} + {{server.type}} + + + + + + + + + + + + {{else}} + + No servers found + + {{/each}} + + + + Add a new server + + diff --git a/Packages/lesiontracker/client/components/serverInformationModal/serverInformationList.js b/Packages/lesiontracker/client/components/serverInformationModal/serverInformationList.js new file mode 100644 index 000000000..f706ab21b --- /dev/null +++ b/Packages/lesiontracker/client/components/serverInformationModal/serverInformationList.js @@ -0,0 +1,26 @@ +Template.serverInformationList.onRendered(function() { + var instance = Template.instance(); + instance.$('[data-toggle="tooltip"]').tooltip({ container: 'body' }); +}); + +Template.serverInformationList.helpers({ + tooltipTop: function(title) { + return { + 'data-toggle': 'tooltip', + 'data-placement': 'top', + title: title + }; + }, + servers: function() { + return Servers.find().fetch(); + } +}); + +Template.serverInformationList.events({ + 'click .addServer': function(event, instance) { + instance.data.mode.set("create"); + }, + 'click .editServer': function(event, instance) { + instance.data.mode.set("edit"); + } +}); diff --git a/Packages/lesiontracker/client/components/serverInformationModal/serverInformationModal.html b/Packages/lesiontracker/client/components/serverInformationModal/serverInformationModal.html index c7f90959e..6c9a832f4 100644 --- a/Packages/lesiontracker/client/components/serverInformationModal/serverInformationModal.html +++ b/Packages/lesiontracker/client/components/serverInformationModal/serverInformationModal.html @@ -1,44 +1,18 @@ - + × Server Information - {{#each serverInformation}} - - - - - Host - - - {{host}} - - - - - Port - - - {{port}} - - - - - AE Title - - - {{aeTitle}} - - - - - - {{/each}} - + {{#if equals instance.container.mode.get "list"}} + {{>serverInformationList instance.container}} + {{/if}} + {{#if or (equals instance.container.mode.get "edit") (equals instance.container.mode.get "create")}} + {{>serverInformationForm instance.container}} + {{/if}} - \ No newline at end of file + diff --git a/Packages/lesiontracker/client/components/serverInformationModal/serverInformationModal.js b/Packages/lesiontracker/client/components/serverInformationModal/serverInformationModal.js index d510b5d86..16cacc383 100644 --- a/Packages/lesiontracker/client/components/serverInformationModal/serverInformationModal.js +++ b/Packages/lesiontracker/client/components/serverInformationModal/serverInformationModal.js @@ -1,28 +1,6 @@ -function parseUrl(url) { - var parser = document.createElement('a'); - parser.href = url; - return parser; -} - -Template.serverInformationModal.helpers({ - serverInformation: function() { - // TODO: change for Collections - var defaultServiceType = Meteor.settings && Meteor.settings.defaultServiceType || 'dicomWeb'; - var serviceInfo = Meteor.settings.servers[defaultServiceType]; - if (defaultServiceType === 'dicomWeb') { - var serverInformationDicom = []; - serviceInfo.forEach(function(endpoint) { - var parsedUrl = parseUrl(endpoint.qidoRoot); - serverInformationDicom.push({ - host: parsedUrl.hostname, - port: parsedUrl.port, - aeTitle: endpoint.name - }); - }); - - return serverInformationDicom; - } - - return serviceInfo; - } +Template.serverInformationModal.onCreated(function() { + var instance = Template.instance(); + instance.container = { + mode: new ReactiveVar("list") + }; }); diff --git a/Packages/lesiontracker/client/components/serverInformationModal/serverInformationModal.styl b/Packages/lesiontracker/client/components/serverInformationModal/serverInformationModal.styl deleted file mode 100644 index 5392abda8..000000000 --- a/Packages/lesiontracker/client/components/serverInformationModal/serverInformationModal.styl +++ /dev/null @@ -1,13 +0,0 @@ -#serverInformationModal - width: 350px - margin: 0 auto - - .modal-dialog - width: 100% - #tblServer - tbody - tr - th - width: 30% - td - width: 70% \ No newline at end of file diff --git a/Packages/lesiontracker/client/helpers/blaze.js b/Packages/lesiontracker/client/helpers/blaze.js new file mode 100644 index 000000000..8f5bc1163 --- /dev/null +++ b/Packages/lesiontracker/client/helpers/blaze.js @@ -0,0 +1,14 @@ +Template.registerHelper("instance", function() { + return Template.instance(); +}); + +Template.registerHelper("extend", function(object, extendedProperties){ + const result = {}; + for (let i=0; i { + if (result || value instanceof Spacebars.kw) return; + value && (result = value); + }); + return result; +}); + +Template.registerHelper("bool", function(value) { + return !!value; +}); + +Template.registerHelper("equals", function(a, b) { + return a === b; +}); + +Template.registerHelper("not", function(value) { + return !value; +}); + +Template.registerHelper("and", function() { + let result = true; + _.each(arguments, value => value || (result = false)); + return result; +}); + +Template.registerHelper("or", function() { + let result = false; + _.each(arguments, value => { + if (value instanceof Spacebars.kw) return; + value && (result = true); + }); + return result; +}); diff --git a/Packages/lesiontracker/package.js b/Packages/lesiontracker/package.js index 711f109d4..f641c75b0 100644 --- a/Packages/lesiontracker/package.js +++ b/Packages/lesiontracker/package.js @@ -58,6 +58,10 @@ Package.onUse(function(api) { api.addFiles('client/tools.js', 'client'); + // Spacebars helpers + api.addFiles('client/helpers/blaze.js', 'client'); + api.addFiles('client/helpers/logical.js', 'client'); + // UI Components api.addFiles('client/components/viewer/viewer.html', 'client'); api.addFiles('client/components/viewer/viewer.styl', 'client'); @@ -182,8 +186,10 @@ Package.onUse(function(api) { api.addFiles('client/components/lesionTrackerViewportOverlay/lesionTrackerViewportOverlay.html', 'client'); api.addFiles('client/components/lesionTrackerViewportOverlay/lesionTrackerViewportOverlay.js', 'client'); + api.addFiles('client/components/serverInformationModal/serverInformationForm.html', 'client'); + api.addFiles('client/components/serverInformationModal/serverInformationList.html', 'client'); + api.addFiles('client/components/serverInformationModal/serverInformationList.js', 'client'); api.addFiles('client/components/serverInformationModal/serverInformationModal.html', 'client'); - api.addFiles('client/components/serverInformationModal/serverInformationModal.styl', 'client'); api.addFiles('client/components/serverInformationModal/serverInformationModal.js', 'client'); api.addFiles('client/components/userAccountMenu/userAccountMenu.html', 'client');