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"> <template name="serverInformationDicomWeb">
<div class="row"> <div class="row">
{{>serverInformationDicomWebField name="wadoUriRoot" label="WADO URI root"}} {{>serverInformationFormField name="wadoUriRoot" label="WADO URI root"}}
{{>serverInformationDicomWebField name="wadoUriRootNOTE" label="WADO URI root note"}} {{>serverInformationFormField name="wadoUriRootNOTE" label="WADO URI root note"}}
{{>serverInformationDicomWebField name="wadoRoot" label="WADO root"}} {{>serverInformationFormField name="wadoRoot" label="WADO root"}}
<div class="col-lg-6"> <div class="col-lg-6">
<div class="form-group"> <div class="form-group">
<label class="wrapper"> <label class="wrapper">
@ -15,7 +15,7 @@
</label> </label>
</div> </div>
</div> </div>
{{>serverInformationDicomWebField name="qidoRoot" label="QIDO root"}} {{>serverInformationFormField name="qidoRoot" label="QIDO root"}}
<div class="col-lg-6"> <div class="col-lg-6">
<strong>QIDO options</strong> <strong>QIDO options</strong>
<div class="form-group"> <div class="form-group">
@ -33,7 +33,7 @@
<hr> <hr>
<h4>Request options</h4> <h4>Request options</h4>
<div class="row"> <div class="row">
{{>serverInformationDicomWebField name="requestOptions.auth" label="Authentication"}} {{>serverInformationFormField name="requestOptions.auth" label="Authentication"}}
<div class="col-lg-6"> <div class="col-lg-6">
<strong>Logging options</strong> <strong>Logging options</strong>
<div class="form-group"> <div class="form-group">
@ -61,14 +61,3 @@
</div> </div>
</div> </div>
</template> </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>
</div> </div>
<hr> <hr>
{{#if equals serverType.get "dicomWeb"}} {{#if equals this.serverType.get "dicomWeb"}}
{{>serverInformationDicomWeb this}} {{>serverInformationDicomWeb this}}
{{/if}} {{/if}}
{{#if equals serverType.get "dimse"}} {{#if equals this.serverType.get "dimse"}}
TODO: Print DIMSE form {{>serverInformationDimse this}}
{{/if}} {{/if}}
{{#if serverType.get}} {{#if this.serverType.get}}
<div> <div>
<input type="submit" class="btn btn-primary" value="Save"> <input type="submit" class="btn btn-primary" value="Save">
</div> </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(); return Template.instance();
}); });
Template.registerHelper("extend", function(object, extendedProperties){ Template.registerHelper('extend', function() {
const result = {}; const result = {};
for (let i=0; i<arguments.length; i++) { const kw = arguments.pop();
let current = arguments[i]; _.each(arguments, function(current) {
if (typeof current !== "object") continue; if (typeof current !== 'object') {
current instanceof Spacebars.kw && (current = current.hash); return;
}
_.extend(result, current); _.extend(result, current);
} });
_.extend(result, kw.hash);
return result; return result;
}); });

View File

@ -1,35 +1,35 @@
Template.registerHelper("choose", function() { Template.registerHelper('choose', function() {
let result; let result;
_.each(arguments, value => { _.each(_.initial(arguments, 1), function(value) {
if (result || value instanceof Spacebars.kw) return; return value && (result = value);
value && (result = value);
}); });
return result; return result;
}); });
Template.registerHelper("bool", function(value) { Template.registerHelper('bool', function(value) {
return !!value; return !!value;
}); });
Template.registerHelper("equals", function(a, b) { Template.registerHelper('equals', function(a, b) {
return a === b; return a === b;
}); });
Template.registerHelper("not", function(value) { Template.registerHelper('not', function(value) {
return !value; return !value;
}); });
Template.registerHelper("and", function() { Template.registerHelper('and', function() {
let result = true; let result = true;
_.each(arguments, value => value || (result = false)); _.each(_.initial(arguments, 1), function(value) {
return result; return value || (result = false);
}); });
return result;
Template.registerHelper("or", function() { });
let result = false;
_.each(arguments, value => { Template.registerHelper('or', function() {
if (value instanceof Spacebars.kw) return; let result = false;
value && (result = true); _.each(_.initial(arguments, 1), function(value) {
return value && (result = true);
}); });
return result; 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 propertyArray = key.split('.');
var currentObject = nestedObject; var currentObject = nestedObject;
while (propertyArray.length) { 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) { if (!propertyArray.length) {
currentObject[currentProperty] = value; currentObject[key] = value;
} else { } else {
if (!currentObject[currentProperty]) { if (!currentObject[key]) {
currentObject[currentProperty] = {}; 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 currentKey = baseKey ? baseKey + '.' + key : key;
var currentValue = nestedObject[key]; var currentValue = nestedObject[key];
if (typeof currentValue === 'object') { if (typeof currentValue === 'object') {
if (currentValue instanceof Array) {
currentKey += '[]';
}
putValues(currentKey, currentValue, resultObject); putValues(currentKey, currentValue, resultObject);
} else { } else {
resultObject[currentKey] = currentValue; resultObject[currentKey] = currentValue;

View File

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

View File

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