import { locateNode } from "./node_explorer.js"; function getRiskColor( risk ) { if ( risk === "High" ) { return "#ff4444"; } if ( risk === "Medium" ) { return "#ffaa00"; } return "#00cc66"; } export function buildWorkflowAdvisor( advisorData ) { const wrapper = document.createElement( "div" ); wrapper.style.padding = "12px"; const score = advisorData?.advisor_score ?? 0; const grade = advisorData?.workflow_grade ?? "N/A"; const status = advisorData?.workflow_status ?? "Unknown"; const riskAssessment = advisorData?.risk_assessment ?? {}; const safeRemovalCandidates = advisorData?.safe_removal_candidates ?? 0; let scoreColor = "#00cc66"; if ( score < 75 ) { scoreColor = "#ffaa00"; } if ( score < 60 ) { scoreColor = "#ff4444"; } wrapper.innerHTML = `
High Risk Nodes: ${riskAssessment.high_risk_nodes ?? 0}
Medium Risk Nodes: ${riskAssessment.medium_risk_nodes ?? 0}
Safe Removal Candidates: ${riskAssessment.safe_removal_candidates ?? 0}
Branch Complexity: ${riskAssessment.branch_complexity ?? "Unknown"}
Dependency Complexity: ${riskAssessment.dependency_complexity ?? "Unknown"}
`; wrapper.appendChild( riskSection ); const recommendationSection = document.createElement( "div" ); recommendationSection.style.background = "#252526"; recommendationSection.style.border = "1px solid #444"; recommendationSection.style.borderRadius = "10px"; recommendationSection.style.padding = "15px"; recommendationSection.style.marginBottom = "20px"; recommendationSection.innerHTML = `No recommendations available.
`; } else { recommendations.forEach( recommendation => { const card = document.createElement( "div" ); card.style.border = `1px solid ${ getRiskColor( recommendation.severity ) }`; card.style.borderRadius = "8px"; card.style.padding = "12px"; card.style.marginBottom = "12px"; let impactHtml = ""; if ( recommendation.impact ) { impactHtml = `Dependencies: ${recommendation.impact.dependencies}
Dependents: ${recommendation.impact.dependents}
Affected Branches: ${recommendation.impact.affected_branches}
Risk: ${recommendation.impact.risk}
Safe To Remove: ${ recommendation .impact .safe_to_remove ? "Yes" : "No" }
`; } card.innerHTML = `Severity: ${recommendation.severity}
Node: ${recommendation.node_type}
Description: ${recommendation.description}
Recommended Action: ${recommendation.recommended_action}
${impactHtml} `; if ( recommendation.node_id !== undefined && recommendation.node_id !== null ) { const button = document.createElement( "button" ); button.innerText = "Locate Node"; button.onclick = () => { locateNode( recommendation.node_id ); }; card.appendChild( button ); } recommendationSection .appendChild( card ); } ); } wrapper.appendChild( recommendationSection ); const impactSection = document.createElement( "div" ); impactSection.style.background = "#252526"; impactSection.style.border = "1px solid #444"; impactSection.style.borderRadius = "10px"; impactSection.style.padding = "15px"; impactSection.style.marginBottom = "20px"; impactSection.innerHTML = `Node ID: ${node.node_id}
Dependencies: ${node.dependencies}
Dependents: ${node.dependents}
Affected Branches: ${node.affected_branches}
Risk: ${node.risk}
Safe To Remove: ${ node.safe_to_remove ? "Yes" : "No" }
`; const button = document.createElement( "button" ); button.innerText = "Locate Node"; button.onclick = () => { locateNode( node.node_id ); }; card.appendChild( button ); impactSection.appendChild( card ); } ); wrapper.appendChild( impactSection ); const insightSection = document.createElement( "div" ); insightSection.style.background = "#252526"; insightSection.style.border = "1px solid #444"; insightSection.style.borderRadius = "10px"; insightSection.style.padding = "15px"; insightSection.innerHTML = `