# HG changeset patch # User Michiel Broek # Date 1406216554 -7200 # Node ID 25158b08843f7da5283175c2638e47a823ec6fb5 # Parent 2817c65fba8902ebc6e27dc3fa1f767df3565d71 Added maintenance tabs for units and profiles diff -r 2817c65fba89 -r 25158b08843f www-thermferm/getunits.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www-thermferm/getunits.php Thu Jul 24 17:42:34 2014 +0200 @@ -0,0 +1,64 @@ + + * + * This file is part of ThermFerm + * + * 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. + * + * ThermFerm is distributed 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. + *****************************************************************************/ + +require_once('utilities.php'); + + +$sock = open_socket(); +if ($sock == false) { + echo ""; + return; +} + +socket_write($sock, "LIST", 4096); +$answer = ""; +while (1) { + $line = socket_read($sock, 4096); + if ($line === '') + break; + $answer .= $line; +} +socket_close($sock); +$arr = explode("\r\n", $answer); + + +$row = '['; + +/* We don't use json_encode because it doesn't work for our purpose */ +if (startsWith($arr[0], "212")) { + $j = 1; + while (1) { + if (strcmp($arr[$j], ".") == 0) + break; + if ($j > 1) + $row .= ','; + $f = explode(",", $arr[$j]); + $row .= '{"Id":"'.$f[0].'","UUID":"'.$f[1].'","Name":"'.$f[2].'","Mode":"'.$f[3].'"}'; + $j++; + } +} + +$row .= ']'; +echo $row; + +?> diff -r 2817c65fba89 -r 25158b08843f www-thermferm/js/maintenance_panel.js --- a/www-thermferm/js/maintenance_panel.js Wed Jul 23 21:34:02 2014 +0200 +++ b/www-thermferm/js/maintenance_panel.js Thu Jul 24 17:42:34 2014 +0200 @@ -21,7 +21,10 @@ *****************************************************************************/ $(document).ready(function () { - var source_bus = { + /* + * 1-Wire bus + */ + var source_bus = { datatype: "json", datafields: [ { name: 'Address', type: 'string' }, @@ -44,4 +47,58 @@ { text: 'Description', datafield: 'Description', minwidth: 120 } ] }); + + /* + * Profiles + */ + var source_profiles = { + datatype: "json", + datafields: [ + { name: 'Id', type: 'int' }, + { name: 'UUID', type: 'string' }, + { name: 'Name', type: 'string' }, + { name: 'Steps', type: 'int' } + ], + url: 'getprofiles.php' + }; + var dataAdapter_profiles = new $.jqx.dataAdapter(source_profiles); + $("#jqxgrid_profiles").jqxGrid( { + width: 770, height: 280, + source: dataAdapter_profiles, + theme: 'ui-redmond', + columnsresize: true, + columns: [ + { text: 'Id', datafield: 'Id', width: 40 }, + { text: 'UUID', datafield: 'UUID', width: 280 }, + { text: 'Name', datafield: 'Name', minwidth: 120 }, + { text: 'Steps', datafield: 'Steps', width: 50 } + ] + }); + + /* + * Units + */ + var source_units = { + datatype: "json", + datafields: [ + { name: 'Id', type: 'int' }, + { name: 'UUID', type: 'string' }, + { name: 'Name', type: 'string' }, + { name: 'Mode', type: 'string' } + ], + url: 'getunits.php' + }; + var dataAdapter_units = new $.jqx.dataAdapter(source_units); + $("#jqxgrid_units").jqxGrid( { + width: 770, height: 280, + source: dataAdapter_units, + theme: 'ui-redmond', + columnsresize: true, + columns: [ + { text: 'Id', datafield: 'Id', width: 40 }, + { text: 'UUID', datafield: 'UUID', width: 280 }, + { text: 'Name', datafield: 'Name', minwidth: 120 }, + { text: 'Mode', datafield: 'Mode', width: 70 } + ] + }); }); diff -r 2817c65fba89 -r 25158b08843f www-thermferm/maintenance_panel.php --- a/www-thermferm/maintenance_panel.php Wed Jul 23 21:34:02 2014 +0200 +++ b/www-thermferm/maintenance_panel.php Thu Jul 24 17:42:34 2014 +0200 @@ -54,10 +54,10 @@ $outstr .= '
'.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= '
'.PHP_EOL; - $outstr .= ' Profiles'.PHP_EOL; + $outstr .= '
'.PHP_EOL; $outstr .= '
'.PHP_EOL; $outstr .= '
'.PHP_EOL; - $outstr .= ' Units'.PHP_EOL; + $outstr .= '
'.PHP_EOL; $outstr .= '
'.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL;