From 7c1d2eab9edf8c5eaa9d62ce99b6671ba07e80c3 Mon Sep 17 00:00:00 2001
From: rudolfkoenig <>
Date: Mon, 22 Apr 2013 18:27:46 +0000
Subject: [PATCH] module dependent summaryFn and detailFn for FHEMWEB
Defineable webCmdFn for FHEMWEB
git-svn-id: https://svn.fhem.de/fhem/trunk@3102 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/CHANGED | 1 +
fhem/FHEM/01_FHEMWEB.pm | 438 +++++++++++++++-------------------------
fhem/FHEM/92_FileLog.pm | 37 ++++
fhem/FHEM/98_weblink.pm | 115 ++++++++++-
4 files changed, 316 insertions(+), 275 deletions(-)
diff --git a/fhem/CHANGED b/fhem/CHANGED
index fb528a202..d3e028475 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: module specific summaryFn/detailFn + defineable webCmdFn
- change: ESA2000: adapted device detection , rename readings
- change: stucture triggers on each change, see event-on-change-reading
- feature: PRESENCE: new mode "function" to use own perl functions for
diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm
index f587288fe..6b6984f6c 100755
--- a/fhem/FHEM/01_FHEMWEB.pm
+++ b/fhem/FHEM/01_FHEMWEB.pm
@@ -19,7 +19,6 @@ sub FW_calcWeblink($$);
sub FW_dev2image($);
sub FW_digestCgi($);
sub FW_doDetail($);
-sub FW_dumpFileLog($$$);
sub FW_fatal($);
sub FW_fileList($);
sub FW_htmlEscape($);
@@ -40,7 +39,6 @@ sub FW_select($$$$$@);
sub FW_serveSpecial($$$$);
sub FW_showLog($);
sub FW_showRoom();
-sub FW_showWeblink($$$$);
sub FW_style($$);
sub FW_submit($$@);
sub FW_substcfg($$$$$$);
@@ -59,7 +57,7 @@ use vars qw($FW_gplotdir);# gplot directory for web server: the first
# available from $FW_dir/gplot,$FW_dir
use vars qw($MW_dir); # moddir (./FHEM), needed by edit Files in new
# structure
-use vars qw($FW_ME); # webname (default is fhem), needed by 97_GROUP
+use vars qw($FW_ME); # webname (default is fhem), used by 97_GROUP/weblink
use vars qw($FW_ss); # is smallscreen, needed by 97_GROUP/95_VIEW
use vars qw($FW_tp); # is touchpad (iPad / etc)
use vars qw($FW_sp); # stylesheetPrefix
@@ -68,9 +66,12 @@ use vars qw($FW_sp); # stylesheetPrefix
use vars qw(%FW_types); # device types,
use vars qw($FW_RET); # Returned data (html)
use vars qw($FW_wname); # Web instance
-use vars qw($FW_subdir); # Sub-path in URL for extensions, e.g. 95_FLOORPLAN
+use vars qw($FW_subdir); # Sub-path in URL, used by FLOORPLAN/weblink
use vars qw(%FW_pos); # scroll position
use vars qw($FW_cname); # Current connection name
+use vars qw(%FW_hiddenroom); # hash of hidden rooms, used by weblink
+use vars qw($FW_plotmode);# Global plot mode (WEB attribute), used by weblink
+use vars qw($FW_plotsize);# Global plot size (WEB attribute), used by weblink
my $FW_zlib_checked;
my $FW_use_zlib = 1;
@@ -86,13 +87,10 @@ my $FW_data; # Filecontent from browser when editing a file
my $FW_detail; # currently selected device for detail view
my %FW_devs; # hash of from/to entries per device
my %FW_icons; # List of icons
-my $FW_plotmode; # Global plot mode (WEB attribute)
-my $FW_plotsize; # Global plot size (WEB attribute)
my $FW_RETTYPE; # image/png or the like
my $FW_room; # currently selected room
my %FW_rooms; # hash of all rooms
my %FW_types; # device types, for sorting
-my %FW_hiddenroom; # hash of hidden rooms
my %FW_hiddengroup;# hash of hidden groups
my $FW_inform;
my $FW_XHR; # Data only answer, no HTML
@@ -116,7 +114,7 @@ FHEMWEB_Initialize($)
$hash->{UndefFn} = "FW_Undef";
$hash->{NotifyFn}= "FW_SecurityCheck";
$hash->{AttrList}=
- "loglevel:0,1,2,3,4,5,6 webname fwcompress:0,1 javascripts ".
+ "loglevel:0,1,2,3,4,5,6 webname fwcompress:0,1 ".
"plotmode:gnuplot,gnuplot-scroll,SVG plotsize endPlotToday:1,0 plotfork ".
"stylesheetPrefix touchpad:deprecated smallscreen:deprecated ".
"basicAuth basicAuthMsg hiddenroom hiddengroup HTTPS allowfrom CORS:0,1 ".
@@ -124,10 +122,7 @@ FHEMWEB_Initialize($)
###############
# Initialize internal structures
- addToAttrList("webCmd");
- addToAttrList("icon");
- addToAttrList("devStateIcon");
- addToAttrList("sortby");
+ map { addToAttrList($_) } ( "webCmd", "icon", "devStateIcon", "sortby");
InternalTimer(time()+60, "FW_closeOldClients", 0, 0);
$FW_dir = "$attr{global}{modpath}/www";
@@ -135,6 +130,9 @@ FHEMWEB_Initialize($)
$FW_cssdir = "$FW_dir/pgm2";
$FW_gplotdir = "$FW_dir/gplot";
+ $data{webCmdFn}{slider} = "FW_sliderFn";
+ $data{webCmdFn}{timepicker} = "FW_timepickerFn";
+ $data{webCmdFn}{"~dropdown"}= "FW_dropdownFn"; # Should be the last
}
#####################################
@@ -450,13 +448,13 @@ FW_answerCall($)
# Axels FHEMWEB modules...
if(defined($data{FWEXT})) {
foreach my $k (sort keys %{$data{FWEXT}}) {
- if($arg =~ m/^$k/) {
- no strict "refs";
- #Returns undef if it already sent a HTTP header
- ($FW_RETTYPE, $FW_RET) = &{$data{FWEXT}{$k}{FUNC}}($arg);
- use strict "refs";
- return defined($FW_RETTYPE) ? 0 : -1;
- }
+ my $h = $data{FWEXT}{$k};
+ next if($arg !~ m/^$k/ || $h !~ m/HASH/ || !$h->{FUNC});
+ no strict "refs";
+ #Returns undef if it already sent a HTTP header
+ ($FW_RETTYPE, $FW_RET) = &{$h->{FUNC}}($arg);
+ use strict "refs";
+ return defined($FW_RETTYPE) ? 0 : -1;
}
}
@@ -542,9 +540,6 @@ FW_answerCall($)
my $jsTemplate = '';
FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/svg.js") if($FW_plotmode eq "SVG");
FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/fhemweb.js");
- foreach my $js (split(",", AttrVal($FW_wname, "javascripts", ""))) {
- FW_pO sprintf($jsTemplate, $js);
- }
my $onload = AttrVal($FW_wname, "longpoll", undef) ?
"onload=\"FW_delayedStart()\"" : "";
@@ -564,13 +559,13 @@ FW_answerCall($)
}
FW_pO "";
- }
+ }
FW_roomOverview($cmd);
if($cmd =~ m/^style /) { FW_style($cmd,undef); }
+ elsif($cmd =~ /^logwrapper/) { return FW_logWrapper($cmd); }
elsif($FW_detail) { FW_doDetail($FW_detail); }
elsif($FW_room) { FW_showRoom(); }
- elsif($cmd =~ /^logwrapper/) { return FW_logWrapper($cmd); }
elsif(!$FW_cmdret && AttrVal("global", "motd", "none") ne "none") {
my $motd = AttrVal("global","motd",undef);
$motd =~ s/\n/ /g;
@@ -721,6 +716,7 @@ FW_makeTable($$@)
}
##############################
+# Used only for set or attr lists.
sub
FW_makeSelect($$$$)
{
@@ -787,13 +783,6 @@ FW_doDetail($)
FW_makeSelect($d, "attr", $attrList,"attr");
FW_makeTable($d, $attr{$d}, "deleteattr"); # Attributes
-
- if($t eq "FileLog" ) {
- FW_pO "