mirror of https://github.com/apache/druid.git
fix js bugs with indexer console
This commit is contained in:
parent
2a94bd508d
commit
6f771796b6
|
@ -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>";
|
||||
}
|
||||
|
|
|
@ -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 + " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue