Added maintenance tabs for units and profiles

Thu, 24 Jul 2014 17:42:34 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 24 Jul 2014 17:42:34 +0200
changeset 130
25158b08843f
parent 129
2817c65fba89
child 131
528dc0bb81ab

Added maintenance tabs for units and profiles

www-thermferm/getunits.php file | annotate | diff | comparison | revisions
www-thermferm/js/maintenance_panel.js file | annotate | diff | comparison | revisions
www-thermferm/maintenance_panel.php file | annotate | diff | comparison | revisions
--- /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 @@
+<?php
+/*****************************************************************************
+ * Copyright (C) 2014
+ *   
+ * Michiel Broek <mbroek at mbse dot eu>
+ *
+ * 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;
+
+?>
--- 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 }
+        ]
+    });
 });
--- 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 .= '       <div id="jqxgrid_bus" style="margin-left: 8px; margin-top: 6px;"></div>'.PHP_EOL;
     $outstr .= '      </div>'.PHP_EOL;
     $outstr .= '      <div>'.PHP_EOL;
-    $outstr .= '       Profiles'.PHP_EOL;
+    $outstr .= '       <div id="jqxgrid_profiles" style="margin-left: 8px; margin-top: 6px;"></div>'.PHP_EOL;
     $outstr .= '      </div>'.PHP_EOL;
     $outstr .= '      <div>'.PHP_EOL;
-    $outstr .= '       Units'.PHP_EOL;
+    $outstr .= '       <div id="jqxgrid_units" style="margin-left: 8px; margin-top: 6px;"></div>'.PHP_EOL;
     $outstr .= '      </div>'.PHP_EOL;
     $outstr .= '     </div>'.PHP_EOL;
     $outstr .= '     <input type="button" id="maintenance_ok" value="Dismiss" style="margin-top: 5px; margin-left: 365px" />'.PHP_EOL;

mercurial