mirror of
https://github.com/thecyberlearn/quantum-ai-v3.git
synced 2026-08-18 17:12:58 +00:00
Standardize AgentUtils function calls across all agents
- Remove duplicate updateWalletBalance and showToast functions from individual agents - Standardize all agents to use AgentUtils.functionName() pattern consistently - Update Five Whys Analyzer to use shared utility functions - Maintain agent-specific functions only where necessary for unique workflows - Ensure consistent function call patterns across Data Analyzer, Job Posting Generator, and Five Whys Analyzer 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f40450851b
commit
2e25b96807
@ -688,7 +688,7 @@
|
||||
|
||||
// Update wallet balance if provided
|
||||
if (result.wallet_balance !== undefined) {
|
||||
updateWalletBalance(result.wallet_balance);
|
||||
AgentUtils.updateWalletBalance(result.wallet_balance);
|
||||
}
|
||||
|
||||
// Handle errors
|
||||
@ -844,14 +844,6 @@
|
||||
}
|
||||
|
||||
|
||||
function updateWalletBalance(newBalance) {
|
||||
// Update wallet balance display
|
||||
const balanceElement = document.getElementById('walletBalance');
|
||||
if (balanceElement) {
|
||||
balanceElement.textContent = `${newBalance.toFixed(2)} AED`;
|
||||
}
|
||||
window.currentWalletBalance = newBalance;
|
||||
}
|
||||
|
||||
function copyAnalysisReport() {
|
||||
const reportText = AgentUtils.generateTextForExport('analysisContent');
|
||||
|
||||
@ -312,7 +312,7 @@
|
||||
const message = input.value.trim();
|
||||
|
||||
if (!message) {
|
||||
showToast('Please enter a message', 'error');
|
||||
AgentUtils.showToast('Please enter a message', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -352,14 +352,14 @@
|
||||
// Check if report button should be enabled
|
||||
checkReportReadiness();
|
||||
} else {
|
||||
showToast(data.error || 'Failed to send message', 'error');
|
||||
AgentUtils.showToast(data.error || 'Failed to send message', 'error');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
// Hide typing indicator on error
|
||||
hideTypingIndicator();
|
||||
console.error('Error:', error);
|
||||
showToast('Network error occurred', 'error');
|
||||
AgentUtils.showToast('Network error occurred', 'error');
|
||||
})
|
||||
.finally(() => {
|
||||
isProcessing = false;
|
||||
@ -516,12 +516,12 @@
|
||||
if (isProcessing) return;
|
||||
|
||||
if (!currentSessionId) {
|
||||
showToast('Please start a chat session first', 'error');
|
||||
AgentUtils.showToast('Please start a chat session first', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
if (messageCount < 2) {
|
||||
showToast('Please ask at least 2 questions before generating a report', 'error');
|
||||
AgentUtils.showToast('Please ask at least 2 questions before generating a report', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -560,16 +560,16 @@
|
||||
displayReport(data.report);
|
||||
|
||||
// Update wallet balance
|
||||
updateWalletBalance(data.wallet_balance);
|
||||
AgentUtils.updateWalletBalance(data.wallet_balance);
|
||||
|
||||
showToast('✅ Report generated and payment processed!', 'success');
|
||||
AgentUtils.showToast('✅ Report generated and payment processed!', 'success');
|
||||
} else {
|
||||
showToast(data.error || 'Failed to generate report', 'error');
|
||||
AgentUtils.showToast(data.error || 'Failed to generate report', 'error');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
showToast('Network error occurred', 'error');
|
||||
AgentUtils.showToast('Network error occurred', 'error');
|
||||
})
|
||||
.finally(() => {
|
||||
isProcessing = false;
|
||||
@ -618,54 +618,16 @@
|
||||
return formatted;
|
||||
}
|
||||
|
||||
function updateWalletBalance(newBalance) {
|
||||
document.querySelectorAll('[data-wallet-balance]').forEach(element => {
|
||||
element.textContent = `${newBalance.toFixed(2)} AED`;
|
||||
});
|
||||
}
|
||||
|
||||
function copyReport() {
|
||||
const reportElement = document.getElementById('reportContent');
|
||||
const reportText = reportElement.innerText || reportElement.textContent;
|
||||
navigator.clipboard.writeText(reportText).then(() => {
|
||||
showToast('📋 Report copied to clipboard!', 'success');
|
||||
}).catch(() => {
|
||||
showToast('Failed to copy report', 'error');
|
||||
});
|
||||
const reportText = AgentUtils.generateTextForExport('reportContent');
|
||||
AgentUtils.copyToClipboard(reportText, '📋 Report copied to clipboard!');
|
||||
}
|
||||
|
||||
function downloadReport() {
|
||||
const reportElement = document.getElementById('reportContent');
|
||||
const reportText = reportElement.innerText || reportElement.textContent;
|
||||
const blob = new Blob([reportText], { type: 'text/plain' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `five-whys-analysis-${Date.now()}.txt`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
showToast('💾 Report downloaded!', 'success');
|
||||
const reportText = AgentUtils.generateTextForExport('reportContent');
|
||||
AgentUtils.downloadAsFile(reportText, `five-whys-analysis-${Date.now()}.txt`, '💾 Report downloaded!');
|
||||
}
|
||||
|
||||
function showToast(message, type = 'info') {
|
||||
const toast = document.createElement('div');
|
||||
toast.style.cssText = `
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
padding: 12px 20px;
|
||||
border-radius: 8px;
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
z-index: 1000;
|
||||
${type === 'success' ? 'background: #10b981;' : 'background: #ef4444;'}
|
||||
`;
|
||||
toast.textContent = message;
|
||||
document.body.appendChild(toast);
|
||||
|
||||
setTimeout(() => {
|
||||
toast.remove();
|
||||
}, 3000);
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
@ -285,14 +285,6 @@
|
||||
// Initialize on page load
|
||||
document.addEventListener('DOMContentLoaded', initializeFormEnhancements);
|
||||
|
||||
// Update wallet balance display
|
||||
function updateWalletBalance(newBalance) {
|
||||
const balanceElements = document.querySelectorAll('[data-wallet-balance]');
|
||||
balanceElements.forEach(element => {
|
||||
element.textContent = `${newBalance.toFixed(2)} AED`;
|
||||
});
|
||||
window.currentWalletBalance = newBalance;
|
||||
}
|
||||
|
||||
|
||||
// Display job posting results with professional formatting
|
||||
@ -307,7 +299,7 @@
|
||||
|
||||
// Update wallet balance if provided
|
||||
if (result.wallet_balance !== undefined) {
|
||||
updateWalletBalance(result.wallet_balance);
|
||||
AgentUtils.updateWalletBalance(result.wallet_balance);
|
||||
}
|
||||
|
||||
// Handle errors
|
||||
|
||||
Loading…
Reference in New Issue
Block a user