api structure cleaning 1
This commit is contained in:
1 parent
a8eb4866eb
commit
87cd24234a
2 files changed
+7
-6
No files matched your search
+2
-1
@@ -152,12 +152,13 @@ def get_sensor_details(friendly_date = False):
|
|||||||
first_seen = ts_to_pst_string(sensor.first_seen)
|
first_seen = ts_to_pst_string(sensor.first_seen)
|
||||||
last_seen = ts_to_pst_string(sensor.last_seen)
|
last_seen = ts_to_pst_string(sensor.last_seen)
|
||||||
# print(f"Summary - {sensor.name}")
|
# print(f"Summary - {sensor.name}")
|
||||||
|
sensor_dict = sensor.to_dict()
|
||||||
new_sensor = {
|
new_sensor = {
|
||||||
"name": sensor.name,
|
"name": sensor.name,
|
||||||
"first_seen": first_seen,
|
"first_seen": first_seen,
|
||||||
"last_seen": last_seen,
|
"last_seen": last_seen,
|
||||||
"comment": sensor.comment,
|
"comment": sensor.comment,
|
||||||
"data": sensor.to_dict()
|
**sensor_dict
|
||||||
|
|
||||||
}
|
}
|
||||||
sensor_list.append(new_sensor)
|
sensor_list.append(new_sensor)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
# ---------- Settings ----------
|
# ---------- Settings ----------
|
||||||
date_default_timezone_set('America/Los_Angeles');
|
date_default_timezone_set('America/Los_Angeles');
|
||||||
$api_host = 'http://172.17.0.1';
|
$api_host = 'http://172.20.20.51';
|
||||||
$api_port = 5001; // drive‑health API
|
$api_port = 5001; // drive‑health API
|
||||||
$api_path = '/details'; // endpoint that returns the JSON you showed
|
$api_path = '/details'; // endpoint that returns the JSON you showed
|
||||||
|
|
||||||
@@ -24,7 +24,9 @@ function fetch_json(string $url): ?array
|
|||||||
# ---------- Load data ----------
|
# ---------- Load data ----------
|
||||||
$api_url = "$api_host:$api_port$api_path";
|
$api_url = "$api_host:$api_port$api_path";
|
||||||
$payload = fetch_json($api_url);
|
$payload = fetch_json($api_url);
|
||||||
|
foreach ($payload['sensors'] as $s){
|
||||||
|
echo $s;
|
||||||
|
}
|
||||||
# ---------- Render ----------
|
# ---------- Render ----------
|
||||||
?>
|
?>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
@@ -34,9 +36,7 @@ $payload = fetch_json($api_url);
|
|||||||
<title>Sensor Dashboard</title>
|
<title>Sensor Dashboard</title>
|
||||||
<link rel="stylesheet" href="src/styles.css">
|
<link rel="stylesheet" href="src/styles.css">
|
||||||
<style>
|
<style>
|
||||||
table{border-collapse:collapse;width:100%;margin:1rem 0}
|
.card { max-width: 550px;}
|
||||||
th,td{border:1px solid #ddd;padding:.5rem;text-align:left}
|
|
||||||
th{background:#f4f4f4}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in new issue
Block a user