Merge branch 'master' of github.com:metamx/druid

This commit is contained in:
Eric Tschetter 2013-03-18 12:59:33 -05:00
commit bbed862b0b
14 changed files with 35 additions and 22 deletions

View File

@ -28,7 +28,7 @@
<parent>
<groupId>com.metamx</groupId>
<artifactId>druid</artifactId>
<version>0.3.23-SNAPSHOT</version>
<version>0.3.24-SNAPSHOT</version>
</parent>
<dependencies>

View File

@ -28,7 +28,7 @@
<parent>
<groupId>com.metamx</groupId>
<artifactId>druid</artifactId>
<version>0.3.23-SNAPSHOT</version>
<version>0.3.24-SNAPSHOT</version>
</parent>
<dependencies>

View File

@ -24,11 +24,11 @@
<artifactId>druid-services</artifactId>
<name>druid-services</name>
<description>druid-services</description>
<version>0.3.23-SNAPSHOT</version>
<version>0.3.24-SNAPSHOT</version>
<parent>
<groupId>com.metamx</groupId>
<artifactId>druid</artifactId>
<version>0.3.23-SNAPSHOT</version>
<version>0.3.24-SNAPSHOT</version>
</parent>
<dependencies>

View File

@ -28,7 +28,7 @@
<parent>
<groupId>com.metamx</groupId>
<artifactId>druid</artifactId>
<version>0.3.23-SNAPSHOT</version>
<version>0.3.24-SNAPSHOT</version>
</parent>
<modules>

View File

@ -9,7 +9,7 @@
<parent>
<groupId>com.metamx</groupId>
<artifactId>druid-examples</artifactId>
<version>0.3.23-SNAPSHOT</version>
<version>0.3.24-SNAPSHOT</version>
</parent>
<dependencies>

View File

@ -9,7 +9,7 @@
<parent>
<groupId>com.metamx</groupId>
<artifactId>druid-examples</artifactId>
<version>0.3.23-SNAPSHOT</version>
<version>0.3.24-SNAPSHOT</version>
</parent>
<dependencies>

View File

@ -28,7 +28,7 @@
<parent>
<groupId>com.metamx</groupId>
<artifactId>druid</artifactId>
<version>0.3.23-SNAPSHOT</version>
<version>0.3.24-SNAPSHOT</version>
</parent>
<dependencies>

View File

@ -28,7 +28,7 @@
<parent>
<groupId>com.metamx</groupId>
<artifactId>druid</artifactId>
<version>0.3.23-SNAPSHOT</version>
<version>0.3.24-SNAPSHOT</version>
</parent>
<dependencies>

View File

@ -28,7 +28,7 @@
<parent>
<groupId>com.metamx</groupId>
<artifactId>druid</artifactId>
<version>0.3.23-SNAPSHOT</version>
<version>0.3.24-SNAPSHOT</version>
</parent>
<dependencies>

View File

@ -23,7 +23,7 @@
<groupId>com.metamx</groupId>
<artifactId>druid</artifactId>
<packaging>pom</packaging>
<version>0.3.23-SNAPSHOT</version>
<version>0.3.24-SNAPSHOT</version>
<name>druid</name>
<description>druid</description>
<scm>

View File

@ -28,7 +28,7 @@
<parent>
<groupId>com.metamx</groupId>
<artifactId>druid</artifactId>
<version>0.3.23-SNAPSHOT</version>
<version>0.3.24-SNAPSHOT</version>
</parent>
<properties>

View File

@ -28,7 +28,7 @@
<parent>
<groupId>com.metamx</groupId>
<artifactId>druid</artifactId>
<version>0.3.23-SNAPSHOT</version>
<version>0.3.24-SNAPSHOT</version>
</parent>
<dependencies>

View File

@ -55,16 +55,24 @@ var DruidTable = function() {
// build table header
html += "<thead>";
// find all unique field names
var fieldNames = {};
for (var row in this.getRows()) {
for (var field in this.getRow(row)) {
fieldNames[field] = 1;
}
}
// build table header filters
html += "<tr>";
for (var field in this.getRow(0)) {
for (var field in fieldNames) {
html += "<td><input type = \"text\" name=\"" + field + "\" value=\"" + field + "\" class=\"search_init\"/></td>";
}
html += "</tr>";
// build table header column headings
html += "<tr>";
for (var field in this.getRow(0)) {
for (var field in fieldNames) {
html += "<th>" + field + "</th>";
}
html += "</tr>";
@ -74,8 +82,13 @@ var DruidTable = function() {
html += "<tbody>";
for (var r in this.getRows()) {
html += "<tr>";
for (var field in this.getRow(r)) {
html += "<td " + "class=\"" + field.replace(' ', '_').toLowerCase() + "\">" + this.getCell(r, field) + "</td>";
for (var field in fieldNames) {
var row = this.getRow(r);
if (row.hasOwnProperty(field)) {
html += "<td " + "class=\"" + field.replace(' ', '_').toLowerCase() + "\">" + this.getCell(r, field) + "</td>";
} else {
html += "<td></td>";
}
}
html += "</tr>";
}

View File

@ -18,7 +18,7 @@ function buildTable(data, el, dontDisplay, table, row) {
// parse JSON
for (var item in data) {
setTable(data[item], el, dontDisplay, table, row);
setTable(data[item], el, dontDisplay, table, row, "");
row++;
}
@ -26,16 +26,16 @@ function buildTable(data, el, dontDisplay, table, row) {
initDataTable(el);
}
function setTable(data, el, dontDisplay, table, row) {
function setTable(data, el, dontDisplay, table, row, fieldNamespace) {
for (var field in data) {
if (_.contains(dontDisplay, field)) {
// do nothing
} else if (Array.isArray(data[field])) {
table.setCell(row, field, JSON.stringify(data[field]));
table.setCell(row, fieldNamespace + field, JSON.stringify(data[field]));
} else if (!(data[field] instanceof Object)) {
table.setCell(row, field, data[field]);
table.setCell(row, fieldNamespace + field, data[field]);
} else {
setTable(data[field], el, dontDisplay, table, row);
setTable(data[field], el, dontDisplay, table, row, fieldNamespace + field + " ");
}
}
}