mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
FHEMWEB console
git-svn-id: https://svn.fhem.de/fhem/trunk@1296 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
89236aa1be
commit
924e4b58a3
@ -16,6 +16,7 @@
|
|||||||
- feature: webCmd in smallScreen added
|
- feature: webCmd in smallScreen added
|
||||||
- feature: TRX modules by Willi
|
- feature: TRX modules by Willi
|
||||||
- feature: FHEMWEB icons (by Joerg)
|
- feature: FHEMWEB icons (by Joerg)
|
||||||
|
- feature: FHEMWEB console (== inform timer)
|
||||||
|
|
||||||
- 2011-12-31 (5.2)
|
- 2011-12-31 (5.2)
|
||||||
- bugfix: applying smallscreen attributes to firefox/opera
|
- bugfix: applying smallscreen attributes to firefox/opera
|
||||||
|
@ -417,7 +417,7 @@ FW_AnswerCall($)
|
|||||||
$FW_cmdret = $docmd ? FW_fC($cmd) : "";
|
$FW_cmdret = $docmd ? FW_fC($cmd) : "";
|
||||||
|
|
||||||
if($FW_inform) { # Longpoll header
|
if($FW_inform) { # Longpoll header
|
||||||
$me->{inform} = $FW_room;
|
$me->{inform} = ($FW_room ? $FW_room : $FW_inform);
|
||||||
# NTFY_ORDER is larger than the normal order (50-)
|
# NTFY_ORDER is larger than the normal order (50-)
|
||||||
$me->{NTFY_ORDER} = $FW_cname; # else notifyfn won't be called
|
$me->{NTFY_ORDER} = $FW_cname; # else notifyfn won't be called
|
||||||
my $c = $me->{CD};
|
my $c = $me->{CD};
|
||||||
@ -806,6 +806,7 @@ FW_roomOverview($)
|
|||||||
# "Examples", "$FW_ME/cmd=style%20examples",
|
# "Examples", "$FW_ME/cmd=style%20examples",
|
||||||
"Edit files", "$FW_ME/cmd=style%20list",
|
"Edit files", "$FW_ME/cmd=style%20list",
|
||||||
"Select style","$FW_ME/cmd=style%20select",
|
"Select style","$FW_ME/cmd=style%20select",
|
||||||
|
"Console", "$FW_ME/cmd=style%20console",
|
||||||
"", "");
|
"", "");
|
||||||
my $lastname = ","; # Avoid double "".
|
my $lastname = ","; # Avoid double "".
|
||||||
for(my $idx = 0; $idx < @list; $idx+= 2) {
|
for(my $idx = 0; $idx < @list; $idx+= 2) {
|
||||||
@ -1576,6 +1577,12 @@ FW_style($$)
|
|||||||
}
|
}
|
||||||
FW_pO "</table></div>";
|
FW_pO "</table></div>";
|
||||||
|
|
||||||
|
} elsif($a[1] eq "console") {
|
||||||
|
FW_pO "<script type=\"text/javascript\" src=\"$FW_ME/console.js\"></script>";
|
||||||
|
FW_pO "<div id=\"content\">";
|
||||||
|
FW_pO "<div id=\"console\">";
|
||||||
|
FW_pO "</div>";
|
||||||
|
FW_pO "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1849,26 +1856,44 @@ FW_Notify($$)
|
|||||||
return undef if(!$filter);
|
return undef if(!$filter);
|
||||||
|
|
||||||
my $ln = $ntfy->{NAME};
|
my $ln = $ntfy->{NAME};
|
||||||
|
|
||||||
my $dn = $dev->{NAME};
|
my $dn = $dev->{NAME};
|
||||||
return undef if($filter ne "all" && AttrVal($dn, "room", "") ne $filter);
|
my $data;
|
||||||
|
|
||||||
FW_ReadIcons();
|
if($filter eq "all" || AttrVal($dn, "room", "") eq $filter) {
|
||||||
|
FW_ReadIcons();
|
||||||
|
|
||||||
my @old = ($FW_wname, $FW_ME, $FW_longpoll, $FW_ss, $FW_tp);
|
my @old = ($FW_wname, $FW_ME, $FW_longpoll, $FW_ss, $FW_tp);
|
||||||
$FW_wname = $ntfy->{SNAME};
|
$FW_wname = $ntfy->{SNAME};
|
||||||
$FW_ME = "/" . AttrVal($FW_wname, "webname", "fhem");
|
$FW_ME = "/" . AttrVal($FW_wname, "webname", "fhem");
|
||||||
$FW_longpoll = 1;
|
$FW_longpoll = 1;
|
||||||
$FW_ss = AttrVal($FW_wname, "smallscreen", 0);
|
$FW_ss = AttrVal($FW_wname, "smallscreen", 0);
|
||||||
$FW_tp = AttrVal($FW_wname, "touchpad", $FW_ss);
|
$FW_tp = AttrVal($FW_wname, "touchpad", $FW_ss);
|
||||||
my ($allSet, $cmdlist, $txt) = FW_devState($dn, "");
|
my ($allSet, $cmdlist, $txt) = FW_devState($dn, "");
|
||||||
($FW_wname, $FW_ME, $FW_longpoll, $FW_ss, $FW_tp) = @old;
|
($FW_wname, $FW_ME, $FW_longpoll, $FW_ss, $FW_tp) = @old;
|
||||||
|
$data = "$dn;$dev->{STATE};$txt\n";
|
||||||
|
|
||||||
# Collect multiple changes (e.g. from noties) into one message
|
} elsif($filter eq "console") {
|
||||||
$ntfy->{INFORMBUF} = "" if(!defined($ntfy->{INFORMBUF}));
|
if($dev->{CHANGED}) { # It gets deleted sometimes (?)
|
||||||
$ntfy->{INFORMBUF} .= "$dn;$dev->{STATE};$txt\n";
|
my $tn = TimeNow();
|
||||||
RemoveInternalTimer($ln);
|
if($attr{global}{mseclog}) {
|
||||||
InternalTimer(gettimeofday()+0.1, "FW_FlushInform", $ln, 0);
|
my ($seconds, $microseconds) = gettimeofday();
|
||||||
|
$tn .= sprintf(".%03d", $microseconds/1000);
|
||||||
|
}
|
||||||
|
my $max = int(@{$dev->{CHANGED}});
|
||||||
|
my $dt = $dev->{TYPE};
|
||||||
|
for(my $i = 0; $i < $max; $i++) {
|
||||||
|
$data .= "$tn $dt $dn ".$dev->{CHANGED}[$i]."<br>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($data) {
|
||||||
|
# Collect multiple changes (e.g. from noties) into one message
|
||||||
|
$ntfy->{INFORMBUF} .= $data;
|
||||||
|
RemoveInternalTimer($ln);
|
||||||
|
InternalTimer(gettimeofday()+0.1, "FW_FlushInform", $ln, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -1881,6 +1906,7 @@ FW_FlushInform($)
|
|||||||
return if(!$hash);
|
return if(!$hash);
|
||||||
my $c = $hash->{CD};
|
my $c = $hash->{CD};
|
||||||
print $c $hash->{INFORMBUF};
|
print $c $hash->{INFORMBUF};
|
||||||
|
$hash->{INFORMBUF}="";
|
||||||
|
|
||||||
CommandDelete(undef, $name);
|
CommandDelete(undef, $name);
|
||||||
}
|
}
|
||||||
|
30
fhem/webfrontend/pgm2/console.js
Normal file
30
fhem/webfrontend/pgm2/console.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
var consConn;
|
||||||
|
|
||||||
|
function
|
||||||
|
consUpdate()
|
||||||
|
{
|
||||||
|
if(consConn.readyState != 4 || consConn.status != 200)
|
||||||
|
return;
|
||||||
|
var el = document.getElementById("console");
|
||||||
|
if(el)
|
||||||
|
el.innerHTML=el.innerHTML+consConn.responseText;
|
||||||
|
consConn.abort();
|
||||||
|
consFill();
|
||||||
|
}
|
||||||
|
|
||||||
|
function
|
||||||
|
consFill()
|
||||||
|
{
|
||||||
|
consConn = new XMLHttpRequest();
|
||||||
|
consConn.open("GET", document.location.pathname+"?XHR=1&inform=console", true);
|
||||||
|
consConn.onreadystatechange = consUpdate;
|
||||||
|
consConn.send(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function
|
||||||
|
consStart()
|
||||||
|
{
|
||||||
|
setTimeout("consFill()", 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.onload = consStart;
|
@ -1,13 +1,5 @@
|
|||||||
var pollConn;
|
var pollConn;
|
||||||
|
|
||||||
function
|
|
||||||
cmd(arg)
|
|
||||||
{
|
|
||||||
var req = new XMLHttpRequest();
|
|
||||||
req.open("GET", arg, true);
|
|
||||||
req.send(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function
|
function
|
||||||
doUpdate()
|
doUpdate()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user