notes
This commit is contained in:
+80
-4
@@ -5,6 +5,7 @@
|
||||
<title>Органайзер RustDesk</title>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.12/jstree.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> <!-- Библиотека для Markdown -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.12/themes/default/style.min.css">
|
||||
<style>
|
||||
body { display: flex; font-family: Arial, sans-serif; }
|
||||
@@ -29,6 +30,12 @@
|
||||
#import-label:hover { background: #0056b3; }
|
||||
.folder-select { margin: 5px 0; }
|
||||
.time-hint { font-size: 12px; color: #666; margin-top: 5px; }
|
||||
#notes-panel { width: 100%; padding: 10px; border-left: 1px solid #ccc; background: #f9f9f9; min-height: 200px; }
|
||||
#notes-content { margin-top: 10px; }
|
||||
#note-modal { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: white; padding: 20px; border: 1px solid #ccc; box-shadow: 0 0 10px rgba(0,0,0,0.3); z-index: 1000; width: 500px; }
|
||||
#note-modal textarea { width: 100%; height: 200px; margin-bottom: 10px; }
|
||||
#note-modal button { margin-right: 10px; }
|
||||
#modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 999; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -71,6 +78,7 @@
|
||||
<option value="vnc">VNC</option>
|
||||
<option value="rdp">RDP</option>
|
||||
</select>
|
||||
<textarea id="note" placeholder="Заметка (Markdown поддерживается)"></textarea>
|
||||
<button onclick="addInstall()">Добавить</button>
|
||||
<div class="time-hint">Пример: 2025-03-05 14:30:00</div>
|
||||
</div>
|
||||
@@ -82,11 +90,25 @@
|
||||
</div>
|
||||
<div id="installs-list"></div>
|
||||
</div>
|
||||
<div id="notes-panel">
|
||||
<h2>Заметка</h2>
|
||||
<div id="notes-content"></div>
|
||||
</div>
|
||||
|
||||
<!-- Модальное окно для редактирования заметок -->
|
||||
<div id="modal-overlay"></div>
|
||||
<div id="note-modal">
|
||||
<h3>Редактировать заметку</h3>
|
||||
<textarea id="note-textarea" placeholder="Введите заметку (Markdown поддерживается)"></textarea>
|
||||
<button onclick="saveNote()">Сохранить</button>
|
||||
<button onclick="closeNoteModal()">Закрыть</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const API_URL = "/api";
|
||||
let selectedFolderId = null;
|
||||
let allInstalls = [];
|
||||
let selectedInstallId = null;
|
||||
let sortField = null;
|
||||
let sortDirection = 'asc';
|
||||
|
||||
@@ -181,6 +203,7 @@
|
||||
allInstalls = data;
|
||||
let filtered = folderId ? data.filter(i => i.folder_id == folderId) : data.filter(i => i.folder_id === null);
|
||||
displayInstalls(filtered);
|
||||
updateNotesPanel(); // Обновляем заметки после загрузки
|
||||
});
|
||||
selectedFolderId = folderId;
|
||||
}
|
||||
@@ -192,8 +215,9 @@
|
||||
<div style="flex: 1; text-align: center;">${item.computer_name}</div>
|
||||
<div style="flex: 1; text-align: center;">${item.install_time}</div>
|
||||
<div style="flex: 1; text-align: center;">
|
||||
<button onclick="editInstall(${item.id}, '${item.rust_id}', '${item.computer_name}', '${item.install_time}', '${item.protocol}')">Редактировать</button>
|
||||
<button onclick="editInstall(${item.id}, '${item.rust_id}', '${item.computer_name}', '${item.install_time}', '${item.protocol}', '${item.note}')">Редактировать</button>
|
||||
<button onclick="deleteInstall(${item.id})">Удалить</button>
|
||||
<button onclick="openNoteModal(${item.id}, '${item.note}')">Заметка</button>
|
||||
</div>
|
||||
</div>
|
||||
`).join(''));
|
||||
@@ -306,6 +330,7 @@
|
||||
const computerName = $('#computerName').val();
|
||||
const installTime = $('#installTime').val() || ''; // Пустая строка, если не указано
|
||||
const protocol = $('#protocol').val();
|
||||
const note = $('#note').val() || ''; // Новая заметка из формы
|
||||
|
||||
if (installTime && !/^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/.test(installTime)) {
|
||||
alert("Неверный формат времени. Используйте ГГГГ-ММ-ДД ЧЧ:ММ:СС (например, 2025-03-05 14:30:00)");
|
||||
@@ -316,7 +341,7 @@
|
||||
url: `${API_URL}/install`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ rust_id: rustId, computer_name: computerName, install_time: installTime, folder_id: selectedFolderId, protocol: protocol }),
|
||||
data: JSON.stringify({ rust_id: rustId, computer_name: computerName, install_time: installTime, folder_id: selectedFolderId, protocol: protocol, note: note }),
|
||||
success: function () {
|
||||
loadInstalls(selectedFolderId);
|
||||
},
|
||||
@@ -330,11 +355,12 @@
|
||||
});
|
||||
}
|
||||
|
||||
function editInstall(id, rustId, computerName, installTime, protocol) {
|
||||
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)");
|
||||
@@ -346,7 +372,7 @@
|
||||
url: `${API_URL}/install/${id}`,
|
||||
type: 'PUT',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ rust_id: newRustId, computer_name: newComputerName, install_time: newInstallTime, folder_id: selectedFolderId, protocol: newProtocol }),
|
||||
data: JSON.stringify({ rust_id: newRustId, computer_name: newComputerName, install_time: newInstallTime, folder_id: selectedFolderId, protocol: newProtocol, note: newNote }),
|
||||
success: function () {
|
||||
loadInstalls(selectedFolderId);
|
||||
},
|
||||
@@ -425,6 +451,56 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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("Не удалось сохранить заметку");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function closeNoteModal() {
|
||||
$('#note-modal').hide();
|
||||
$('#modal-overlay').hide();
|
||||
$('#note-textarea').val('');
|
||||
}
|
||||
|
||||
function updateNotesPanel() {
|
||||
if (selectedInstallId) {
|
||||
const install = allInstalls.find(i => i.id === selectedInstallId);
|
||||
if (install && install.note) {
|
||||
$('#notes-content').html(marked.parse(install.note)); // Рендеринг Markdown
|
||||
} else {
|
||||
$('#notes-content').html('<p>Нет заметок</p>');
|
||||
}
|
||||
} else {
|
||||
$('#notes-content').html('<p>Выберите подключение для просмотра заметки</p>');
|
||||
}
|
||||
}
|
||||
|
||||
// Обновляем заметки при клике на подключение
|
||||
$('#installs-list').on('click', '.install-item', function () {
|
||||
selectedInstallId = $(this).data('id');
|
||||
updateNotesPanel();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user