drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ku...@apache.org
Subject [drill] 02/02: DRILL-6611: Add Ctrl+Enter support for query submission
Date Mon, 05 Nov 2018 18:30:56 GMT
This is an automated email from the ASF dual-hosted git repository.

kunal pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git

commit ad61c6bc1dd24994e50fe7dfed043d5e57dba8f9
Author: Kunal Khatua <kkhatua@maprtech.com>
AuthorDate: Mon Nov 5 10:23:39 2018 -0800

    DRILL-6611: Add Ctrl+Enter support for query submission
    
    1. BugFix on parent commit: Ensure query submission is done with user name when impersonation
is enabled.
    2. Support non-Mac browsers
    3. Support keyboard submission for profile pages with Edit Query tab.
---
 .../src/main/resources/rest/profile/profile.ftl        | 18 +++++++++++++++++-
 exec/java-exec/src/main/resources/rest/query/query.ftl | 18 ++++++++++++++----
 2 files changed, 31 insertions(+), 5 deletions(-)

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 61f63fe..1d6a0c2 100644
--- a/exec/java-exec/src/main/resources/rest/profile/profile.ftl
+++ b/exec/java-exec/src/main/resources/rest/profile/profile.ftl
@@ -105,6 +105,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>
@@ -458,7 +459,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;
@@ -466,6 +467,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 4040deb..00fdd9e 100644
--- a/exec/java-exec/src/main/resources/rest/query/query.ftl
+++ b/exec/java-exec/src/main/resources/rest/query/query.ftl
@@ -71,7 +71,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>
@@ -111,11 +112,20 @@
       enableBasicAutocompletion: true,
       enableLiveAutocompletion: false
     });
-    // meta-enter to submit query
+
+    //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)) return;
-      if (e.target.form) e.target.form.submit();
+      if (!(e.keyCode == 13 && (e.metaKey || e.ctrlKey))) return;
+      if (e.target.form) doSubmitQueryWithUserName();
     });
   </script>
 


Mime
View raw message