LT-67 Creating utility helpers for lesiontracker package and implementing servers listing
This commit is contained in:
parent
fd5e7dd2f4
commit
d9367cf200
@ -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">×</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%
|
||||
14
Packages/lesiontracker/client/helpers/blaze.js
Normal file
14
Packages/lesiontracker/client/helpers/blaze.js
Normal file
@ -0,0 +1,14 @@
|
||||
Template.registerHelper("instance", function() {
|
||||
return Template.instance();
|
||||
});
|
||||
|
||||
Template.registerHelper("extend", function(object, extendedProperties){
|
||||
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);
|
||||
_.extend(result, current);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
35
Packages/lesiontracker/client/helpers/logical.js
Normal file
35
Packages/lesiontracker/client/helpers/logical.js
Normal file
@ -0,0 +1,35 @@
|
||||
Template.registerHelper("choose", function() {
|
||||
let result;
|
||||
_.each(arguments, value => {
|
||||
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;
|
||||
});
|
||||
@ -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');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user