From fbc228eb6c2299106b6985ceb623b6854da58f63 Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Mon, 5 Dec 2022 16:35:57 -0600 Subject: [PATCH] Make query input box resizable --- static/css/app.css | 32 ++++++++++++------ static/index.html | 39 +++++++++++----------- static/js/app.js | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 29 deletions(-) diff --git a/static/css/app.css b/static/css/app.css index f5c90df..59a1077 100644 --- a/static/css/app.css +++ b/static/css/app.css @@ -283,18 +283,34 @@ } #input { - height: 255px; + width: 100%; + height: 300px; + position: relative; } -#input .wrapper { - position: relative; +#input .input-wrapper { + height: 250px; + padding-top: 12px; +} + +#input_resize_handler { + width: 100%; + height: 1px; + background: #ddd; + cursor: row-resize; + position: absolute; + bottom: 0px; +} + +#input_resize_handler:hover, #input_resize_handler.dragging { + height: 3px; } #input .actions { background: #fff; padding: 10px; height: 50px; - border-bottom: solid 1px #ddd; + bottom: 0px; } #input .actions #result-rows-count { @@ -363,13 +379,10 @@ margin-right: 0px; } -#objects { -} - #output { position: absolute; left: 0px; - top: 256px; + top: 300px; bottom: 0px; right: 0px; margin: 0px; @@ -591,8 +604,7 @@ /* -------------------------------------------------------------------------- */ #custom_query { - height: 193px; - margin-top: 12px; + height: 238px; } #connection_window { diff --git a/static/index.html b/static/index.html index ced2239..9374c0b 100644 --- a/static/index.html +++ b/static/index.html @@ -73,28 +73,29 @@
-
+
-
- -
- - -
-
Please wait, query is executing...
-
- - - - -
+
+
+ +
+ + +
+
Please wait, query is executing...
+
+ + + +
+
diff --git a/static/js/app.js b/static/js/app.js index b23f597..103081e 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -4,6 +4,8 @@ var bookmarks = {}; var default_rows_limit = 100; var currentObject = null; var autocompleteObjects = []; +var inputResizing = false; +var inputResizeOffset = null; var filterOptions = { "equal": "= 'DATA'", @@ -1247,7 +1249,87 @@ function enableDatabaseSearch(data) { }); } +function bindInputResizeEvents() { + var height = sessionStorage.getItem("input_height"); + if (height) { + resizeInput(height); + checkInputSize(); + } + + $("body").on("mousemove", function(e) { + onInputResize(e); + }); + + $("body").on("mouseup", function() { + endInputResize(); + }); + + $("#input_resize_handler").on("mousedown", function() { + beginInputResize(); + }); + + $(window).on("resize", function() { + checkInputSize(); + }); +} + +function checkInputSize() { + var inputHeight = $("#input").height(); + var bodyHeight = $("#body").height(); + + if (bodyHeight == 0 || inputHeight == 0) return; + + if (inputHeight > bodyHeight || bodyHeight - inputHeight < 200) { + resizeInput(bodyHeight - 200); + } +} + +function resizeInput(height) { + var diff = 50 + 12; // actions box + padding + + $("#input").height(height); + $("#input .input-wrapper").height(height - diff); + $("#custom_query").height(height - diff); + $("#output").css("top", height + "px"); + + if (editor) { + editor.resize(); + } +} + +function beginInputResize() { + inputResizing = true; + inputResizeOffset = $("#input").offset().top; + + $("html").css("cursor", "row-resize"); + $("#input_resize_handler").addClass("dragging"); +} + +function endInputResize() { + if (!inputResizing) return; + + inputResizing = false; + inputResizeOffset = null; + + $("html").css("cursor", "auto"); + $("#input_resize_handler").removeClass("dragging"); + + // Save current settings for page reloads + sessionStorage.setItem("input_height", $("#input").height()); +} + +function onInputResize(event) { + if (!inputResizing) return; + + var computedHeight = event.clientY - inputResizeOffset; + if (computedHeight < 150) computedHeight = 150; + + resizeInput(computedHeight); +} + $(document).ready(function() { + bindInputResizeEvents(); + $("#table_content").on("click", function() { showTableContent(); }); $("#table_structure").on("click", function() { showTableStructure(); }); $("#table_indexes").on("click", function() { showTableIndexes(); }); @@ -1627,3 +1709,4 @@ $(document).ready(function() { bindDatabaseObjectsFilter(); }); +