From c2338eefae13459563c4ac146df88da2119776a6 Mon Sep 17 00:00:00 2001 From: andersonid Date: Thu, 2 Oct 2025 19:23:51 -0300 Subject: [PATCH] fix: create individual cards per workload instead of aggregated card - Use data.categories instead of data.recommendations for individual workloads - Create separate ServiceCard for each workload with specific recommendations - Add priority scoring based on workload priority_score - Add detailed metadata: score, impact, age, VPA readiness - Generate specific titles and descriptions per workload type - Support different recommendation types: vpa_activation, resource_config, ratio_adjustment --- app/static/index.html | 145 +++++++++++++++++++++++++++--------------- 1 file changed, 92 insertions(+), 53 deletions(-) diff --git a/app/static/index.html b/app/static/index.html index e3224ac..8ce718f 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -1480,10 +1480,10 @@ const container = document.getElementById('smart-recommendations-container'); // Store recommendations globally for button functions - window.currentRecommendations = data.recommendations || []; + window.currentRecommendations = data.categories || []; window.selectedRecommendations = new Set(); - if (!data || !data.recommendations || data.recommendations.length === 0) { + if (!data || !data.categories || data.categories.length === 0) { container.innerHTML = `
@@ -1496,67 +1496,106 @@ } // Update bulk select counters - document.getElementById('total-recommendations').textContent = data.recommendations.length; - document.getElementById('page-recommendations').textContent = data.recommendations.length; + document.getElementById('total-recommendations').textContent = data.categories.length; + document.getElementById('page-recommendations').textContent = data.categories.length; - const recommendationsHtml = data.recommendations.map((rec, index) => ` -
-
-
- + const recommendationsHtml = data.categories.map((workload, index) => { + // Determine priority based on priority_score + let priority = 'low'; + if (workload.priority_score >= 6) priority = 'high'; + else if (workload.priority_score >= 4) priority = 'medium'; + + // Determine recommendation type based on resource config status + let recommendationType = 'vpa_activation'; + let title = `Activate VPA for ${workload.workload_name}`; + let description = `Enable VPA for ${workload.workload_name} to get automatic resource recommendations based on usage patterns.`; + + if (workload.resource_config_status === 'missing_requests') { + recommendationType = 'resource_config'; + title = `Configure Resources for ${workload.workload_name}`; + description = `Add missing resource requests and limits for ${workload.workload_name} to improve resource management.`; + } else if (workload.resource_config_status === 'suboptimal_ratio') { + recommendationType = 'ratio_adjustment'; + title = `Optimize Resource Ratios for ${workload.workload_name}`; + description = `Adjust CPU to memory ratio for ${workload.workload_name} to optimize resource allocation.`; + } + + return ` +
+
+
+ +
+

${title}

+
+ +
-

${rec.title}

-
- -
-
- -
-

${rec.description}

-
-
- - ${rec.workload_name || 'N/A'} +
+

${description}

+ +
+
+ + ${workload.workload_name} +
+
+ + ${workload.namespace} +
+
+ + ${recommendationType} +
+
+ ${priority.toUpperCase()} +
-
- - ${rec.namespace || 'N/A'} -
-
- - ${rec.recommendation_type} -
-
- ${rec.priority.toUpperCase()} + +
+
+ + Score: ${workload.priority_score}/10 +
+
+ + Impact: ${workload.estimated_impact} +
+
+ + Age: ${workload.age_days} days +
+
+ + VPA Ready +
-
- -
-
- `).join(''); + `; + }).join(''); container.innerHTML = recommendationsHtml; updateBulkSelectUI();