image fix

This commit is contained in:
2025-03-06 16:47:58 +03:00
parent 0d7cb6f8d1
commit d0899f178f
2 changed files with 13 additions and 10 deletions
+11 -8
View File
@@ -983,11 +983,14 @@
function uploadImage() {
const fileInput = document.getElementById('image-upload-input');
const file = fileInput.files[0];
if (!file) return;
if (!file || !selectedInstallId) {
alert('Пожалуйста, выберите запись и изображение.');
return;
}
const formData = new FormData();
formData.append('image', file);
formData.append('install_id', selectedInstallId);
formData.append('install_id', selectedInstallId); // Отправляем как часть формы
formData.append('file', file); // Отправляем файл
$.ajax({
url: `${API_URL}/upload-image`,
@@ -1009,7 +1012,7 @@
},
error: function (xhr, status, error) {
console.error('Error uploading image:', status, error);
alert(`Не удалось загрузить изображение: ${xhr.responseJSON?.detail || error}`);
alert(`Не удалось загрузить изображение: ${xhr.responseJSON?.detail || 'Неизвестная ошибка'}`);
}
});
}
@@ -1047,7 +1050,7 @@
}
function closeNoteModal() {
$('#note-modal').hide(); //
$('#note-modal').hide();
$('#modal-overlay').hide();
$('#note-textarea').val(''); // Очищаем текстовое поле
selectedInstallId = null; // Сбрасываем выбранный ID
@@ -1106,7 +1109,7 @@
function formatItalic() {
const textarea = $('#note-textarea');
const start = textarea[0].selectionStart;
end = textarea[0].selectionEnd;
const end = textarea[0].selectionEnd;
const text = textarea.val();
const selected = text.substring(start, end);
const newText = `*${selected}*`;
@@ -1154,7 +1157,7 @@
$('#folder-tree').jstree(true).refresh();
},
error: function (xhr, status, error) {
console.error("Error saving folder position:", status, error);
console.error("Error saving folder position:", status, error);
console.error("Response:", xhr.responseText);
alert("Не удалось сохранить новое положение папки. Проверьте консоль.");
$('#folder-tree').jstree(true).refresh();
@@ -1163,4 +1166,4 @@
}
</script>
</body>
</html>
</html>