File size: 11,679 Bytes
4c9b9f7 d9e9c09 ddf3c5a d9e9c09 ddf3c5a ee39f4f 0328fc4 21c83f2 a5da0ae 21c83f2 75f525d 0d40735 75f525d 0d40735 21c83f2 ee5bf2e 6fb6ade ee5bf2e 6fb6ade bcbfb06 fcc319d bcbfb06 fcc319d 21c83f2 4c9b9f7 bcbfb06 d9e9c09 bcbfb06 3495df2 bcbfb06 d9e9c09 350a56c d9e9c09 27aed46 2ee4c4d 89f4a55 af77883 89f4a55 af77883 0328fc4 b9c96a5 0328fc4 b9c96a5 0328fc4 3ddbe34 0328fc4 3ddbe34 0328fc4 3ddbe34 0328fc4 b9c96a5 0328fc4 350a56c 4c9b9f7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/ico" href="https://huggingface.co/spaces/igs-img/stor/resolve/main/list.ico">
<title>Таблица данных</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link href="https://unpkg.com/[email protected]/dist/css/tabulator.min.css" rel="stylesheet">
<script src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
.container {
width: 100%;
max-width: 100%;
}
/* Шапка */
.header {
width: 100%;
padding: 0px 0; /* Убраны отступы справа и слева */
display: flex;
justify-content: space-between;
align-items: center;
background-color: #f8f9fa;
border-bottom: 1px solid #ddd;
}
/* Кнопки и лейбл в шапке */
.header .buttons,
.header .label {
margin: 0; /* Полностью убраны отступы */
}
#download-xlsx{
color: white;
background-color: #4CAF50;
border: none;
cursor: pointer;
padding: 10px 20px;
font-size: 16px;
border-radius: 5px;
margin: 5px;
transition: background-color 0.3s ease;
}
#download-xlsx:hover {
background-color: #388E3C;
}
#delite_db {
color: white;
background-color: #c90202;
border: none;
cursor: pointer;
padding: 10px 20px;
font-size: 16px;
border-radius: 5px;
margin: 5px;
transition: background-color 0.3s ease;
}
#delite_db:hover {
background-color: #388E3C;
}
#protection-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5); /* Полупрозрачный чёрный */
z-index: 5; /* На передний план */
display: block; /* Включено по умолчанию */
pointer-events: auto; /* Блокирует клики */
}
/* Поднимаем SweetAlert2 выше */
.swal2-container {
z-index: 10 !important;
}
</style>
</head>
<body>
<div id="protection-overlay"></div> <!-- Полупрозрачный фон -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const overlay = document.getElementById("protection-overlay");
let pageKey = localStorage.getItem("page_key");
// Функция проверки ключа
function checkApiKey(apiKey) {
fetch(`/page_key?api_sys=${apiKey}`)
.then(response => response.json())
.then(data => {
if (data.status === "ok") {
overlay.style.display = "none"; // ✅ Убираем защиту
} else {
requestNewKey("Неверный код. Введите заново!");
}
})
.catch(() => requestNewKey("Ошибка сервера. Попробуйте снова."));
}
// Функция запроса нового ключа
function requestNewKey(message = "Введите код доступа:") {
Swal.fire({
title: "Внимание!",
text: message,
input: "text",
inputAttributes: { autocapitalize: "off" },
showCancelButton: false,
confirmButtonText: "Отправить",
confirmButtonColor: "#4CAF50",
allowOutsideClick: false
}).then((result) => {
if (result.isConfirmed && result.value) {
localStorage.setItem("page_key", result.value); // 🔥 Сохраняем ключ
checkApiKey(result.value); // 🔥 Проверяем ключ
} else {
requestNewKey("Введите корректный код!"); // Повторяем ввод
}
});
}
// Если ключ есть → Проверяем его, иначе запрашиваем новый
if (pageKey) {
checkApiKey(pageKey);
} else {
requestNewKey();
}
});
</script>
<!-- Навигационная панель -->
<nav class="navbar navbar-light bg-light w-100">
<div class="container">
<a class="navbar-brand" href="/online">
<img src="https://huggingface.co/spaces/igs-img/stor/resolve/main/list.png" width="30" height="30" class="d-inline-block align-top" alt="">
MackorLab
</a>
<form class="form-inline">
<button id="st_onl" class="btn btn-outline-success" type="button">Онлайн</button>
<button id="st_set" class="btn btn-outline-success" type="button">Настройки</button>
<button id="st_plot" class="btn btn-outline-success" type="button">Графики</button>
<button id="st_table" class="btn btn-success" type="button">Таблица</button>
</form>
</div>
</nav>
<button id="download-xlsx">Скачать XLSX</button>
<button id="delite_db">Удалить базу данных</button>
<div id="data-table"></div>
<script>
document.addEventListener("DOMContentLoaded", function () {
fetch("/get_all_data")
.then(response => response.json())
.then(data => {
const table = new Tabulator("#data-table", {
layout: "fitColumns",
pagination: "local", // Включаем локальную пагинацию
paginationSize: 50, // Количество строк на странице
paginationSizeSelector: [50, 100, 200], // Выбор количества строк
columns: [
{ title: "ID", field: "id", sorter: "number" },
{ title: "Неделя", field: "wek", sorter: "number" },
{ title: "День", field: "dey", sorter: "number" },
{ title: "Время системы", field: "time_system", sorter: "string" },
{ title: "Уровень pH", field: "ph", sorter: "number" },
{ title: "Уровень EC", field: "ec", sorter: "number" },
{ title: "Темп. раствора", field: "tS", sorter: "number" },
{ title: "Темп. воздуха", field: "tA", sorter: "number" },
{ title: "Влажность воздуха", field: "hDm", sorter: "number" },
{ title: "Об. вентилятора", field: "sVen", sorter: "number" },
{ title: "pH (нас)", field: "nPh", sorter: "number" },
{ title: "EC (нас)", field: "nEC", sorter: "number" },
{ title: "Свет ВКЛ (нас)", field: "nLon", sorter: "string" },
{ title: "Свет ОТКЛ (нас)", field: "nLoff", sorter: "string" },
{ title: "Темп. воздуха (нас)", field: "nTa", sorter: "number" },
{ title: "Насос A (нас)", field: "onA", sorter: "number" },
{ title: "Насос B (нас)", field: "onB", sorter: "number" },
{ title: "Насос C (нас)", field: "onC", sorter: "number" },
{ title: "Дата записи", field: "date_time", sorter: "datetime" }
],
data: data.map(item => ({
...item,
time_system: `${item.v_hid}:${item.v_min}` // Объединяем v_hid и v_min через двоеточие
}))
});
// Добавляем обработчик для кнопки скачивания XLSX
document.getElementById("download-xlsx").addEventListener("click", function () {
table.download("xlsx", "table_data.xlsx", { sheetName: "Данные" });
});
})
.catch(error => console.error("Ошибка загрузки данных:", error));
});
</script>
<script>
document.getElementById("delite_db").addEventListener("click", function () {
Swal.fire({
title: "Внимание",
text: "При нажатии кнопки 'Удалить' вы полностью очистите базу данных предыдущего цикла выращивания!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#d33", // Красная кнопка "Удалить"
cancelButtonColor: "#28a745", // Зеленая кнопка "Нет"
confirmButtonText: "Удалить",
cancelButtonText: "Нет"
}).then((result) => {
if (result.isConfirmed) {
fetch("/delite_db")
.then(response => response.json())
.then(data => {
if (data.status === "ok") {
Swal.fire({
title: "Удалено!",
text: "База данных успешно очищена.",
icon: "success",
confirmButtonColor: "#28a745", // ✅ Зеленая кнопка "OK"
}).then(() => {
location.reload(); // 🔄 Перезагружаем страницу
});
} else {
Swal.fire({
title: "Ошибка",
text: "Не удалось очистить базу данных.",
icon: "error",
confirmButtonColor: "#d33", // Красная кнопка "OK" в случае ошибки
});
}
})
.catch(() => {
Swal.fire({
title: "Ошибка",
text: "Ошибка соединения с сервером.",
icon: "error",
confirmButtonColor: "#d33", // Красная кнопка "OK" в случае ошибки
});
});
}
});
});
</script>
<script>
document.getElementById("st_onl").addEventListener("click", function() {
var baseUrl = window.location.origin;
var targetUrl = baseUrl + "/online";
window.location.href = targetUrl;
});
</script>
<script>
document.getElementById("st_set").addEventListener("click", function() {
var baseUrl = window.location.origin;
var targetUrl = baseUrl + "/settings";
window.location.href = targetUrl;
});
</script>
<script>
document.getElementById("st_plot").addEventListener("click", function() {
var baseUrl = window.location.origin;
var targetUrl = baseUrl + "/plot_week";
window.location.href = targetUrl;
});
</script>
<script>
document.getElementById("st_table").addEventListener("click", function() {
var baseUrl = window.location.origin;
var targetUrl = baseUrl + "/table";
window.location.href = targetUrl;
});
</script>
</body>
</html>
|