www/js/mon_node.js

changeset 181
db4e62482d0b
child 494
af28ebe4a779
equal deleted inserted replaced
180:a5aa3502310c 181:db4e62482d0b
1 /*****************************************************************************
2 * Copyright (C) 2019
3 *
4 * Michiel Broek <mbroek at mbse dot eu>
5 *
6 * This file is part of BMS
7 *
8 * This is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * Brewery Management System istributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *****************************************************************************/
22
23
24 $(document).ready(function () {
25
26 var url = "getnode.php?uuid='" + my_uuid + "'";
27 var source = {
28 datatype: "json",
29 datafields: [
30 { name: 'record', type: 'int' },
31 { name: 'uuid', type: 'string' },
32 { name: 'node', type: 'string' },
33 { name: 'online', type: 'bool' },
34 { name: 'group_id', type: 'string' },
35 { name: 'hardwaremake', type: 'string' },
36 { name: 'hardwaremodel', type: 'string' },
37 { name: 'os', type: 'string' },
38 { name: 'os_version', type: 'string' },
39 { name: 'firmware', type: 'string' },
40 { name: 'firstseen', type: 'string' },
41 { name: 'lastseen', type: 'string' },
42 { name: 'temperature', type: 'float' },
43 { name: 'humidity', type: 'float' },
44 { name: 'barometer', type: 'float' },
45 { name: 'gps_latitude', type: 'float' },
46 { name: 'gps_longitude', type: 'float' },
47 { name: 'gps_altitude', type: 'float' },
48 { name: 'net_address', type: 'string' },
49 { name: 'net_ifname', type: 'string' },
50 { name: 'net_rssi', type: 'int' }
51 ],
52 id: 'record',
53 url: url
54 };
55
56 var dataAdapter = new $.jqx.dataAdapter(source, {
57 loadComplete: function (records) {
58 var record = dataAdapter.records[0];
59 var html = "<div id='node_table'>";
60 html += "<table style='width: 100%; padding: 10px;'>";
61 html += "<tr><th colspan=2>Systeem overzicht</th></tr>";
62 html += "<tr><td>Uuid</td><td>" + record.uuid + "</td></tr>";
63 html += "<tr><td>Systeem</td><td>" + record.node + "</td></tr>";
64 html += "<tr><td>Online</td><td>" + record.online + "</td></tr>";
65 html += "<tr><td>Type</td><td>" + record.group_id + "</td></tr>";
66 html += "<tr><td>Eerst gezien</td><td>" + record.firstseen + "</td></tr>";
67 html += "<tr><td>Laatst gezien</td><td>" + record.lastseen + "</td></tr>";
68 html += "<tr><td>Hardware maker</td><td>" + record.hardwaremake+ "</td></tr>";
69 html += "<tr><td>Hardware model</td><td>" + record.hardwaremodel+ "</td></tr>";
70 html += "<tr><td>OS</td><td>" + record.os + " versie: " + record.os_version + "</td></tr>";
71 html += "<tr><td>Firmware</td><td>" + record.firmware + "</td></tr>";
72 if (record.online) {
73 html += "<tr><td>Temperatuur</td><td>" + record.temperature.toFixed(1) + "&deg;C</td></tr>";
74 if (record.humidity > 0) {
75 html += "<tr><td>Vochtigheid</td><td>" + record.humidity.toFixed(1) + "%</td></tr>";
76 }
77 if (record.barometer > 0) {
78 html += "<tr><td>Luchtdruk</td><td>" + record.barometer.toFixed(0) + "</td></tr>";
79 }
80 if ((record.gps_latitude != 0) && (record.gps_longitude != 0)) {
81 html += "<tr><td>GPS</td><td>"+ record.gps_latitude + " " + record.gps_longitude + " " + record.gps_altitude + "</td></tr>";
82 }
83 html += "<tr><td>Netwerk</td><td>"+ record.net_ifname + " " + record.net_address + "</td></tr>";
84 }
85 html += "</<table>";
86 html += "</div>";
87 $("#ContentPanel").html(html);
88 }
89 });
90
91 // Get the data immediatly and then at regular intervals to refresh.
92 dataAdapter.dataBind();
93 setInterval(function(){
94 dataAdapter.dataBind();
95 }, 30000);
96 });
97

mercurial