Skip to content

Commit

Permalink
Rename to key since hardware_id doesn't make sense now
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferry Schoenmakers committed May 30, 2022
1 parent 95517d8 commit 1062103
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions rosboard/html/js/viewers/DiagnosticViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,66 +44,66 @@ class DiagnosticViewer extends Viewer {
this.diagnosticStatuses[status._name] = status;
}

for(let hardware_id in this.diagnosticStatuses) {
if(!this.dataTables[hardware_id]) {
this.dataTables[hardware_id] = $('<table></table>')
for(let key in this.diagnosticStatuses) {
if(!this.dataTables[key]) {
this.dataTables[key] = $('<table></table>')
.addClass('mdl-data-table')
.addClass('mdl-data-table-diagnostic')
.addClass('mdl-js-data-table')
.appendTo(this.viewer);

this.dataTables[hardware_id].thead = $('<thead></thead>')
.appendTo(this.dataTables[hardware_id]);
this.dataTables[hardware_id].headRow = $('<tr></tr>').appendTo(this.dataTables[hardware_id].thead);
this.dataTables[hardware_id].icon = $('<td><i class="material-icons">chevron_right</i></td>').appendTo(this.dataTables[hardware_id].headRow);
this.dataTables[hardware_id].hardwareIdDisplay = $('<td><b>' + hardware_id + '</b></td>').appendTo(this.dataTables[hardware_id].headRow);
this.dataTables[hardware_id].messageDisplay = $('<td></td>').appendTo(this.dataTables[hardware_id].headRow);
this.dataTables[hardware_id].tbody = $("<tbody></tbody>").appendTo(this.dataTables[hardware_id]).hide();
this.dataTables[key].thead = $('<thead></thead>')
.appendTo(this.dataTables[key]);
this.dataTables[key].headRow = $('<tr></tr>').appendTo(this.dataTables[key].thead);
this.dataTables[key].icon = $('<td><i class="material-icons">chevron_right</i></td>').appendTo(this.dataTables[key].headRow);
this.dataTables[key].hardwareIdDisplay = $('<td><b>' + key + '</b></td>').appendTo(this.dataTables[key].headRow);
this.dataTables[key].messageDisplay = $('<td></td>').appendTo(this.dataTables[key].headRow);
this.dataTables[key].tbody = $("<tbody></tbody>").appendTo(this.dataTables[key]).hide();

let that = this;
this.dataTables[hardware_id].thead[0].addEventListener('click', function(e) {
that.dataTables[hardware_id].tbody.toggle();
if(that.dataTables[hardware_id].icon.children('i').text() === "chevron_right") {
that.dataTables[hardware_id].icon.children('i').text("expand_more");
this.dataTables[key].thead[0].addEventListener('click', function(e) {
that.dataTables[key].tbody.toggle();
if(that.dataTables[key].icon.children('i').text() === "chevron_right") {
that.dataTables[key].icon.children('i').text("expand_more");
} else {
that.dataTables[hardware_id].icon.children('i').text("chevron_right");
that.dataTables[key].icon.children('i').text("chevron_right");
}
})
}

let status = this.diagnosticStatuses[hardware_id];
let status = this.diagnosticStatuses[key];

this.dataTables[hardware_id].messageDisplay.text(status._message);
this.dataTables[key].messageDisplay.text(status._message);

if(status._level === 0) {
this.dataTables[hardware_id].headRow.addClass("diagnostic-level-ok");
this.dataTables[hardware_id].headRow.removeClass("diagnostic-level-warn");
this.dataTables[hardware_id].headRow.removeClass("diagnostic-level-error");
this.dataTables[hardware_id].headRow.removeClass("diagnostic-level-stale");
this.dataTables[key].headRow.addClass("diagnostic-level-ok");
this.dataTables[key].headRow.removeClass("diagnostic-level-warn");
this.dataTables[key].headRow.removeClass("diagnostic-level-error");
this.dataTables[key].headRow.removeClass("diagnostic-level-stale");
} else if(status._level === 1) {
this.dataTables[hardware_id].headRow.removeClass("diagnostic-level-ok");
this.dataTables[hardware_id].headRow.addClass("diagnostic-level-warn");
this.dataTables[hardware_id].headRow.removeClass("diagnostic-level-error");
this.dataTables[hardware_id].headRow.removeClass("diagnostic-level-stale");
this.dataTables[key].headRow.removeClass("diagnostic-level-ok");
this.dataTables[key].headRow.addClass("diagnostic-level-warn");
this.dataTables[key].headRow.removeClass("diagnostic-level-error");
this.dataTables[key].headRow.removeClass("diagnostic-level-stale");
} else if(status._level === 2) {
this.dataTables[hardware_id].headRow.removeClass("diagnostic-level-ok");
this.dataTables[hardware_id].headRow.removeClass("diagnostic-level-warn");
this.dataTables[hardware_id].headRow.addClass("diagnostic-level-error");
this.dataTables[hardware_id].headRow.removeClass("diagnostic-level-stale");
this.dataTables[key].headRow.removeClass("diagnostic-level-ok");
this.dataTables[key].headRow.removeClass("diagnostic-level-warn");
this.dataTables[key].headRow.addClass("diagnostic-level-error");
this.dataTables[key].headRow.removeClass("diagnostic-level-stale");
} else if(status._level === 3) {
this.dataTables[hardware_id].headRow.removeClass("diagnostic-level-ok");
this.dataTables[hardware_id].headRow.removeClass("diagnostic-level-warn");
this.dataTables[hardware_id].headRow.removeClass("diagnostic-level-error");
this.dataTables[hardware_id].headRow.addClass("diagnostic-level-stale");
this.dataTables[key].headRow.removeClass("diagnostic-level-ok");
this.dataTables[key].headRow.removeClass("diagnostic-level-warn");
this.dataTables[key].headRow.removeClass("diagnostic-level-error");
this.dataTables[key].headRow.addClass("diagnostic-level-stale");
}

this.dataTables[hardware_id].tbody.empty();
this.dataTables[key].tbody.empty();
let html = "";
for(let key in status) {
if(key[0] === "_") continue;
html += '<tr><td>&nbsp;</td><td>' + key + '</td><td>' + status[key] + "</td></tr>";
}
$(html).appendTo(this.dataTables[hardware_id].tbody);
$(html).appendTo(this.dataTables[key].tbody);
}
}
}
Expand Down

0 comments on commit 1062103

Please sign in to comment.