From 85c894431a6ea2a7ad3786bf65fe2a15cd7d4e71 Mon Sep 17 00:00:00 2001
From: rudolfkoenig <>
Date: Sat, 6 Mar 2021 11:05:44 +0000
Subject: [PATCH] 01_FHEMWEB.pm: Group Attributes (Forum #119289)
git-svn-id: https://svn.fhem.de/fhem/trunk@23898 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/01_FHEMWEB.pm | 27 ++++++++++++++++++++-------
fhem/fhem.pl | 37 +++++++++++++++++++++++--------------
fhem/www/pgm2/f18.js | 2 +-
3 files changed, 44 insertions(+), 22 deletions(-)
diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm
index 3ef3096cb..846d84988 100644
--- a/fhem/FHEM/01_FHEMWEB.pm
+++ b/fhem/FHEM/01_FHEMWEB.pm
@@ -1438,10 +1438,9 @@ FW_makeTable($$$@)
sub
FW_detailSelect(@)
{
- my ($d, $cmd, $list, $param) = @_;
+ my ($d, $cmd, $list, $param, $typeHash) = @_;
return "" if(!$list || $FW_hiddenroom{input});
- my %al = map { s/:.*//;$_ => 1 } split(" ", $list);
- my @al = sort keys %al; # remove duplicate items in list
+ my @al = map { s/:.*//; $_ } split(" ", $list);
my $selEl = (defined($al[0]) ? $al[0] : " ");
$selEl = $1 if($list =~ m/([^ ]*):slider,/); # promote a slider if available
@@ -1458,7 +1457,7 @@ FW_detailSelect(@)
$ret .= FW_submit("cmd.$cmd$d", $cmd, $cmd.($psc?" psc":""));
$ret .= "
$d ".
($param ? " $param":"")."
";
- $ret .= FW_select("sel_$cmd$d","arg.$cmd$d",\@al, $selEl, $cmd);
+ $ret .= FW_select("sel_$cmd$d","arg.$cmd$d",\@al,$selEl,$cmd,undef,$typeHash);
$ret .= FW_textfield("val.$cmd$d", 30, $cmd);
$ret .= "";
return $ret;
@@ -1542,7 +1541,8 @@ FW_doDetail($)
FW_makeTable("Internals", $d, $h);
FW_makeTable("Readings", $d, $h->{READINGS});
- my $attrList = getAllAttr($d);
+ my %attrTypeHash;
+ my $attrList = getAllAttr($d, undef, \%attrTypeHash);
my $roomList = "multiple,".join(",",
sort map { $_ =~ s/ /#/g ;$_} keys %FW_rooms);
my $groupList = "multiple,".join(",",
@@ -1553,7 +1553,7 @@ FW_doDetail($)
$attrList = FW_widgetOverride($d, $attrList);
$attrList =~ s/\\/\\\\/g;
$attrList =~ s/'/\\'/g;
- FW_pO FW_detailSelect($d, "attr", $attrList);
+ FW_pO FW_detailSelect($d, "attr", $attrList, undef, \%attrTypeHash);
FW_makeTable("Attributes", $d, $attr{$d}, "deleteattr");
FW_makeTableFromArray("Probably associated with", "assoc", getPawList($d));
@@ -2273,18 +2273,31 @@ FW_hidden($$)
sub
FW_select($$$$$@)
{
- my ($id, $name, $valueArray, $selected, $class, $jSelFn) = @_;
+ my ($id, $name, $valueArray, $selected, $class, $jSelFn, $typeHash) = @_;
$jSelFn = ($jSelFn ? "onchange=\"$jSelFn\"" : "");
$id =~ s/\./_/g if($id); # to avoid problems in JS DOM Search
$id = ($id ? "id=\"$id\" informId=\"$id\"" : "");
my $s = "";
return $s;
}
diff --git a/fhem/fhem.pl b/fhem/fhem.pl
index 509c02ae1..e490bd0c9 100755
--- a/fhem/fhem.pl
+++ b/fhem/fhem.pl
@@ -125,7 +125,7 @@ sub fhem($@);
sub fhemTimeGm($$$$$$);
sub fhemTimeLocal($$$$$$);
sub fhemTzOffset($);
-sub getAllAttr($;$);
+sub getAllAttr($;$$);
sub getAllGets($;$);
sub getAllSets($;$);
sub getPawList($);
@@ -282,7 +282,7 @@ $cvsid = '$Id$';
my $AttrList = "alias comment:textField-long eventMap:textField-long ".
"group room suppressReading userReadings:textField-long ".
- "verbose:0,1,2,3,4,5";
+ "verbose:0,1,2,3,4,5 userattr";
my $currcfgfile=""; # current config/include file
my $currlogfile; # logfile, without wildcards
@@ -2735,28 +2735,37 @@ CommandRename($$)
#####################################
sub
-getAllAttr($;$)
+getAllAttr($;$$)
{
- my ($d, $cl) = @_;
+ my ($d, $cl, $typeHash) = @_;
return "" if(!$defs{$d});
+ my $list = "";
- my $list = $AttrList; # Global values
+ my $add = sub($$)
+ {
+ my ($v,$type) = @_;
+ return if(!defined($v));
+ $list .= " " if($list);
+ $list .= $v;
+ map { s/:.*//; $typeHash->{$_} = $type } split(" ",$v) if($typeHash);
+ };
+
+ &$add($AttrList, "global");
if($defs{$d}{".AttrList"}) {
- $list .= " " . $defs{$d}{".AttrList"};
- } elsif($modules{$defs{$d}{TYPE}}{AttrList}) {
- $list .= " " . $modules{$defs{$d}{TYPE}}{AttrList};
+ &$add($defs{$d}{".AttrList"}, "Module");
+ } else {
+ &$add($modules{$defs{$d}{TYPE}}{AttrList}, "Module");
}
- my $nl2space = sub($)
+ my $nl2space = sub($$)
{
- my $v = $_[0];
+ my ($v,$type) = @_;
return if(!defined($v));
$v =~ s/\n/ /g;
- $list .= " $v";
+ &$add($v, $type);
};
- $nl2space->($attr{global}{userattr});
- $nl2space->($attr{$d}{userattr}) if($attr{$d});
- $list .= " userattr";
+ $nl2space->($attr{global}{userattr}, "Global userattr");
+ $nl2space->($attr{$d}{userattr}, "Device userattr") if($attr{$d});
return $list;
}
diff --git a/fhem/www/pgm2/f18.js b/fhem/www/pgm2/f18.js
index 81c49ca62..a785cf0aa 100644
--- a/fhem/www/pgm2/f18.js
+++ b/fhem/www/pgm2/f18.js
@@ -735,7 +735,7 @@ f18_setCss(why)
function bg(c) { return "{ background:#"+c+"; fill:#"+c+"; }\n" }
function fg(c) { return "{ color:#"+c+"; }\n" }
style += ".col_fg, body, input, textarea "+fg(col("fg"));
- style += ".col_bg, textarea, input, option "+bg(col("bg"));
+ style += ".col_bg, textarea, input, option, optgroup "+bg(col("bg"));
style += ".col_link,a:not(.changed),.handle,.fhemlog,input[type=submit],"+
"select,div.ui-widget-content a "+
"{color:#"+col("link")+"!important; stroke:#"+col("link")+";}\n";