min pivot distance only applies to L1 pivots ,

charts minimize addons,
delete buttons WIP
This commit is contained in:
Dobromir Popov
2025-10-24 13:49:16 +03:00
parent 42bf91b735
commit b970c4ca4d
8 changed files with 532 additions and 169 deletions

View File

@@ -299,58 +299,15 @@
toast.addEventListener('hidden.bs.toast', () => toast.remove());
}
function setupGlobalFunctions() {
// Make functions globally available
window.showError = showError;
window.showSuccess = showSuccess;
window.renderAnnotationsList = renderAnnotationsList;
window.deleteAnnotation = deleteAnnotation;
window.highlightAnnotation = highlightAnnotation;
// Verify functions are set
console.log('Global functions setup complete:');
console.log(' - window.deleteAnnotation:', typeof window.deleteAnnotation);
console.log(' - window.renderAnnotationsList:', typeof window.renderAnnotationsList);
console.log(' - window.showError:', typeof window.showError);
console.log(' - window.showSuccess:', typeof window.showSuccess);
}
function renderAnnotationsList(annotations) {
const listElement = document.getElementById('annotations-list');
if (!listElement) return;
listElement.innerHTML = '';
annotations.forEach(annotation => {
const item = document.createElement('div');
item.className = 'annotation-item mb-2 p-2 border rounded';
item.innerHTML = `
<div class="d-flex justify-content-between align-items-center">
<div>
<small class="text-muted">${annotation.timeframe}</small>
<div class="fw-bold ${annotation.profit_loss_pct >= 0 ? 'text-success' : 'text-danger'}">
${annotation.direction} ${annotation.profit_loss_pct >= 0 ? '+' : ''}${annotation.profit_loss_pct.toFixed(2)}%
</div>
<small class="text-muted">
${new Date(annotation.entry.timestamp).toLocaleString()}
</small>
</div>
<div class="btn-group btn-group-sm">
<button class="btn btn-outline-primary btn-sm" onclick="highlightAnnotation('${annotation.annotation_id}')" title="Highlight">
<i class="fas fa-eye"></i>
</button>
<button class="btn btn-outline-danger btn-sm" onclick="deleteAnnotation('${annotation.annotation_id}')" title="Delete">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
`;
listElement.appendChild(item);
});
}
function deleteAnnotation(annotationId) {
console.log('deleteAnnotation called with ID:', annotationId);
if (!window.appState || !window.appState.annotations) {
console.error('appState not initialized');
return;
}
console.log('Current annotations:', window.appState.annotations.map(a => a.annotation_id));
if (!confirm('Delete this annotation?')) {
console.log('Delete cancelled by user');
@@ -406,9 +363,84 @@
}
function highlightAnnotation(annotationId) {
if (window.appState.chartManager) {
if (window.appState && window.appState.chartManager) {
window.appState.chartManager.highlightAnnotation(annotationId);
}
}
function setupGlobalFunctions() {
// Make functions globally available
window.showError = showError;
window.showSuccess = showSuccess;
window.renderAnnotationsList = renderAnnotationsList;
window.deleteAnnotation = deleteAnnotation;
window.highlightAnnotation = highlightAnnotation;
// Verify functions are set
console.log('Global functions setup complete:');
console.log(' - window.deleteAnnotation:', typeof window.deleteAnnotation);
console.log(' - window.renderAnnotationsList:', typeof window.renderAnnotationsList);
console.log(' - window.showError:', typeof window.showError);
console.log(' - window.showSuccess:', typeof window.showSuccess);
}
function renderAnnotationsList(annotations) {
const listElement = document.getElementById('annotations-list');
if (!listElement) return;
listElement.innerHTML = '';
annotations.forEach(annotation => {
const item = document.createElement('div');
item.className = 'annotation-item mb-2 p-2 border rounded';
item.innerHTML = `
<div class="d-flex justify-content-between align-items-center">
<div>
<small class="text-muted">${annotation.timeframe}</small>
<div class="fw-bold ${annotation.profit_loss_pct >= 0 ? 'text-success' : 'text-danger'}">
${annotation.direction} ${annotation.profit_loss_pct >= 0 ? '+' : ''}${annotation.profit_loss_pct.toFixed(2)}%
</div>
<small class="text-muted">
${new Date(annotation.entry.timestamp).toLocaleString()}
</small>
</div>
<div class="btn-group btn-group-sm">
<button class="btn btn-outline-primary btn-sm highlight-btn" title="Highlight">
<i class="fas fa-eye"></i>
</button>
<button class="btn btn-outline-danger btn-sm delete-btn" title="Delete">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
`;
// Add event listeners
item.querySelector('.highlight-btn').addEventListener('click', function(e) {
e.stopPropagation();
console.log('Highlight button clicked for:', annotation.annotation_id);
if (typeof window.highlightAnnotation === 'function') {
window.highlightAnnotation(annotation.annotation_id);
}
});
item.querySelector('.delete-btn').addEventListener('click', function(e) {
e.stopPropagation();
console.log('Delete button clicked for:', annotation.annotation_id);
console.log('window.deleteAnnotation type:', typeof window.deleteAnnotation);
if (typeof window.deleteAnnotation === 'function') {
console.log('Calling window.deleteAnnotation...');
window.deleteAnnotation(annotation.annotation_id);
} else {
console.error('window.deleteAnnotation is not a function:', typeof window.deleteAnnotation);
alert('Delete function not available. Please refresh the page.');
}
});
listElement.appendChild(item);
});
}
</script>
{% endblock %}