From 60bb75877451409f1dd4135ce9e3dda6fb353bef Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 4 Oct 2010 03:29:12 +0200 Subject: [PATCH] fixed smaller incompabilities and issues --- frontend/index.html | 3 +- frontend/javascripts/backend.js | 153 ++++++++++++--------- frontend/javascripts/frontend.js | 37 ++--- frontend/javascripts/init.js | 18 ++- frontend/javascripts/uuid.js | 12 +- frontend/stylesheets/jquery.jqplot.min.css | 1 - frontend/stylesheets/style.css | 4 + 7 files changed, 128 insertions(+), 100 deletions(-) delete mode 100644 frontend/stylesheets/jquery.jqplot.min.css 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('' + getPropertyForm(property) + '(*)'); + $('#properties') + .append($('') + .addClass('required') + .append($('') + .append($('