mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-05 17:48:44 +00:00
fhemweb.js: online attribute updates, perlSyntaxCheck for Attributes
git-svn-id: https://svn.fhem.de/fhem/trunk@11220 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b8ec4b53a3
commit
84b3fbf305
@ -1061,14 +1061,7 @@ FW_makeTable($$$@)
|
||||
FW_makeEdit($name, $n, $val);
|
||||
|
||||
} else {
|
||||
if( $title eq "Attributes" ) {
|
||||
my $id = "sel_attr$name"; $id =~ s/\./_/g;
|
||||
FW_pO "<td><div class=\"dname\">".
|
||||
"<a onClick='FW_querySetSelected(\"$id\",\"$n\")'>".
|
||||
"$n</a></div></td>";
|
||||
} else {
|
||||
FW_pO "<td><div class=\"dname\">$n</div></td>";
|
||||
}
|
||||
FW_pO "<td><div class=\"dname\" data-name=\"$name\">$n</div></td>";
|
||||
|
||||
if(ref($val)) { #handle readings
|
||||
my ($v, $t) = ($val->{VAL}, $val->{TIME});
|
||||
@ -1083,16 +1076,17 @@ FW_makeTable($$$@)
|
||||
}
|
||||
} else {
|
||||
$val = FW_htmlEscape($val);
|
||||
my $tattr = "informId=\"$name-$n\" class=\"dval\"";
|
||||
|
||||
# if possible provide some links
|
||||
if ($n eq "room"){
|
||||
FW_pO "<td><div class=\"dval\">".
|
||||
FW_pO "<td><div $tattr>".
|
||||
join(",", map { FW_pH("room=$_",$_,0,"",1,1) } split(",",$val)).
|
||||
"</div></td>";
|
||||
|
||||
} elsif ($n eq "webCmd"){
|
||||
my $lc = "detail=$name&cmd.$name=set $name";
|
||||
FW_pO "<td><div name=\"$name-$n\" class=\"dval\">".
|
||||
FW_pO "<td><div name=\"$name-$n\" $tattr>".
|
||||
join(":", map {FW_pH("$lc $_",$_,0,"",1,1)} split(":",$val) ).
|
||||
"</div></td>";
|
||||
|
||||
@ -1104,7 +1098,7 @@ FW_makeTable($$$@)
|
||||
|
||||
} else {
|
||||
$val = "<pre>$val</pre>" if($val =~ m/\n/ && $title eq "Attributes");
|
||||
FW_pO "<td><div class=\"dval\">".
|
||||
FW_pO "<td><div $tattr>".
|
||||
join(",", map { ($_ ne $name && $defs{$_}) ?
|
||||
FW_pH( "detail=$_", $_ ,0,"",1,1) : $_ } split(",",$val)).
|
||||
"</div></td>";
|
||||
@ -1138,13 +1132,14 @@ FW_detailSelect(@)
|
||||
$list =~ s/"/"/g;
|
||||
|
||||
my $ret ="";
|
||||
my $psc = AttrVal("global", "perlSyntaxCheck", ($featurelevel>5.7) ? 1 : 0);
|
||||
$ret .= "<div class='makeSelect' dev=\"$d\" cmd=\"$cmd\" list=\"$list\">";
|
||||
$ret .= "<form method=\"$FW_formmethod\" ".
|
||||
"action=\"$FW_ME$FW_subdir\" autocomplete=\"off\">";
|
||||
$ret .= FW_hidden("detail", $d);
|
||||
$ret .= FW_hidden("fwcsrf", $defs{$FW_wname}{CSRFTOKEN}) if($FW_CSRF);
|
||||
$ret .= FW_hidden("dev.$cmd$d", $d.($param ? " $param":""));
|
||||
$ret .= FW_submit("cmd.$cmd$d", $cmd, $cmd);
|
||||
$ret .= FW_submit("cmd.$cmd$d", $cmd, $cmd.($psc?" psc":""));
|
||||
$ret .= "<div class=\"$cmd downText\"> $d ".
|
||||
($param ? " $param":"")."</div>";
|
||||
$ret .= FW_select("sel_$cmd$d","arg.$cmd$d",\@al, $selEl, $cmd);
|
||||
@ -2505,6 +2500,7 @@ FW_Notify($$)
|
||||
my $h = $ntfy->{inform};
|
||||
return undef if(!$h);
|
||||
my $isStatus = ($h->{type} =~ m/status/);
|
||||
my $events;
|
||||
|
||||
my $dn = $dev->{NAME};
|
||||
if($dn eq "global" && $isStatus) {
|
||||
@ -2512,7 +2508,15 @@ FW_Notify($$)
|
||||
my $data = FW_longpollInfo($h->{fmt},
|
||||
"#FHEMWEB:$ntfy->{NAME}","\$('#saveCheck').css('visibility','$vs')","");
|
||||
addToWritebuffer($ntfy, $data."\n");
|
||||
$dn = $1 if($dev->{CHANGED} && $dev->{CHANGED}->[0] =~ m/^MODIFIED (.*)$/);
|
||||
|
||||
if($dev->{CHANGED}) {
|
||||
$dn = $1 if($dev->{CHANGED}->[0] =~ m/^MODIFIED (.*)$/);
|
||||
if($dev->{CHANGED}->[0] =~ m/^ATTR ([^ ]+) ([^ ]+.*) (.*)$/) {
|
||||
$dn = $1;
|
||||
my @a = ("$2: $3");
|
||||
$events = \@a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($dn eq $ntfy->{SNAME} &&
|
||||
@ -2530,7 +2534,9 @@ FW_Notify($$)
|
||||
my @data;
|
||||
my %extPage;
|
||||
my $isRaw = ($h->{type} =~ m/raw/);
|
||||
my $events = deviceEvents($dev, AttrVal($FW_wname, "addStateEvent",!$isRaw));
|
||||
$events = deviceEvents($dev, AttrVal($FW_wname, "addStateEvent",!$isRaw))
|
||||
if(!$events);
|
||||
Log 1, "C: $dn $events->[0]";
|
||||
|
||||
if($isStatus) {
|
||||
# Why is saving this stuff needed? FLOORPLAN?
|
||||
|
@ -196,6 +196,19 @@ FW_jqueryReadyFn()
|
||||
});
|
||||
});
|
||||
|
||||
$("table.attributes tr div.dname") // Click on attribute fills input value
|
||||
.each(function(){
|
||||
$(this)
|
||||
.html('<a href="#">'+$(this).html()+'</a>')
|
||||
.css({cursor:"pointer"})
|
||||
.click(function(){
|
||||
var aname = "#sel_attr"+$(this).attr("data-name");
|
||||
$(aname).val($(this).text());
|
||||
FW_detailSelect(aname);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
FW_smallScreenCommands();
|
||||
|
||||
FW_inlineModify();
|
||||
@ -460,10 +473,28 @@ FW_replaceLink(el)
|
||||
function
|
||||
FW_inlineModify() // Do not generate a new HTML page upon pressing modify
|
||||
{
|
||||
$("div#edit input.psc[type=submit]").click(function(e){
|
||||
$("div input.psc[type=submit]").click(function(e){
|
||||
e.preventDefault();
|
||||
var newDef = $(this).closest("form").find("textarea").val();
|
||||
var cmd = $(this).attr("name")+"="+$(this).attr("value")+" "+newDef;
|
||||
|
||||
if( newDef == undefined ) {
|
||||
var div = $(this).closest("div.makeSelect");
|
||||
var devName = $(div).attr("dev"),
|
||||
cmd = $(div).attr("cmd");
|
||||
var sel = $(this).closest("form").find("select");
|
||||
var arg = $(sel).val();
|
||||
if($(".dval[informid="+devName+"-"+arg+"]").length == 0) {
|
||||
console.log(this);
|
||||
$(this).unbind('click').click();// No element found to replace
|
||||
return;
|
||||
}
|
||||
newDef = $(this).closest("form").find("input:text").val();
|
||||
if(newDef == undefined)
|
||||
newDef = $(this).closest("form").find("select:last").val();
|
||||
cmd = $(this).attr("name")+"="+cmd+" "+devName+" "+arg+" "+newDef;
|
||||
}
|
||||
|
||||
FW_cmd(FW_root+"?"+encodeURIComponent(cmd)+"&XHR=1", function(resp){
|
||||
if(resp)
|
||||
return FW_okDialog(resp);
|
||||
@ -725,13 +756,6 @@ FW_queryValue(cmd, el)
|
||||
qConn.send(null);
|
||||
}
|
||||
|
||||
function
|
||||
FW_querySetSelected(el, val) // called by the attribute links
|
||||
{
|
||||
$("#"+el).val(val);
|
||||
FW_detailSelect("#"+el);
|
||||
}
|
||||
|
||||
/*************** TEXTFIELD **************/
|
||||
function
|
||||
FW_createTextField(elName, devName, vArr, currVal, set, params, cmd)
|
||||
|
Loading…
x
Reference in New Issue
Block a user