projects
/
ampy.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
56c303e
)
graph: Added support for days and steps
author
Nirgal
<contact_ampy@nirgal.com>
Wed, 16 Oct 2019 11:10:19 +0000
(11:10 +0000)
committer
Nirgal
<contact_ampy@nirgal.com>
Wed, 16 Oct 2019 11:10:19 +0000
(11:10 +0000)
html/graph.php
patch
|
blob
|
history
diff --git
a/html/graph.php
b/html/graph.php
index 9f6f4e70e9472e6ef806b59b3b37dba970c7de1c..34f73ba30a2b2ee2e36ffb040b7d7880d48e37d0 100644
(file)
--- a/
html/graph.php
+++ b/
html/graph.php
@@
-4,14
+4,16
@@
require("config.php");
$IMGFILE="/tmp/power.svg";
$IMGFILE="/tmp/power.svg";
+$days = array_key_exists('d', $_REQUEST) ? (int)$_REQUEST['d'] : 0;
$hours = array_key_exists('h', $_REQUEST) ? (int)$_REQUEST['h'] : 0;
$minutes = array_key_exists('m', $_REQUEST) ? (int)$_REQUEST['m'] : 0;
$hours = array_key_exists('h', $_REQUEST) ? (int)$_REQUEST['h'] : 0;
$minutes = array_key_exists('m', $_REQUEST) ? (int)$_REQUEST['m'] : 0;
-if (!$hours && !$minutes)
+if (!$
days && !$
hours && !$minutes)
$hours = 1;
$hours = 1;
+$step = array_key_exists('step', $_REQUEST) ? (int)$_REQUEST['step'] : 0;
$params = [
"--daemon", RRDSOCK,
"--imgformat", "SVG",
$params = [
"--daemon", RRDSOCK,
"--imgformat", "SVG",
- "-s", "now-".$hours."h".$minutes."m",
+ "-s", "now-".$
days."d".$
hours."h".$minutes."m",
"--width", "".IMGWIDTH,
"--height", "".IMGHEIGHT,
"--vertical-label", "watts",
"--width", "".IMGWIDTH,
"--height", "".IMGHEIGHT,
"--vertical-label", "watts",
@@
-29,6
+31,10
@@
$params = [
#"LINE:maxwatts#0000FF",
#"GPRINT:maxwatts:Max %6.2lf %sW",
];
#"LINE:maxwatts#0000FF",
#"GPRINT:maxwatts:Max %6.2lf %sW",
];
+if ($step) {
+ $params[] = '--step';
+ $params[] = "$step";
+}
/*header("Content-Type: text/plain");
foreach ($params as $param) echo(escapeshellarg($param)." ");
/*header("Content-Type: text/plain");
foreach ($params as $param) echo(escapeshellarg($param)." ");
@@
-42,6
+48,6
@@
if ($result === FALSE) {
}
header("Content-Type: image/svg+xml");
header("Cache-Control: no-cache, max-age=0, must-revalidate");
}
header("Content-Type: image/svg+xml");
header("Cache-Control: no-cache, max-age=0, must-revalidate");
-header("Refresh: ".(60*(60*
$hours
)+$minutes)/IMGWIDTH);
+header("Refresh: ".(60*(60*
(24*$days+$hours)
)+$minutes)/IMGWIDTH);
readfile($IMGFILE);
?>
readfile($IMGFILE);
?>