# HG changeset patch # User Michiel Broek # Date 1546876003 -3600 # Node ID db4e62482d0b7605d5b4f1a160a0aac80b0b9e72 # Parent a5aa3502310cba6a1a9e51ec970277a8469a41d6 Moved javascript out of mon_node.php diff -r a5aa3502310c -r db4e62482d0b www/js/mon_node.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/js/mon_node.js Mon Jan 07 16:46:43 2019 +0100 @@ -0,0 +1,97 @@ +/***************************************************************************** + * Copyright (C) 2019 + * + * Michiel Broek + * + * This file is part of BMS + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * Brewery Management System istributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ThermFerm; see the file COPYING. If not, write to the Free + * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + *****************************************************************************/ + + +$(document).ready(function () { + + var url = "getnode.php?uuid='" + my_uuid + "'"; + var source = { + datatype: "json", + datafields: [ + { name: 'record', type: 'int' }, + { name: 'uuid', type: 'string' }, + { name: 'node', type: 'string' }, + { name: 'online', type: 'bool' }, + { name: 'group_id', type: 'string' }, + { name: 'hardwaremake', type: 'string' }, + { name: 'hardwaremodel', type: 'string' }, + { name: 'os', type: 'string' }, + { name: 'os_version', type: 'string' }, + { name: 'firmware', type: 'string' }, + { name: 'firstseen', type: 'string' }, + { name: 'lastseen', type: 'string' }, + { name: 'temperature', type: 'float' }, + { name: 'humidity', type: 'float' }, + { name: 'barometer', type: 'float' }, + { name: 'gps_latitude', type: 'float' }, + { name: 'gps_longitude', type: 'float' }, + { name: 'gps_altitude', type: 'float' }, + { name: 'net_address', type: 'string' }, + { name: 'net_ifname', type: 'string' }, + { name: 'net_rssi', type: 'int' } + ], + id: 'record', + url: url + }; + + var dataAdapter = new $.jqx.dataAdapter(source, { + loadComplete: function (records) { + var record = dataAdapter.records[0]; + var html = "
"; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + if (record.online) { + html += ""; + if (record.humidity > 0) { + html += ""; + } + if (record.barometer > 0) { + html += ""; + } + if ((record.gps_latitude != 0) && (record.gps_longitude != 0)) { + html += ""; + } + html += ""; + } + html += ""; + html += ""; + $("#ContentPanel").html(html); + } + }); + + // Get the data immediatly and then at regular intervals to refresh. + dataAdapter.dataBind(); + setInterval(function(){ + dataAdapter.dataBind(); + }, 30000); +}); + diff -r a5aa3502310c -r db4e62482d0b www/mon_node.php --- a/www/mon_node.php Mon Jan 07 16:35:55 2019 +0100 +++ b/www/mon_node.php Mon Jan 07 16:46:43 2019 +0100 @@ -1,83 +1,7 @@ -
Systeem overzicht
Uuid" + record.uuid + "
Systeem" + record.node + "
Online" + record.online + "
Type" + record.group_id + "
Eerst gezien" + record.firstseen + "
Laatst gezien" + record.lastseen + "
Hardware maker" + record.hardwaremake+ "
Hardware model" + record.hardwaremodel+ "
OS" + record.os + " versie: " + record.os_version + "
Firmware" + record.firmware + "
Temperatuur" + record.temperature.toFixed(1) + "°C
Vochtigheid" + record.humidity.toFixed(1) + "%
Luchtdruk" + record.barometer.toFixed(0) + "
GPS"+ record.gps_latitude + " " + record.gps_longitude + " " + record.gps_altitude + "
Netwerk"+ record.net_ifname + " " + record.net_address + "