From ad453f5cc5570c8b27b8390c484633316829646e Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Wed, 19 Jun 2013 16:17:13 +0000 Subject: [PATCH] longpollSVG added git-svn-id: https://svn.fhem.de/fhem/trunk@3307 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/01_FHEMWEB.pm | 28 ++++++++++++++++++++++------ fhem/FHEM/92_FileLog.pm | 5 ++--- fhem/FHEM/98_SVG.pm | 12 +++++++++--- fhem/www/pgm2/fhemweb.js | 36 ++++++++++++++++++++++++++++++++---- 5 files changed, 66 insertions(+), 16 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 5bbc5f002..33c8e35dc 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII - SVN + - feature: FHEMWEB: longpoll is default now, longpollSVG (default off) added - feature: HUEDevice: allow usage of openautomation svg icons - feature: FHEMWEB: svg icons / iconPath / www/images/openautomation added - feature: FHEMWEB: SVGcache attribute & clearSvgCache set command added diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm index c6e23c5c3..7f198dc5e 100755 --- a/fhem/FHEM/01_FHEMWEB.pm +++ b/fhem/FHEM/01_FHEMWEB.pm @@ -118,8 +118,8 @@ FHEMWEB_Initialize($) "plotmode:gnuplot,gnuplot-scroll,SVG plotsize endPlotToday:1,0 plotfork ". "stylesheetPrefix touchpad:deprecated smallscreen:deprecated ". "basicAuth basicAuthMsg hiddenroom hiddengroup HTTPS allowfrom CORS:0,1 ". - "refresh longpoll:1,0 redirectCmds:0,1 reverseLogs:0,1 menuEntries ". - "roomIcons SVGcache iconPath"; + "refresh longpoll:0,1 longpollSVG:1,0 redirectCmds:0,1 reverseLogs:0,1 ". + "menuEntries roomIcons SVGcache iconPath"; ############### # Initialize internal structures @@ -550,7 +550,7 @@ FW_answerCall($) FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/svg.js") if($FW_plotmode eq "SVG"); FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/fhemweb.js"); - my $onload = AttrVal($FW_wname, "longpoll", undef) ? + my $onload = AttrVal($FW_wname, "longpoll", 1) ? "onload=\"FW_delayedStart()\"" : ""; FW_pO "\n"; @@ -1527,7 +1527,7 @@ FW_showLog($) FW_fC("get $d $file INT $f $t " . join(" ", @{$flog}), 1); ($cfg, $plot) = FW_substcfg(1, $wl, $cfg, $plot, $file, ""); $ret = SVG_render($wl, $f, $t, $cfg, - $internal_data, $plot, $FW_wname, $FW_cssdir); + $internal_data, $plot, $FW_wname, $FW_cssdir, $flog); FW_pO $ret; if($SVGcache) { mkdir($cDir) if(! -d $cDir); @@ -2319,7 +2319,7 @@ FW_roomStatesForInform($) foreach my $dn (@rl) { my ($allSet, $cmdlist, $txt) = FW_devState($dn, "", \%extPage); $data .= "$dn<<$defs{$dn}{STATE}<<$txt\r\n" - if($defs{$dn} && $defs{$dn}{STATE}); + if($defs{$dn} && $defs{$dn}{STATE} && $defs{$dn}{TYPE} ne "weblink"); } return $data; } @@ -2463,7 +2463,7 @@ FW_devState($$@) } $link .= "&room=$room"; } - if(AttrVal($FW_wname, "longpoll", undef)) { + if(AttrVal($FW_wname, "longpoll", 1)) { $txt = "$txt"; } elsif($FW_ss || $FW_tp) { @@ -2930,9 +2930,25 @@ FW_dropdownFn() In this mode status update is refreshed more or less instantaneously, and state change (on/off only) is done without requesting a complete refresh from the server. + Default is on.
+ +
  • longpollSVG
    + Reloads an SVG weblink, if an event should modify its content. Since + an exact determination of the affected events is too complicated, we + need some help from the #FileLog definition in the .gplot file: the + filter used there (second parameter) must either contain only the + deviceName or have the form deviceName.event or deviceName.*. This is + always the case when using the Plot + editor. The SVG will be reloaded for any event triggered by + this deviceName. + Default is off. +
  • +
    + +
  • redirectCmds
    Clear the browser URL window after issuing the command by redirecting diff --git a/fhem/FHEM/92_FileLog.pm b/fhem/FHEM/92_FileLog.pm index e73a40ea1..688afa9c0 100755 --- a/fhem/FHEM/92_FileLog.pm +++ b/fhem/FHEM/92_FileLog.pm @@ -383,9 +383,9 @@ FileLog_Get($@) $internal = 1; } - + if($inf eq "-") { - # In case the plot is drawn afte midnight, before the first event is logged. + # In case now is after midnight, before the first event is logged. FileLog_Switch($hash); $inf = $hash->{currentlogfile}; @@ -414,7 +414,6 @@ FileLog_Get($@) if(!-f $linf) { # ... or in the archivelog $linf = AttrVal($hash->{NAME},"archivedir",".") ."/". $inf; - $linf = ""; } $inf = $linf; } diff --git a/fhem/FHEM/98_SVG.pm b/fhem/FHEM/98_SVG.pm index 6835380eb..33672b6b6 100755 --- a/fhem/FHEM/98_SVG.pm +++ b/fhem/FHEM/98_SVG.pm @@ -9,7 +9,7 @@ use POSIX; -sub SVG_render($$$$$$$$); +sub SVG_render($$$$$$$$$); sub SVG_time_to_sec($); sub SVG_fmtTime($$); sub SVG_time_align($$); @@ -76,7 +76,7 @@ SVG_digestConf($$) ##################################### sub -SVG_render($$$$$$$$) +SVG_render($$$$$$$$$) { my $name = shift; # e.g. wl_8 my $from = shift; # e.g. 2008-01-01 @@ -86,6 +86,7 @@ SVG_render($$$$$$$$) my $plot = shift; # Plot lines from the .gplot file my $parent_name = shift; # e.g. FHEMWEB instance name my $parent_dir = shift; # FW_dir + my $flog = shift; # #FileLog lines, as array pointer $SVG_RET=""; @@ -103,12 +104,17 @@ SVG_render($$$$$$$$) my ($ow,$oh) = split(",", $ps); # Original width my ($w, $h) = ($ow-2*$x, $oh-2*$y); # Rect size + # Keep only the Filter part of the #FileLog + $flog = join(" ", map { my @a=split(":",$_); + $a[1]=~s/\.[^\.]*$//; $a[1]; } @{$flog}); + $flog = AttrVal($parent_name, "longpollSVG", 0) ? "flog=\"$flog\"" : ""; + ###################### # Html Header SVG_pO ''; SVG_pO ''; SVG_pO ''; + 'xmlns:xlink="http://www.w3.org/1999/xlink" '.$flog.'>'; my $prf = AttrVal($parent_name, "stylesheetPrefix", ""); SVG_pO "