feat&fix: add score display banner and update task status with animation
This commit is contained in:
@@ -42,6 +42,15 @@ function fetchTasksForRefresh() {
|
||||
|
||||
// New function: only update task status, do not re-render the entire list
|
||||
function updateTaskStatus(data) {
|
||||
// Add pulse animation to score banner when refreshing
|
||||
const scoreBanner = document.querySelector('.score-banner');
|
||||
if (scoreBanner) {
|
||||
scoreBanner.classList.add('refreshing');
|
||||
setTimeout(() => {
|
||||
scoreBanner.classList.remove('refreshing');
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// Update the status display of each task
|
||||
Object.entries(data).forEach(([taskType, tasks]) => {
|
||||
tasks.forEach(task => {
|
||||
@@ -167,6 +176,7 @@ function updateStatistics(data) {
|
||||
let activeTasks = 0;
|
||||
let completedTasks = 0;
|
||||
let errorTasks = 0;
|
||||
let totalScore = 0;
|
||||
|
||||
Object.entries(data).forEach(([taskType, tasks]) => {
|
||||
totalTasks += tasks.length;
|
||||
@@ -175,6 +185,17 @@ function updateStatistics(data) {
|
||||
activeTasks++;
|
||||
} else if (task.status.status === 'Done' || task.status.status === 'Done (Message Exit)' || task.status.status === 'Done (Max Steps)') {
|
||||
completedTasks++;
|
||||
// Calculate score if task is completed
|
||||
if (task.status.result) {
|
||||
try {
|
||||
const score = parseFloat(task.status.result);
|
||||
if (!isNaN(score) && score >= 0 && score <= 1) {
|
||||
totalScore += score;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`Could not parse score for task: ${task.id}`);
|
||||
}
|
||||
}
|
||||
} else if (task.status.status === 'Error') {
|
||||
errorTasks++;
|
||||
}
|
||||
@@ -186,6 +207,15 @@ function updateStatistics(data) {
|
||||
document.getElementById('completed-tasks').textContent = completedTasks;
|
||||
document.getElementById('error-tasks').textContent = errorTasks;
|
||||
|
||||
// Update score display with formatted score
|
||||
const scoreDisplay = document.getElementById('score-display');
|
||||
if (completedTasks > 0) {
|
||||
const scoreFormatted = totalScore.toFixed(2);
|
||||
scoreDisplay.innerHTML = `<span>${scoreFormatted}</span> / <span>${completedTasks}</span>`;
|
||||
} else {
|
||||
scoreDisplay.innerHTML = '<span>0.00</span> / <span>0</span>';
|
||||
}
|
||||
|
||||
// Highlight the currently selected statistics card
|
||||
document.querySelectorAll('.stat-card').forEach(card => card.classList.remove('selected'));
|
||||
if (currentFilter === 'all') {
|
||||
|
||||
Reference in New Issue
Block a user