From 03bc10a98e0993467f21aa84770e0de296661d70 Mon Sep 17 00:00:00 2001 From: "Satur@it-depot.ru" Date: Thu, 6 Mar 2025 14:16:30 +0300 Subject: [PATCH] 23 --- templates/index.html | 87 ++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 55 deletions(-) diff --git a/templates/index.html b/templates/index.html index 4c809e0..c94dd5a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -83,7 +83,6 @@ transform: translateY(-50%); margin-left: 0; } - /* Стили для выбранного узла в jstree в темной теме */ .jstree-default-dark .jstree-clicked { background: #005580 !important; color: #e0e0e0 !important; @@ -751,6 +750,11 @@ if (field === 'install_time') { data['folder_id'] = selectedFolderId; } + // Добавляем текущее значение protocol + const install = allInstalls.find(i => i.id === installId); + if (install) { + data['protocol'] = install.protocol; + } $.ajax({ url: `${API_URL}/install/${installId}`, type: 'PUT', @@ -787,7 +791,11 @@ url: `${API_URL}/install/${installId}`, type: 'PUT', contentType: 'application/json', - data: JSON.stringify({ folder_id: folderId }), + data: JSON.stringify({ + folder_id: folderId, + // Добавляем текущее значение protocol + protocol: allInstalls.find(i => i.id === installId)?.protocol || 'rustdesk' + }), success: function () { loadInstalls(selectedFolderId); }, @@ -797,60 +805,29 @@ }); } - function exportCSV() { - const folderId = $('#folder-select').val() || ''; - window.location.href = `${API_URL}/export/csv?folder_id=${folderId}`; - } - - function importCSV(file) { - if (!file) return; - - const folderId = $('#folder-select').val() || ''; - const formData = new FormData(); - formData.append('file', file); - if (folderId) { - formData.append('folder_id', folderId); - } - - $.ajax({ - url: `${API_URL}/import/csv`, - type: 'POST', - data: formData, - processData: false, - contentType: false, - success: function (response) { - alert(response.message); - loadInstalls(selectedFolderId); - }, - error: function (xhr, status, error) { - alert(`Ошибка импорта: ${xhr.responseJSON.detail || error}`); - } - }); - } - - function openNoteModal(installId, currentNote) { - selectedInstallId = installId; - $('#note-textarea').val(currentNote); - $('#note-modal').show(); - $('#modal-overlay').show(); - } - function saveNote() { const note = $('#note-textarea').val() || ''; - $.ajax({ - url: `${API_URL}/install/${selectedInstallId}`, - type: 'PUT', - contentType: 'application/json', - data: JSON.stringify({ note: note }), - success: function () { - loadInstalls(selectedFolderId); - closeNoteModal(); - }, - error: function (xhr, status, error) { - console.error("Ошибка сохранения заметки:", status, error); - alert("Не удалось сохранить заметку"); - } - }); + const install = allInstalls.find(i => i.id === selectedInstallId); + if (install) { + $.ajax({ + url: `${API_URL}/install/${selectedInstallId}`, + type: 'PUT', + contentType: 'application/json', + data: JSON.stringify({ + note: note, + // Добавляем текущее значение protocol + protocol: install.protocol + }), + success: function () { + loadInstalls(selectedFolderId); + closeNoteModal(); + }, + error: function (xhr, status, error) { + console.error("Ошибка сохранения заметки:", status, error); + alert("Не удалось сохранить заметку"); + } + }); + } } function closeNoteModal() { @@ -911,7 +888,7 @@ function formatItalic() { const textarea = $('#note-textarea'); const start = textarea[0].selectionStart; - const end = textarea[0].selectionEnd; + end: textarea[0].selectionEnd; const text = textarea.val(); const selected = text.substring(start, end); const newText = `*${selected}*`;