|
<!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; |
|
} |
|
|
|
|
|
.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}` |
|
})) |
|
}); |
|
|
|
|
|
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", |
|
}).then(() => { |
|
location.reload(); |
|
}); |
|
} else { |
|
Swal.fire({ |
|
title: "Ошибка", |
|
text: "Не удалось очистить базу данных.", |
|
icon: "error", |
|
confirmButtonColor: "#d33", |
|
}); |
|
} |
|
}) |
|
.catch(() => { |
|
Swal.fire({ |
|
title: "Ошибка", |
|
text: "Ошибка соединения с сервером.", |
|
icon: "error", |
|
confirmButtonColor: "#d33", |
|
}); |
|
}); |
|
} |
|
}); |
|
}); |
|
</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> |
|
|