LT-67 Creating utility helpers for lesiontracker package and implementing servers listing

This commit is contained in:
Bruno Alves de Faria authored and Erik Ziegler committed 2016-08-04 16:48:26 +02:00
1 parent fd5e7dd2f4
commit d9367cf200
9 files changed
+150 -75

No files matched your search

@@ -0,0 +1,19 @@
<template name="serverInformationForm">
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label for="serverName">Server Name</label>
<input type="text" class="form-control" id="serverName">
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label for="serverType">Server Type</label>
<select class="form-control" id="serverType">
<option value="dicomWeb">DICOM Web</option>
<option value="dimse">DIMSE</option>
</select>
</div>
</div>
</div>
</template>
@@ -0,0 +1,36 @@
<template name="serverInformationList">
<table id="tblServer" class="table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="text-right">Actions</th>
</tr>
</thead>
<tbody>
{{#each server in servers}}
<tr>
<td>{{server.name}}</td>
<td>{{server.type}}</td>
<td class="text-right">
<div class="btn-group" role="group" aria-label="Actions">
<button class="btn btn-sm btn-default editServer" {{tooltipTop "Edit"}}>
<i class="fa fa-pencil"></i>
</button>
<button class="btn btn-sm btn-danger removeServer" {{tooltipTop "Remove"}}>
<i class="fa fa-trash"></i>
</button>
</div>
</td>
</tr>
{{else}}
<tr>
<td class="text-center" colspan="3">No servers found</td>
</tr>
{{/each}}
</tbody>
</table>
<button class="btn btn-default addServer">
<i class="fa fa-plus"></i> Add a new server
</button>
</template>
@@ -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");
}
});
@@ -1,44 +1,18 @@
<template name="serverInformationModal">
<div class="modal" id="serverInformationModal" tabindex="-1" role="dialog" aria-labelledby="serverInformationModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="serverInformationModalLabel">Server Information</h4>
</div>
<div class="modal-body">
{{#each serverInformation}}
<table id="tblServer" class="table table-bordered table-hovered">
<tbody>
<tr>
<th>
Host
</th>
<td>
{{host}}
</td>
</tr>
<tr>
<th>
Port
</th>
<td>
{{port}}
</td>
</tr>
<tr>
<th>
AE Title
</th>
<td>
{{aeTitle}}
</td>
</tr>
</tbody>
</table>
{{/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}}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
@@ -46,4 +20,4 @@
</div>
</div>
</div>
</template>
</template>
@@ -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")
};
});
@@ -1,13 +0,0 @@
#serverInformationModal
width: 350px
margin: 0 auto
.modal-dialog
width: 100%
#tblServer
tbody
tr
th
width: 30%
td
width: 70%