dis
parent
9f39071732
commit
c76f0a3020
|
|
@ -11,10 +11,11 @@
|
||||||
body { display: flex; font-family: Arial, sans-serif; margin: 0; }
|
body { display: flex; font-family: Arial, sans-serif; margin: 0; }
|
||||||
#tree-container { width: 20%; padding: 10px; border-right: 1px solid #ccc; }
|
#tree-container { width: 20%; padding: 10px; border-right: 1px solid #ccc; }
|
||||||
#installs-container { width: 50%; padding: 10px; position: relative; }
|
#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; }
|
.form-container { margin-bottom: 20px; }
|
||||||
.jstree-node { position: relative; }
|
.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-container { position: absolute; top: 10px; right: 10px; text-align: right; }
|
||||||
#search-input { width: 200px; }
|
#search-input { width: 200px; }
|
||||||
#installs-list { margin-top: 20px; }
|
#installs-list { margin-top: 20px; }
|
||||||
|
|
@ -24,6 +25,11 @@
|
||||||
.sort-arrow { font-size: 12px; margin-left: 5px; }
|
.sort-arrow { font-size: 12px; margin-left: 5px; }
|
||||||
.protocol-icon { margin-right: 5px; height: 16px; width: 16px; vertical-align: middle; }
|
.protocol-icon { margin-right: 5px; height: 16px; width: 16px; vertical-align: middle; }
|
||||||
.connection-link { color: blue; text-decoration: underline; cursor: pointer; }
|
.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-form { margin-top: 10px; }
|
||||||
#import-file { display: none; }
|
#import-file { display: none; }
|
||||||
#import-label { cursor: pointer; background: #007bff; color: white; padding: 5px 10px; border-radius: 5px; }
|
#import-label { cursor: pointer; background: #007bff; color: white; padding: 5px 10px; border-radius: 5px; }
|
||||||
|
|
@ -222,14 +228,25 @@
|
||||||
|
|
||||||
function displayInstalls(installs) {
|
function displayInstalls(installs) {
|
||||||
$('#installs-list').html(installs.map(item => `
|
$('#installs-list').html(installs.map(item => `
|
||||||
<div class="install-item" data-id="${item.id}" draggable="true" style="display: flex; justify-content: space-between;">
|
<div class="install-item" data-id="${item.id}" draggable="true" style="display: flex; justify-content: space-between; position: relative;">
|
||||||
<div style="flex: 1; text-align: center;"><span class="protocol-icon">${protocolIcons[item.protocol]}</span><a href="${protocolLinks[item.protocol]}${item.rust_id}" class="connection-link" onclick="openRemote('${item.rust_id}', '${item.protocol}'); return false;">${item.rust_id}</a></div>
|
<div style="flex: 1; text-align: center; position: relative;">
|
||||||
<div style="flex: 1; text-align: center;">${item.computer_name}</div>
|
<span class="protocol-icon">${protocolIcons[item.protocol]}</span>
|
||||||
<div style="flex: 1; text-align: center;">${item.install_time}</div>
|
<a href="${protocolLinks[item.protocol]}${item.rust_id}" class="connection-link" onclick="openRemote('${item.rust_id}', '${item.protocol}'); return false;">${item.rust_id}</a>
|
||||||
<div style="flex: 1; text-align: center;">
|
<button class="edit-button" onclick="editField(${item.id}, 'rust_id', '${item.rust_id}')">✏️</button>
|
||||||
<button onclick="editInstall(${item.id}, '${item.rust_id}', '${item.computer_name}', '${item.install_time}', '${item.protocol}', '${item.note}')">Редактировать</button>
|
</div>
|
||||||
<button onclick="deleteInstall(${item.id})">Удалить</button>
|
<div style="flex: 1; text-align: center; position: relative;">
|
||||||
<button onclick="openNoteModal(${item.id}, '${item.note}')">Заметка</button>
|
${item.computer_name}
|
||||||
|
<button class="edit-button" onclick="editField(${item.id}, 'computer_name', '${item.computer_name}')">✏️</button>
|
||||||
|
</div>
|
||||||
|
<div style="flex: 1; text-align: center; position: relative;">
|
||||||
|
${item.install_time}
|
||||||
|
<button class="edit-button" onclick="editField(${item.id}, 'install_time', '${item.install_time}')">✏️</button>
|
||||||
|
</div>
|
||||||
|
<div style="flex: 1; text-align: center; position: relative;">
|
||||||
|
<span class="action-buttons">
|
||||||
|
<button onclick="deleteInstall(${item.id})">Удалить</button>
|
||||||
|
<button onclick="openNoteModal(${item.id}, '${item.note}')">Заметка</button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`).join(''));
|
`).join(''));
|
||||||
|
|
@ -367,24 +384,29 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function editInstall(id, rustId, computerName, installTime, protocol, note) {
|
function editField(installId, field, currentValue) {
|
||||||
const newRustId = prompt("ID подключения:", rustId);
|
let newValue;
|
||||||
const newComputerName = prompt("Имя компьютера:", computerName);
|
if (field === 'install_time') {
|
||||||
let newInstallTime = prompt("Время установки (опционально, формат: ГГГГ-ММ-ДД ЧЧ:ММ:СС):", installTime || '');
|
newValue = prompt(`Новое ${field === 'rust_id' ? 'ID подключения' : field === 'computer_name' ? 'Имя компьютера' : 'Время установки'} (опционально, формат для времени: ГГГГ-ММ-ДД ЧЧ:ММ:СС):`, currentValue || '');
|
||||||
const newProtocol = prompt("Протокол (rustdesk, anydesk, ammyy, teamviewer, vnc, rdp):", protocol);
|
if (newValue && field === 'install_time' && !/^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/.test(newValue)) {
|
||||||
const newNote = prompt("Заметка (Markdown поддерживается):", note || '');
|
alert("Неверный формат времени. Используйте ГГГГ-ММ-ДД ЧЧ:ММ:СС (например, 2025-03-05 14:30:00)");
|
||||||
|
return;
|
||||||
if (newInstallTime && !/^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/.test(newInstallTime)) {
|
}
|
||||||
alert("Неверный формат времени. Используйте ГГГГ-ММ-ДД ЧЧ:ММ:СС (например, 2025-03-05 14:30:00)");
|
} else {
|
||||||
return;
|
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({
|
$.ajax({
|
||||||
url: `${API_URL}/install/${id}`,
|
url: `${API_URL}/install/${installId}`,
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
contentType: 'application/json',
|
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 () {
|
success: function () {
|
||||||
loadInstalls(selectedFolderId);
|
loadInstalls(selectedFolderId);
|
||||||
},
|
},
|
||||||
|
|
@ -392,7 +414,7 @@
|
||||||
if (xhr.status === 400) {
|
if (xhr.status === 400) {
|
||||||
alert(xhr.responseJSON.detail);
|
alert(xhr.responseJSON.detail);
|
||||||
} else {
|
} else {
|
||||||
console.error("Ошибка редактирования:", status, error);
|
console.error(`Ошибка редактирования ${field}:`, status, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue