Skip to content

Commit 095f77b

Browse files
authored
Merge pull request #49 from flowbi/multiple-fixes
feat: add parameter overlay toggle button with responsive behavior
2 parents da5e731 + 9e290c8 commit 095f77b

File tree

4 files changed

+146
-13
lines changed

4 files changed

+146
-13
lines changed

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
## Changelog
22

3-
Current [release](https://github.com/flowbi/pgweb/releases) is `0.16.14`.
3+
Current [release](https://github.com/flowbi/pgweb/releases) is `0.16.17`.
4+
5+
## 0.16.17 - 2025-11-23
6+
7+
- `NEW` Add parameter overlay toggle button with localStorage persistence and responsive behavior
8+
- `NEW` Toggle automatically hides overlay when window width < 1400px
9+
- `FIX` Parameter overlay toggle button positioned to avoid overlap with connection buttons
10+
11+
## 0.16.16 - 2025-11-23
12+
13+
- `FIX` Unwanted gap between cursor and typed character in ACE editor
14+
15+
## 0.16.15 - 2025-11-23
16+
17+
- `NEW` Enhance development script and documentation for PostgreSQL setup
18+
- `FIX` Issue with custom fonts
19+
- `FIX` Docker compose file name and command in development script
420

521
## 0.16.14 - 2025-09-01
622

static/css/app.css

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,18 +749,36 @@ body, html {
749749
}
750750

751751
.connection-actions {
752-
position: fixed;
752+
position: absolute;
753+
right: 8px;
754+
top: 10px;
755+
display: none;
756+
}
757+
758+
.parameter-toggle-action {
759+
position: absolute;
753760
right: 8px;
754761
top: 10px;
755762
display: none;
756763
}
757764

765+
/* When both are visible, shift parameter toggle to the left */
766+
.connection-actions:not([style*="display: none"]) ~ .parameter-toggle-action {
767+
right: 200px;
768+
}
769+
758770
#edit_connection, #close_connection {
759771
background: var(--pgweb-primary-color);
760772
color: var(--pgweb-primary-text);
761773
border-color: var(--pgweb-primary-text);
762774
}
763775

776+
#toggle_param_overlay {
777+
background: var(--pgweb-primary-color);
778+
color: var(--pgweb-primary-text);
779+
border-color: var(--pgweb-primary-text);
780+
}
781+
764782
#edit_connection i {
765783
margin-right: 4px;
766784
}

static/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
<a href="#" id="edit_connection" class="btn btn-default btn-sm"><i class="fa fa-database"></i> Connect</a>
4141
<a href="#" id="close_connection" class="btn btn-default btn-sm">Disconnect</a>
4242
</div>
43+
44+
<div class="parameter-toggle-action">
45+
<a href="#" id="toggle_param_overlay" class="btn btn-default btn-sm" title="Toggle parameter overlay">
46+
<i class="fa fa-toggle-off"></i>
47+
</a>
48+
</div>
4349
</div>
4450
<div id="sidebar">
4551
<div class="current-database">

static/js/app.js

Lines changed: 104 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -792,11 +792,16 @@ function setCurrentTab(id) {
792792

793793
// Persist tab selection into the session storage
794794
sessionStorage.setItem("tab", id);
795-
795+
796796
// Update parameter overlay visibility based on new tab
797797
if (typeof updateParameterOverlay === 'function') {
798798
updateParameterOverlay(id);
799799
}
800+
801+
// Update parameter toggle button visibility based on new tab
802+
if (typeof updateParamToggleVisibility === 'function') {
803+
updateParamToggleVisibility(id);
804+
}
800805
}
801806

802807
function showQueryHistory() {
@@ -1408,6 +1413,62 @@ function addShortcutTooltips() {
14081413
// Global variables for parameter overlay management
14091414
var globalSqlParamsForOverlay = {};
14101415
var shouldShowParamIndicator = false;
1416+
var paramOverlayManuallySet = false; // Track if user manually toggled
1417+
1418+
// Get parameter overlay preference from localStorage
1419+
function getParamOverlayPreference() {
1420+
var pref = localStorage.getItem("param_overlay_enabled");
1421+
return pref === null ? null : pref === "true";
1422+
}
1423+
1424+
// Set parameter overlay preference to localStorage
1425+
function setParamOverlayPreference(enabled) {
1426+
localStorage.setItem("param_overlay_enabled", enabled.toString());
1427+
}
1428+
1429+
// Check if screen width is >= 1400px
1430+
function isWideScreen() {
1431+
return window.innerWidth >= 1400;
1432+
}
1433+
1434+
// Determine if overlay should be visible based on toggle state and screen size
1435+
function shouldShowOverlay() {
1436+
var preference = getParamOverlayPreference();
1437+
1438+
// If user has set a preference, use it
1439+
if (preference !== null) {
1440+
return preference;
1441+
}
1442+
1443+
// Default: show on wide screens, hide on narrow screens
1444+
return isWideScreen();
1445+
}
1446+
1447+
// Update toggle button icon and overlay visibility
1448+
function updateParamToggleState() {
1449+
var showOverlay = shouldShowOverlay();
1450+
var currentTab = $('#nav ul li.selected').attr('id') || 'table_query';
1451+
1452+
// Update toggle button icon
1453+
if (showOverlay) {
1454+
$('#toggle_param_overlay i').removeClass('fa-toggle-off').addClass('fa-toggle-on');
1455+
} else {
1456+
$('#toggle_param_overlay i').removeClass('fa-toggle-on').addClass('fa-toggle-off');
1457+
}
1458+
1459+
// Update overlay visibility based on toggle state
1460+
shouldShowParamIndicator = showOverlay && Object.keys(globalSqlParamsForOverlay).length > 0;
1461+
updateParameterOverlay(currentTab);
1462+
}
1463+
1464+
// Show/hide toggle button based on current tab
1465+
function updateParamToggleVisibility(currentTabId) {
1466+
if (currentTabId === 'table_query' && Object.keys(globalSqlParamsForOverlay).length > 0) {
1467+
$('.parameter-toggle-action').show();
1468+
} else {
1469+
$('.parameter-toggle-action').hide();
1470+
}
1471+
}
14111472

14121473
function updateParameterOverlay(currentTabId) {
14131474
// Remove existing indicator
@@ -1429,24 +1490,23 @@ function updateParameterOverlay(currentTabId) {
14291490

14301491
function displayURLParameters() {
14311492
var urlParams = new URLSearchParams(window.location.search);
1432-
var hideIndicator = urlParams.get('hideParamIndicator') === 'true';
14331493

14341494
// Extract SQL parameters and store them globally (always do this for substitution to work)
14351495
var sqlParams = extractSqlParameters();
14361496
var hasParams = Object.keys(sqlParams).length > 0;
14371497

1438-
// Store parameters and indicator preference globally
1498+
// Store parameters globally
14391499
globalSqlParamsForOverlay = sqlParams;
1440-
shouldShowParamIndicator = hasParams && !hideIndicator;
1441-
1442-
// Show overlay for current tab (will be managed by setCurrentTab from now on)
1443-
if (shouldShowParamIndicator) {
1444-
var currentTab = $('#nav ul li.selected').attr('id') || 'table_query';
1445-
updateParameterOverlay(currentTab);
1446-
}
1447-
1500+
14481501
if (hasParams) {
14491502
console.log('URL parameters available for query substitution:', sqlParams);
1503+
1504+
// Initialize toggle state and overlay visibility
1505+
updateParamToggleState();
1506+
1507+
// Show toggle button if on query tab
1508+
var currentTab = $('#nav ul li.selected').attr('id') || 'table_query';
1509+
updateParamToggleVisibility(currentTab);
14501510
}
14511511
}
14521512

@@ -2262,6 +2322,39 @@ $(document).ready(function() {
22622322
addShortcutTooltips();
22632323
bindDatabaseObjectsFilter();
22642324

2325+
// Parameter overlay toggle button click handler
2326+
$("#toggle_param_overlay").on("click", function(e) {
2327+
e.preventDefault();
2328+
2329+
// Toggle the preference
2330+
var currentPreference = shouldShowOverlay();
2331+
var newPreference = !currentPreference;
2332+
2333+
// Save to localStorage
2334+
setParamOverlayPreference(newPreference);
2335+
2336+
// Update toggle state and overlay visibility
2337+
updateParamToggleState();
2338+
});
2339+
2340+
// Window resize handler for responsive behavior
2341+
$(window).on("resize", function() {
2342+
// Only update if there are parameters
2343+
if (Object.keys(globalSqlParamsForOverlay).length > 0) {
2344+
var preference = getParamOverlayPreference();
2345+
2346+
// If preference is set to ON but screen is now narrow, turn it OFF
2347+
if (preference && !isWideScreen()) {
2348+
setParamOverlayPreference(false);
2349+
updateParamToggleState();
2350+
}
2351+
// If no preference is set (null), update based on screen size
2352+
else if (preference === null) {
2353+
updateParamToggleState();
2354+
}
2355+
}
2356+
});
2357+
22652358
// Set session from the url
22662359
var reqUrl = new URL(window.location);
22672360
var sessionId = reqUrl.searchParams.get("session");

0 commit comments

Comments
 (0)