mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
01_FHEMWEB.pm: Group Attributes (Forum #119289)
git-svn-id: https://svn.fhem.de/fhem/trunk@23898 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6b8750b2d1
commit
85c894431a
@ -1438,10 +1438,9 @@ FW_makeTable($$$@)
|
|||||||
sub
|
sub
|
||||||
FW_detailSelect(@)
|
FW_detailSelect(@)
|
||||||
{
|
{
|
||||||
my ($d, $cmd, $list, $param) = @_;
|
my ($d, $cmd, $list, $param, $typeHash) = @_;
|
||||||
return "" if(!$list || $FW_hiddenroom{input});
|
return "" if(!$list || $FW_hiddenroom{input});
|
||||||
my %al = map { s/:.*//;$_ => 1 } split(" ", $list);
|
my @al = map { s/:.*//; $_ } split(" ", $list);
|
||||||
my @al = sort keys %al; # remove duplicate items in list
|
|
||||||
|
|
||||||
my $selEl = (defined($al[0]) ? $al[0] : " ");
|
my $selEl = (defined($al[0]) ? $al[0] : " ");
|
||||||
$selEl = $1 if($list =~ m/([^ ]*):slider,/); # promote a slider if available
|
$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 .= FW_submit("cmd.$cmd$d", $cmd, $cmd.($psc?" psc":""));
|
||||||
$ret .= "<div class=\"$cmd downText\"> $d ".
|
$ret .= "<div class=\"$cmd downText\"> $d ".
|
||||||
($param ? " $param":"")."</div>";
|
($param ? " $param":"")."</div>";
|
||||||
$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 .= FW_textfield("val.$cmd$d", 30, $cmd);
|
||||||
$ret .= "</form></div>";
|
$ret .= "</form></div>";
|
||||||
return $ret;
|
return $ret;
|
||||||
@ -1542,7 +1541,8 @@ FW_doDetail($)
|
|||||||
FW_makeTable("Internals", $d, $h);
|
FW_makeTable("Internals", $d, $h);
|
||||||
FW_makeTable("Readings", $d, $h->{READINGS});
|
FW_makeTable("Readings", $d, $h->{READINGS});
|
||||||
|
|
||||||
my $attrList = getAllAttr($d);
|
my %attrTypeHash;
|
||||||
|
my $attrList = getAllAttr($d, undef, \%attrTypeHash);
|
||||||
my $roomList = "multiple,".join(",",
|
my $roomList = "multiple,".join(",",
|
||||||
sort map { $_ =~ s/ /#/g ;$_} keys %FW_rooms);
|
sort map { $_ =~ s/ /#/g ;$_} keys %FW_rooms);
|
||||||
my $groupList = "multiple,".join(",",
|
my $groupList = "multiple,".join(",",
|
||||||
@ -1553,7 +1553,7 @@ FW_doDetail($)
|
|||||||
$attrList = FW_widgetOverride($d, $attrList);
|
$attrList = FW_widgetOverride($d, $attrList);
|
||||||
$attrList =~ s/\\/\\\\/g;
|
$attrList =~ s/\\/\\\\/g;
|
||||||
$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_makeTable("Attributes", $d, $attr{$d}, "deleteattr");
|
||||||
FW_makeTableFromArray("Probably associated with", "assoc", getPawList($d));
|
FW_makeTableFromArray("Probably associated with", "assoc", getPawList($d));
|
||||||
@ -2273,18 +2273,31 @@ FW_hidden($$)
|
|||||||
sub
|
sub
|
||||||
FW_select($$$$$@)
|
FW_select($$$$$@)
|
||||||
{
|
{
|
||||||
my ($id, $name, $valueArray, $selected, $class, $jSelFn) = @_;
|
my ($id, $name, $valueArray, $selected, $class, $jSelFn, $typeHash) = @_;
|
||||||
$jSelFn = ($jSelFn ? "onchange=\"$jSelFn\"" : "");
|
$jSelFn = ($jSelFn ? "onchange=\"$jSelFn\"" : "");
|
||||||
$id =~ s/\./_/g if($id); # to avoid problems in JS DOM Search
|
$id =~ s/\./_/g if($id); # to avoid problems in JS DOM Search
|
||||||
$id = ($id ? "id=\"$id\" informId=\"$id\"" : "");
|
$id = ($id ? "id=\"$id\" informId=\"$id\"" : "");
|
||||||
my $s = "<select $jSelFn $id name=\"$name\" class=\"$class\">";
|
my $s = "<select $jSelFn $id name=\"$name\" class=\"$class\">";
|
||||||
|
my $oldType="";
|
||||||
|
my %processed;
|
||||||
foreach my $v (@{$valueArray}) {
|
foreach my $v (@{$valueArray}) {
|
||||||
|
next if($processed{$v});
|
||||||
|
if($typeHash) {
|
||||||
|
my $newType = $typeHash->{$v};
|
||||||
|
if($newType ne $oldType) {
|
||||||
|
$s .= "</optgroup>" if($oldType);
|
||||||
|
$s .= "<optgroup label='$newType'>" if($newType);
|
||||||
|
}
|
||||||
|
$oldType = $newType;
|
||||||
|
}
|
||||||
if(defined($selected) && $v eq $selected) {
|
if(defined($selected) && $v eq $selected) {
|
||||||
$s .= "<option selected=\"selected\" value='$v'>$v</option>\n";
|
$s .= "<option selected=\"selected\" value='$v'>$v</option>\n";
|
||||||
} else {
|
} else {
|
||||||
$s .= "<option value='$v'>$v</option>\n";
|
$s .= "<option value='$v'>$v</option>\n";
|
||||||
}
|
}
|
||||||
|
$processed{$v} = 1;
|
||||||
}
|
}
|
||||||
|
$s .= "</optgroup>" if($oldType);
|
||||||
$s .= "</select>";
|
$s .= "</select>";
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
37
fhem/fhem.pl
37
fhem/fhem.pl
@ -125,7 +125,7 @@ sub fhem($@);
|
|||||||
sub fhemTimeGm($$$$$$);
|
sub fhemTimeGm($$$$$$);
|
||||||
sub fhemTimeLocal($$$$$$);
|
sub fhemTimeLocal($$$$$$);
|
||||||
sub fhemTzOffset($);
|
sub fhemTzOffset($);
|
||||||
sub getAllAttr($;$);
|
sub getAllAttr($;$$);
|
||||||
sub getAllGets($;$);
|
sub getAllGets($;$);
|
||||||
sub getAllSets($;$);
|
sub getAllSets($;$);
|
||||||
sub getPawList($);
|
sub getPawList($);
|
||||||
@ -282,7 +282,7 @@ $cvsid = '$Id$';
|
|||||||
|
|
||||||
my $AttrList = "alias comment:textField-long eventMap:textField-long ".
|
my $AttrList = "alias comment:textField-long eventMap:textField-long ".
|
||||||
"group room suppressReading userReadings: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 $currcfgfile=""; # current config/include file
|
||||||
my $currlogfile; # logfile, without wildcards
|
my $currlogfile; # logfile, without wildcards
|
||||||
@ -2735,28 +2735,37 @@ CommandRename($$)
|
|||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub
|
||||||
getAllAttr($;$)
|
getAllAttr($;$$)
|
||||||
{
|
{
|
||||||
my ($d, $cl) = @_;
|
my ($d, $cl, $typeHash) = @_;
|
||||||
return "" if(!$defs{$d});
|
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"}) {
|
if($defs{$d}{".AttrList"}) {
|
||||||
$list .= " " . $defs{$d}{".AttrList"};
|
&$add($defs{$d}{".AttrList"}, "Module");
|
||||||
} elsif($modules{$defs{$d}{TYPE}}{AttrList}) {
|
} else {
|
||||||
$list .= " " . $modules{$defs{$d}{TYPE}}{AttrList};
|
&$add($modules{$defs{$d}{TYPE}}{AttrList}, "Module");
|
||||||
}
|
}
|
||||||
|
|
||||||
my $nl2space = sub($)
|
my $nl2space = sub($$)
|
||||||
{
|
{
|
||||||
my $v = $_[0];
|
my ($v,$type) = @_;
|
||||||
return if(!defined($v));
|
return if(!defined($v));
|
||||||
$v =~ s/\n/ /g;
|
$v =~ s/\n/ /g;
|
||||||
$list .= " $v";
|
&$add($v, $type);
|
||||||
};
|
};
|
||||||
$nl2space->($attr{global}{userattr});
|
$nl2space->($attr{global}{userattr}, "Global userattr");
|
||||||
$nl2space->($attr{$d}{userattr}) if($attr{$d});
|
$nl2space->($attr{$d}{userattr}, "Device userattr") if($attr{$d});
|
||||||
$list .= " userattr";
|
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,7 +735,7 @@ f18_setCss(why)
|
|||||||
function bg(c) { return "{ background:#"+c+"; fill:#"+c+"; }\n" }
|
function bg(c) { return "{ background:#"+c+"; fill:#"+c+"; }\n" }
|
||||||
function fg(c) { return "{ color:#"+c+"; }\n" }
|
function fg(c) { return "{ color:#"+c+"; }\n" }
|
||||||
style += ".col_fg, body, input, textarea "+fg(col("fg"));
|
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],"+
|
style += ".col_link,a:not(.changed),.handle,.fhemlog,input[type=submit],"+
|
||||||
"select,div.ui-widget-content a "+
|
"select,div.ui-widget-content a "+
|
||||||
"{color:#"+col("link")+"!important; stroke:#"+col("link")+";}\n";
|
"{color:#"+col("link")+"!important; stroke:#"+col("link")+";}\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user