Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
70969b2
template setup for tree component
dkrasner Nov 4, 2022
8f8fcf3
adding TreeNode and updating basic example setup
dkrasner Nov 4, 2022
7fbf00c
adding depths to trees and webpack
dkrasner Nov 5, 2022
947d46f
[WIP] rewriting Tree as regular object to dealing with leaderlines
dkrasner Nov 7, 2022
44676d4
[WIP] add tree.css and minor updates to leaderlines
dkrasner Nov 8, 2022
de7677b
v0 of working tree with conneiton lines
dkrasner Nov 15, 2022
a94d0cf
leadrlines use proper js document.createElementNS API
dkrasner Nov 15, 2022
64175ad
adding global css, better styling and window resize listener
dkrasner Nov 16, 2022
6f75f80
adding subtree zoom in/out and related css updates to tree and node
dkrasner Nov 30, 2022
1344b95
optimizing svg line rendering; adding findParentSubTree for nav
dkrasner Nov 30, 2022
993661d
adding keyboard events for better scrolling up tree
dkrasner Nov 30, 2022
9cd87ac
initial integration of tree [WIP]
dkrasner Nov 30, 2022
b872dd8
adding proper display depth and related
dkrasner Dec 1, 2022
0675f74
fixing up connector lines in tree
dkrasner Dec 5, 2022
e784196
updating id key for messages from CellHandler to devtools
dkrasner Dec 31, 2022
06620c1
adding handling of DOM invalid cell/node ids
dkrasner Dec 31, 2022
17c8426
addiung non-starting-root node handling
dkrasner Jan 2, 2023
098b492
fixing up vertical paths in tree and adding on hover highlight
dkrasner Jan 2, 2023
1d35ea0
adding forgotten setupDevtools() in CellHandler
dkrasner Jan 2, 2023
580767f
typo fix
dkrasner Jan 2, 2023
9006db8
hightlight query selector fix
dkrasner Jan 2, 2023
6db1ea7
adding better overlay cleanup for devtools
dkrasner Jan 2, 2023
35b3cb1
adding better hover devtools highlighting and related changes
dkrasner Jan 2, 2023
d8871ce
filtering out non cells from messager to devtools in CellHandler
dkrasner Jan 24, 2023
f04608c
removing old d3 tree js file
dkrasner Jan 25, 2023
9b0227b
adding node click and customization handlers
dkrasner Jan 25, 2023
4de7667
improving the bezier curves connecting trees
dkrasner May 1, 2023
a6ee429
updating cell info panel
dkrasner May 3, 2023
71d0049
temp removal of child node display in info panel
dkrasner May 4, 2023
6de8bd8
minor clean and improvement of cells panel
dkrasner May 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ object_database/web/content/dist
\#*
\.#*
*~
.projectile

# leading slash means only match at repo-root level
/.python-version
Expand Down
48 changes: 42 additions & 6 deletions object_database/web/content/src/CellHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class CellHandler {
// devtools related messages
this.sendMessageToDevtools = this.sendMessageToDevtools.bind(this);
this.updateDevtools = this.updateDevtools.bind(this);
this.setupDevtools = this.setupDevtools.bind(this);
}

tearDownAllLiveCells() {
Expand Down Expand Up @@ -131,6 +132,7 @@ class CellHandler {
])
])
);
this.setupDevtools();
this.sendMessageToDevtools({
status: "initial load"
});
Expand Down Expand Up @@ -507,6 +509,32 @@ class CellHandler {
}
}

/**
* Setup utilities for devtools to call using chrome.devtools.inspectedWindow.eval()
* TODO: potentially this should pass via the content-scripts
*/
setupDevtools(){
const overlayId = "cells-devtools-overlay";
window.addDevtoolsHighlight = (id) => {
const cell = document.querySelector(`[data-cell-id="${id}"]`);
const rect = cell.getBoundingClientRect();
const overlay = document.createElement("div");
overlay.style.position = "absolute";
overlay.style.backgroundColor = "#cec848";
overlay.style.opacity = "0.5";
overlay.style.left = rect.left +"px";
overlay.style.top = rect.top + "px";
overlay.style.height = rect.height + "px";
overlay.style.width = rect.width + "px";
overlay.setAttribute("id", overlayId);
document.body.append(overlay);
}

window.removeDevtoolsHighlight = () => {
const overlays = document.querySelectorAll(`#${overlayId}`);
overlays.forEach((el) => el.remove());
}
}
sendMessageToDevtools(msg){
// TODO perhaps this should be run by a worker
msg.type = "cells_devtools";
Expand All @@ -518,10 +546,12 @@ class CellHandler {
**/
updateDevtools(){
const buildTree = (cell) => {
return {
name: cell.constructor.name,
identity: cell.identity,
children: mapChildren(cell.namedChildren)
if (cell.isCell) {
return {
name: cell.constructor.name,
id: cell.identity,
children: mapChildren(cell.namedChildren)
}
}
}
// NOTE: sometimes a named child is a cell, sometimes it's an array of cells
Expand All @@ -533,10 +563,16 @@ class CellHandler {
if (child){
if (child instanceof Array){
child.forEach((subchild) => {
children.push(buildTree(subchild));
const subTree = buildTree(subchild);
if (subTree){
children.push(buildTree(subchild));
}
})
}
children.push(buildTree(child));
const subTree = buildTree(child);
if (subTree) {
children.push(buildTree(child));
}
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions object_database/web/devtools/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function connected(port) {
// from the target window we forward this message to the panels
// if the connection is not alive we log this in the devtools's
// debugger console
notifyDevtoolsPabel(msg.data);
notifyDevtoolsPanel(msg.data);
});
}
// notify if the port has disconnected
Expand All @@ -42,7 +42,7 @@ function connected(port) {

chrome.runtime.onConnect.addListener(connected);

function notifyDevtoolsPabel(msg){
function notifyDevtoolsPanel(msg){
if (portFromPanel){
portFromPanel.postMessage(msg);
} else {
Expand Down
3 changes: 3 additions & 0 deletions object_database/web/devtools/cells_panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ div#cell-info {
justify-content: center;
align-items: center;
min-width: 30%;
text-align: center;
font-family: Roboto;
font-size: 20px;
}

.node {
Expand Down
4 changes: 3 additions & 1 deletion object_database/web/devtools/cells_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
<head>
<meta charset="UTF-8" />
<title>Cells</title>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<!--<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>-->
<script src="tree/dist/tree.bundle.js"></script>
<link rel="stylesheet" type="text/css" href="cells_panel.css">
<link rel="stylesheet" href="tree/tree.css" />
</head>
<body>
<div id="main"></div>
Expand Down
62 changes: 59 additions & 3 deletions object_database/web/devtools/js/cell_panel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {CellsTree} from './tree.js';
// import {CellsTree} from './tree.js';

// GLOBALS (TODO: should be handled better)
let state = null;
Expand Down Expand Up @@ -44,13 +44,69 @@ const reconnectingDisplay = () => {
main.textContent = "Reconnecting: no cells loaded";
}

const updateInfoPanel = (node) => {
const infoPanel = document.getElementById("cell-info");
const id = node.getAttribute("data-original-id");
const name = node.name;
let info = `${name}\ncell-id: ${id}`;
const tree = document.querySelector("tree-graph");
const parentSubtree = tree.findParentSubTree(id, tree.data);
if (parentSubtree.name.match("Subscribed")) {
info = `${info}\nsubscribed to cell-id: ${parentSubtree.id}`;
}
/*
const nodeTree = parentSubtree.children.filter((n) => {
return n.id = node.id;
})[0]
let childIds = "";
nodeTree.children.forEach((c) => {
childIds = `${childIds}, ${c.id}`;
});
info = `${info}\nchild node ids: ${childIds}`;
*/
infoPanel.innerText = info;
}

const cellsTreeDisplay = (cells) => {
clearDisplay();
// init and run
// NOTE: the tree class itself attaches the
// svg element to #main
const cTree = new CellsTree(cells);
cTree.setupTree();
// const cTree = new CellsTree(cells);
// cTree.setupTree();
const tree = document.createElement("tree-graph");
const main = document.getElementById("main");
main.append(tree);
tree.setAttribute("display-depth", 4);
// setup node hover event listeners
// NOTE: these are defined on window by CellHandler
tree.onNodeMouseover = (event) => {
// highlight the corresponding element in the target window
const id = event.target.getAttribute("data-original-id");
chrome.devtools.inspectedWindow.eval(
`window.addDevtoolsHighlight(${id})`
);
}
tree.onNodeMouseleave = (event) => {
// un-highlight the corresponding element in the target window
chrome.devtools.inspectedWindow.eval(
`window.removeDevtoolsHighlight()`
);
}

tree.onNodeClick = (event) => {
updateInfoPanel(event.target);
}
tree.customizeNode = (node) => {
if (node.name == "Subscribed") {
node.style.backgroundColor = "var(--palette-beige)";
}
// customize a tooltip here
const id = node.getAttribute("data-original-id");
node.title = `cell-id: ${id}`;
}
// displaying tree
tree.setup(cells);
}


Expand Down
Loading