main
Satur@it-depot.ru 2025-03-06 14:30:36 +03:00
parent 6a904b76f0
commit 564f056b05
1 changed files with 25 additions and 17 deletions

View File

@ -519,15 +519,20 @@
// Drag-and-drop для записей
$('#installs-list').on('dragstart', '.install-item', function (e) {
console.log('Drag start:', $(this).data('id'));
e.originalEvent.dataTransfer.setData('text/plain', $(this).data('id'));
});
$('#folder-tree').on('dragover', function (e) {
e.preventDefault();
console.log('Drag over');
}).on('drop', function (e) {
e.preventDefault();
console.log('Drop event triggered');
const installId = e.originalEvent.dataTransfer.getData('text');
console.log('Dropped installId:', installId);
let targetFolderId = $(e.target).closest('.jstree-node').attr('id');
console.log('Target folderId:', targetFolderId);
if (installId && targetFolderId) {
targetFolderId = targetFolderId === "root" ? null : targetFolderId;
moveInstallToFolder(installId, targetFolderId);
@ -787,24 +792,27 @@
}
function moveInstallToFolder(installId, folderId) {
const install = allInstalls.find(i => i.id === installId);
if (install) {
$.ajax({
url: `${API_URL}/install/${installId}`,
type: 'PUT',
contentType: 'application/json',
data: JSON.stringify({
folder_id: folderId,
protocol: install.protocol
}),
success: function () {
loadInstalls(selectedFolderId);
},
error: function (xhr, status, error) {
console.error("Ошибка переноса:", status, error);
console.log('Moving installId:', installId, 'to folderId:', folderId);
$.ajax({
url: `${API_URL}/install/${installId}`,
type: 'PUT',
contentType: 'application/json',
data: JSON.stringify({
folder_id: folderId
}),
success: function () {
console.log('Move successful');
loadInstalls(selectedFolderId);
},
error: function (xhr, status, error) {
console.error("Ошибка переноса:", status, error);
if (xhr.status === 404) {
alert("Запись не найдена");
} else {
alert("Ошибка при перемещении записи");
}
});
}
}
});
}
function exportCSV() {