mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 01:46:08 +00:00
update: Minimize CHANGED-file output, filter events in background mode (Forum #26329)
git-svn-id: https://svn.fhem.de/fhem/trunk@6611 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
433c752cb5
commit
91744d09be
@ -689,8 +689,8 @@ FW_answerCall($)
|
|||||||
FW_pO "</head>\n<body name=\"$t\" $csrf $onload>";
|
FW_pO "</head>\n<body name=\"$t\" $csrf $onload>";
|
||||||
|
|
||||||
if($FW_activateInform) {
|
if($FW_activateInform) {
|
||||||
|
$cmd = "style eventMonitor $FW_activateInform";
|
||||||
$FW_cmdret = $FW_activateInform = "";
|
$FW_cmdret = $FW_activateInform = "";
|
||||||
$cmd = "style eventMonitor";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FW_roomOverview($cmd);
|
FW_roomOverview($cmd);
|
||||||
@ -1740,8 +1740,13 @@ FW_style($$)
|
|||||||
FW_pO "<script type=\"text/javascript\" src=\"$FW_ME/pgm2/console.js\">".
|
FW_pO "<script type=\"text/javascript\" src=\"$FW_ME/pgm2/console.js\">".
|
||||||
"</script>";
|
"</script>";
|
||||||
FW_pO "<div id=\"content\">";
|
FW_pO "<div id=\"content\">";
|
||||||
|
if($a[2] && $a[2] ne "1") {
|
||||||
|
FW_pO "<div id=\"console\" filter=\"$a[2]\">";
|
||||||
|
FW_pO "Events ($a[2] only):<br>\n";
|
||||||
|
} else {
|
||||||
FW_pO "<div id=\"console\">";
|
FW_pO "<div id=\"console\">";
|
||||||
FW_pO "Events:<br>\n";
|
FW_pO "Events:<br>\n";
|
||||||
|
}
|
||||||
FW_pO "</div>";
|
FW_pO "</div>";
|
||||||
FW_pO "</div>";
|
FW_pO "</div>";
|
||||||
|
|
||||||
@ -2184,7 +2189,11 @@ FW_Notify($$)
|
|||||||
return undef if(!$h);
|
return undef if(!$h);
|
||||||
|
|
||||||
my $dn = $dev->{NAME};
|
my $dn = $dev->{NAME};
|
||||||
return undef if(!$h->{devices}{$dn} && $h->{type} !~ m/raw/);
|
if($h->{type} eq "raw") {
|
||||||
|
return undef if($dn !~ m/$h->{filter}/);
|
||||||
|
} else { # Status
|
||||||
|
return undef if(!$h->{devices}{$dn});
|
||||||
|
}
|
||||||
|
|
||||||
my @data;
|
my @data;
|
||||||
my %extPage;
|
my %extPage;
|
||||||
@ -2558,9 +2567,10 @@ FW_visibleDevices(;$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
FW_ActivateInform()
|
FW_ActivateInform($;$)
|
||||||
{
|
{
|
||||||
$FW_activateInform = 1;
|
my ($cl, $arg) = @_;
|
||||||
|
$FW_activateInform = ($arg ? $arg : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
|
@ -324,11 +324,12 @@ telnet_Undef($$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
telnet_ActivateInform($)
|
telnet_ActivateInform($;$)
|
||||||
{
|
{
|
||||||
my ($cl) = @_;
|
my ($cl, $arg) = @_;
|
||||||
my $name = $cl->{NAME};
|
my $name = $cl->{NAME};
|
||||||
CommandInform($cl, "timer") if(!$inform{$name});
|
$arg = "" if(!defined($arg));
|
||||||
|
CommandInform($cl, "timer $arg") if(!$inform{$name});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ CommandUpdate($$)
|
|||||||
$updateInBackground = 0 if($arg ne "all");
|
$updateInBackground = 0 if($arg ne "all");
|
||||||
$updArg = $arg;
|
$updArg = $arg;
|
||||||
if($updateInBackground) {
|
if($updateInBackground) {
|
||||||
CallFn($cl->{NAME}, "ActivateInformFn", $cl);
|
CallFn($cl->{NAME}, "ActivateInformFn", $cl, "global");
|
||||||
BlockingCall("doUpdateInBackground", {src=>$src,arg=>$arg});
|
BlockingCall("doUpdateInBackground", {src=>$src,arg=>$arg});
|
||||||
return "Executing the update the background.";
|
return "Executing the update the background.";
|
||||||
|
|
||||||
@ -150,8 +150,7 @@ doUpdate($$)
|
|||||||
|
|
||||||
my @excl = split(" ", AttrVal("global", "exclude_from_update", ""));
|
my @excl = split(" ", AttrVal("global", "exclude_from_update", ""));
|
||||||
|
|
||||||
uLog 1, "List of new / modified files since last update:"
|
my @rl = upd_getChanges($root, $basePath);
|
||||||
if($arg eq "check");
|
|
||||||
###########################
|
###########################
|
||||||
# process the remote controlfile
|
# process the remote controlfile
|
||||||
my $nChanged = 0;
|
my $nChanged = 0;
|
||||||
@ -194,6 +193,8 @@ doUpdate($$)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uLog 1, "List of new / modified files since last update:"
|
||||||
|
if($arg eq "check" && $nChanged == 0);
|
||||||
uLog 1, "$r[0] $fName";
|
uLog 1, "$r[0] $fName";
|
||||||
$nChanged++;
|
$nChanged++;
|
||||||
next if($arg eq "check");
|
next if($arg eq "check");
|
||||||
@ -222,17 +223,12 @@ doUpdate($$)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($arg eq "check") {
|
if(@rl) {
|
||||||
my @lines = split(/[\r\n]/,upd_getUrl("$basePath/CHANGED"));
|
uLog(1, "");
|
||||||
my $ret = "";
|
uLog 1, "New entries in the CHANGED file:";
|
||||||
foreach my $line (@lines) {
|
map { uLog 1, $_ } @rl;
|
||||||
next if($line =~ m/^#/);
|
|
||||||
last if($line eq "");
|
|
||||||
$ret .= $line."\n";
|
|
||||||
}
|
|
||||||
uLog 1, "\nList of last changes:\n".$ret;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return if($arg eq "check");
|
||||||
|
|
||||||
if($arg eq "all" || $arg eq "force") { # store the controlfile
|
if($arg eq "all" || $arg eq "force") { # store the controlfile
|
||||||
return if(!upd_writeFile($root, $restoreDir,
|
return if(!upd_writeFile($root, $restoreDir,
|
||||||
@ -272,6 +268,35 @@ upd_mkDir($$$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
upd_getChanges($$)
|
||||||
|
{
|
||||||
|
my ($root, $basePath) = @_;
|
||||||
|
my $lFile = "";
|
||||||
|
if(open(FH, "$root/CHANGED")) {
|
||||||
|
foreach my $l (<FH>) { # first non-comment line
|
||||||
|
next if($l =~ m/^#/);
|
||||||
|
chomp $l;
|
||||||
|
$lFile = $l;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
close(FH);
|
||||||
|
}
|
||||||
|
my @lines = split(/[\r\n]/,upd_getUrl("$basePath/CHANGED"));
|
||||||
|
my $maxLines = 25;
|
||||||
|
my @ret;
|
||||||
|
foreach my $line (@lines) {
|
||||||
|
next if($line =~ m/^#/);
|
||||||
|
last if($line eq "" || $line eq $lFile);
|
||||||
|
push @ret, $line;
|
||||||
|
if($maxLines-- < 1) {
|
||||||
|
push @ret, "... rest of lines skipped.";
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return @ret;
|
||||||
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
upd_getUrl($)
|
upd_getUrl($)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
var consConn;
|
var consConn;
|
||||||
|
|
||||||
var isFF = (navigator.userAgent.toLowerCase().indexOf('firefox') > -1);
|
var isFF = (navigator.userAgent.toLowerCase().indexOf('firefox') > -1);
|
||||||
|
var consFilter, consTxt;
|
||||||
|
|
||||||
log("Console is opening");
|
log("Console is opening");
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ consUpdate()
|
|||||||
|
|
||||||
var el = document.getElementById("console");
|
var el = document.getElementById("console");
|
||||||
if(el) {
|
if(el) {
|
||||||
el.innerHTML="Events:<br>"+consConn.responseText;
|
el.innerHTML=consTxt+consConn.responseText;
|
||||||
el.scrollTop = el.scrollHeight;
|
el.scrollTop = el.scrollHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -27,9 +28,10 @@ function
|
|||||||
consFill()
|
consFill()
|
||||||
{
|
{
|
||||||
FW_errmsg("");
|
FW_errmsg("");
|
||||||
|
|
||||||
consConn = new XMLHttpRequest();
|
consConn = new XMLHttpRequest();
|
||||||
var query = document.location.pathname+"?XHR=1"+
|
var query = document.location.pathname+"?XHR=1"+
|
||||||
"&inform=type=raw;filter=.*"+
|
"&inform=type=raw;filter="+consFilter+
|
||||||
"×tamp="+new Date().getTime();
|
"×tamp="+new Date().getTime();
|
||||||
query = addcsrf(query);
|
query = addcsrf(query);
|
||||||
consConn.open("GET", query, true);
|
consConn.open("GET", query, true);
|
||||||
@ -40,6 +42,12 @@ consFill()
|
|||||||
function
|
function
|
||||||
consStart()
|
consStart()
|
||||||
{
|
{
|
||||||
|
var el = document.getElementById("console");
|
||||||
|
|
||||||
|
consFilter = el.getAttribute("filter");
|
||||||
|
if(consFilter == undefined)
|
||||||
|
consFilter = ".*";
|
||||||
|
consTxt = el.innerHTML;
|
||||||
setTimeout("consFill()", 1000);
|
setTimeout("consFill()", 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user