context menu option
This commit is contained in:
@@ -561,6 +561,16 @@ input[type="text"]:focus, select:focus {
|
||||
color: #00ff41;
|
||||
}
|
||||
|
||||
.graph-context-menu ul li[disabled] {
|
||||
color: #666;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.graph-context-menu ul li[disabled]:hover {
|
||||
background-color: #2a2a2a;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.graph-placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -68,6 +68,7 @@ class GraphManager {
|
||||
this.trueRootIds = new Set();
|
||||
// Track large entity members for proper hiding
|
||||
this.largeEntityMembers = new Set();
|
||||
this.isScanning = false;
|
||||
|
||||
this.options = {
|
||||
nodes: {
|
||||
@@ -1002,8 +1003,7 @@ class GraphManager {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @param {Set} excludedNodeIds - Node IDs to exclude from analysis (for simulation)
|
||||
/* * @param {Set} excludedNodeIds - Node IDs to exclude from analysis (for simulation)
|
||||
* @param {Set} excludedEdgeTypes - Edge types to exclude from traversal
|
||||
* @param {Set} excludedNodeTypes - Node types to exclude from traversal
|
||||
* @returns {Object} Analysis results with reachable/unreachable nodes
|
||||
@@ -1400,14 +1400,30 @@ class GraphManager {
|
||||
*/
|
||||
showContextMenu(nodeId, event) {
|
||||
console.log('Showing context menu for node:', nodeId);
|
||||
const node = this.nodes.get(nodeId);
|
||||
|
||||
// Create menu items
|
||||
this.contextMenu.innerHTML = `
|
||||
let menuItems = `
|
||||
<ul>
|
||||
<li data-action="focus" data-node-id="${nodeId}">
|
||||
<span class="menu-icon">🎯</span>
|
||||
<span>Focus on Node</span>
|
||||
</li>
|
||||
`;
|
||||
|
||||
// Add "Iterate Scan" option only for domain or IP nodes
|
||||
if (node && (node.type === 'domain' || node.type === 'ip')) {
|
||||
const disabled = this.isScanning ? 'disabled' : ''; // Check if scanning
|
||||
const title = this.isScanning ? 'A scan is already in progress' : 'Iterate Scan (Add to Graph)'; // Add a title for disabled state
|
||||
menuItems += `
|
||||
<li data-action="iterate" data-node-id="${nodeId}" ${disabled} title="${title}">
|
||||
<span class="menu-icon">➕</span>
|
||||
<span>Iterate Scan (Add to Graph)</span>
|
||||
</li>
|
||||
`;
|
||||
}
|
||||
|
||||
menuItems += `
|
||||
<li data-action="hide" data-node-id="${nodeId}">
|
||||
<span class="menu-icon">👁️🗨️</span>
|
||||
<span>Hide Node</span>
|
||||
@@ -1423,6 +1439,8 @@ class GraphManager {
|
||||
</ul>
|
||||
`;
|
||||
|
||||
this.contextMenu.innerHTML = menuItems;
|
||||
|
||||
// Position the menu
|
||||
this.contextMenu.style.left = `${event.clientX}px`;
|
||||
this.contextMenu.style.top = `${event.clientY}px`;
|
||||
@@ -1440,6 +1458,10 @@ class GraphManager {
|
||||
// Add event listeners to menu items
|
||||
this.contextMenu.querySelectorAll('li').forEach(item => {
|
||||
item.addEventListener('click', (e) => {
|
||||
if (e.currentTarget.hasAttribute('disabled')) { // Prevent action if disabled
|
||||
e.stopPropagation();
|
||||
return;
|
||||
}
|
||||
e.stopPropagation();
|
||||
const action = e.currentTarget.dataset.action;
|
||||
const nodeId = e.currentTarget.dataset.nodeId;
|
||||
@@ -1471,6 +1493,13 @@ class GraphManager {
|
||||
this.focusOnNode(nodeId);
|
||||
break;
|
||||
|
||||
case 'iterate':
|
||||
const event = new CustomEvent('iterateScan', {
|
||||
detail: { nodeId }
|
||||
});
|
||||
document.dispatchEvent(event);
|
||||
break;
|
||||
|
||||
case 'hide':
|
||||
// Use enhanced method with reachability analysis
|
||||
this.hideNodeWithReachabilityAnalysis(nodeId);
|
||||
|
||||
@@ -193,6 +193,18 @@ class DNSReconApp {
|
||||
document.addEventListener('nodeSelected', (e) => {
|
||||
this.showNodeModal(e.detail.node);
|
||||
});
|
||||
|
||||
// Listen for the new iterateScan event from the graph context menu
|
||||
document.addEventListener('iterateScan', (e) => {
|
||||
if (this.isScanning) {
|
||||
this.showWarning('A scan is already in progress.');
|
||||
return;
|
||||
}
|
||||
const { nodeId } = e.detail;
|
||||
console.log(`Received iterateScan event for node: ${nodeId}`);
|
||||
this.elements.targetInput.value = nodeId;
|
||||
this.startScan(false); // Start scan in "add to graph" mode
|
||||
});
|
||||
|
||||
// Keyboard shortcuts
|
||||
document.addEventListener('keydown', (e) => {
|
||||
@@ -671,6 +683,9 @@ class DNSReconApp {
|
||||
switch (state) {
|
||||
case 'scanning':
|
||||
this.isScanning = true;
|
||||
if (this.graphManager) {
|
||||
this.graphManager.isScanning = true;
|
||||
}
|
||||
if (this.elements.startScan) {
|
||||
this.elements.startScan.disabled = true;
|
||||
this.elements.startScan.classList.add('loading');
|
||||
@@ -695,6 +710,9 @@ class DNSReconApp {
|
||||
case 'failed':
|
||||
case 'stopped':
|
||||
this.isScanning = false;
|
||||
if (this.graphManager) {
|
||||
this.graphManager.isScanning = false;
|
||||
}
|
||||
if (this.elements.startScan) {
|
||||
this.elements.startScan.disabled = !isQueueEmpty;
|
||||
this.elements.startScan.classList.remove('loading');
|
||||
|
||||
Reference in New Issue
Block a user