From c76f0a302034b69f7ce9beea4baec89a02362176 Mon Sep 17 00:00:00 2001 From: "Satur@it-depot.ru" Date: Wed, 5 Mar 2025 12:45:23 +0300 Subject: [PATCH] dis --- templates/index.html | 70 +++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/templates/index.html b/templates/index.html index 487150a..c3944c8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -11,10 +11,11 @@ body { display: flex; font-family: Arial, sans-serif; margin: 0; } #tree-container { width: 20%; padding: 10px; border-right: 1px solid #ccc; } #installs-container { width: 50%; padding: 10px; position: relative; } - .install-item { padding: 5px; margin: 2px; border: 1px solid #ddd; cursor: move; } + .install-item { padding: 5px; margin: 2px; border: 1px solid #ddd; cursor: move; position: relative; } .form-container { margin-bottom: 20px; } .jstree-node { position: relative; } - .folder-actions { display: inline; margin-left: 10px; } + .folder-actions { display: none; margin-left: 10px; } + .jstree-node:hover .folder-actions { display: inline; } #search-container { position: absolute; top: 10px; right: 10px; text-align: right; } #search-input { width: 200px; } #installs-list { margin-top: 20px; } @@ -24,6 +25,11 @@ .sort-arrow { font-size: 12px; margin-left: 5px; } .protocol-icon { margin-right: 5px; height: 16px; width: 16px; vertical-align: middle; } .connection-link { color: blue; text-decoration: underline; cursor: pointer; } + .edit-button { display: none; position: absolute; right: 5px; top: 50%; transform: translateY(-50%); background: #007bff; color: white; border: none; padding: 2px 5px; border-radius: 3px; cursor: pointer; } + .edit-button:hover { background: #0056b3; } + .install-item:hover .edit-button { display: inline-block; } + .action-buttons { display: none; } + .install-item:hover .action-buttons { display: inline; } #import-form { margin-top: 10px; } #import-file { display: none; } #import-label { cursor: pointer; background: #007bff; color: white; padding: 5px 10px; border-radius: 5px; } @@ -222,14 +228,25 @@ function displayInstalls(installs) { $('#installs-list').html(installs.map(item => ` -
-
${protocolIcons[item.protocol]}${item.rust_id}
-
${item.computer_name}
-
${item.install_time}
-
- - - +
+
+ ${protocolIcons[item.protocol]} + ${item.rust_id} + +
+
+ ${item.computer_name} + +
+
+ ${item.install_time} + +
+
+ + + +
`).join('')); @@ -367,24 +384,29 @@ }); } - function editInstall(id, rustId, computerName, installTime, protocol, note) { - const newRustId = prompt("ID подключения:", rustId); - const newComputerName = prompt("Имя компьютера:", computerName); - let newInstallTime = prompt("Время установки (опционально, формат: ГГГГ-ММ-ДД ЧЧ:ММ:СС):", installTime || ''); - const newProtocol = prompt("Протокол (rustdesk, anydesk, ammyy, teamviewer, vnc, rdp):", protocol); - const newNote = prompt("Заметка (Markdown поддерживается):", note || ''); - - if (newInstallTime && !/^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/.test(newInstallTime)) { - alert("Неверный формат времени. Используйте ГГГГ-ММ-ДД ЧЧ:ММ:СС (например, 2025-03-05 14:30:00)"); - return; + function editField(installId, field, currentValue) { + let newValue; + if (field === 'install_time') { + newValue = prompt(`Новое ${field === 'rust_id' ? 'ID подключения' : field === 'computer_name' ? 'Имя компьютера' : 'Время установки'} (опционально, формат для времени: ГГГГ-ММ-ДД ЧЧ:ММ:СС):`, currentValue || ''); + if (newValue && field === 'install_time' && !/^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/.test(newValue)) { + alert("Неверный формат времени. Используйте ГГГГ-ММ-ДД ЧЧ:ММ:СС (например, 2025-03-05 14:30:00)"); + return; + } + } else { + newValue = prompt(`Новое ${field === 'rust_id' ? 'ID подключения' : field === 'computer_name' ? 'Имя компьютера' : 'Время установки'}:`, currentValue || ''); } - if (newRustId && newComputerName) { + if (newValue !== null && newValue !== currentValue) { // Проверяем, что значение изменилось + let data = {}; + data[field] = newValue; + if (field === 'install_time') { + data['folder_id'] = selectedFolderId; // Добавляем folder_id для обновления + } $.ajax({ - url: `${API_URL}/install/${id}`, + url: `${API_URL}/install/${installId}`, type: 'PUT', contentType: 'application/json', - data: JSON.stringify({ rust_id: newRustId, computer_name: newComputerName, install_time: newInstallTime, folder_id: selectedFolderId, protocol: newProtocol, note: newNote }), + data: JSON.stringify(data), success: function () { loadInstalls(selectedFolderId); }, @@ -392,7 +414,7 @@ if (xhr.status === 400) { alert(xhr.responseJSON.detail); } else { - console.error("Ошибка редактирования:", status, error); + console.error(`Ошибка редактирования ${field}:`, status, error); } } });