From 1592862d44411c05f21f14addb05ca224d43affe Mon Sep 17 00:00:00 2001 From: Ellert Date: Sat, 18 Mar 2017 10:38:37 +0000 Subject: [PATCH] 98_DOIFtools.pm: minor fixes, added create DOIF Definition with event derived operands when using event monitor in DOIFtools git-svn-id: https://svn.fhem.de/fhem/trunk@13727 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 + fhem/FHEM/98_DOIFtools.pm | 121 ++++++++++++++++++++++++++++---------- 2 files changed, 93 insertions(+), 30 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 9314deddd..ab28fa6e4 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # 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. + - update: 98_DOIFtools: minor fixes, added create DOIF Definition with + event derived operands when using event monitor in DOIFtools - update: 49_TBot_List: handleUnsolicited & multiline entries - bugfix: 93_DbRep: get svrinfo has only used /opt/fhem/fhem.db (SQLite) - new: 98_expandJSON: initial check in diff --git a/fhem/FHEM/98_DOIFtools.pm b/fhem/FHEM/98_DOIFtools.pm index d21fb9900..9852023b6 100644 --- a/fhem/FHEM/98_DOIFtools.pm +++ b/fhem/FHEM/98_DOIFtools.pm @@ -129,37 +129,78 @@ function doiftoolsCopyToClipboard() { '\n'; var inputPrf = "
"; + txt += (lang ? "Bitte einen Opranden wählen." : "Select an Operand please.") + "

"; for (var i = 0; i < diop.length; i++) { txt += "
"+inputPrf+"'opType' id='di"+i+"' />"+ "

"; } - txt += ""; + + if ($('#doiftoolstype').attr('devtype') == 'doif') { + txt += ""; + } else if ($('#doiftoolstype').attr('devtype') == 'doiftools') { + txt += ""; + } $('body').append(''); - $('#evtCoM').dialog( - { modal:true, closeOnEscape:true, width:"auto", - close:function(){ $('#evtCoM').remove(); }, - buttons:[ - { text:"Cancel", click:function(){ $(this).dialog('close'); }}, - { text:"Open DEF-Editor", title:(lang ? "Kopiert die Eingabezeile in die Zwischenablage und öffnet den DEF-Editor der aktuellen Detailansicht. Mit Strg-v kann der Inhalt der Zwischenablage in die Definition eingefügt werden." : "Copies the input line to clipboard and opens the DEF editor of the current detail view. Paste the content of the clipboard to the editor by using ctrl-v"), click:function(){ - $("input#opditmp").val($("input#opditmp").val()).select(); - document.execCommand("copy"); - if ($("#edit").css("display") == "none") - $("#DEFa").click(); - $(this).dialog('close'); - }}], - open:function(){ - $("#evtCoM input,#evtCoM select").change(optChanged); - } - }); + if ($('#doiftoolstype').attr('devtype') == 'doif') { + $('#evtCoM').dialog( + { modal:true, closeOnEscape:true, width:"auto", + close:function(){ $('#evtCoM').remove(); }, + buttons:[ + { text:"Cancel", click:function(){ $(this).dialog('close'); }}, + { text:"Open DEF-Editor", title:(lang ? "Kopiert die Eingabezeile in die Zwischenablage und öffnet den DEF-Editor der aktuellen Detailansicht. Mit Strg-v kann der Inhalt der Zwischenablage in die Definition eingefügt werden." : "Copies the input line to clipboard and opens the DEF editor of the current detail view. Paste the content of the clipboard to the editor by using ctrl-v"), click:function(){ + $("input#opditmp").select(); + document.execCommand("copy"); + if ($("#edit").css("display") == "none") + $("#DEFa").click(); + $(this).dialog('close'); + }}], + open:function(){ + $("#evtCoM input[name='opType'],#evtCoM select").change(optChanged); + } + }); + } else if ($('#doiftoolstype').attr('devtype') == 'doiftools') { + $('#evtCoM').dialog( + { modal:true, closeOnEscape:true, width:"auto", + close:function(){ $('#evtCoM').remove(); }, + buttons:[ + { text:"Cancel", click:function(){ $(this).dialog('close'); }}, + { text:"Execute Definition", title:(lang ? "Führt den define-Befehl aus und öffnet die Detailansicht des erzeugten Gerätes." : "Executes the define command and opens the detail view of the created device."), click:function(){ + FW_cmd(myFW_root+"?cmd="+$("input#opditmp").val()+"&XHR=1"); + $("input[class='maininput'][name='cmd']").val($("input#opditmp").val()); + var newDev = $("input#opditmp").val(); + $(this).dialog('close'); + var rex = newDev.match(/define\s+(.*)\s+DOIF/); + try { + location = myFW_root+'?detail='+rex[1]; + } catch (e) { + + } + }}], + open:function(){ + $("#evtCoM input[name='opType'],#evtCoM select").change(optChanged); + } + }); + } + }); } function optChanged() { - $("input#opditmp").val($("#evtCoM input:checked").next("label").text()); + if ($('#doiftoolstype').attr('devtype') == 'doif') { + $("input#opditmp").val($("#evtCoM input:checked").next("label").text()); + } else if ($('#doiftoolstype').attr('devtype') == 'doiftools') { + var N = 8; + var newDev = Array(N+1).join((Math.random().toString(36)+'00000000000000000').slice(2, 18)).slice(0, N); + $("input#opditmp").val('define newDevice_'+newDev+' DOIF ('+$("#evtCoM input:checked").next("label").text()+') ()'); + var inpt = document.getElementById("opditmp"); + inpt.focus(); + inpt.setSelectionRange(7,17+N); + } } function delbutton() { @@ -298,12 +339,12 @@ sub DOIFtools_eM($$$$) { $ret .= ""; my $filter = $a ? ($a eq "log" ? "global" : $a) : ".*"; $ret .= "
"; - $ret .= "

"; + $ret .= "

"; $ret .= "Events (Filter: $filter) ". "  FHEM log ". "". - "  
\n"; + "  ".($lang eq "DE" ? " Hinweis: Eventzeile markieren, Operanden auswählen, Definition ergänzen" : " Hint: select event line, choose operand, modify definition")."
\n"; $ret .= ""; $ret .= "
"; $ret .= $DOIFtoolsJSfuncEM; @@ -486,9 +527,9 @@ sub DOIFtools_fhemwebFn($$$$) { "  FHEM log ". "". - "  \n"; - $ret .= "
"; - $ret .= ""; + "  ".($lang eq "DE" ? " Hinweis: Eventzeile markieren, Operanden auswählen, neue Definition erzeugen" : " Hint: select event line, choose operand, create definition")."
\n"; + $ret .= "
"; + $ret .= ""; $ret .= "
"; $ret .= $DOIFtoolsJSfuncEM; } @@ -1423,7 +1464,7 @@ DOIFtools contains tools to support DOIF.
  • show a list of running wait timer

  • -Just one definition per FHEM-installation is allowed. +Just one definition per FHEM-installation is allowed. More in the german section.
    =end html @@ -1450,13 +1491,27 @@ DOIFtools stellt Funktionen zur Unterstützung von DOIF-Geräten bereit.
  • Zugriff aus DOIFtools auf vorhandene DOIFtoolsLog-Logdateien.
  • zeigt den Event Monitor in der Detailansicht von DOIFtools.
  • ermöglicht den Zugriff auf den Event Monitor in der Detailansicht von DOIF.
  • -
  • erzeugt DOIF-Operanden aus einer Event-Zeile des Event-Monitors, ein gewählter Operand wird in die Zwischenablage kopiert und kann im DEF-Editor in die Definition eingefügt werden.
  • +
  • erzeugt DOIF-Operanden aus einer Event-Zeile des Event-Monitors:
  • +
  • prüfen der DOIF Definitionen mit Empfehlungen.
  • erstellen von Shortcuts
  • optionalen Menüeintrag erstellen
  • Liste der laufenden Wait-Timer anzeigen

  • +Inhalt
    +
    Bedienungsanleitung @@ -1477,7 +1532,6 @@ DOIFtools stellt Funktionen zur Unterstützung von DOIF-Geräten bereit.
    defmod DOIFtools DOIFtools
    attr DOIFtools DOIFtoolsEventMonitorInDOIF 1
    - attr DOIFtools DOIFtoolsEMbeforeReadings 1
    attr DOIFtools DOIFtoolsExecuteDefinition 1
    attr DOIFtools DOIFtoolsExecuteSave 1
    attr DOIFtools DOIFtoolsMenuEntry 1
    @@ -1638,7 +1692,14 @@ DOIFtools stellt Funktionen zur Unterstützung von DOIF-Geräten bereit.

    =end html_DE