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

@@ -93,34 +93,52 @@ class AnnotationManager {
* Delete old annotation and save updated one
*/
deleteAndSaveAnnotation(oldId, newAnnotation) {
console.log('Updating annotation:', oldId, newAnnotation);
// Delete old
fetch('/api/delete-annotation', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({annotation_id: oldId})
})
.then(() => {
// Save new
return fetch('/api/save-annotation', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(newAnnotation)
});
.then(response => response.json())
.then(deleteData => {
console.log('Delete response:', deleteData);
if (deleteData.success) {
// Save new
return fetch('/api/save-annotation', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(newAnnotation)
});
} else {
throw new Error('Failed to delete old annotation: ' + deleteData.error.message);
}
})
.then(response => response.json())
.then(data => {
console.log('Save response:', data);
if (data.success) {
// Update app state
window.appState.annotations = window.appState.annotations.filter(a => a.annotation_id !== oldId);
window.appState.annotations.push(data.annotation);
// Update UI
window.renderAnnotationsList(window.appState.annotations);
if (typeof window.renderAnnotationsList === 'function') {
window.renderAnnotationsList(window.appState.annotations);
}
// Update chart
this.chartManager.removeAnnotation(oldId);
this.chartManager.addAnnotation(data.annotation);
window.showSuccess('Annotation updated successfully');
} else {
throw new Error('Failed to save updated annotation: ' + data.error.message);
}
})
.catch(error => {
console.error('Update annotation error:', error);
window.showError('Failed to update annotation: ' + error.message);
});
}