Skip to content

Commit

Permalink
adding node props/args table to info panel
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrasner committed Jul 10, 2023
1 parent c5b18e2 commit 3db09e8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
5 changes: 5 additions & 0 deletions object_database/web/devtools/cells_panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ div#main {

div#cell-info {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-width: 30%;
Expand All @@ -27,6 +28,10 @@ div#cell-info {
font-size: 20px;
}

div#cell-info > table {
border: 2px solid;
}

.node {
cursor: pointer;
}
Expand Down
42 changes: 35 additions & 7 deletions object_database/web/devtools/js/cell_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,47 @@ const updateInfoPanel = (node) => {
}


const createPropsTable = (propsDict) => {
const table = document.createElement('table');
// header
const thead = document.createElement('thead');
const tr = document.createElement('tr');
const th = document.createElement('table');
thead.append(tr);
tr.append(th);
th.textContent = "Node Arguments";
th.setAttribute("colspan", 2);
table.append(thead);
// body
const tbody = document.createElement('tbody');
table.append(tbody);
Object.keys(propsDict).forEach((key) => {
const tr = document.createElement('tr');
const tdKey = document.createElement('td');
const tdValue = document.createElement('td');
tdKey.textContent = key;
tdValue.textContent = propsDict[key];
tr.append(tdKey);
tr.append(tdValue);
tbody.append(tr);
});

return table;
}

// I handle incoming background 'info' messages
// ie generally these are coming from a devtools request
// to the target application and response from the target app
// returning via content script -> background
const handleInfoFromBackground = (msg) => {
console.log("message from backgound", msg)
const infoPanel = document.getElementById("cell-info");
const propsDiv = document.createElement("div");
let data = msg.data;
if (data) {
data = JSON.stringify(data);
if (Object.keys(msg.data).length) {
const table = createPropsTable(msg.data);
infoPanel.append(table);
} else {
const span = document.createElement('span');
span.textContent = "This node takes no args";
infoPanel.append(span);
}
propsDiv.innerText = `props: ${data}`;
infoPanel.append(propsDiv);

}

0 comments on commit 3db09e8

Please sign in to comment.