main #11

Merged
mstoeck3 merged 66 commits from main into forensic-ai 2025-08-11 12:02:56 +00:00
4 changed files with 232 additions and 159 deletions
Showing only changes of commit 6918df9348 - Show all commits

View File

@ -193,6 +193,16 @@ domains.forEach((domain: any) => {
</div> </div>
<script define:vars={{ toolsData: tools, domainAgnosticSoftware, domainAgnosticTools }}> <script define:vars={{ toolsData: tools, domainAgnosticSoftware, domainAgnosticTools }}>
// Ensure isToolHosted is available
if (!window.isToolHosted) {
window.isToolHosted = function(tool) {
return tool.projectUrl !== undefined &&
tool.projectUrl !== null &&
tool.projectUrl !== "" &&
tool.projectUrl.trim() !== "";
};
}
function getSelectedPhase() { function getSelectedPhase() {
const activePhaseChip = document.querySelector('.phase-chip.active'); const activePhaseChip = document.querySelector('.phase-chip.active');
return activePhaseChip ? activePhaseChip.getAttribute('data-phase') : ''; return activePhaseChip ? activePhaseChip.getAttribute('data-phase') : '';
@ -216,9 +226,7 @@ domains.forEach((domain: any) => {
if (selectedDomain) { if (selectedDomain) {
const domainRow = matrixTable.querySelector(`tr[data-domain="${selectedDomain}"]`); const domainRow = matrixTable.querySelector(`tr[data-domain="${selectedDomain}"]`);
if (domainRow) { if (domainRow) domainRow.classList.add('highlight-row');
domainRow.classList.add('highlight-row');
}
} }
if (selectedPhase) { if (selectedPhase) {
@ -231,9 +239,7 @@ domains.forEach((domain: any) => {
const columnIndex = phaseIndex + 1; const columnIndex = phaseIndex + 1;
matrixTable.querySelectorAll(`tr`).forEach(row => { matrixTable.querySelectorAll(`tr`).forEach(row => {
const cell = row.children[columnIndex]; const cell = row.children[columnIndex];
if (cell) { if (cell) cell.classList.add('highlight-column');
cell.classList.add('highlight-column');
}
}); });
} }
} }
@ -267,9 +273,7 @@ domains.forEach((domain: any) => {
const params = new URLSearchParams(); const params = new URLSearchParams();
params.set('tool', toolSlug); params.set('tool', toolSlug);
params.set('view', view); params.set('view', view);
if (modal) { if (modal) params.set('modal', modal);
params.set('modal', modal);
}
return `${baseUrl}?${params.toString()}`; return `${baseUrl}?${params.toString()}`;
} }
@ -301,7 +305,7 @@ domains.forEach((domain: any) => {
} }
} }
window.showShareDialog = function(shareButton) { function showShareDialog(shareButton) {
const toolName = shareButton.getAttribute('data-tool-name'); const toolName = shareButton.getAttribute('data-tool-name');
const context = shareButton.getAttribute('data-context'); const context = shareButton.getAttribute('data-context');
@ -438,17 +442,12 @@ domains.forEach((domain: any) => {
copyToClipboard(url, btn); copyToClipboard(url, btn);
}); });
}); });
};
window.toggleDomainAgnosticSection = toggleDomainAgnosticSection;
window.showToolDetails = function(toolName, modalType = 'primary') {
const tool = toolsData.find(t => t.name === toolName);
if (!tool) {
console.error('Tool not found:', toolName);
return;
} }
function showToolDetails(toolName, modalType = 'primary') {
const tool = toolsData.find(t => t.name === toolName);
if (!tool) return;
const isMethod = tool.type === 'method'; const isMethod = tool.type === 'method';
const isConcept = tool.type === 'concept'; const isConcept = tool.type === 'concept';
@ -462,10 +461,7 @@ domains.forEach((domain: any) => {
}; };
for (const [key, element] of Object.entries(elements)) { for (const [key, element] of Object.entries(elements)) {
if (!element) { if (!element) return;
console.error(`Element not found: tool-${key}-${modalType}`);
return;
}
} }
const iconHtml = tool.icon ? `<span class="mr-3 text-xl">${tool.icon}</span>` : ''; const iconHtml = tool.icon ? `<span class="mr-3 text-xl">${tool.icon}</span>` : '';
@ -709,9 +705,9 @@ domains.forEach((domain: any) => {
if (primaryActive && secondaryActive) { if (primaryActive && secondaryActive) {
document.body.classList.add('modals-side-by-side'); document.body.classList.add('modals-side-by-side');
} }
}; }
window.hideToolDetails = function(modalType = 'both') { function hideToolDetails(modalType = 'both') {
const overlay = document.getElementById('modal-overlay'); const overlay = document.getElementById('modal-overlay');
const primaryModal = document.getElementById('tool-details-primary'); const primaryModal = document.getElementById('tool-details-primary');
const secondaryModal = document.getElementById('tool-details-secondary'); const secondaryModal = document.getElementById('tool-details-secondary');
@ -763,11 +759,22 @@ domains.forEach((domain: any) => {
} else { } else {
document.body.classList.remove('modals-side-by-side'); document.body.classList.remove('modals-side-by-side');
} }
}; }
window.hideAllToolDetails = function() { function hideAllToolDetails() {
window.hideToolDetails('both'); hideToolDetails('both');
}; }
// Register all functions globally
window.showToolDetails = showToolDetails;
window.hideToolDetails = hideToolDetails;
window.hideAllToolDetails = hideAllToolDetails;
window.toggleDomainAgnosticSection = toggleDomainAgnosticSection;
window.showShareDialog = showShareDialog;
// Register matrix-prefixed versions for delegation
window.matrixShowToolDetails = showToolDetails;
window.matrixHideToolDetails = hideToolDetails;
window.addEventListener('viewChanged', (event) => { window.addEventListener('viewChanged', (event) => {
const view = event.detail; const view = event.detail;
@ -798,13 +805,6 @@ domains.forEach((domain: any) => {
const domainAgnosticPhaseIds = domainAgnosticSoftware.map(section => section.id); const domainAgnosticPhaseIds = domainAgnosticSoftware.map(section => section.id);
const isDomainAgnosticPhase = domainAgnosticPhaseIds.includes(selectedPhase); const isDomainAgnosticPhase = domainAgnosticPhaseIds.includes(selectedPhase);
domainAgnosticSoftware.forEach(sectionData => {
const section = document.getElementById(`domain-agnostic-section-${sectionData.id}`);
const container = document.getElementById(`domain-agnostic-tools-${sectionData.id}`);
if (!section || !container) return;
});
if (!isDomainAgnosticPhase) { if (!isDomainAgnosticPhase) {
document.getElementById('dfir-matrix-section').style.display = 'block'; document.getElementById('dfir-matrix-section').style.display = 'block';
@ -813,9 +813,7 @@ domains.forEach((domain: any) => {
}); });
filtered.forEach(tool => { filtered.forEach(tool => {
if (tool.type === 'concept') { if (tool.type === 'concept') return;
return;
}
const isMethod = tool.type === 'method'; const isMethod = tool.type === 'method';
const hasValidProjectUrl = window.isToolHosted(tool); const hasValidProjectUrl = window.isToolHosted(tool);

3
src/env.d.ts vendored
View File

@ -11,6 +11,9 @@ declare global {
showToolDetails: (toolName: string, modalType?: string) => void; showToolDetails: (toolName: string, modalType?: string) => void;
hideToolDetails: (modalType?: string) => void; hideToolDetails: (modalType?: string) => void;
hideAllToolDetails: () => void; hideAllToolDetails: () => void;
matrixShowToolDetails?: (toolName: string, modalType?: string) => void;
matrixHideToolDetails?: (modalType?: string) => void;
toggleKbEntry: (entryId: string) => void; toggleKbEntry: (entryId: string) => void;
toggleDomainAgnosticSection: (sectionId: string) => void; toggleDomainAgnosticSection: (sectionId: string) => void;
restoreAIResults?: () => void; restoreAIResults?: () => void;

View File

@ -32,12 +32,33 @@ const { title, description = 'ForensicPathways - A comprehensive directory of di
(window as any).createToolSlug = createToolSlug; (window as any).createToolSlug = createToolSlug;
(window as any).findToolByIdentifier = findToolByIdentifier; (window as any).findToolByIdentifier = findToolByIdentifier;
(window as any).isToolHosted = isToolHosted; (window as any).isToolHosted = isToolHosted;
console.log('[UTILS] Utility functions loaded successfully');
} catch (error) { } catch (error) {
console.error('Failed to load utility functions:', error); console.error('Failed to load utility functions:', error);
// Provide fallback implementations
(window as any).createToolSlug = (toolName: string) => { (window as any).createToolSlug = (toolName: string) => {
if (!toolName || typeof toolName !== 'string') return ''; if (!toolName || typeof toolName !== 'string') return '';
return toolName.toLowerCase().replace(/[^a-z0-9\s-]/g, '').replace(/\s+/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, ''); return toolName.toLowerCase().replace(/[^a-z0-9\s-]/g, '').replace(/\s+/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '');
}; };
(window as any).findToolByIdentifier = (tools: any[], identifier: string) => {
if (!identifier || !Array.isArray(tools)) return undefined;
return tools.find((tool: any) =>
tool.name === identifier ||
(window as any).createToolSlug(tool.name) === identifier.toLowerCase()
);
};
(window as any).isToolHosted = (tool: any) => {
return tool.projectUrl !== undefined &&
tool.projectUrl !== null &&
tool.projectUrl !== "" &&
tool.projectUrl.trim() !== "";
};
console.log('[UTILS] Fallback utility functions registered');
} }
} }
@ -97,8 +118,9 @@ const { title, description = 'ForensicPathways - A comprehensive directory of di
(window as any).scrollToElementBySelector = scrollToElementBySelector; (window as any).scrollToElementBySelector = scrollToElementBySelector;
(window as any).prioritizeSearchResults = prioritizeSearchResults; (window as any).prioritizeSearchResults = prioritizeSearchResults;
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', async () => {
loadUtilityFunctions(); // CRITICAL: Load utility functions FIRST before any URL handling
await loadUtilityFunctions();
const THEME_KEY = 'dfir-theme'; const THEME_KEY = 'dfir-theme';
@ -151,6 +173,44 @@ const { title, description = 'ForensicPathways - A comprehensive directory of di
getStoredTheme getStoredTheme
}; };
(window as any).showToolDetails = function(toolName: string, modalType: string = 'primary') {
let attempts = 0;
const maxAttempts = 50;
const tryDelegate = () => {
const matrixShowToolDetails = (window as any).matrixShowToolDetails;
if (matrixShowToolDetails && typeof matrixShowToolDetails === 'function') {
return matrixShowToolDetails(toolName, modalType);
}
const directShowToolDetails = (window as any).directShowToolDetails;
if (directShowToolDetails && typeof directShowToolDetails === 'function') {
return directShowToolDetails(toolName, modalType);
}
attempts++;
if (attempts < maxAttempts) {
setTimeout(tryDelegate, 100);
} else {
}
};
tryDelegate();
};
(window as any).hideToolDetails = function(modalType: string = 'both') {
const matrixHideToolDetails = (window as any).matrixHideToolDetails;
if (matrixHideToolDetails && typeof matrixHideToolDetails === 'function') {
return matrixHideToolDetails(modalType);
}
};
(window as any).hideAllToolDetails = function() {
(window as any).hideToolDetails('both');
};
async function checkClientAuth(context = 'general') { async function checkClientAuth(context = 'general') {
try { try {
const response = await fetch('/api/auth/status'); const response = await fetch('/api/auth/status');

View File

@ -510,6 +510,8 @@ if (aiAuthRequired) {
}; };
function handleSharedURL() { function handleSharedURL() {
console.log('[SHARE] Handling shared URL:', window.location.search);
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
const toolParam = urlParams.get('tool'); const toolParam = urlParams.get('tool');
const viewParam = urlParams.get('view'); const viewParam = urlParams.get('view');
@ -522,12 +524,18 @@ if (aiAuthRequired) {
return; return;
} }
const tool = window.findToolByIdentifier(window.toolsData, toolParam); if (!window.findToolByIdentifier) {
if (!tool) { console.error('[SHARE] findToolByIdentifier not available, retrying...');
console.warn('Shared tool not found:', toolParam); setTimeout(() => handleSharedURL(), 200);
return; return;
} }
const tool = window.findToolByIdentifier(window.toolsData, toolParam);
if (!tool) {
return;
}
const cleanUrl = window.location.protocol + "//" + window.location.host + window.location.pathname; const cleanUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
window.history.replaceState({}, document.title, cleanUrl); window.history.replaceState({}, document.title, cleanUrl);
@ -549,7 +557,7 @@ if (aiAuthRequired) {
default: default:
window.navigateToGrid(tool.name); window.navigateToGrid(tool.name);
} }
}, 100); }, 300);
} }
window.addEventListener('toolsFiltered', (event) => { window.addEventListener('toolsFiltered', (event) => {
@ -678,7 +686,11 @@ if (aiAuthRequired) {
window.switchToAIView = () => switchToView('ai'); window.switchToAIView = () => switchToView('ai');
window.switchToView = switchToView; window.switchToView = switchToView;
// CRITICAL: Handle shared URLs AFTER everything is set up
// Increased timeout to ensure all components and utility functions are loaded
setTimeout(() => {
handleSharedURL(); handleSharedURL();
}, 1000);
}); });
</script> </script>
</BaseLayout> </BaseLayout>