[ 
https://issues.apache.org/jira/browse/DRILL-6611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16675558#comment-16675558
 ] 

ASF GitHub Bot commented on DRILL-6611:
---------------------------------------

kkhatua closed pull request #1521: DRILL-6611: Add Ctrl+Enter support for query 
submission
URL: https://github.com/apache/drill/pull/1521
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/exec/java-exec/src/main/resources/rest/profile/profile.ftl 
b/exec/java-exec/src/main/resources/rest/profile/profile.ftl
index 13bd8c45d69..bb559202ded 100644
--- a/exec/java-exec/src/main/resources/rest/profile/profile.ftl
+++ b/exec/java-exec/src/main/resources/rest/profile/profile.ftl
@@ -106,6 +106,7 @@ table.sortable thead .sorting_desc { background-image: 
url("/static/img/black-de
         <form role="form" id="queryForm" action="/query" method="POST">
           <div id="query-editor" 
class="form-group">${model.getProfile().query}</div>
           <input class="form-control" id="query" name="query" type="hidden" 
value="${model.getProfile().query}"/>
+          <div style="padding:5px"><b>Hint: </b>Use <div id="keyboardHint" 
style="display:inline-block; font-style:italic"></div> to submit</div>
           <div class="form-group">
             <div class="radio-inline">
               <label>
@@ -459,7 +460,7 @@ table.sortable thead .sorting_desc { background-image: 
url("/static/img/black-de
       enableLiveAutocompletion: false
     });
 
-    //Pops out a new window and provids prompt to print
+    //Pops out a new window and provide prompt to print
     var popUpAndPrintPlan = function() {
       var srcSvg = $('#query-visual-canvas');
       var screenRatio=0.9;
@@ -467,6 +468,21 @@ table.sortable thead .sorting_desc { background-image: 
url("/static/img/black-de
       printWindow.document.writeln($(srcSvg).parent().html());
       printWindow.print();
     };
+
+    //Provides hint based on OS
+    var browserOS = navigator.platform.toLowerCase();
+    if ((browserOS.indexOf("mac") > -1)) {
+      document.getElementById('keyboardHint').innerHTML="Meta+Enter";
+    } else {
+      document.getElementById('keyboardHint').innerHTML="Ctrl+Enter";
+    }
+
+    // meta+enter / ctrl+enter to submit query
+    document.getElementById('queryForm')
+            .addEventListener('keydown', function(e) {
+      if (!(e.keyCode == 13 && (e.metaKey || e.ctrlKey))) return;
+      if (e.target.form) doSubmitQueryWithUserName();
+    });
     </script>
 
 </#macro>
diff --git a/exec/java-exec/src/main/resources/rest/query/query.ftl 
b/exec/java-exec/src/main/resources/rest/query/query.ftl
index 078333e3f8e..9b08e687022 100644
--- a/exec/java-exec/src/main/resources/rest/query/query.ftl
+++ b/exec/java-exec/src/main/resources/rest/query/query.ftl
@@ -72,7 +72,8 @@
       </div>
     </div>
     <div class="form-group">
-      <label for="query">Query</label>
+      <div style="display: inline-block"><label for="query">Query</label></div>
+      <div style="display: inline-block; float:right; 
padding-right:5%"><b>Hint: </b>Use <div id="keyboardHint" 
style="display:inline-block; font-style:italic"></div> to submit</div>
       <div id="query-editor-format"></div>
       <input class="form-control" type="hidden" id="query" name="query"/>
     </div>
@@ -112,6 +113,21 @@
       enableBasicAutocompletion: true,
       enableLiveAutocompletion: false
     });
+
+    //Provides hint based on OS
+    var browserOS = navigator.platform.toLowerCase();
+    if ((browserOS.indexOf("mac") > -1)) {
+      document.getElementById('keyboardHint').innerHTML="Meta+Enter";
+    } else {
+      document.getElementById('keyboardHint').innerHTML="Ctrl+Enter";
+    }
+
+    // meta+enter / ctrl+enter to submit query
+    document.getElementById('queryForm')
+            .addEventListener('keydown', function(e) {
+      if (!(e.keyCode == 13 && (e.metaKey || e.ctrlKey))) return;
+      if (e.target.form) doSubmitQueryWithUserName();
+    });
   </script>
 
 </#macro>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Add [meta]-[Enter] js handler for query form submission
> -------------------------------------------------------
>
>                 Key: DRILL-6611
>                 URL: https://issues.apache.org/jira/browse/DRILL-6611
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Web Server
>    Affects Versions: 1.14.0
>            Reporter: Bob Rudis
>            Assignee: Kunal Khatua
>            Priority: Minor
>              Labels: doc-impacting
>             Fix For: 1.15.0
>
>
> The new ACE-based SQL query editor is great. Being able to submit the form 
> without using a mouse would be even better.
> Adding:
>  
> {noformat}
> document.getElementById('queryForm')
>  .addEventListener('keydown', function(e) {
>  if (!(e.keyCode == 13 && e.metaKey)) return;
>  if (e.target.form) doSubmitQueryWithUserName();
> });
> {noformat}
> {{to ./exec/java-exec/src/main/resources/rest/query/query.ftl adds such 
> support.}}
> I can file a PR with the code if desired.
> ------
> Functionality (for the documentation):
> This JIRA's commit introduces the following to Drill:
> When composing queries in the web query editor it is now possible to submit 
> the query text by using the {{Meta+Enter}} key combination. This will trigger 
> the same action as pressing the {{Submit}} button. On Mac keyboards 
> {{Meta+Enter}} is {{Cmd+Enter}}. On Windows or Linux is {{Ctrl+Enter}} though 
> Linux users may have keymapped the {{Meta}} key to another physical keyboard 
> key.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to