mirror of
https://github.com/thecyberlearn/quantum-ai-v3.git
synced 2026-08-18 21:52:57 +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
|
// Update wallet balance if provided
|
||||||
if (result.wallet_balance !== undefined) {
|
if (result.wallet_balance !== undefined) {
|
||||||
updateWalletBalance(result.wallet_balance);
|
AgentUtils.updateWalletBalance(result.wallet_balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle errors
|
// 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() {
|
function copyAnalysisReport() {
|
||||||
const reportText = AgentUtils.generateTextForExport('analysisContent');
|
const reportText = AgentUtils.generateTextForExport('analysisContent');
|
||||||
|
|||||||
@ -312,7 +312,7 @@
|
|||||||
const message = input.value.trim();
|
const message = input.value.trim();
|
||||||
|
|
||||||
if (!message) {
|
if (!message) {
|
||||||
showToast('Please enter a message', 'error');
|
AgentUtils.showToast('Please enter a message', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,14 +352,14 @@
|
|||||||
// Check if report button should be enabled
|
// Check if report button should be enabled
|
||||||
checkReportReadiness();
|
checkReportReadiness();
|
||||||
} else {
|
} else {
|
||||||
showToast(data.error || 'Failed to send message', 'error');
|
AgentUtils.showToast(data.error || 'Failed to send message', 'error');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
// Hide typing indicator on error
|
// Hide typing indicator on error
|
||||||
hideTypingIndicator();
|
hideTypingIndicator();
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
showToast('Network error occurred', 'error');
|
AgentUtils.showToast('Network error occurred', 'error');
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
isProcessing = false;
|
isProcessing = false;
|
||||||
@ -516,12 +516,12 @@
|
|||||||
if (isProcessing) return;
|
if (isProcessing) return;
|
||||||
|
|
||||||
if (!currentSessionId) {
|
if (!currentSessionId) {
|
||||||
showToast('Please start a chat session first', 'error');
|
AgentUtils.showToast('Please start a chat session first', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messageCount < 2) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,16 +560,16 @@
|
|||||||
displayReport(data.report);
|
displayReport(data.report);
|
||||||
|
|
||||||
// Update wallet balance
|
// 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 {
|
} else {
|
||||||
showToast(data.error || 'Failed to generate report', 'error');
|
AgentUtils.showToast(data.error || 'Failed to generate report', 'error');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
showToast('Network error occurred', 'error');
|
AgentUtils.showToast('Network error occurred', 'error');
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
isProcessing = false;
|
isProcessing = false;
|
||||||
@ -618,54 +618,16 @@
|
|||||||
return formatted;
|
return formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateWalletBalance(newBalance) {
|
|
||||||
document.querySelectorAll('[data-wallet-balance]').forEach(element => {
|
|
||||||
element.textContent = `${newBalance.toFixed(2)} AED`;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyReport() {
|
function copyReport() {
|
||||||
const reportElement = document.getElementById('reportContent');
|
const reportText = AgentUtils.generateTextForExport('reportContent');
|
||||||
const reportText = reportElement.innerText || reportElement.textContent;
|
AgentUtils.copyToClipboard(reportText, '📋 Report copied to clipboard!');
|
||||||
navigator.clipboard.writeText(reportText).then(() => {
|
|
||||||
showToast('📋 Report copied to clipboard!', 'success');
|
|
||||||
}).catch(() => {
|
|
||||||
showToast('Failed to copy report', 'error');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadReport() {
|
function downloadReport() {
|
||||||
const reportElement = document.getElementById('reportContent');
|
const reportText = AgentUtils.generateTextForExport('reportContent');
|
||||||
const reportText = reportElement.innerText || reportElement.textContent;
|
AgentUtils.downloadAsFile(reportText, `five-whys-analysis-${Date.now()}.txt`, '💾 Report downloaded!');
|
||||||
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');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -285,14 +285,6 @@
|
|||||||
// Initialize on page load
|
// Initialize on page load
|
||||||
document.addEventListener('DOMContentLoaded', initializeFormEnhancements);
|
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
|
// Display job posting results with professional formatting
|
||||||
@ -307,7 +299,7 @@
|
|||||||
|
|
||||||
// Update wallet balance if provided
|
// Update wallet balance if provided
|
||||||
if (result.wallet_balance !== undefined) {
|
if (result.wallet_balance !== undefined) {
|
||||||
updateWalletBalance(result.wallet_balance);
|
AgentUtils.updateWalletBalance(result.wallet_balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle errors
|
// Handle errors
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user