From 39deca84c6b618fa23c2922c8893811e9af85d82 Mon Sep 17 00:00:00 2001 From: svenson08 <> Date: Tue, 20 May 2014 18:52:01 +0000 Subject: [PATCH] Changed View of readingsHistory. Fix Linebrake in unlock state. Bugfix Display Group with similar group names. CSS Class Changes. Insert Configdialog for Tabs. Change handling of parameters in both directions. git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@5917 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- CHANGED | 1 + FHEM/95_Dashboard.pm | 185 ++++++++++++++++-------- www/pgm2/dashboard.js | 225 ++++++++++++++++++++++------- www/pgm2/dashboard_darkstyle.css | 239 ++++++++++++++++--------------- www/pgm2/dashboard_ios7.css | 223 ++++++++++++++++------------ www/pgm2/dashboard_style.css | 222 ++++++++++++++++------------ 6 files changed, 683 insertions(+), 412 deletions(-) diff --git a/CHANGED b/CHANGED index 005f6dae1..cc83f4d24 100644 --- a/CHANGED +++ b/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: Dashboard Configuration-Dialog for Tabs - feature: new module 33_readingsHistory.pm added (justme1968) - feature: new command copy (justme1968) - feature: enabled GIF, PNG and JPG as background image formats, enabled diff --git a/FHEM/95_Dashboard.pm b/FHEM/95_Dashboard.pm index d8f687d8e..e1c4616c4 100644 --- a/FHEM/95_Dashboard.pm +++ b/FHEM/95_Dashboard.pm @@ -4,7 +4,7 @@ # 95_Dashboard.pm # ######################################################################################## -# Released : 20.12.2013 @svenson08 +# Released : 20.12.2013 Sascha Hermann # Version : # 1.00: Released to testers # 1.02: Don't show link on Groups with WebLinks. Hide GroupToogle Button (new Attribut dashboard_showtooglebuttons). @@ -47,13 +47,14 @@ # 2.10: Internal Changes. Lock/Unlock now only in Detail view. Attribut dashboard_lockstate are obsolet. # 2.11: Attribute dashboard_showhelper ist obolet. Erase tabs-at-the-top-buttonbar-hidden and tabs-on-the-bottom-buttonbar-hidden values # from Attribute dashboard_showtabs. Change Buttonbar Style. Clear CSS and Dashboard.js. -# 2.12: Update Docu. CSS Class Changes. +# 2.12: Update Docu. CSS Class Changes. Insert Configdialog for Tabs. Change handling of parameters in both directions. +# 2.13: Changed View of readingsHistory. Fix Linebrake in unlock state. Bugfix Display Group with similar group names. # # Known Bugs/Todos: -# BUG: Nicht alle Inhalte aller Tabs laden, bei Plots dauert die bedienung des Dashboards zu lange. -> elemente hidden? +# BUG: Nicht alle Inhalte aller Tabs laden, bei Plots dauert die bedienung des Dashboards zu lange. -> elemente hidden? -> widgets aus js über XHR nachladen und dann anzeigen (jquery xml nachladen...) # BUG: Variabler abstand wird nicht gesichert # BUG: dashboard_webfrontendfilter doesn't Work Antwort #469 -# BUG: Überlappen Gruppen andere? +# BUG: Überlappen Gruppen andere? ->Zindex oberer reihe > als darunter liegenden # # Log 1, "[DASHBOARD simple debug] '".$g."' "; ######################################################################################## @@ -84,24 +85,31 @@ package main; use strict; use warnings; - -use vars qw($FW_dir); # base directory for web server -use vars qw($FW_icondir); # icon base directory +use vars qw(%FW_icons); # List of icons +use vars qw($FW_dir); # base directory for web server +use vars qw($FW_icondir); # icon base directory use vars qw($FW_room); # currently selected room use vars qw(%defs); # FHEM device/button definitions -use vars qw($FW_wname); # Web instance +#use vars qw(%FW_groups); # List of Groups +use vars qw($FW_wname); # Web instance use vars qw(%FW_hiddenroom);# hash of hidden rooms, used by weblink -use vars qw(%FW_types); # device types -use vars qw($FW_ss); # is smallscreen, needed by 97_GROUP/95_VIEW +use vars qw(%FW_types); # device types +use vars qw($FW_ss); # is smallscreen, needed by 97_GROUP/95_VIEW -# --------------------------- Global Variable ----------------------------------------------- +######################### +# Forward declaration +sub Dashboard_GetGroupList(); + +######################### +# Global variables my %group; +my $dashboard_groupListfhem; my $fwjquery = "jquery.min.js"; my $fwjqueryui = "jquery-ui.min.js"; my $dashboardname = "Dashboard"; # Link Text my $dashboardhiddenroom = "DashboardRoom"; # Hiddenroom -my $dashboardversion = "2.12"; -# ------------------------------------------------------------------------------------------- +my $dashboardversion = "2.13"; + ############################################################################################# sub Dashboard_Initialize ($) { @@ -109,6 +117,7 @@ sub Dashboard_Initialize ($) { $hash->{DefFn} = "Dashboard_define"; $hash->{SetFn} = "Dashboard_Set"; + $hash->{GetFn} = "Dashboard_Get"; $hash->{UndefFn} = "Dashboard_undef"; $hash->{FW_detailFn} = "Dashboard_DetailFN"; $hash->{AttrFn} = "Dashboard_attr"; @@ -182,12 +191,12 @@ sub Dashboard_DetailFN() { my $ret = ""; $ret .= "\n"; - $ret .= "\n"; + $ret .= " \n"; + $ret .= " \n"; + $ret .= " \n"; + $ret .= "\n"; $ret .= "
\n"; -# $ret .= "
\n"; + $ret .= "
Helper:\n
\n"; $ret .= " \n"; -# $ret .= "
\n"; - $ret .= "
\n"; - $ret .= "
\n"; return $ret; } @@ -206,6 +215,66 @@ sub Dashboard_Set($@) { } } +sub Dashboard_Escape($) { + my $a = shift; + return "null" if(!defined($a)); + my %esc = ("\n" => '\n', "\r" => '\r', "\t" => '\t', "\f" => '\f', "\b" => '\b', "\"" => '\"', "\\" => '\\\\', "\'" => '\\\'', ); + $a =~ s/([\x22\x5c\n\r\t\f\b])/$esc{$1}/eg; + return $a; +} + +sub Dashboard_Get($@) { + my ($hash, @a) = @_; + my $res = ""; + + my $arg = (defined($a[1]) ? $a[1] : ""); + if ($arg eq "config") { + my $name = $hash->{NAME}; + my $attrdata = $attr{$name}; + if ($attrdata) { + my $x = keys $attrdata; + my $i = 0; + my @splitattr; + $res .= "{\n"; + $res .= " \"CONFIG\": {\n"; + $res .= " \"name\": \"$name\",\n"; + $res .= " \"lockstate\": \"".ReadingsVal($name,"lockstate","unlock")."\",\n"; + + my @iconFolders = split(":", AttrVal($FW_wname, "iconPath", "$FW_sp:default:fhemSVG:openautomation")); + my $iconDirs = ""; + foreach my $idir (@iconFolders) {$iconDirs .= "$attr{global}{modpath}/www/images/".$idir.",";} + $res .= " \"icondirs\": \"$iconDirs\""; + + $res .= ($i != $x) ? ",\n" : "\n"; + foreach my $attr (sort keys $attrdata) { + $i++; + @splitattr = split("@", $attrdata->{$attr}); + if (@splitattr == 2) { + $res .= " \"".Dashboard_Escape($attr)."\": \"".$splitattr[0]."\",\n"; + $res .= " \"".Dashboard_Escape($attr)."color\": \"".$splitattr[1]."\""; + } else { $res .= " \"".Dashboard_Escape($attr)."\": \"".$attrdata->{$attr}."\"";} + $res .= ($i != $x) ? ",\n" : "\n"; + } + $res .= " }\n"; + $res .= "}\n"; + return $res; + } + } elsif ($arg eq "groupWidget") { +#### Comming Soon ###### +# For dynamic load of GroupWidgets from JavaScript + my $dbgroup = ""; + #for (my $p=2;$p<@a;$p++){$dbgroup .= @a[$p]." ";} #For Groupnames with Space + for (my $p=2;$p<@a;$p++){$dbgroup .= $a[$p]." ";} #For Groupnames with Space + + $dashboard_groupListfhem = Dashboard_GetGroupList; + %group = BuildGroupList($dashboard_groupListfhem); + $res .= BuildGroupWidgets(1,1,1212,trim($dbgroup),"t1c1,".trim($dbgroup).",true,0,0:"); + return $res; + } else { + return "Unknown argument $arg choose one of config:noArg groupWidget"; + } +} + sub Dashboard_define ($$) { my ($hash, $def) = @_; my $now = time(); @@ -216,6 +285,8 @@ sub Dashboard_define ($$) { RemoveInternalTimer($hash); InternalTimer ($now + 5, 'CreateDashboardEntry', $hash, 0); InternalTimer ($now + 5, 'CheckDashboardAttributUssage', $hash, 0); + my $dashboard_groupListfhem = Dashboard_GetGroupList; + return; } @@ -295,15 +366,7 @@ sub Dashboard_SummaryFN($$$$) AttrVal($defs{$d}{NAME}, "dashboard_tab4sorting", ""), AttrVal($defs{$d}{NAME}, "dashboard_tab5sorting", ""), AttrVal($defs{$d}{NAME}, "dashboard_tab6sorting", ""), - AttrVal($defs{$d}{NAME}, "dashboard_tab7sorting", "")); - my @tabicons = (AttrVal($defs{$d}{NAME}, "dashboard_tab1icon", ""), - AttrVal($defs{$d}{NAME}, "dashboard_tab2icon", ""), - AttrVal($defs{$d}{NAME}, "dashboard_tab3icon", ""), - AttrVal($defs{$d}{NAME}, "dashboard_tab4icon", ""), - AttrVal($defs{$d}{NAME}, "dashboard_tab5icon", ""), - AttrVal($defs{$d}{NAME}, "dashboard_tab6icon", ""), - AttrVal($defs{$d}{NAME}, "dashboard_tab7icon", "")); - + AttrVal($defs{$d}{NAME}, "dashboard_tab7sorting", "")); ############################################################################################# if ($disable == 1) { @@ -324,6 +387,7 @@ sub Dashboard_SummaryFN($$$$) if (trim($FW_wname) eq trim($webfilter[$i]) ) { $filterhit = 1; } } if ($filterhit == 0) { + # construction site # $ret .= "No Dashboard configured for ".$FW_wname."
"; # $ret .= "Set Attribute dashboard_webfrontendfilter, see Details"; return $ret; @@ -352,25 +416,33 @@ sub Dashboard_SummaryFN($$$$) #------------------------------------------------------------------------------------------------- if ($room ne "all") { + + ################################ + $dashboard_groupListfhem = Dashboard_GetGroupList; + ################################ + $ret .= "
\n"; $ret .= "
\n"; $ret .= " \n"; $ret .= "
\n"; $ret .= " \n"; $ret .= " \n"; $ret .= " "; - $ret .= " "; - $ret .= " "; - $ret .= " "; + $ret .= " "; + $ret .= " "; + $ret .= " "; $ret .= "
Tabtitle:
Tabicon:
Groups:
Tabicon:
Groups:
\n"; - $ret .= "
\n"; + $ret .= "
\n"; + $ret .= "
\n"; + $ret .= "Comming soon"; + $ret .= "
\n"; $ret .= "
\n"; $ret .= "\n"; + $ret .= "
$d
\n"; $ret .= "\n"; $ret .= "
\n"; @@ -380,25 +452,19 @@ sub Dashboard_SummaryFN($$$$) $ret .= "
\n"; ########################### Dashboard Tab-Liste ############################################## - my $tabicon = ""; - $ret .= "