newvera
parent
587887c759
commit
8fac444974
|
|
@ -14,6 +14,7 @@
|
||||||
.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: inline; margin-left: 10px; }
|
||||||
|
#search-input, #sort-select { margin-bottom: 10px; width: 200px; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
@ -31,12 +32,23 @@
|
||||||
<input type="text" id="installTime" placeholder="Время (опционально)">
|
<input type="text" id="installTime" placeholder="Время (опционально)">
|
||||||
<button onclick="addInstall()">Добавить</button>
|
<button onclick="addInstall()">Добавить</button>
|
||||||
</div>
|
</div>
|
||||||
|
<input type="text" id="search-input" placeholder="Поиск по ID или имени" onkeyup="filterInstalls()">
|
||||||
|
<select id="sort-select" onchange="sortInstalls()">
|
||||||
|
<option value="">Без сортировки</option>
|
||||||
|
<option value="rust_id_asc">Rust ID (А-Я)</option>
|
||||||
|
<option value="rust_id_desc">Rust ID (Я-А)</option>
|
||||||
|
<option value="computer_name_asc">Имя (А-Я)</option>
|
||||||
|
<option value="computer_name_desc">Имя (Я-А)</option>
|
||||||
|
<option value="install_time_asc">Время (ранее-позже)</option>
|
||||||
|
<option value="install_time_desc">Время (позже-ранее)</option>
|
||||||
|
</select>
|
||||||
<div id="installs-list"></div>
|
<div id="installs-list"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const API_URL = "/api";
|
const API_URL = "/api";
|
||||||
let selectedFolderId = null;
|
let selectedFolderId = null;
|
||||||
|
let allInstalls = []; // Храним все записи для поиска и сортировки
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
// Инициализация дерева папок
|
// Инициализация дерева папок
|
||||||
|
|
@ -92,8 +104,15 @@
|
||||||
|
|
||||||
function loadInstalls(folderId) {
|
function loadInstalls(folderId) {
|
||||||
$.getJSON(`${API_URL}/installs`, function (data) {
|
$.getJSON(`${API_URL}/installs`, function (data) {
|
||||||
const filtered = folderId ? data.filter(i => i.folder_id == folderId) : data;
|
allInstalls = data; // Сохраняем все записи
|
||||||
$('#installs-list').html(filtered.map(item => `
|
let filtered = folderId ? data.filter(i => i.folder_id == folderId) : data.filter(i => i.folder_id === null);
|
||||||
|
displayInstalls(filtered);
|
||||||
|
});
|
||||||
|
selectedFolderId = folderId; // Обновляем текущую папку
|
||||||
|
}
|
||||||
|
|
||||||
|
function displayInstalls(installs) {
|
||||||
|
$('#installs-list').html(installs.map(item => `
|
||||||
<div class="install-item" data-id="${item.id}" draggable="true">
|
<div class="install-item" data-id="${item.id}" draggable="true">
|
||||||
<a href="rustdesk://${item.rust_id}" onclick="openRustDesk('${item.rust_id}'); return false;">${item.rust_id}</a>
|
<a href="rustdesk://${item.rust_id}" onclick="openRustDesk('${item.rust_id}'); return false;">${item.rust_id}</a>
|
||||||
- ${item.computer_name} (${item.install_time})
|
- ${item.computer_name} (${item.install_time})
|
||||||
|
|
@ -101,8 +120,39 @@
|
||||||
<button onclick="deleteInstall(${item.id})">Удалить</button>
|
<button onclick="deleteInstall(${item.id})">Удалить</button>
|
||||||
</div>
|
</div>
|
||||||
`).join(''));
|
`).join(''));
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterInstalls() {
|
||||||
|
const query = $('#search-input').val().toLowerCase();
|
||||||
|
let filtered = selectedFolderId
|
||||||
|
? allInstalls.filter(i => i.folder_id == selectedFolderId)
|
||||||
|
: allInstalls.filter(i => i.folder_id === null);
|
||||||
|
filtered = filtered.filter(i =>
|
||||||
|
i.rust_id.toLowerCase().includes(query) ||
|
||||||
|
i.computer_name.toLowerCase().includes(query)
|
||||||
|
);
|
||||||
|
sortInstalls(filtered);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortInstalls(filteredInstalls = null) {
|
||||||
|
let installs = filteredInstalls || (selectedFolderId
|
||||||
|
? allInstalls.filter(i => i.folder_id == selectedFolderId)
|
||||||
|
: allInstalls.filter(i => i.folder_id === null));
|
||||||
|
const sortBy = $('#sort-select').val();
|
||||||
|
|
||||||
|
if (sortBy) {
|
||||||
|
const [field, direction] = sortBy.split('_');
|
||||||
|
installs.sort((a, b) => {
|
||||||
|
let valA = a[field], valB = b[field];
|
||||||
|
if (field === 'install_time') {
|
||||||
|
valA = new Date(valA);
|
||||||
|
valB = new Date(valB);
|
||||||
|
}
|
||||||
|
if (direction === 'asc') return valA > valB ? 1 : -1;
|
||||||
|
return valA < valB ? 1 : -1;
|
||||||
});
|
});
|
||||||
selectedFolderId = folderId; // Обновляем текущую папку
|
}
|
||||||
|
displayInstalls(installs);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFolder() {
|
function addFolder() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue