From f984a6b27d84fd37ee1800a7733707e74919181f Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Wed, 6 May 2009 06:59:27 +0000 Subject: [PATCH] Attributes inn title & co git-svn-id: https://svn.fhem.de/fhem/trunk@370 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/webfrontend/pgm2/98_SVG.pm | 21 ++++++--- fhem/webfrontend/pgm2/README | 77 --------------------------------- 2 files changed, 14 insertions(+), 84 deletions(-) delete mode 100644 fhem/webfrontend/pgm2/README diff --git a/fhem/webfrontend/pgm2/98_SVG.pm b/fhem/webfrontend/pgm2/98_SVG.pm index b4fd91c01..108a5d8c0 100755 --- a/fhem/webfrontend/pgm2/98_SVG.pm +++ b/fhem/webfrontend/pgm2/98_SVG.pm @@ -8,7 +8,7 @@ use POSIX; -sub SVG_render($$$$$$$); +sub SVG_render($$$$$); sub time_to_sec($); sub fmtTime($$); @@ -24,20 +24,25 @@ SVG_Initialize($) ##################################### sub -SVG_render($$$$$$$) +SVG_render($$$$$) { - my ($file, $wh, $from, $to, $confp, $dp, $plot) = @_; + my ($from, $to, $confp, $dp, $plot) = @_; - my ($ow,$oh) = split(",", $wh); # Original width my $th = 16; # "Font" height my ($x, $y) = (3*$th, 1.2*$th); # Rect offset - my ($w, $h) = ($ow-2*$x, $oh-2*$y); # Rect size my %conf; # gnuplot file settings # Convert the configuration to a "readable" form -> array to hash map { chomp; my @a=split(" ",$_, 3); if($a[0] && $a[0] eq "set") { $conf{$a[1]} = $a[2]; } } @{$confp}; + my $ps = "800,400"; + $ps = $1 if($conf{terminal} =~ m/.*size[ ]*([^ ]*)/); + $conf{title} =~ s/'//g; + + my ($ow,$oh) = split(",", $ps); # Original width + my ($w, $h) = ($ow-2*$x, $oh-2*$y); # Rect size + # Html Header pO "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; pO "<?xml-stylesheet href=\"$__ME/svg_style.css\" type=\"text/css\"?>\n"; @@ -50,7 +55,7 @@ SVG_render($$$$$$$) my ($off1,$off2) = ($ow/2, 3*$y/4); pO "<text x=\"$off1\" y=\"$off2\" - class=\"title\" text-anchor=\"middle\">$file</text>\n"; + class=\"title\" text-anchor=\"middle\">$conf{title}</text>\n"; my $t = ($conf{ylabel} ? $conf{ylabel} : ""); $t =~ s/"//g; @@ -105,7 +110,6 @@ SVG_render($$$$$$$) $l = substr($$dp, $dpoff, $ndpoff-$dpoff); } $dpoff = $ndpoff+1; - if($l =~ m/^#/) { my $a = $axes[$idx]; $hmin{$a} = $min if(!defined($hmin{$a}) || $hmin{$a} > $min); @@ -352,6 +356,9 @@ sub time_to_sec($) { my ($str) = @_; + if(!$str) { + return 0; + } my ($y,$m,$d,$h,$mi,$s) = split("[-_:]", $str); $s = 0 if(!$s); $mi= 0 if(!$mi); diff --git a/fhem/webfrontend/pgm2/README b/fhem/webfrontend/pgm2/README deleted file mode 100644 index f11f79f9a..000000000 --- a/fhem/webfrontend/pgm2/README +++ /dev/null @@ -1,77 +0,0 @@ -Installation: -============= -- copy the gif files to the destination directory - cp *.gif /home/httpd/icons -- copy docs/commandref.html to the doc directory - cp ../..docs/commandref.html /home/httpd/html -- check if the above directories are set correctly in 01_FHEMWEB.pm - vi 01_FHEMWEB.pm -- copy 01_FHEMWEB.pm to the fhem module directory - cp *.pm /usr/local/lib/FHEM -- restart fhem.pl -- define a new FHEMWEB instance in fhem - define WEB FHEMWEB 8080 global - -Now you can access it from the web browser via - http://<yourhost>:8080/fhem - -Additional features: -==================== -- Rooms: If you have more than 10 devices/logs/notifies/etc. then it make sense - to divide them into "rooms". For this purpose assign the attribute room to - each device. -- hide devices: Devices in the room "hidden" will not be shown. Devices without - a room attribute go to the room "Unsorted". -- Title: You can set the title of the webpage with - attr global title "My-Title" -- If you set the attribute model of an FS20 device, and the device is an - FS20-sender, then you will not be able to switch it from the frontend. -- You can first set an attribute to an arbitrary (wrong) value, then click on - the attribute: you will be guided to the correct place in the documentation; - now you can chnage the attribute value to the correct one. -- To log the HTTP requests in the logfile, either set the global verbose to a - value greater than 3 or set the HTTP device loglevel to a lower value - attr <FHEMWEBDEVICE> loglevel 2 - - -Graphs for plotted logs (gnuplot): -================================== -- Set FHEMWEB_gnuplot in 01_FHEMWEB.pm to the gnuplot binary -- copy the gnuplot files to the gnuplot scripts to the gnuplot directory - cp *.gplot /home/httpd/cgi-bin -- copy 99_weblink.pm to the FHEM modules directory and restart fhem.pl -- assign the logtype attribute to your FileLog device. - Look at the XXX.gplot file, how the FileLog should be defined, and - set the corresponding logtype attribute to XXX. - You can use more than one logtype, see commandref.html for more. -- To show more than one plot on one page, convert them to weblink, and assign - each weblink the same room. If a weblink is created for the CURRENT logfile, - it will always use the CURRENT logfile. - -Password/HTTPS: -=============== -- These features are implemented by apache, and apache must be configured to - redirect the page to 01_FHEMWEB.pm. For this purpose add the following lines - to your httpd.conf: - - <Proxy *> - AuthType Basic - AuthName "Password Required" - AuthUserFile /home/httpd/etc/passwd - Require valid-user - Allow from 127.0.0.1 - </Proxy> - ProxyPass /fhem http://localhost:<FHEMPORT>/fhem - ProxyPassReverse /fhem http://localhost:<FHEMPORT>/fhem - - and then restart httpd with apachectl graceful. To create the password file, - execute htpasswd -c /home/httpd/etc/passwd <username> - -- To enable HTTPS, please check the web. - In essence: - - Edit httpd.conf, add: - LoadModule ssl_module lib/apache/mod_ssl.so - Include /etc/httpd/conf/ssl.conf - - Create a server certificate - - Start httpd with the startssl option (SSL or the like must be set in one - of your system files, look at /etc/init.d/httpd).