LT-67 Adding form for DIMSE servers

This commit is contained in:
Bruno Alves de Faria 2016-05-14 12:30:11 -03:00 committed by Erik Ziegler
parent 3873ac6b3b
commit 16a302e979
11 changed files with 145 additions and 50 deletions

View File

@ -1,8 +1,8 @@
<template name="serverInformationDicomWeb">
<div class="row">
{{>serverInformationDicomWebField name="wadoUriRoot" label="WADO URI root"}}
{{>serverInformationDicomWebField name="wadoUriRootNOTE" label="WADO URI root note"}}
{{>serverInformationDicomWebField name="wadoRoot" label="WADO root"}}
{{>serverInformationFormField name="wadoUriRoot" label="WADO URI root"}}
{{>serverInformationFormField name="wadoUriRootNOTE" label="WADO URI root note"}}
{{>serverInformationFormField name="wadoRoot" label="WADO root"}}
<div class="col-lg-6">
<div class="form-group">
<label class="wrapper">
@ -15,7 +15,7 @@
</label>
</div>
</div>
{{>serverInformationDicomWebField name="qidoRoot" label="QIDO root"}}
{{>serverInformationFormField name="qidoRoot" label="QIDO root"}}
<div class="col-lg-6">
<strong>QIDO options</strong>
<div class="form-group">
@ -33,7 +33,7 @@
<hr>
<h4>Request options</h4>
<div class="row">
{{>serverInformationDicomWebField name="requestOptions.auth" label="Authentication"}}
{{>serverInformationFormField name="requestOptions.auth" label="Authentication"}}
<div class="col-lg-6">
<strong>Logging options</strong>
<div class="form-group">
@ -61,14 +61,3 @@
</div>
</div>
</template>
<template name="serverInformationDicomWebField">
<div class="col-lg-6">
<div class="form-group">
<label class="wrapper">
<span>{{this.label}}</span>
<input type="text" name="{{this.name}}" class="form-control">
</label>
</div>
</div>
</template>

View File

@ -0,0 +1,43 @@
<template name="serverInformationDimse">
<div class="panel panel-default panel-body">
<div class="clearfix">
<h4 class="pull-left">Peer list</h4>
<button class="btn btn-primary pull-right js-new-peer">New peer</button>
</div>
<hr>
<div class="row">
{{#each peer in instance.peers.get}}
<div class="col-lg-6">
<div class="panel panel-default panel-body">
<div class="row">
{{>serverInformationFormField name=(concat "peers[]." @index ".aeTitle") label="AE title"}}
{{>serverInformationFormField name=(concat "peers[]." @index ".hostAE") label="AE host"}}
{{>serverInformationFormField name=(concat "peers[]." @index ".host") label="Host"}}
{{>serverInformationFormField name=(concat "peers[]." @index ".port") label="Port"}}
<div class="col-lg-12">
<strong>Settings</strong>
<div class="form-group">
<div class="form-control clearfix">
<div class="checkbox pull-left">
<label>
<input type="checkbox" name="peers[].{{@index}}.default">
<span>Default</span>
</label>
</div>
<div class="checkbox pull-left">
<label>
<input type="checkbox" name="peers[].{{@index}}.server">
<span>Server</span>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{{/each}}
</div>
</div>
<hr>
</template>

View File

@ -0,0 +1,28 @@
Template.serverInformationDimse.onCreated(function() {
var instance = Template.instance();
instance.peers = new ReactiveVar([]);
instance.autorun(function() {
var currentItem = instance.data.currentItem.get();
instance.peers.set(currentItem.peers || []);
});
});
Template.serverInformationDimse.onRendered(function() {
var instance = Template.instance();
instance.autorun(function() {
var mode = instance.data.mode.get();
if (mode === 'edit') {
var data = instance.data.currentItem.get();
FormUtils.setFormData(instance.data.$form, data);
}
});
});
Template.serverInformationDimse.events({
'click .js-new-peer': function(event, instance) {
event.preventDefault();
var peers = instance.peers.get();
peers.push({});
instance.peers.set(peers);
}
});

View File

@ -24,13 +24,13 @@
</div>
</div>
<hr>
{{#if equals serverType.get "dicomWeb"}}
{{#if equals this.serverType.get "dicomWeb"}}
{{>serverInformationDicomWeb this}}
{{/if}}
{{#if equals serverType.get "dimse"}}
TODO: Print DIMSE form
{{#if equals this.serverType.get "dimse"}}
{{>serverInformationDimse this}}
{{/if}}
{{#if serverType.get}}
{{#if this.serverType.get}}
<div>
<input type="submit" class="btn btn-primary" value="Save">
</div>

View File

@ -0,0 +1,10 @@
<template name="serverInformationFormField">
<div class="col-lg-6">
<div class="form-group">
<label class="wrapper">
<span>{{this.label}}</span>
<input type="text" name="{{this.name}}" class="form-control">
</label>
</div>
</div>
</template>

View File

@ -1,14 +1,17 @@
Template.registerHelper("instance", function() {
Template.registerHelper('instance', function() {
return Template.instance();
});
Template.registerHelper("extend", function(object, extendedProperties){
Template.registerHelper('extend', function() {
const result = {};
for (let i=0; i<arguments.length; i++) {
let current = arguments[i];
if (typeof current !== "object") continue;
current instanceof Spacebars.kw && (current = current.hash);
const kw = arguments.pop();
_.each(arguments, function(current) {
if (typeof current !== 'object') {
return;
}
_.extend(result, current);
}
});
_.extend(result, kw.hash);
return result;
});

View File

@ -1,35 +1,35 @@
Template.registerHelper("choose", function() {
Template.registerHelper('choose', function() {
let result;
_.each(arguments, value => {
if (result || value instanceof Spacebars.kw) return;
value && (result = value);
_.each(_.initial(arguments, 1), function(value) {
return value && (result = value);
});
return result;
});
Template.registerHelper("bool", function(value) {
Template.registerHelper('bool', function(value) {
return !!value;
});
Template.registerHelper("equals", function(a, b) {
Template.registerHelper('equals', function(a, b) {
return a === b;
});
Template.registerHelper("not", function(value) {
Template.registerHelper('not', function(value) {
return !value;
});
Template.registerHelper("and", function() {
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);
_.each(_.initial(arguments, 1), function(value) {
return value || (result = false);
});
return result;
});
Template.registerHelper('or', function() {
let result = false;
_.each(_.initial(arguments, 1), function(value) {
return value && (result = true);
});
return result;
});

View File

@ -0,0 +1,7 @@
Template.registerHelper('concat', function() {
let result = '';
_.each(_.initial(arguments, 1), function(value) {
result += value;
});
return result;
});

View File

@ -39,15 +39,18 @@ class Form {
var propertyArray = key.split('.');
var currentObject = nestedObject;
while (propertyArray.length) {
var currentProperty = propertyArray.shift();
var property = propertyArray.shift();
var isArray = property.slice(-2) === '[]';
var key = isArray ? property.slice(0, -2) : property;
if (!propertyArray.length) {
currentObject[currentProperty] = value;
currentObject[key] = value;
} else {
if (!currentObject[currentProperty]) {
currentObject[currentProperty] = {};
if (!currentObject[key]) {
var dataStructure = isArray ? [] : {};
currentObject[key] = dataStructure;
}
currentObject = currentObject[currentProperty];
currentObject = currentObject[key];
}
}
}
@ -63,6 +66,10 @@ class Form {
var currentKey = baseKey ? baseKey + '.' + key : key;
var currentValue = nestedObject[key];
if (typeof currentValue === 'object') {
if (currentValue instanceof Array) {
currentKey += '[]';
}
putValues(currentKey, currentValue, resultObject);
} else {
resultObject[currentKey] = currentValue;

View File

@ -61,6 +61,7 @@ Package.onUse(function(api) {
// Spacebars helpers
api.addFiles('client/helpers/blaze.js', 'client');
api.addFiles('client/helpers/logical.js', 'client');
api.addFiles('client/helpers/string.js', 'client');
// Utility classes
api.addFiles('client/utils/form.js', 'client');
@ -191,8 +192,11 @@ Package.onUse(function(api) {
api.addFiles('client/components/serverInformationModal/serverInformationDicomWeb.html', 'client');
api.addFiles('client/components/serverInformationModal/serverInformationDicomWeb.js', 'client');
api.addFiles('client/components/serverInformationModal/serverInformationDimse.html', 'client');
api.addFiles('client/components/serverInformationModal/serverInformationDimse.js', 'client');
api.addFiles('client/components/serverInformationModal/serverInformationForm.html', 'client');
api.addFiles('client/components/serverInformationModal/serverInformationForm.js', 'client');
api.addFiles('client/components/serverInformationModal/serverInformationFormField.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');

View File

@ -23,12 +23,16 @@ Meteor.methods({
var options = {
upsert: true
};
if (!serverSettings._id) {
delete serverSettings._id;
}
var callback = function(error, affected) {
if (error) {
throw new Meteor.Error('data-write', error);
}
console.log(Servers.findOne());
};
Servers.update(criteria, serverSettings, options, callback);