diff --git a/fhem/contrib/DS_Starter/95_Dashboard.pm b/fhem/contrib/DS_Starter/95_Dashboard.pm index dcf77d8ea..5fd02dd76 100644 --- a/fhem/contrib/DS_Starter/95_Dashboard.pm +++ b/fhem/contrib/DS_Starter/95_Dashboard.pm @@ -1,4 +1,4 @@ -# $Id: 95_Dashboard.pm 20275 2019-09-29 12:58:28Z DS_Starter $ +# $Id: 95_Dashboard.pm 20323 2019-10-06 20:12:38Z DS_Starter $ ######################################################################################## # 95_Dashboard.pm # @@ -55,7 +55,8 @@ use vars qw($FW_ss); # is smallscreen, needed by 97_GROUP/95_VIEW # Versions History intern our %Dashboard_vNotesIntern = ( - "3.17.0" => "04.10.2019 Path handling of backgroundimage changed ", + "3.17.1" => "10.02.2020 fix perl warning, Forum: https://forum.fhem.de/index.php/topic,16503.msg1023004.html#msg1023004 ", + "3.17.0" => "06.10.2019 Path handling of backgroundimage changed ", "3.16.0" => "04.10.2019 new attribute dashboard_hideGroupHeader, commandref revised ", "3.15.2" => "29.09.2019 fix warnings, Forum: https://forum.fhem.de/index.php/topic,16503.msg978883.html#msg978883 ", "3.15.1" => "25.09.2019 change initial attributes, commandref revised ", @@ -301,16 +302,16 @@ sub Dashboard_Attr($$$) { } if ($aName =~ m/dashboard_(.*)backgroundimage/) { - my $container = ""; + my $ct = ""; if (!$1) { - $container = "MAIN"; + $ct = "MAIN"; } else { - $container = $1; + $ct = $1; } - delete $hash->{HELPER}{BIMG}{$container}; + delete $hash->{HELPER}{BIMG}{$ct}; if($cmd eq "set") { - Dashboard_searchImage($name, "$FW_dir/images", $aVal,$container); - if (!$hash->{HELPER}{BIMG}{$container}) { + Dashboard_searchImage($name, "$FW_dir/images", $aVal,$ct); + if (!$hash->{HELPER}{BIMG}{$ct}) { Log3 ($name, 2, "Dashboard $name - Background image file not found: $aVal"); return "Background image file not found: $aVal"; } @@ -430,7 +431,7 @@ sub Dashboard_SummaryFN ($$$$) { my $showfullsize = AttrVal($name, "dashboard_showfullsize", 0); my $flexible = AttrVal($name, "dashboard_flexible", 0); my $customcss = AttrVal($name, "dashboard_customcss", "none"); - my $row = AttrVal($name, "dashboard_row", "center"); + # my $row = AttrVal($name, "dashboard_row", "center"); my $debug = AttrVal($name, "dashboard_debug", "0"); my ($activetab,$tabname) = Dashboard_GetActiveTab($name,1); my $tabcount = Dashboard_GetTabCount($hash, 1); @@ -477,28 +478,44 @@ sub Dashboard_SummaryFN ($$$$) { ############################ Set FHEM url to avoid hardcoding it in javascript ############################ $ret .= ""; + ## Dashboard-Tab Details Tabelle (Stift rechte Seite im Kopf) $ret .= "
\n"; $ret .= "
\n"; - $ret .= "\n"; + + $ret .= "
\n"; $ret .= "\n"; - $ret .= "\n"; - $ret .= ""; - $ret .= ""; + $ret .= ""; + $ret .= ""; + $ret .= "\n"; + $ret .= ""; + $ret .= ""; + $ret .= ""; + $ret .= ""; + $ret .= ""; + $ret .= ""; # the method FW_multipleSelect seems not to be available any more in fhem #$ret .= ""; - $ret .= ""; - $ret .= ""; + $ret .= ""; + $ret .= ""; + $ret .= ""; + $ret .= ""; + $ret .= ""; + $ret .= ""; $ret .= "
Tabtitle:
Tabicon:
Tabtitle:
Tabicon:
Groups:
Groups:
Groups:
\n"; - $ret .= "
\n"; + $ret .= "
\n"; + $ret .= "
\n"; $ret .= "Comming soon"; $ret .= "
\n"; - $ret .= "
\n"; + + $ret .= "\n"; $ret .= "\n"; + ## Ende Dashboard-Tab Details Tabelle $ret .= "
$name
\n"; $ret .= "\n"; @@ -507,7 +524,10 @@ sub Dashboard_SummaryFN ($$$$) { $ret .= "\n"; $ret .= "\n"; $ret .= "\n"; - $ret .= "\n"; + $ret .= ""; + $ret .= "\n"; $ret .= "
\n"; + + ## Tab Content + $ret .= "
\n"; + $ret .= "
"; ########################### Dashboard Tab-Liste ############################################## $ret .= "
    \n"; @@ -522,7 +542,8 @@ sub Dashboard_SummaryFN ($$$$) { $ret .= Dashboard_BuildDashboardTab($t, $name); } } - $ret .= "
\n"; } else { @@ -546,6 +567,7 @@ return $ret; sub Dashboard_BuildDashboardTab ($$) { my ($t, $name) = @_; my $hash = $defs{$name}; + my $ret; my $id = $hash->{NR}; my $colcount = AttrVal($name, 'dashboard_tab'.($t+1).'colcount', AttrVal($name, "dashboard_colcount", 1)); @@ -563,8 +585,8 @@ sub Dashboard_BuildDashboardTab ($$) { } # Hintergrundbild bauen - my $container = "tab".($t+1); - my $bimg = $hash->{HELPER}{BIMG}{$container}?"url(/fhem/images/$hash->{HELPER}{BIMG}{$container})":"none"; + my $ct = "tab".($t+1); + my $bimg = $hash->{HELPER}{BIMG}{$ct}?"url(/fhem/images/$hash->{HELPER}{BIMG}{$ct})":"none"; my @temptabdevicegroup = split(' ', $tabdevicegroups); my @tabdevicegroups = (); @@ -620,9 +642,9 @@ sub Dashboard_BuildDashboardTab ($$) { } } - my $ret = "
\n"; - $ret .= " \n"; - $ret .= "
\n"; + $ret .= "\n"; + $ret .= "\n"; + $ret .= "\n"; return $ret; } @@ -653,9 +675,11 @@ sub Dashboard_BuildDashboardTopRow ($$$$$) { $ret .= "\n"; $ret .= "
\n"; - $ret .= "
\n"; + + $ret .= "
\n"; $ret .= Dashboard_BuildGroupWidgets($name,$t,"100",$id,$devicegroups,$groupsorting); - $ret .= "
\n"; + $ret .= "
\n"; + $ret .= "
\n"; $ret .= "\n"; @@ -673,7 +697,7 @@ sub Dashboard_BuildDashboardCenterRow ($$$$$$) { my $currentcol = $colcount; my $maxcolindex = $colcount - 1; - my $replace = "t" . $t . "c" . $maxcolindex . ","; + my $replace = "t".$t."c".$maxcolindex.","; # replace all sortings referencing not existing columns # this does only work if there is no empty column inbetween @@ -684,9 +708,9 @@ sub Dashboard_BuildDashboardCenterRow ($$$$$$) { } for (my $i=0;$i<$colcount;$i++){ - $ret .= "
\n"; + $ret .= "
\n"; $ret .= Dashboard_BuildGroupWidgets($name,$t,$i,$id,$devicegroups,$groupsorting); - $ret .= "
\n"; + $ret .= "
\n"; } $ret .= "\n"; $ret .= "\n"; @@ -701,10 +725,11 @@ sub Dashboard_BuildDashboardBottomRow ($$$$$) { my ($name,$t,$id, $devicegroups, $groupsorting) = @_; my $ret; $ret .= "\n"; - $ret .= "
\n"; - $ret .= "
\n"; + + $ret .= "
\n"; $ret .= Dashboard_BuildGroupWidgets($name,$t,"200",$id,$devicegroups,$groupsorting); - $ret .= "
\n"; + $ret .= "
\n"; + $ret .= "
\n"; $ret .= "\n"; @@ -1030,7 +1055,8 @@ sub Dashboard_GetActiveTab ($;$) { if (defined($FW_httpheader{Cookie})) { Log3 ($name, 4, "Dashboard $name - Cookie set: ".$FW_httpheader{Cookie}); - my %cookie = map({ split('=', $_) } split(/; */, $FW_httpheader{Cookie})); + my %cookie = map({ $_!~/^.*=$/ ? split('=', $_) : "" } split(/; */, $FW_httpheader{Cookie})); # 10.02.2020, Forum: https://forum.fhem.de/index.php/topic,16503.msg1023004.html#msg1023004 + # my %cookie = map({ split('=', $_) } split(/; */, $FW_httpheader{Cookie})); if (defined($cookie{dashboard_activetab})) { $activeTab = $cookie{dashboard_activetab}; $activeTab = ($activeTab <= $maxTab)?$activeTab:$maxTab; @@ -1081,12 +1107,12 @@ sub Dashboard_setVersionInfo($) { if($modules{$type}{META}{x_prereqs_src} && !$hash->{HELPER}{MODMETAABSENT}) { # META-Daten sind vorhanden $modules{$type}{META}{version} = "v".$v; # Version aus META.json überschreiben, Anzeige mit {Dumper $modules{SMAPortal}{META}} - if($modules{$type}{META}{x_version}) { # {x_version} ( nur gesetzt wenn $Id: 95_Dashboard.pm 20275 2019-09-29 12:58:28Z DS_Starter $ im Kopf komplett! vorhanden ) + if($modules{$type}{META}{x_version}) { # {x_version} ( nur gesetzt wenn $Id: 95_Dashboard.pm 20323 2019-10-06 20:12:38Z DS_Starter $ im Kopf komplett! vorhanden ) $modules{$type}{META}{x_version} =~ s/1.1.1/$v/g; } else { $modules{$type}{META}{x_version} = $v; } - return $@ unless (FHEM::Meta::SetInternals($hash)); # FVERSION wird gesetzt ( nur gesetzt wenn $Id: 95_Dashboard.pm 20275 2019-09-29 12:58:28Z DS_Starter $ im Kopf komplett! vorhanden ) + return $@ unless (FHEM::Meta::SetInternals($hash)); # FVERSION wird gesetzt ( nur gesetzt wenn $Id: 95_Dashboard.pm 20323 2019-10-06 20:12:38Z DS_Starter $ im Kopf komplett! vorhanden ) if(__PACKAGE__ eq "FHEM::$type" || __PACKAGE__ eq $type) { # es wird mit Packages gearbeitet -> Perl übliche Modulversion setzen use version 0.77; our $VERSION = FHEM::Meta::Get( $hash, 'version' ); # mit {->VERSION()} im FHEMWEB kann Modulversion abgefragt werden } @@ -1167,10 +1193,10 @@ return $a; ###################################################################################### # angegebenes $file im $dir und Unterverzeichnissen suchen -# und mit Pfad ab ".../images/" in $container speichern wenn gefunden +# und mit Pfad ab ".../images/" in $ct speichern wenn gefunden ###################################################################################### sub Dashboard_searchImage($$$$) { - my ($name,$dir,$file,$container) = @_; + my ($name,$dir,$file,$ct) = @_; my $hash = $defs{$name}; my ($t,$im); @@ -1179,11 +1205,11 @@ sub Dashboard_searchImage($$$$) { closedir(DIR); foreach (@files) { if (-d ($t = "$dir/$_")) { # -d returns true if the following string is a directory. - Dashboard_searchImage($name,$t,$file,$container); + Dashboard_searchImage($name,$t,$file,$ct); } else { next if ($_ ne $file); $im = (split("images\/", $dir."/".$_))[1]; - $hash->{HELPER}{BIMG}{$container} = $im; # Ergebnisfile in Container speichern wenn gefunden + $hash->{HELPER}{BIMG}{$ct} = $im; # Ergebnisfile in Container speichern wenn gefunden Log3 ($name, 5, "Dashboard $name - Background image file found in: $dir/$_"); } } @@ -1307,7 +1333,7 @@ sub Dashboard_searchImage($$$$) {
  • dashboard_backgroundimage
    Displays a background image for the complete dashboard. The image is not stretched in any way. So the size should match/extend the dashboard height/width. Only the filename has to be set.
    - The file must be located anywhere below the directory "./www/images/".
    + The file must be at any location below the directory "./www/images/".
    Suggestion: Create the directory "./www/images/dashboard" and put the image file into.

    @@ -1412,7 +1438,7 @@ sub Dashboard_searchImage($$$$) { Shows a background image for the tab. (also valid for further dashboard_tabXbackgroundimage)
    The image is not stretched in any way, it should therefore match the tab size or extend it. Only the filename has to be set.
    - The file must be located anywhere below the directory "./www/images/".
    + The file must be at any location below the directory "./www/images/".
    Suggestion: Create the directory "./www/images/dashboard" and put the image file into.

    @@ -1607,7 +1633,7 @@ sub Dashboard_searchImage($$$$) {
  • dashboard_backgroundimage
    Zeigt ein Hintergrundbild im Dashboard an. Das Bild wird nicht gestreckt, es sollte daher auf die Größe des Dashboards passen oder diese überschreiten. Es ist nur der Filename anzugeben.
    - Das File muss sich irgendwo unterhalb des Verzeichnisses "./www/images/" befinden.
    + Das File muss sich an beliebiger Stelle unterhalb des Verzeichnisses "./www/images/" befinden.
    Empfehlung: Das Verzeichnis "./www/images/dashboard" anlegen und das Bildfile in diesem Verzeichnis ablegen.

    @@ -1721,7 +1747,7 @@ sub Dashboard_searchImage($$$$) { Zeigt ein Hintergrundbild für den Tab an. (gilt ebenfalls für weitere dashboard_tabXbackgroundimage)
    Das Bild wird nicht gestreckt, es sollte also auf die Größe des Tabs passen oder diese überschreiten. Es ist nur der Filename anzugeben.
    - Das File muss sich irgendwo unterhalb des Verzeichnisses "./www/images/" befinden.
    + Das File muss sich an beliebiger Stelle unterhalb des Verzeichnisses "./www/images/" befinden.
    Empfehlung: Das Verzeichnis "./www/images/dashboard" anlegen und das Bildfile in diesem Verzeichnis ablegen.