Skip to content

Commit 57c2dc0

Browse files
committed
Add compact sidebar configuration
1 parent be680dd commit 57c2dc0

3 files changed

Lines changed: 66 additions & 2 deletions

File tree

debug-db-base/src/main/assets/custom.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@
2424
word-break: normal;
2525
}
2626

27+
body.addb-sidebar-compact #addb-db-column .panel-heading,
28+
body.addb-sidebar-compact #addb-table-column .panel-heading {
29+
padding: 6px 8px;
30+
font-size: 12px;
31+
}
32+
33+
body.addb-sidebar-compact #db-list .list-group-item,
34+
body.addb-sidebar-compact #table-list .list-group-item {
35+
padding: 6px 8px;
36+
font-size: 12px;
37+
white-space: nowrap;
38+
overflow: hidden;
39+
text-overflow: ellipsis;
40+
word-break: normal;
41+
}
42+
2743
.addb-customize-link {
2844
margin-right: 8px;
2945
}

debug-db-base/src/main/assets/index.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@
134134

135135
<div class="row padding-twenty">
136136

137-
<div class="col-sm-2">
137+
<div id="addb-db-column" class="col-sm-2">
138138
<div class="panel panel-info">
139139
<div class="panel-heading">Databases</div>
140140
</div>
141141
<div id="db-list" class="list-group">
142142
</div>
143143
</div>
144144

145-
<div class="col-sm-2">
145+
<div id="addb-table-column" class="col-sm-2">
146146
<div class="panel panel-info">
147147
<div class="panel-heading">Tables</div>
148148
</div>
@@ -199,6 +199,17 @@
199199
<p class="help-block">Controls how much horizontal space the UI uses.</p>
200200
</div>
201201

202+
<div class="form-group">
203+
<label>Sidebar width</label>
204+
<div class="radio">
205+
<label><input type="radio" name="addb-sidebar-width" value="standard"> Standard (default)</label>
206+
</div>
207+
<div class="radio">
208+
<label><input type="radio" name="addb-sidebar-width" value="compact"> Compact</label>
209+
</div>
210+
<p class="help-block">Controls how much space the database/table lists use (compact gives more room to the data table).</p>
211+
</div>
212+
202213
<div class="form-group">
203214
<label>Row density</label>
204215
<div class="radio">

debug-db-base/src/main/assets/ui-customization.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
var DEFAULT_SETTINGS = {
1414
tableWidth: "fixed", // fixed | full | fluid
15+
sidebarWidth: "standard", // standard | compact
1516
rowDensity: "normal", // compact | normal | comfortable
1617
wrapLongText: false,
1718
maxColumnWidthPx: null, // number | null
@@ -21,6 +22,7 @@
2122
};
2223

2324
var allowedTableWidths = { fixed: true, full: true, fluid: true };
25+
var allowedSidebarWidths = { standard: true, compact: true };
2426
var allowedRowDensities = { compact: true, normal: true, comfortable: true };
2527
var allowedJsonModes = { raw: true, wrapped: true, pretty: true };
2628
var allowedPageLengths = { 10: true, 25: true, 50: true, 100: true };
@@ -90,6 +92,7 @@
9092
if (!raw || typeof raw !== "object") return settings;
9193

9294
if (allowedTableWidths[raw.tableWidth]) settings.tableWidth = raw.tableWidth;
95+
if (allowedSidebarWidths[raw.sidebarWidth]) settings.sidebarWidth = raw.sidebarWidth;
9396
if (allowedRowDensities[raw.rowDensity]) settings.rowDensity = raw.rowDensity;
9497
if (allowedJsonModes[raw.jsonMode]) settings.jsonMode = raw.jsonMode;
9598

@@ -142,6 +145,35 @@
142145
}
143146
}
144147

148+
function setBootstrapSmColumn(el, span) {
149+
if (!el || !el.length) return;
150+
if (typeof span !== "number") return;
151+
if (span < 1) span = 1;
152+
if (span > 12) span = 12;
153+
154+
var className = el.attr("class") || "";
155+
var classes = className.split(/\s+/).filter(Boolean);
156+
var updated = [];
157+
for (var i = 0; i < classes.length; i++) {
158+
if (/^col-sm-\d+$/.test(classes[i])) continue;
159+
updated.push(classes[i]);
160+
}
161+
updated.push("col-sm-" + span);
162+
el.attr("class", updated.join(" "));
163+
}
164+
165+
function applySidebarWidth(settings) {
166+
var dbCol = $("#addb-db-column");
167+
var tableCol = $("#addb-table-column");
168+
var dataCol = $("#parent-data-div");
169+
if (!dbCol.length || !tableCol.length || !dataCol.length) return;
170+
171+
var isCompact = settings.sidebarWidth === "compact";
172+
setBootstrapSmColumn(dbCol, isCompact ? 1 : 2);
173+
setBootstrapSmColumn(tableCol, isCompact ? 1 : 2);
174+
setBootstrapSmColumn(dataCol, isCompact ? 10 : 8);
175+
}
176+
145177
function applyBodyClasses(settings) {
146178
var body = $("body");
147179

@@ -154,6 +186,8 @@
154186
body.addClass("addb-json-mode-" + settings.jsonMode);
155187

156188
body.toggleClass("addb-sticky-header", !!settings.stickyHeader);
189+
190+
body.toggleClass("addb-sidebar-compact", settings.sidebarWidth === "compact");
157191
}
158192

159193
function applyMaxColumnWidth(settings) {
@@ -423,6 +457,7 @@
423457
currentSettings = normalizeSettings(settings);
424458

425459
applyContainerWidth(currentSettings);
460+
applySidebarWidth(currentSettings);
426461
applyBodyClasses(currentSettings);
427462
applyMaxColumnWidth(currentSettings);
428463

@@ -550,6 +585,7 @@
550585
var maxWidthRaw = $("#addb-max-column-width").val();
551586
var settings = {
552587
tableWidth: $("input[name='addb-table-width']:checked").val(),
588+
sidebarWidth: $("input[name='addb-sidebar-width']:checked").val(),
553589
rowDensity: $("input[name='addb-row-density']:checked").val(),
554590
wrapLongText: $("#addb-wrap-long-text").is(":checked"),
555591
maxColumnWidthPx: maxWidthRaw === "" ? null : maxWidthRaw,
@@ -562,6 +598,7 @@
562598

563599
function writeFormFromSettings(settings) {
564600
$("input[name='addb-table-width'][value='" + settings.tableWidth + "']").prop("checked", true);
601+
$("input[name='addb-sidebar-width'][value='" + settings.sidebarWidth + "']").prop("checked", true);
565602
$("input[name='addb-row-density'][value='" + settings.rowDensity + "']").prop("checked", true);
566603
$("#addb-wrap-long-text").prop("checked", !!settings.wrapLongText);
567604
$("#addb-max-column-width").val(settings.maxColumnWidthPx === null ? "" : settings.maxColumnWidthPx);

0 commit comments

Comments
 (0)