forked from ph2lb/LoRaWAN_TTN_Env
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttnlora_env_chart.php
119 lines (104 loc) · 2.85 KB
/
ttnlora_env_chart.php
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
<html>
<?php
// include the global vars
// default
$filter_id = "0004a30b001ad790";
$filter_from = NULL;
$filter_to = NULL;
if (isset($_GET["id"]))
{
$filter_id = $_GET["id"];
}
if (isset($_GET["to"]))
{
$filter_to = $_GET["to"];
}
else
{
$filter_to = new DateTime();
$filter_to = $filter_to->format("Y-m-d H:i:s");
}
if (isset($_GET["from"]))
{
$filter_from = $_GET["from"];
}
else
{
$dt = new DateTime();
$dt->modify("-1 day");
$filter_from = $dt;
$filter_from = $filter_from->format("Y-m-d H:i:s");
}
echo'<script src="./ttnlora_env_last_aw.php?id='.$filter_id.'" type="text/javascript"></script>';
echo '<script type="text/javascript">';
echo 'var filter_id = "' . $filter_id . '";';
echo 'var filter_from = "' . $filter_from . '";';
echo 'var filter_to = "' . $filter_to . '";';
echo '</script>';
?>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>TTN Enviromental chart</title>
<!-- Styles -->
<style>
#chartdiv {
width : 80%;
height : 500px;
}
</style>
<!-- Resources -->
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/plugins/dataloader/dataloader.min.js"></script>
<!-- <script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script> -->
<link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css" type="text/css" media="all" />
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
</head>
<body>
<center>
<h3>TTN sensor chart map</h3>
<?php
echo '<p>For TTN sensor : ' . $filter_id ;
echo ' from : '. $filter_from .' to : '. $filter_to ;
echo '</p>';
echo '<p>Switch view to last : ';
// create new span
$view_to = new DateTime();
$view_to = $view_to->format("Y-m-d H:i:s");
$days = array(-1, -2, -7, -14, -28);
foreach($days as $span)
{
$dt = new DateTime();
$dt->modify($span .' day');
$view_from = $dt;
$view_from = $view_from->format("Y-m-d H:i:s");
echo '<a href="ttnlora_env_chart.php?id='. $filter_id .'&from='. $view_from .'&to='. $view_to .'">['. $span*-1 .' days]</a> ';
}
echo '<a href="ttnlora_env_map.php">(back to map)</a> ';
echo '</p>';
?>
</center>
<!-- HTML -->
<div id="chartdiv"></div>
<script src="./ttnlora_env_chart_embedded.js"></script>
<style>
table {
font-family: Arial;
border: 1px solid #ccc;
border-collapse: collapse;
}
table td, table th {
padding: 5px 9px;
border: 1px solid #eee;
text-align: left;
}
table tr:nth-child(even) td {
background: #eee;
}
</style>
<div><h2>Last alarms and warnings</h2></div>
<div><i>Open and last 24 hours.</i></div>
<div id="awdatatable"></div>
<script src="./ttnlora_env_map_table_aw.js" type="text/javascript"></script>
</body>
</html>