Database page: affichage npm_status dans table NPM + export CSV
Colonne Status avec badge vert 'OK' si 0, badge orange '0xXX' si erreur. Inclus dans le download CSV. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -327,6 +327,7 @@ function get_data_sqlite(table, limit, download , startDate = "", endDate = "")
|
|||||||
<th>PM10</th>
|
<th>PM10</th>
|
||||||
<th>Temperature (°C)</th>
|
<th>Temperature (°C)</th>
|
||||||
<th>Humidity (%)</th>
|
<th>Humidity (%)</th>
|
||||||
|
<th>Status</th>
|
||||||
`;
|
`;
|
||||||
} else if (table === "data_BME280") {
|
} else if (table === "data_BME280") {
|
||||||
tableHTML += `
|
tableHTML += `
|
||||||
@@ -400,6 +401,10 @@ function get_data_sqlite(table, limit, download , startDate = "", endDate = "")
|
|||||||
tableHTML += `<tr${rowClass}>`;
|
tableHTML += `<tr${rowClass}>`;
|
||||||
|
|
||||||
if (table === "data_NPM") {
|
if (table === "data_NPM") {
|
||||||
|
const statusVal = parseInt(columns[6]) || 0;
|
||||||
|
const statusBadge = statusVal === 0
|
||||||
|
? '<span class="badge text-bg-success">OK</span>'
|
||||||
|
: `<span class="badge text-bg-warning">0x${statusVal.toString(16).toUpperCase().padStart(2,'0')}</span>`;
|
||||||
tableHTML += `
|
tableHTML += `
|
||||||
<td>${columns[0]}</td>
|
<td>${columns[0]}</td>
|
||||||
<td>${columns[1]}</td>
|
<td>${columns[1]}</td>
|
||||||
@@ -407,6 +412,7 @@ function get_data_sqlite(table, limit, download , startDate = "", endDate = "")
|
|||||||
<td>${columns[3]}</td>
|
<td>${columns[3]}</td>
|
||||||
<td>${columns[4]}</td>
|
<td>${columns[4]}</td>
|
||||||
<td>${columns[5]}</td>
|
<td>${columns[5]}</td>
|
||||||
|
<td>${statusBadge}</td>
|
||||||
`;
|
`;
|
||||||
} else if (table === "data_BME280") {
|
} else if (table === "data_BME280") {
|
||||||
tableHTML += `
|
tableHTML += `
|
||||||
@@ -519,7 +525,7 @@ function downloadCSV(response, table) {
|
|||||||
|
|
||||||
// Add headers based on table type
|
// Add headers based on table type
|
||||||
if (table === "data_NPM") {
|
if (table === "data_NPM") {
|
||||||
csvContent += "TimestampUTC,PM1,PM2.5,PM10,Temperature_sensor,Humidity_sensor\n";
|
csvContent += "TimestampUTC,PM1,PM2.5,PM10,Temperature_sensor,Humidity_sensor,npm_status\n";
|
||||||
} else if (table === "data_BME280") {
|
} else if (table === "data_BME280") {
|
||||||
csvContent += "TimestampUTC,Temperature (°C),Humidity (%),Pressure (hPa)\n";
|
csvContent += "TimestampUTC,Temperature (°C),Humidity (%),Pressure (hPa)\n";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user