diff --git a/frontend/index.html b/frontend/index.html
index 9c03afc..92b1c4c 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -22,9 +22,8 @@
-
-
+
diff --git a/frontend/javascripts/backend.js b/frontend/javascripts/backend.js
index c618cb9..5982f71 100644
--- a/frontend/javascripts/backend.js
+++ b/frontend/javascripts/backend.js
@@ -46,53 +46,59 @@ function showEntities() {
eachRecursive(vz.entities, function(entity, parent) {
entity.active = true; // TODO active by default or via backend property?
entity.color = vz.options.plot.colors[i++ % vz.options.plot.colors.length];
+
+ var row = $('
')
+ .addClass((parent) ? 'child-of-entity-' + parent.uuid : '')
+ .attr('id', 'entity-' + entity.uuid)
+ .append($('')
+ .css('background-color', entity.color)
+ .css('width', 19)
+ .append($('')
+ .attr('type', 'checkbox')
+ .attr('checked', entity.active)
+ .bind('change', entity, function(event) {
+ event.data.active = $(this).attr('checked');
+ loadData();
+ })
+ )
+ )
+ .append($(' | ')
+ .css('width', 20)
+ )
+ .append($(' | ')
+ .append($('')
+ .text(entity.title)
+ .addClass('indicator')
+ .addClass((entity.type == 'group') ? 'group' : 'channel')
+ )
+ )
+ .append($(' | ').text(entity.type))
+ .append($(' | ')) // min
+ .append($(' | ')) // max
+ .append($(' | ')) // avg
+ .append($(' | ') // operations
+ .addClass('ops')
+ .append($('')
+ .attr('type', 'image')
+ .attr('src', 'images/information.png')
+ .attr('alt', 'details')
+ .bind('click', entity, function(event) { showEntityDetails(event.data); })
+ )
+ );
+
+ if (parent == null) {
+ $('td.ops', row).prepend($('')
+ .attr('type', 'image')
+ .attr('src', 'images/delete.png')
+ .attr('alt', 'delete')
+ .bind('click', entity, function(event) {
+ removeUUID(event.data.uuid);
+ loadEntities();
+ })
+ );
+ }
- $('#entities tbody').append(
- $(' |
')
- .addClass((parent) ? 'child-of-entity-' + parent.uuid : '')
- .attr('id', 'entity-' + entity.uuid)
- .append($('')
- .css('background-color', entity.color)
- .css('width', 19)
- .append($('')
- .attr('type', 'checkbox')
- .attr('checked', entity.active)
- .bind('change', entity, function(event) {
- event.data.active = $(this).attr('checked');
- loadData();
- })
- )
- )
- .append($(' | ')
- .css('width', 20)
- )
- .append($(' | ')
- .append($('')
- .text(entity.title)
- .addClass('indicator')
- .addClass((entity.type == 'group') ? 'group' : 'channel')
- )
- )
- .append($(' | ').text(entity.type))
- .append($(' | ')) // min
- .append($(' | ')) // max
- .append($(' | ')) // avg
- .append($(' | ') // operations
- .css('text-align', 'right')
- .append($('')
- .attr('type', 'image')
- .attr('src', 'images/information.png')
- .attr('alt', 'details')
- .bind('click', entity, function(event) { showEntityDetails(event.data); })
- )
- .append($('')
- .attr('type', 'image')
- .attr('src', 'images/delete.png')
- .attr('alt', 'delete')
- .bind('click', entity, function(event) { removeUUID(event.data.uuid); })
- )
- )
- );
+ $('#entities tbody').append(row);
});
// http://ludo.cubicphuse.nl/jquery-plugins/treeTable/doc/index.html
@@ -134,11 +140,11 @@ function showEntityDetails(entity) {
});
}
-function validateEntity(form) {
- var entity = getDefinition(entities, form.type.value);
+function validateEntity(entity) {
+ var def = getDefinition(vz.definitions.entities, entity.type);
- $.each(entity.required, function(index, property) {
- var property = getDefinition(properties, property);
+ $.each(def.required, function(index, property) {
+ var property = getDefinition(vz.definitions.properties, property);
if (!validateProperty(property, form.elements[property.name].value)) {
alert('Error: invalid property: ' + property.name + ' = ' + form.elements[property.name].value);
return false;
@@ -195,17 +201,22 @@ function getEntityDOM(type) {
var property = getDefinition(properties, property);
if (property) {
- $('#properties').append(' |
')
+ .addClass('required')
+ .append($('')
+ .append($(' |