This commit is contained in:
overcuriousity
2025-08-07 09:13:04 +02:00
parent 7f5fdef445
commit 5d05c62a55
9 changed files with 19 additions and 545 deletions

View File

@@ -217,12 +217,7 @@ const domainAgnosticSoftware = data['domain-agnostic-software'] || [];
<script type="module" define:vars={{ tools, phases, domainAgnosticSoftware }}>
// ===================================================================
// CONSOLIDATED UTILITIES
// ===================================================================
const Utils = {
// Phase configuration for audit trail
phaseConfig: {
'initialization': { icon: '🚀', displayName: 'Initialisierung' },
'retrieval': { icon: '🔍', displayName: 'Datensuche' },
@@ -232,7 +227,6 @@ const Utils = {
'completion': { icon: '✅', displayName: 'Finalisierung' }
},
// Action translations for display
actionTranslations: {
'pipeline-start': 'Analyse gestartet',
'embeddings-search': 'Ähnliche Tools gesucht',
@@ -316,7 +310,6 @@ const Utils = {
return String(data);
},
// DOM utilities
showElement(element) {
if (element) {
element.style.display = 'block';
@@ -332,10 +325,6 @@ const Utils = {
}
};
// ===================================================================
// AUDIT TRAIL PROCESSOR
// ===================================================================
class AuditTrailProcessor {
static processAuditTrail(rawAuditTrail) {
if (!rawAuditTrail || !Array.isArray(rawAuditTrail) || rawAuditTrail.length === 0) {
@@ -355,7 +344,6 @@ class AuditTrailProcessor {
const highConfidenceSteps = rawAuditTrail.filter(entry => (entry.confidence || 0) >= 80).length;
const lowConfidenceSteps = rawAuditTrail.filter(entry => (entry.confidence || 0) < 60).length;
// Group entries by phase
const groupedEntries = rawAuditTrail.reduce((groups, entry) => {
const phase = entry.phase || 'unknown';
if (!groups[phase]) groups[phase] = [];
@@ -363,7 +351,6 @@ class AuditTrailProcessor {
return groups;
}, {});
// Process phases
const phases = Object.entries(groupedEntries).map(([phase, entries]) => {
const phaseConfig = Utils.phaseConfig[phase] || { icon: '📋', displayName: phase };
const validEntries = entries.filter(entry => entry && typeof entry === 'object');
@@ -463,10 +450,6 @@ class AuditTrailProcessor {
}
}
// ===================================================================
// AUDIT TRAIL RENDERER
// ===================================================================
class AuditTrailRenderer {
constructor(containerId, options = {}) {
this.containerId = containerId;
@@ -740,7 +723,6 @@ class AuditTrailRenderer {
}
attachEventHandlers() {
// Handle collapsible header
if (this.options.collapsible) {
const header = document.querySelector(`[data-target="${this.componentId}-details"]`);
const details = document.getElementById(`${this.componentId}-details`);
@@ -755,7 +737,6 @@ class AuditTrailRenderer {
}
}
// Handle technical details toggle
const technicalBtn = document.querySelector(`[data-target="${this.componentId}-technical"]`);
const technicalDetails = document.getElementById(`${this.componentId}-technical`);
@@ -771,10 +752,6 @@ class AuditTrailRenderer {
}
}
// ===================================================================
// MAIN AI QUERY INTERFACE
// ===================================================================
class AIQueryInterface {
constructor() {
this.currentMode = 'workflow';
@@ -1251,7 +1228,6 @@ class AIQueryInterface {
this.showResults();
// Render audit trail after DOM is ready
setTimeout(() => {
try {
this.renderAuditTrail(recommendation.auditTrail);
@@ -1764,7 +1740,6 @@ class AIQueryInterface {
return texts[score] || 'GEEIGNET';
}
// Display state management
showLoading() {
Utils.showElement(this.elements.loading);
}
@@ -1791,7 +1766,6 @@ class AIQueryInterface {
Utils.hideElement(this.elements.error);
}
// Public method for restoring AI results after navigation
restoreAIResults() {
if (this.currentRecommendation && this.elements.results) {
this.showResults();
@@ -1813,14 +1787,9 @@ class AIQueryInterface {
}
}
// ===================================================================
// INITIALIZATION
// ===================================================================
document.addEventListener('DOMContentLoaded', () => {
const aiInterface = new AIQueryInterface();
// Global functions for external access
window.restoreAIResults = () => aiInterface.restoreAIResults();
window.isToolHosted = window.isToolHosted || isToolHosted;

View File

@@ -354,7 +354,6 @@ const sortedTags = Object.entries(tagFrequency)
let semanticSearchAvailable = false;
let lastSemanticResults = null;
// Check embeddings availability
async function checkEmbeddingsAvailability() {
try {
const res = await fetch('/api/ai/embeddings-status');
@@ -363,15 +362,13 @@ const sortedTags = Object.entries(tagFrequency)
if (semanticSearchAvailable) {
elements.semanticContainer.classList.remove('hidden');
elements.semanticCheckbox.disabled = false; // 👈 re-enable
elements.semanticCheckbox.disabled = false;
}
} catch (err) {
console.error('[EMBEDDINGS] Status check failed:', err);
// leave the checkbox disabled
}
}
// Semantic search function
async function performSemanticSearch(query) {
if (!semanticSearchAvailable || !query.trim()) {
return null;
@@ -576,7 +573,6 @@ const sortedTags = Object.entries(tagFrequency)
}
}
// FIXED: Consolidated filtering logic with semantic search support
async function filterTools() {
const searchTerm = elements.searchInput.value.trim().toLowerCase();
const selectedDomain = elements.domainSelect.value;
@@ -594,7 +590,6 @@ const sortedTags = Object.entries(tagFrequency)
let filteredTools = window.toolsData;
let semanticResults = null;
// CONSOLIDATED: Use semantic search if enabled and search term exists
if (semanticSearchEnabled && semanticSearchAvailable && searchTerm) {
semanticResults = await performSemanticSearch(searchTerm);
lastSemanticResults = semanticResults;
@@ -605,7 +600,6 @@ const sortedTags = Object.entries(tagFrequency)
} else {
lastSemanticResults = null;
// Traditional text-based search
if (searchTerm) {
filteredTools = window.toolsData.filter(tool =>
tool.name.toLowerCase().includes(searchTerm) ||
@@ -615,7 +609,6 @@ const sortedTags = Object.entries(tagFrequency)
}
}
// Apply additional filters to the results
filteredTools = filteredTools.filter(tool => {
if (selectedDomain && !(tool.domains || []).includes(selectedDomain)) {
return false;
@@ -666,9 +659,8 @@ const sortedTags = Object.entries(tagFrequency)
);
}
/* existing code continues */
const finalResults = semanticSearchEnabled && lastSemanticResults
? filteredTools // now properly re-sorted
? filteredTools
: (searchTerm && window.prioritizeSearchResults
? window.prioritizeSearchResults(filteredTools, searchTerm)
: filteredTools);
@@ -726,7 +718,6 @@ const sortedTags = Object.entries(tagFrequency)
filterTagCloud();
}
// Event listeners
elements.searchInput.addEventListener('input', (e) => {
const hasValue = e.target.value.length > 0;
elements.clearSearch.classList.toggle('hidden', !hasValue);
@@ -741,7 +732,6 @@ const sortedTags = Object.entries(tagFrequency)
filterTools();
});
// Semantic search checkbox handler
if (elements.semanticCheckbox) {
elements.semanticCheckbox.addEventListener('change', (e) => {
semanticSearchEnabled = e.target.checked;
@@ -812,7 +802,6 @@ const sortedTags = Object.entries(tagFrequency)
window.clearTagFilters = resetTags;
window.clearAllFilters = resetAllFilters;
// Initialize
checkEmbeddingsAvailability();
initializeCollapsible();
initTagCloud();