From: Brian Flowers Date: Mon, 10 Oct 2016 19:22:22 +0000 (-0400) Subject: Added display of configured options X-Git-Url: http://git.slightlycyberpunk.com%2C%20git.slightlycyberpunk.com/git/?a=commitdiff_plain;h=efc10507e5cc29aa70a7f28d5c3d3e634fac0f56;p=bdsm-web.git Added display of configured options --- diff --git a/index.php b/index.php index 4f74185..60b6b10 100755 --- a/index.php +++ b/index.php @@ -95,33 +95,37 @@ foreach ($hosts as $host) context.lineWidth = 2; query("SELECT DISTINCT attribute FROM MEASUREMENTS WHERE host='$host'"); + $result = $db_handle->query("SELECT attribute, name FROM bdsmweb WHERE host='$host' AND graph=1"); $attributes = Array(); while($attribute = $result->fetchArray(SQLITE3_ASSOC)) + { + print_r($attribute); if ( $attribute['attribute'] ) - array_push($attributes, $attribute['attribute']); + $attributes[$attribute['attribute']] = $attribute['name']; + } $i = 0; - foreach ($attributes as $attribute) + foreach (array_keys($attributes) as $attribute) { - $query = "SELECT timestamp,value ". + $query = "SELECT printf('%d', timestamp) AS timestamp,value ". "FROM MEASUREMENTS ". "WHERE host='$host' AND attribute='$attribute' ". "ORDER BY timestamp DESC LIMIT 100"; -echo "// $query \n"; + $result = $db_handle->query($query); echo " context.beginPath();\n"; echo " context.strokeStyle = '$colors[$i]';\n"; $record = $result->fetchArray(SQLITE3_ASSOC); $final = $record['timestamp']; - echo " context.moveTo(0, ".$record['value'].");\n"; + echo " context.moveTo(0, ".sprintf("%d", $record['value']"".");\n"; while( $record = $result->fetchArray(SQLITE3_ASSOC) ) { - echo " context.lineTo(".($final - $record['timestamp']).", ".(400-$record['value']*4).");\n"; + echo " context.lineTo(".sprintf("%d", $final - $record['timestamp']).", ".(400-$record['value']*4).");\n"; } echo " context.stroke();\n"; - echo " context.strokeText('$attribute', 300, ".(395-15*$i).");"; + $name = $attributes[$attribute]; + echo " context.strokeText('$name', 300, ".(395-15*$i).");"; $i+=1; } ?>