Skip to content

Commit 74f4551

Browse files
committed
[DAPS-14xx] Update tests, consts, fix tooltip
1 parent f715f10 commit 74f4551

File tree

6 files changed

+114
-114
lines changed

6 files changed

+114
-114
lines changed

docs_other/dev/design/graph/graph_schema.html

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -157,54 +157,15 @@
157157

158158
function simTick() {
159159
//console.log("tick");
160-
161-
// Update node positions
162-
nodes.attr("transform", function (d) {
163-
return "translate(" + d.x + "," + d.y + ")";
164-
});
165-
166-
// Update label positions with offsets if they exist
167-
nodes.selectAll("text.label")
168-
.attr("x", function(d) {
169-
// Base position (from original code)
170-
let baseX = d.locked ? r + 12 : r;
171-
172-
// Apply offset if it exists
173-
if (d.labelOffsetX !== undefined) {
174-
return baseX + d.labelOffsetX;
175-
}
176-
return baseX;
177-
})
178-
.attr("y", function(d) {
179-
// Base position (from original code)
180-
let baseY = -r;
181-
182-
// Apply offset if it exists
183-
if (d.labelOffsetY !== undefined) {
184-
return baseY + d.labelOffsetY;
185-
}
186-
return baseY;
187-
});
188-
189-
// Update anchored status visual indicator
190-
nodes.selectAll("circle.obj")
191-
.classed("anchored", function(d) {
192-
return d.anchored === true;
193-
});
160+
nodes
161+
.attr("transform", function(d) {
162+
return "translate(" + d.x + "," + d.y + ")"; });
194163

195164
links
196-
.attr("x1", function (d) {
197-
return d.source.x;
198-
})
199-
.attr("y1", function (d) {
200-
return d.source.y;
201-
})
202-
.attr("x2", function (d) {
203-
return d.target.x;
204-
})
205-
.attr("y2", function (d) {
206-
return d.target.y;
207-
});
165+
.attr("x1", function(d) { return d.source.x; })
166+
.attr("y1", function(d) { return d.source.y; })
167+
.attr("x2", function(d) { return d.target.x; })
168+
.attr("y2", function(d) { return d.target.y; });
208169
}
209170

210171
var r = 15;

web/static/components/provenance/customization_modal.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ function showCustomizationModal(node, x, y, currentCustomizationNode, renderGrap
3232
})
3333
.join("");
3434
} else {
35-
nodeColorInput.value = "#6baed6"; // Default blue
35+
nodeColorInput.value = DEFAULTS.NODE_COLOR;
3636
}
3737
} else {
3838
nodeColorInput.value = fillColor;
3939
}
4040
} else {
41-
nodeColorInput.value = "#6baed6"; // Default blue
41+
nodeColorInput.value = DEFAULTS.NODE_COLOR;
4242
}
4343
} else {
44-
nodeColorInput.value = "#6baed6"; // Default blue
44+
nodeColorInput.value = DEFAULTS.NODE_COLOR;
4545
}
4646
}
4747

@@ -51,7 +51,7 @@ function showCustomizationModal(node, x, y, currentCustomizationNode, renderGrap
5151
labelSizeValue.textContent = `${labelSizeSlider.value}px`;
5252

5353
const labelColorInput = document.getElementById("label-color-input");
54-
labelColorInput.value = node.labelColor || "#333333";
54+
labelColorInput.value = node.labelColor || DEFAULTS.LABEL_COLOR;
5555

5656
const anchorCheckbox = document.getElementById("anchor-checkbox");
5757
anchorCheckbox.checked = node.anchored || false;
@@ -136,7 +136,7 @@ function createCustomizationModal() {
136136
const nodeColorInput = document.createElement("input");
137137
nodeColorInput.type = "color";
138138
nodeColorInput.id = "node-color-input";
139-
nodeColorInput.value = "#6baed6"; // Default blue color
139+
nodeColorInput.value = DEFAULTS.NODE_COLOR;
140140

141141
nodeColorRow.appendChild(nodeColorInput);
142142
nodeSection.appendChild(nodeColorRow);
@@ -180,7 +180,7 @@ function createCustomizationModal() {
180180
const labelColorInput = document.createElement("input");
181181
labelColorInput.type = "color";
182182
labelColorInput.id = "label-color-input";
183-
labelColorInput.value = "#333333"; // Default text color
183+
labelColorInput.value = DEFAULTS.LABEL_COLOR; // Default text color
184184

185185
labelColorRow.appendChild(labelColorInput);
186186
labelSection.appendChild(labelColorRow);

web/static/components/provenance/panel_graph.js

Lines changed: 73 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -329,41 +329,93 @@ function GraphPanel(a_id, a_frame, a_parent) {
329329
};
330330

331331
// Add UI buttons for saving and loading graph state
332-
this.addGraphControls = function (container) {
332+
this.addGraphControls = function (containerSelector) {
333+
const controlsId = "graph-controls";
334+
const helpTipId = "graph-help-tooltip";
335+
let controlsDiv = document.getElementById(controlsId);
336+
let helpTip = document.getElementById(helpTipId);
337+
333338
// Create container for graph controls if it doesn't exist
334-
if (!document.getElementById("graph-controls")) {
335-
const controlsDiv = document.createElement("div");
336-
controlsDiv.id = "graph-controls";
339+
if (!controlsDiv) {
340+
controlsDiv = document.createElement("div");
341+
controlsDiv.id = controlsId;
337342
controlsDiv.className = "graph-controls";
338343

339-
// Help tooltip
340-
const helpTip = document.createElement("div");
344+
// "Show Help" button
345+
const showHelpButton = document.createElement("button");
346+
showHelpButton.textContent = "Show Help";
347+
showHelpButton.id = "show-graph-help-button";
348+
showHelpButton.addEventListener("click", function () {
349+
const tipElement = document.getElementById(helpTipId);
350+
if (tipElement) {
351+
tipElement.style.display = "block";
352+
}
353+
});
354+
controlsDiv.appendChild(showHelpButton);
355+
}
356+
357+
// Create help tooltip if it doesn't exist
358+
if (!helpTip) {
359+
helpTip = document.createElement("div");
360+
helpTip.id = helpTipId;
341361
helpTip.className = "graph-tooltip";
342-
helpTip.innerHTML =
362+
363+
const closeButton = document.createElement("span");
364+
closeButton.innerHTML = "×"; // X button
365+
closeButton.className = "graph-tooltip-close";
366+
closeButton.style.position = "absolute";
367+
closeButton.style.top = "5px";
368+
closeButton.style.right = "10px";
369+
closeButton.style.cursor = "pointer";
370+
closeButton.style.pointerEvents = "all";
371+
closeButton.style.fontSize = "20px";
372+
closeButton.addEventListener("click", function () {
373+
const tipElement = document.getElementById(helpTipId);
374+
if (tipElement) {
375+
tipElement.style.display = "none";
376+
}
377+
});
378+
helpTip.appendChild(closeButton);
379+
380+
const helpText = document.createElement("div");
381+
helpText.innerHTML =
343382
"<strong>Graph Controls:</strong><br>" +
344383
"• Drag nodes to move them<br>" +
345384
"• Shift+Drag to anchor nodes<br>" +
346385
"• Alt+Drag to move label<br>" +
347386
"• Right-click for customization options<br>" +
348387
"• Double-click to toggle anchor";
388+
helpTip.appendChild(helpText);
389+
helpTip.style.display = "block"; // Initially visible
390+
}
349391

350-
// Add container to the graph
351-
let graphContainer;
352-
if (container) {
353-
graphContainer = document.querySelector(container);
354-
} else {
355-
// Make sure we don't double-prefix with #
356-
const selector = a_id.startsWith("#") ? a_id : "#" + a_id;
357-
graphContainer = document.querySelector(selector);
392+
// Add controls and tooltip to the graph container's parent
393+
let graphContainerParent;
394+
if (containerSelector) {
395+
graphContainerParent = document.querySelector(containerSelector);
396+
} else {
397+
const selector = a_id.startsWith("#") ? a_id : "#" + a_id;
398+
const svgElement = document.querySelector(selector);
399+
if (svgElement && svgElement.parentElement) {
400+
graphContainerParent = svgElement.parentElement;
358401
}
402+
}
359403

360-
if (graphContainer) {
361-
graphContainer.style.position = "relative";
362-
graphContainer.appendChild(controlsDiv);
363-
graphContainer.appendChild(helpTip);
364-
} else {
365-
console.error("Graph container not found:", container || "#" + a_id);
404+
if (graphContainerParent) {
405+
graphContainerParent.style.position = "relative"; // Important for absolute positioning of tooltip
406+
if (!document.getElementById(controlsId) && controlsDiv) {
407+
// Append only if not already there
408+
graphContainerParent.appendChild(controlsDiv);
366409
}
410+
if (!document.getElementById(helpTipId) && helpTip) {
411+
// Append only if not already there
412+
graphContainerParent.appendChild(helpTip);
413+
}
414+
} else {
415+
console.error(
416+
"Graph container parent not found for controls:",
417+
containerSelector || a_id,
418+
);
367419
}
368420
};
369421

@@ -901,7 +953,6 @@ function GraphPanel(a_id, a_frame, a_parent) {
901953
//console.log("PRUNE ALL");
902954
graphPrune(node_data, link_data, dest);
903955
} else if (dest.row === undefined) {
904-
//console.log("PRUNE LOCAL EDGE ONLY");
905956
graphPruneReset(link_data, node_data);
906957
loc_trim.push(link);
907958
//link.prune = true;
@@ -918,9 +969,6 @@ function GraphPanel(a_id, a_frame, a_parent) {
918969
}
919970
graphPrune(link_data, node_data);
920971
}
921-
922-
//graphPruneReset();
923-
924972
renderGraph();
925973
}
926974
};
@@ -956,8 +1004,6 @@ function GraphPanel(a_id, a_frame, a_parent) {
9561004

9571005
// Called automatically from API module when data records are impacted by edits or annotations
9581006
this.updateData = function (a_data) {
959-
//console.log( "graph updating:", a_data );
960-
9611007
let j,
9621008
node,
9631009
item,
@@ -967,9 +1013,6 @@ function GraphPanel(a_id, a_frame, a_parent) {
9671013
dep_cnt,
9681014
render = false;
9691015

970-
//if ( focus_node_id )
971-
// inst.load( focus_node_id, sel_node_id );
972-
9731016
// Scan updates for dependency changes that impact current graph,
9741017
// if found, reload entire graph from DB
9751018
// If not reloading, scan for changes to title, annotations, status...
@@ -1124,19 +1167,6 @@ function GraphPanel(a_id, a_frame, a_parent) {
11241167
)
11251168
.append("g");
11261169
// TODO add deselect selected node highlight on double-click
1127-
// .on("dblclick", function () {
1128-
// // Clear selection when double-clicking on empty space
1129-
// if (sel_node) {
1130-
// d3.select(".highlight").attr("class", "select hidden");
1131-
// sel_node = null;
1132-
// sel_node_id = null;
1133-
// panel_info.showSelectedInfo(null);
1134-
// a_parent.updateBtnState();
1135-
// }
1136-
//
1137-
// // Stop event propagation
1138-
// d3.event.stopPropagation();
1139-
// });
11401170

11411171
defineArrowMarkerDeriv(svg);
11421172
defineArrowMarkerComp(svg);

web/static/components/provenance/state.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const DEFAULTS = {
22
NODE_SIZE: 10,
3-
NODE_COLOR: null, // Use CSS default
3+
NODE_COLOR: "#6baed6", // Use CSS default
44
LABEL_SIZE: 14,
5-
LABEL_COLOR: null, // Use CSS default
5+
LABEL_COLOR: "#333333", // Use CSS default
66
};
77

88
// Observer pattern for state management

0 commit comments

Comments
 (0)