Rustdesk_Api/frontend/templates/index.html

70 lines
2.5 KiB
HTML

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Установки RustDesk</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css">
<script>
const API_URL = "/api";
$(document).ready(function () {
$.getJSON(`${API_URL}/installs`, function (data) {
console.log("Полученные данные:", data);
let table = $('#rustdeskTable').DataTable({
"order": [[3, "desc"]],
"destroy": true,
"data": data,
"columns": [
{ "data": "id" },
{ "data": "rust_id" },
{ "data": "computer_name" },
{ "data": "install_time" },
{
"data": "id",
"render": function (data) {
return `<button onclick="deleteEntry(${data})">Удалить</button>`;
}
}
]
});
}).fail(function(jqXHR, textStatus, errorThrown) {
console.error("Ошибка загрузки данных:", textStatus, errorThrown);
});
window.deleteEntry = function(id) {
if (confirm("Вы уверены, что хотите удалить запись?")) {
$.ajax({
url: `${API_URL}/delete/${id}`,
type: 'DELETE',
success: function () {
location.reload();
},
error: function () {
alert("Ошибка при удалении!");
}
});
}
};
});
</script>
</head>
<body>
<h1>Установки RustDesk</h1>
<table id="rustdeskTable" class="display">
<thead>
<tr>
<th>ID</th>
<th>Rust ID</th>
<th>Имя компьютера</th>
<th>Время установки</th>
<th>Действие</th>
</tr>
</thead>
<tbody></tbody>
</table>
</body>
</html>