Dashboard: group names can contain regex special characters now - restoring of group visibility now works as expected - fixed issue that some readingGroups are not updated correctly

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@8949 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
talkabout 2015-07-12 19:56:22 +00:00
parent cf6d611cb5
commit c159e0ee0f
3 changed files with 54 additions and 24 deletions

View File

@ -1,5 +1,8 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # Do not insert empty lines here, update check depends on it.
- bugfix: Dashboard: group names now also can contain regex special characters
restoring of saved group state works now as expected
fixed issue that some readingGroups are not updated correcly
- change: 02_RSS: replaced refresh method by javascript DOM gymnastics - change: 02_RSS: replaced refresh method by javascript DOM gymnastics
- change: 59_Weather: removed empty header row from WeatherAsHtmlV - change: 59_Weather: removed empty header row from WeatherAsHtmlV
- feature: 02_HTTPSRV: support tabletui (Forum #37232) - feature: 02_HTTPSRV: support tabletui (Forum #37232)

View File

@ -542,25 +542,45 @@ sub BuildDashboardTab($$)
my @temptabgroup = split(",", $tabgroups[$t]); #Set temp. position for groups without an stored position my @temptabgroup = split(",", $tabgroups[$t]); #Set temp. position for groups without an stored position
my @tabgroup = (); my @tabgroup = ();
my @index = ();
foreach my $g (@groups){
for (my $i=0;$i<@temptabgroup;$i++) { for (my $i=0;$i<@temptabgroup;$i++) {
my @stabgroup = split(":", trim($temptabgroup[$i])); my @stabgroup = split(":", trim($temptabgroup[$i]));
my $matchGroup = trim($stabgroup[0]); @index = grep { @groups[$_] eq @stabgroup[0] } (0 .. @groups-1);
# fill groups that are matching the configured groups if (@index > 0) {
if ($g =~ m/$matchGroup/ && $g ne $stabgroup[0]) { for (my $j=0; $j<@index;$j++) {
push(@tabgroup, $g); my $groupname = @groups[@index[$j]];
if (@stabgroup > 1) {
$groupname .= ':' . @stabgroup[1];
} }
elsif ($g eq $stabgroup[0]) { push(@tabgroup,$groupname);
push(@tabgroup, $g); }
}
else {
my $matchGroup = '^' . @stabgroup[0] . '$';
@index = grep { @groups[$_] =~ m/$matchGroup/ } (0 .. @groups-1);
if (@index > 0) {
for (my $j=0; $j<@index;$j++) {
my $groupname = @groups[@index[$j]];
if (@stabgroup > 1) {
$groupname .= ':' . @stabgroup[1];
}
push(@tabgroup,$groupname);
} }
} }
} }
}
$tabgroups[$t] = join(',', @tabgroup);
for (my $i=0;$i<@tabgroup;$i++) { for (my $i=0;$i<@tabgroup;$i++) {
my @stabgroup = split(":", trim($tabgroup[$i])); my @stabgroup = split(":", trim($tabgroup[$i]));
my $matchGroup = "," . trim($stabgroup[0]) . ","; my $matchGroup = "," . quotemeta(trim($stabgroup[0])) . ",";
if ($tabsortings[$t] !~ m/$matchGroup/) { if ($tabsortings[$t] !~ m/$matchGroup/) {
$tabsortings[$t] = $tabsortings[$t]."t".$t."c".GetMaxColumnId($row,$colcount).",".trim($stabgroup[0]).",true,0,0:"; $tabsortings[$t] = $tabsortings[$t]."t".$t."c".GetMaxColumnId($row,$colcount).",".trim($stabgroup[0]).",true,0,0:";
@ -657,15 +677,11 @@ sub BuildGroupWidgets($$$$$) {
foreach my $singlesorting (@storedsorting) { foreach my $singlesorting (@storedsorting) {
my @groupdata = split(",", $singlesorting); my @groupdata = split(",", $singlesorting);
my $groupMatch = $dbgroups;
$groupicon = ''; $groupicon = '';
if (scalar(@groupdata) > 1) { if (scalar(@groupdata) > 1) {
if ( if (
index($dbsorting, "t".$tab."c".$column.",".$groupdata[1]) >= 0 index($dbsorting, "t".$tab."c".$column.",".$groupdata[1]) >= 0
&& ( && index($dbgroups, $groupdata[1]) >= 0
index($dbgroups, $groupdata[1]) >= 0
|| $groupdata[1] =~ $groupMatch
)
&& $groupdata[1] ne "" && $groupdata[1] ne ""
) { #group is set to tab ) { #group is set to tab
my $groupId = $id."t".$tab."c".$column."w".$counter; my $groupId = $id."t".$tab."c".$column."w".$counter;
@ -694,7 +710,7 @@ sub BuildGroupList($) {
$grp = trim($grp); $grp = trim($grp);
foreach my $g (@dashboardgroups){ foreach my $g (@dashboardgroups){
my ($gtitle, $iconName) = split(":", trim($g)); my ($gtitle, $iconName) = split(":", trim($g));
my $titleMatch = "^" . $gtitle . "\$"; my $titleMatch = "^" . quotemeta($gtitle) . "\$";
$group{$grp}{$d} = 1 if($grp =~ $titleMatch); $group{$grp}{$d} = 1 if($grp =~ $titleMatch);
} }
} }
@ -718,14 +734,13 @@ sub BuildGroup
my $ret = ""; my $ret = "";
my $row = 1; my $row = 1;
my %extPage = (); my %extPage = ();
my $matchGroup = "^" . $currentgroup . "\$";
my $foundDevices = 0; my $foundDevices = 0;
my $replaceGroup = ""; my $replaceGroup = "";
my $rf = ($FW_room ? "&amp;room=$FW_room" : ""); # stay in the room my $rf = ($FW_room ? "&amp;room=$FW_room" : ""); # stay in the room
foreach my $g (keys %group) { foreach my $g (keys %group) {
next if ($g !~ m/$matchGroup/); next if ($g ne $currentgroup);
$replaceGroup = "," . quotemeta($currentgroup) . ","; $replaceGroup = "," . quotemeta($currentgroup) . ",";
$singleSorting =~ s/$replaceGroup/,$g,/; $singleSorting =~ s/$replaceGroup/,$g,/;
$currentgroup = $g; $currentgroup = $g;

View File

@ -243,7 +243,9 @@ function restoreOrder(ActiveTabId) {
width = $(this).find(".dashboard_content").children().outerWidth()+10; width = $(this).find(".dashboard_content").children().outerWidth()+10;
} }
} }
if (width) {
$(this).outerWidth(width); $(this).outerWidth(width);
}
//--------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------
//-------------------------------- Height of an Group. | Min. Height if need --------------------------- //-------------------------------- Height of an Group. | Min. Height if need ---------------------------
@ -492,11 +494,16 @@ function dashboard_load_tab(tabIndex) {
function dashboard_insert_tab(tabIndex, content) { function dashboard_insert_tab(tabIndex, content) {
$('#dashboardtabs').append(content); $('#dashboardtabs').append(content);
$("#dashboardtabs").tabs('refresh'); $("#dashboardtabs").tabs('refresh');
// call FHEM specific widget replacement
FW_replaceWidgets($("#dashboard_tab" + tabIndex)); FW_replaceWidgets($("#dashboard_tab" + tabIndex));
dashboard_init_tab(tabIndex); dashboard_init_tab(tabIndex);
// call FHEMWEB specific link replacement
$("#dashboard_tab" + tabIndex + " a").each(function() { FW_replaceLink(this); }); $("#dashboard_tab" + tabIndex + " a").each(function() { FW_replaceLink(this); });
restoreOrder(tabIndex); restoreOrder(tabIndex);
restoreGroupVisibility(tabIndex);
if (gridSize = is_dashboard_flexible()) { if (gridSize = is_dashboard_flexible()) {
var $container = $("#dashboard_rowcenter_tab" + tabIndex); var $container = $("#dashboard_rowcenter_tab" + tabIndex);
$("#dashboard_tab" + tabIndex + " .dashboard_widget").draggable({ $("#dashboard_tab" + tabIndex + " .dashboard_widget").draggable({
@ -515,11 +522,16 @@ function dashboard_insert_tab(tabIndex, content) {
}); });
} }
makeResizable('.dashboard_widget'); makeResizable('.dashboard_widget');
// call the initialization of reading groups
FW_readingsGroupReadyFn($('#dashboard_tab' + tabIndex));
if ((DashboardConfigHash['lockstate'] == "lock") || (dashboard_buttonbar == "hidden")) { if ((DashboardConfigHash['lockstate'] == "lock") || (dashboard_buttonbar == "hidden")) {
dashboard_setlock(); dashboard_setlock();
} else { } else {
dashboard_unsetlock(); dashboard_unsetlock();
} }
restoreGroupVisibility(tabIndex);
} }
function dashboard_init_tab(tabIndex) { function dashboard_init_tab(tabIndex) {
@ -537,7 +549,7 @@ function dashboard_init_tab(tabIndex) {
} else { } else {
hideGroupForButton(this); hideGroupForButton(this);
} }
saveOrder(); //saveOrder();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
}); });
} else { $("#dashboard_tab" + tabIndex + " .dashboard_widgetheader").addClass( "dashboard_widgetheader ui-corner-all" );} } else { $("#dashboard_tab" + tabIndex + " .dashboard_widgetheader").addClass( "dashboard_widgetheader ui-corner-all" );}
@ -565,7 +577,7 @@ function hideGroupForButton(button) {
$(button).parent().removeClass("dashboard_widgetmax"); $(button).parent().removeClass("dashboard_widgetmax");
$(button).parent().addClass("dashboard_widgetmin"); $(button).parent().addClass("dashboard_widgetmin");
$.cookie($parentElement.attr('id') + '_hidden', '1'); $.cookie($parentElement.attr('id') + '_hidden', '1', {expires : 365});
} }
function showGroupForButton(button) { function showGroupForButton(button) {