/
index.html
167 lines (147 loc) · 7.66 KB
/
index.html
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Purp!</title>
<link rel="icon" href="favicon.ico">
<link rel="apple-touch-icon" sizes="192x192" href="img/icon-192x192.png">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinycolor/1.4.1/tinycolor.min.js" integrity="sha512-RozPeKxKPtXNqvICs7iMDchhJmypo89PxwY6poaAa7TyED7PgwPbBcsAhLwzcEQf/kRwbOnYRvSezQ5CMqHjIA==" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/tinygradient@1.1.2/browser.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" integrity="sha512-qTXRIMyZIFb8iQcfjXWCO8+M5Tbc38Qi5WzdPOYZHIlZpzBHG3L3by84BBBOiRGiEb7KKtAOAs5qYdUiZiQNNQ==" crossorigin="anonymous"></script>
<!-- development version, includes helpful console warnings
-->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<!-- production version, optimized for size and speed
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
-->
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.jscharting.com/latest/jscharting.js"></script>
<script src="https://code.jscharting.com/latest/modules/toolbar.js"></script>
<link rel="stylesheet" href="purp.css">
<script type="text/javascript" src="utils.js"></script>
<script type="text/javascript" src="PurpleAirApi.js"></script>
<script type="text/javascript" src="SensorData.js"></script>
<script type="text/javascript" src="purp.js"></script>
</head>
<body onload="main()">
<div id="app">
<div class="app-title">
<img src="img/icon.png" width="32" height="32" title="Purp!" alt="Purp!">
<b>Purp</b>
(<a href="https://www.github.com/MarcinZukowski/purp">github</a>)
<label class="btn btn-info" style="float: right">
<input type="checkbox" class="form-check-input" id="reloadCheck" checked>
Reload every 10 minutes
</label>
</div>
<div v-if="!error">
<table class="main-table">
<tr>
<th>Sensor</th>
<th>Current AQI</th>
<th>Current Temperature</th>
<th>Details</th>
<th>Status</th>
</tr>
<tbody v-for="s in sensors">
<!-- Main row per sensor -->
<tr v-if="!s.error">
<td class="info-sensor">
<div class="stat-map" style="float: right"><a v-bind:href="s.getMapURL()"><img src="img/map-small.png" title="Show map"/></a></div>
<div style="float: left">
<a v-bind:href="s.getInfoURL()"><img src="img/info-small.png" title="Show PurpleAir sensor info"/></a>
</div>
<div class="info-sensor-title">
{{ s.results?.Label }}
<img v-if="s.results?.Hidden == 'true'" src="img/hidden.png" width="32" height="32" title="Sensor hidden"/>
</div>
<div class="info-sensor-details">
{{ s.results?.DEVICE_LOCATIONTYPE }}, #{{ s.id }}
</div>
<div v-bind:style="{background: s.color, height: '6px'}">
</div>
</td>
<td class="info-big info-aqi" v-bind:style="{background: s.getStat()?.color, color: s.getStat()?.text}">
<div class="stat-map" style="float: right"><a v-bind:href="s.getStat()?.map"><img src="img/map-small.png" title="Show map"/></a></div>
<div class="info-big-value">{{s.getStat()?.aqi}}</div>
<div class="info-big-pm">{{s.getStat()?.pm}} µg/m3</div>
</td>
<td class="info-big info-temp" v-bind:style="s.getTempCSS()">
<div class="stat-map" style="float: right"><a v-bind:href="s.getTempURL()"><img src="img/map-small.png" title="Show map with temperature"/></a></div>
<div class="info-big-value">{{ s.getTempF() }} °F</div>
</td>
<td class="info-details">
<div style="height: 100%">
<table class="aqi-details">
<tr>
<td v-for="si in statsInfo" v-bind:style="{background: s.getStat(si)?.color, color: s.getStat(si)?.text}">
<div class="stat-map" style="float: right"><a v-bind:href="s.getStat(si)?.map"><img src="img/map-tiny.png" title="Show map"/></a></div>
<div class="stat-label">{{s.getStat(si)?.label}}</div>
<div class="stat-aqi">{{s.getStat(si)?.aqi}}</div>
<div class="stat-pm">{{s.getStat(si)?.pm}} µg/m3</div>
</td>
</tr>
</table>
</div>
</td>
<td class="status">
<div id="status">
Status: {{ s.currentStatus }}
</div>
<button type="button" class="btn btn-info" data-toggle="collapse" v-bind:data-target="`#rawdata${s.id}`">Show raw data</button>
</td>
</tr>
<!-- Raw data, collapsed by default -->
<tr v-if="!s.error" v-bind:id="`rawdata${s.id}`" class="collapse">
<td colspan="5">
<div class="raw-data">
{{ s.results }}
</div>
</td>
</tr>
<!-- Neighbors -->
<tr v-if="!s.error && false" class="neighbors">
<td colspan="3">
Nearby ({{s.getNearbyStat(si)?.count || 0}} devices in {{s.getNearbyStat(si)?.miles || "?"}} mile radius)
</td>
<td>
<table>
<tr>
<td v-for="si in statsInfo" v-bind:style="{background: s.getStat(si)?.color, color: s.getStat(si)?.text}">
<div class="stat-label">{{s.getNearbyStat(si)?.label}}</div>
<div class="stat-aqi">{{s.getNearbyStat(si)?.aqi}}</div>
<div class="stat-pm">{{s.getNearbyStat(si)?.pm}} µg/m3</div>
</td>
</tr>
</table>
</td>
</tr>
<tr v-if="s.error">
<td v-if="s.error" colspan="5" class="error">{{ s.error }}</td>
</tr>
</tbody>
<tr>
<td colspan="5">
<div style="position: relative">
<div id="chart" style="max-width: 100%; height: 400px;margin: 0px auto">
chart
</div>
<div id="chart-bottom" style="position: absolute; bottom: 0; right: 0;">
</div>
</div>
</td>
</tr>
</table>
</div>
<div v-if="error" class="error">
{{error}}
</div>
<div id="log" class="log collapse"></div>
<button id="log-btn" type="button" class="btn" data-toggle="collapse" data-target="#log">Show log</button>
</div>
</body>
</html>