From e41e451b968022ff9d9e87faea8c2f6e4e464ea3 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sun, 22 May 2016 08:01:08 +0000 Subject: [PATCH] 01_FHEMWEB.pm: deviceOverview by justme1968 (Forum #53012) git-svn-id: https://svn.fhem.de/fhem/trunk@11492 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/01_FHEMWEB.pm | 178 ++++++++++++++++++++++++++-------------- 1 file changed, 116 insertions(+), 62 deletions(-) diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm index f9b0a8f4b..ff9c76e12 100755 --- a/fhem/FHEM/01_FHEMWEB.pm +++ b/fhem/FHEM/01_FHEMWEB.pm @@ -146,6 +146,7 @@ FHEMWEB_Initialize($) closeConn:1,0 column defaultRoom + deviceOverview:always,iconOnly,onClick,never editConfig:1,0 editFileList:textField-long endPlotNow:1,0 @@ -1183,9 +1184,39 @@ FW_doDetail($) FW_pO "$txt
" if(defined($txt)); use strict "refs"; } else { - my %extPage = (); - my ($allSets, $cmdlist, $txt) = FW_devState($d, $FW_room, \%extPage); - FW_pO "
$txt
"; + my $show = AttrVal($FW_wname, "deviceOverview", "always"); + + if( $show ne 'never' ) { + my %extPage = (); + + if( $show eq 'iconOnly' ) { + my ($allSets, $cmdlist, $txt) = FW_devState($d, $FW_room, \%extPage); + FW_pO "
$txt
"; + + } else { + my $nameDisplay = AttrVal($FW_wname,"nameDisplay",undef); + my %usuallyAtEnd = (); + + my $style = ""; + if( $show eq 'onClick' ) { + my $pgm = "Javascript:" . + "s=document.getElementById('ddtable').style;". + "s.display = s.display=='none' ? 'block' : 'none';". + "s=document.getElementById('ddisp').style;". + "s.display = s.display=='none' ? 'block' : 'none';"; + FW_pO "

Show DeviceOverview

"; + $style = 'style="display:none"'; + } + + FW_pO "
"; + FW_pO "DeviceOverview"; + FW_pO ""; + FW_makeDeviceLine($d,1,\%extPage,$nameDisplay,\%usuallyAtEnd); + FW_pO "
"; + } + } } FW_pO FW_detailSelect($d, "set", FW_widgetOverride($d, getAllSets($d))); @@ -1449,6 +1480,69 @@ FW_roomOverview($) } +sub +FW_makeDeviceLine($$$$$) +{ + my( $d,$row,$extPage,$nameDisplay,$usuallyAtEnd) = @_;; + my $rf = ($FW_room ? "&room=$FW_room" : ""); # stay in the room + + FW_pF "\n", ($row&1)?"odd":"even"; + my $devName = AttrVal($d, "alias", $d); + if(defined($nameDisplay)) { + my ($DEVICE, $ALIAS) = ($d, $devName); + $devName = eval $nameDisplay; + } + my $icon = AttrVal($d, "icon", ""); + $icon = FW_makeImage($icon,$icon,"icon") . " " if($icon); + + if($FW_hiddenroom{detail}) { + FW_pO "
$icon$devName
" + if(!$usuallyAtEnd->{$d}); + } else { + FW_pH "detail=$d", "$icon$devName", 1, "col1" if(!$usuallyAtEnd->{$d}); + } + $row++; + + my ($allSets, $cmdlist, $txt) = FW_devState($d, $rf, $extPage); + $allSets = FW_widgetOverride($d, $allSets); + + my $colSpan = ($usuallyAtEnd->{$d} ? ' colspan="2"' : ''); + FW_pO "$txt"; + + ###### + # Commands, slider, dropdown + my $smallscreenCommands = AttrVal($FW_wname, "smallscreenCommands", ""); + if((!$FW_ss || $smallscreenCommands) && $cmdlist) { + my @a = split("[: ]", AttrVal($d, "cmdIcon", "")); + Log 1, "ERROR: bad cmdIcon definition for $d" if(@a % 2); + my %cmdIcon = @a; + + foreach my $cmd (split(":", $cmdlist)) { + my $htmlTxt; + my @c = split(' ', $cmd); # @c==0 if $cmd==" "; + if(int(@c) && $allSets && $allSets =~ m/\b$c[0]:([^ ]*)/) { + my $values = $1; + foreach my $fn (sort keys %{$data{webCmdFn}}) { + no strict "refs"; + $htmlTxt = &{$data{webCmdFn}{$fn}}($FW_wname, + $d, $FW_room, $cmd, $values); + use strict "refs"; + last if(defined($htmlTxt)); + } + } + if($htmlTxt) { + FW_pO $htmlTxt; + + } else { + my $nCmd = $cmdIcon{$cmd} ? + FW_makeImage($cmdIcon{$cmd},$cmd,"webCmd") : $cmd; + FW_pH "cmd.$d=set $d $cmd$rf", $nCmd, 1, "col3"; + } + } + } + FW_pO ""; +} + ######################## # Show the overview of devices in one room # room can be a room, all or Unsorted @@ -1467,8 +1561,6 @@ FW_showRoom() FW_pO "
"; FW_pO ""; # Need for equal width of subtables - my $rf = ($FW_room ? "&room=$FW_room" : ""); # stay in the room - # array of all device names in the room (exception weblinks without group # attribute) my @devs= grep { ($FW_rooms{$FW_room}{$_}||$FW_room eq "all") && @@ -1517,63 +1609,9 @@ FW_showRoom() lc(AttrVal($b,"sortby",AttrVal($b,"alias",$b))) } keys %{$group{$g}}) { my $type = $defs{$d}{TYPE}; - - FW_pF "\n", ($row&1)?"odd":"even"; - my $devName = AttrVal($d, "alias", $d); - if(defined($nameDisplay)) { - my ($DEVICE, $ALIAS) = ($d, $devName); - $devName = eval $nameDisplay; - } - my $icon = AttrVal($d, "icon", ""); - $icon = FW_makeImage($icon,$icon,"icon") . " " if($icon); - - if($FW_hiddenroom{detail}) { - FW_pO "" - if(!$usuallyAtEnd{$d}); - } else { - FW_pH "detail=$d", "$icon$devName", 1, "col1" if(!$usuallyAtEnd{$d}); - } - $row++; - $extPage{group} = $g; - my ($allSets, $cmdlist, $txt) = FW_devState($d, $rf, \%extPage); - $allSets = FW_widgetOverride($d, $allSets); - my $colSpan = ($usuallyAtEnd{$d} ? ' colspan="2"' : ''); - FW_pO ""; - - ###### - # Commands, slider, dropdown - my $smallscreenCommands = AttrVal($FW_wname, "smallscreenCommands", ""); - if((!$FW_ss || $smallscreenCommands) && $cmdlist) { - my @a = split("[: ]", AttrVal($d, "cmdIcon", "")); - Log 1, "ERROR: bad cmdIcon definition for $d" if(@a % 2); - my %cmdIcon = @a; - - foreach my $cmd (split(":", $cmdlist)) { - my $htmlTxt; - my @c = split(' ', $cmd); # @c==0 if $cmd==" "; - if(int(@c) && $allSets && $allSets =~ m/\b$c[0]:([^ ]*)/) { - my $values = $1; - foreach my $fn (sort keys %{$data{webCmdFn}}) { - no strict "refs"; - $htmlTxt = &{$data{webCmdFn}{$fn}}($FW_wname, - $d, $FW_room, $cmd, $values); - use strict "refs"; - last if(defined($htmlTxt)); - } - } - if($htmlTxt) { - FW_pO $htmlTxt; - - } else { - my $nCmd = $cmdIcon{$cmd} ? - FW_makeImage($cmdIcon{$cmd},$cmd,"webCmd") : $cmd; - FW_pH "cmd.$d=set $d $cmd$rf", $nCmd, 1, "col3"; - } - } - } - FW_pO ""; + FW_makeDeviceLine($d,$row,\%extPage,$nameDisplay,\%usuallyAtEnd); } FW_pO "
$icon$devName
$txt
"; FW_pO ""; @@ -2139,7 +2177,8 @@ FW_makeImage(@) $data =~ s/[\r\n]/ /g; $data =~ s/ *$//g; $data =~ s/$txt$title - {'<div style="width:32px;height:32px;background-color:green"></div>'} + {'<div + style="width:32px;height:32px;background-color:green"></div>'}
@@ -3106,6 +3146,13 @@ FW_widgetOverride($$)
+
  • deviceOverview
    + Configures if the device line from the room view (device icon, state + icon and webCmds/cmdIcons) should also be shown in the device detail + view. Can be set to always, onClick, iconOnly or never. Default is + always. +

  • +
  • editConfig
    If this FHEMWEB attribute is set to 1, then you will be able to edit @@ -3792,6 +3839,13 @@ FW_widgetOverride($$)

  • +
  • deviceOverview
    + Gibt an ob die Darstellung aus der Raum-Ansicht (Zeile mit + Gerüteicon, Stateicon und webCmds/cmdIcons) auch in der + Detail-Ansicht angezeigt werden soll. Kann auf always, onClick, + iconOnly oder never gesetzt werden. Der Default ist always. +

  • +
  • editConfig
    Falls dieses FHEMWEB Attribut (auf 1) gesetzt ist, dann kann man die