Skip to content

Commit 4140ba9

Browse files
author
jacquesbach
committed
Undo auto resize
1 parent 78399b3 commit 4140ba9

3 files changed

Lines changed: 20 additions & 68 deletions

File tree

static/css/style.css

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,15 @@
162162
margin-left: -20px;
163163
margin-right: -20px;
164164
}
165-
165+
166166
.grid-stack-item-content {
167-
height: 100%;
168-
overflow: hidden;
167+
overflow-x: hidden;
168+
overflow-y: auto;
169+
overflow: visible !important;
169170
background: transparent !important;
170171
box-shadow: none !important;
171172
}
172-
173+
173174
.edit-mode .grid-stack-item-content {
174175
cursor: grab;
175176
border: 1px dashed var(--accent);
@@ -195,19 +196,14 @@
195196
display: flex;
196197
flex-direction: column;
197198
justify-content: center;
198-
height: 100%;
199-
}
200-
201-
.card canvas {
202-
width: 100% !important;
203199
}
204200

205201
.card-gradient {
206202
background: var(--gradient);
207203
color: white;
208204
box-shadow: 0 15px 35px rgba(255, 75, 114, 0.25);
209205
}
210-
206+
211207
.card-gradient .label {
212208
color: rgba(255, 255, 255, 0.85);
213209
font-size: 0.9em;

static/js/layout.js

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ function initGridstack() {
1515
dashboardGrid.on('change', function(event, items) {
1616
saveLayout();
1717
});
18-
19-
dashboardGrid.on('resizestop', function(event, el) {
20-
const charts = el.querySelectorAll("canvas");
21-
charts.forEach(canvas => {
22-
const chart = Chart.getChart(canvas);
23-
if (chart) {
24-
chart.resize();
25-
}
26-
});
27-
});
2818
}
2919

3020
// 2. Layout speichern (Nur in DB und nur wenn PW da ist)
@@ -95,58 +85,10 @@ async function resetDatabaseLayout() {
9585
}
9686
}
9787

98-
function resizeGridItemToContent(gridItemId) {
99-
100-
const el = document.getElementById(gridItemId);
101-
if (!el || !dashboardGrid) return;
102-
103-
const content = el.querySelector(".card");
104-
105-
const contentHeight = content.scrollHeight;
106-
107-
const cellHeight = dashboardGrid.getCellHeight();
108-
const margin = dashboardGrid.opts.margin;
109-
110-
const newHeight = Math.ceil((contentHeight + margin) / cellHeight);
111-
112-
dashboardGrid.update(el, { h: newHeight });
113-
}
114-
115-
function initAutoCardResize() {
116-
117-
const cards = document.querySelectorAll(".grid-stack-item");
118-
119-
const observer = new ResizeObserver(entries => {
120-
121-
entries.forEach(entry => {
122-
123-
const gridItem = entry.target.closest(".grid-stack-item");
124-
125-
if (!gridItem) return;
126-
127-
const id = gridItem.id;
128-
129-
resizeGridItemToContent(id);
130-
131-
});
132-
133-
});
134-
135-
cards.forEach(card => {
136-
137-
const content = card.querySelector(".card");
138-
139-
if (content) observer.observe(content);
140-
141-
});
142-
143-
}
144-
14588
document.addEventListener("DOMContentLoaded", async () => {
14689
// --- PHASE 1: Das Gerüst aufbauen ---
14790
initGridstack();
14891
await loadLayout(); // Wartet, bis Boxen aus DB oder LocalStorage da sind
149-
initAutoCardResize();
15092

15193
// --- PHASE 2: Startwerte für Datumsfelder setzen ---
15294
const t = new Date().toISOString().split('T')[0];

static/js/script.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,20 @@ function showShapDetails(point) {
11511151
};
11521152

11531153
const container = document.getElementById("shapForcePlot");
1154+
1155+
// ===== ResizeObserver nur einmal registrieren =====
1156+
if (!container._resizeObserverAttached) {
1157+
1158+
const observer = new ResizeObserver(() => {
1159+
if (window._lastShapPoint) {
1160+
showShapDetails(window._lastShapPoint);
1161+
}
1162+
});
1163+
1164+
observer.observe(container);
1165+
container._resizeObserverAttached = true;
1166+
}
1167+
11541168
container.innerHTML = "";
11551169
container.style.position = "relative";
11561170
container.style.display = "flex";

0 commit comments

Comments
 (0)