stored
This commit is contained in:
@@ -4,9 +4,14 @@
|
||||
<i class="fas fa-tags"></i>
|
||||
Annotations
|
||||
</h6>
|
||||
<button class="btn btn-sm btn-outline-light" id="export-annotations-btn" title="Export">
|
||||
<i class="fas fa-download"></i>
|
||||
</button>
|
||||
<div class="btn-group btn-group-sm">
|
||||
<button class="btn btn-sm btn-outline-light" id="export-annotations-btn" title="Export">
|
||||
<i class="fas fa-download"></i>
|
||||
</button>
|
||||
<button class="btn btn-sm btn-outline-danger" id="clear-all-annotations-btn" title="Clear All">
|
||||
<i class="fas fa-trash-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-2">
|
||||
<div class="list-group list-group-flush" id="annotations-list">
|
||||
@@ -48,6 +53,48 @@
|
||||
});
|
||||
});
|
||||
|
||||
// Clear all annotations
|
||||
document.getElementById('clear-all-annotations-btn').addEventListener('click', function() {
|
||||
if (appState.annotations.length === 0) {
|
||||
showError('No annotations to clear');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm(`Are you sure you want to delete all ${appState.annotations.length} annotations? This action cannot be undone.`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch('/api/clear-all-annotations', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({
|
||||
symbol: appState.currentSymbol
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
// Clear from app state
|
||||
appState.annotations = [];
|
||||
|
||||
// Update UI
|
||||
renderAnnotationsList(appState.annotations);
|
||||
|
||||
// Clear from chart
|
||||
if (appState.chartManager) {
|
||||
appState.chartManager.clearAllAnnotations();
|
||||
}
|
||||
|
||||
showSuccess(`Cleared ${data.deleted_count} annotations`);
|
||||
} else {
|
||||
showError('Failed to clear annotations: ' + data.error.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
showError('Network error: ' + error.message);
|
||||
});
|
||||
});
|
||||
|
||||
// Function to render annotations list
|
||||
function renderAnnotationsList(annotations) {
|
||||
const listContainer = document.getElementById('annotations-list');
|
||||
|
||||
Reference in New Issue
Block a user