update
This commit is contained in:
@@ -308,9 +308,36 @@ window.onload = function() {
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{ label: "PM1", data: PM1, borderColor: "red", fill: false },
|
||||
{ label: "PM2.5", data: PM25, borderColor: "blue", fill: false },
|
||||
{ label: "PM10", data: PM10, borderColor: "green", fill: false }
|
||||
{
|
||||
label: "PM1",
|
||||
data: PM1,
|
||||
borderColor: "rgba(0, 51, 153, 1)",
|
||||
backgroundColor: "rgba(0, 51, 153, 0.2)", // Very light blue background
|
||||
fill: true,
|
||||
tension: 0.4, // Smooth curves
|
||||
pointRadius: 2, // Larger points
|
||||
pointHoverRadius: 6 // Bigger hover points
|
||||
},
|
||||
{
|
||||
label: "PM2.5",
|
||||
data: PM25,
|
||||
borderColor: "rgba(30, 144, 255, 1)",
|
||||
backgroundColor: "rgba(30, 144, 255, 0.2)", // Very light medium blue background
|
||||
fill: true,
|
||||
tension: 0.4,
|
||||
pointRadius: 2,
|
||||
pointHoverRadius: 6
|
||||
},
|
||||
{
|
||||
label: "PM10",
|
||||
data: PM10,
|
||||
borderColor: "rgba(135, 206, 250, 1)",
|
||||
backgroundColor: "rgba(135, 206, 250, 0.2)", // Very light blue background
|
||||
fill: true,
|
||||
tension: 0.4,
|
||||
pointRadius: 2,
|
||||
pointHoverRadius: 6
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
@@ -325,11 +352,17 @@ window.onload = function() {
|
||||
x: {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Time'
|
||||
text: 'Time (UTC)',
|
||||
font: {
|
||||
size: 16,
|
||||
family: 'Arial, sans-serif'
|
||||
},
|
||||
color: '#4A4A4A'
|
||||
},
|
||||
ticks: {
|
||||
autoSkip: true,
|
||||
maxTicksLimit: 5,
|
||||
color: '#4A4A4A',
|
||||
callback: function(value, index) {
|
||||
// Access the correct label from the `labels` array
|
||||
const label = labels[index]; // Use the original `labels` array
|
||||
@@ -338,6 +371,9 @@ window.onload = function() {
|
||||
}
|
||||
return value; // Fallback for invalid labels
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
display: false // Remove gridlines for a cleaner look
|
||||
}
|
||||
|
||||
|
||||
@@ -345,7 +381,12 @@ window.onload = function() {
|
||||
y: {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Values (µg/m³)'
|
||||
text: 'Values (µg/m³)',
|
||||
font: {
|
||||
size: 16,
|
||||
family: 'Arial, sans-serif'
|
||||
},
|
||||
color: '#4A4A4A'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,10 @@ if ($type == "get_npm_sqlite_data") {
|
||||
// Fetch the last 30 records
|
||||
$stmt = $db->query("SELECT timestamp, PM1, PM25, PM10 FROM data ORDER BY timestamp DESC LIMIT 30");
|
||||
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$reversedData = array_reverse($data); // Reverse the order
|
||||
|
||||
|
||||
echo json_encode($data);
|
||||
echo json_encode($reversedData);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(["error" => $e->getMessage()]);
|
||||
}
|
||||
@@ -94,50 +96,50 @@ if ($type == "clear_loopLogs") {
|
||||
|
||||
if ($type == "database_size") {
|
||||
|
||||
// Path to the SQLite database file
|
||||
$databasePath = '/var/www/nebuleair_pro_4g/sqlite/sensors.db';
|
||||
// Path to the SQLite database file
|
||||
$databasePath = '/var/www/nebuleair_pro_4g/sqlite/sensors.db';
|
||||
|
||||
// Check if the file exists
|
||||
if (file_exists($databasePath)) {
|
||||
try {
|
||||
// Connect to the SQLite database
|
||||
$db = new PDO("sqlite:$databasePath");
|
||||
// Check if the file exists
|
||||
if (file_exists($databasePath)) {
|
||||
try {
|
||||
// Connect to the SQLite database
|
||||
$db = new PDO("sqlite:$databasePath");
|
||||
|
||||
// Get the file size in bytes
|
||||
$fileSizeBytes = filesize($databasePath);
|
||||
// Get the file size in bytes
|
||||
$fileSizeBytes = filesize($databasePath);
|
||||
|
||||
// Convert the file size to human-readable formats
|
||||
$fileSizeKilobytes = $fileSizeBytes / 1024; // KB
|
||||
$fileSizeMegabytes = $fileSizeKilobytes / 1024; // MB
|
||||
// Convert the file size to human-readable formats
|
||||
$fileSizeKilobytes = $fileSizeBytes / 1024; // KB
|
||||
$fileSizeMegabytes = $fileSizeKilobytes / 1024; // MB
|
||||
|
||||
// Query the number of records in the `data` table
|
||||
$query = "SELECT COUNT(*) AS total_records FROM data";
|
||||
$result = $db->query($query);
|
||||
$recordCount = $result ? $result->fetch(PDO::FETCH_ASSOC)['total_records'] : 0;
|
||||
// Query the number of records in the `data` table
|
||||
$query = "SELECT COUNT(*) AS total_records FROM data";
|
||||
$result = $db->query($query);
|
||||
$recordCount = $result ? $result->fetch(PDO::FETCH_ASSOC)['total_records'] : 0;
|
||||
|
||||
// Prepare the JSON response
|
||||
$data = [
|
||||
'path' => $databasePath,
|
||||
'size_bytes' => $fileSizeBytes,
|
||||
'size_kilobytes' => round($fileSizeKilobytes, 2),
|
||||
'size_megabytes' => round($fileSizeMegabytes, 2),
|
||||
'data_table_records' => $recordCount
|
||||
];
|
||||
// Prepare the JSON response
|
||||
$data = [
|
||||
'path' => $databasePath,
|
||||
'size_bytes' => $fileSizeBytes,
|
||||
'size_kilobytes' => round($fileSizeKilobytes, 2),
|
||||
'size_megabytes' => round($fileSizeMegabytes, 2),
|
||||
'data_table_records' => $recordCount
|
||||
];
|
||||
|
||||
// Output the JSON response
|
||||
echo json_encode($data, JSON_PRETTY_PRINT);
|
||||
} catch (PDOException $e) {
|
||||
// Handle database connection errors
|
||||
// Output the JSON response
|
||||
echo json_encode($data, JSON_PRETTY_PRINT);
|
||||
} catch (PDOException $e) {
|
||||
// Handle database connection errors
|
||||
echo json_encode([
|
||||
'error' => 'Database query failed: ' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
// Handle error if the file doesn't exist
|
||||
echo json_encode([
|
||||
'error' => 'Database query failed: ' . $e->getMessage()
|
||||
'error' => 'Database file not found',
|
||||
'path' => $databasePath
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
// Handle error if the file doesn't exist
|
||||
echo json_encode([
|
||||
'error' => 'Database file not found',
|
||||
'path' => $databasePath
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<div class="col-lg-6 col-12">
|
||||
<div class="card" style="height: 80vh;">
|
||||
<div class="card-header">
|
||||
Loop logs <button type="submit" class="btn btn-secondary btn-sm" onclick="clear_loopLogs()">Clear</button>
|
||||
Master logs <button type="submit" class="btn btn-secondary btn-sm" onclick="clear_loopLogs()">Clear</button>
|
||||
|
||||
</div>
|
||||
<div class="card-body overflow-auto" id="card_loop_content">
|
||||
@@ -110,7 +110,7 @@
|
||||
const loop_card_content = document.getElementById('card_loop_content');
|
||||
const boot_card_content = document.getElementById('card_boot_content');
|
||||
|
||||
fetch('../logs/loop.log')
|
||||
fetch('../logs/master.log')
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch the log file.');
|
||||
|
||||
Reference in New Issue
Block a user