adminizer 4.5.0-build.181 → 4.5.0-build.182
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/widgets/widgetHandler.js +28 -1
- package/package.json +1 -1
|
@@ -132,13 +132,40 @@ export class WidgetHandler {
|
|
|
132
132
|
}
|
|
133
133
|
if (!user || !user.widgets || user.widgets.widgets.length === 0) {
|
|
134
134
|
if (this.adminizer.config.dashboard && typeof this.adminizer.config.dashboard !== "boolean" && this.adminizer.config.dashboard.defaultWidgets) {
|
|
135
|
-
|
|
135
|
+
const defaultWidgets = this.adminizer.config.dashboard.defaultWidgets;
|
|
136
136
|
result.widgets = await this.getAll(user, i18n);
|
|
137
|
+
const addedWidgets = [];
|
|
138
|
+
let x = 0, y = 0;
|
|
139
|
+
// Mark default widgets as added and collect them
|
|
137
140
|
result.widgets.forEach(widget => {
|
|
138
141
|
if (defaultWidgets.includes(widget.id.split("__")[0])) {
|
|
139
142
|
widget.added = true;
|
|
143
|
+
addedWidgets.push(widget);
|
|
140
144
|
}
|
|
141
145
|
});
|
|
146
|
+
// Generate layout for all breakpoints
|
|
147
|
+
addedWidgets.forEach(widget => {
|
|
148
|
+
const w = widget.size?.w || 1;
|
|
149
|
+
const h = widget.size?.h || 1;
|
|
150
|
+
const layoutItem = { x, y, w, h, i: widget.id, id: widget.id };
|
|
151
|
+
result.layout.lg.push(layoutItem);
|
|
152
|
+
result.layout.md.push(layoutItem);
|
|
153
|
+
result.layout.sm.push({ ...layoutItem, w: Math.min(w, 4) });
|
|
154
|
+
result.layout.xs.push({ ...layoutItem, w: Math.min(w, 3) });
|
|
155
|
+
result.layout.xxs.push({ ...layoutItem, w: 2 });
|
|
156
|
+
x += w;
|
|
157
|
+
if (x >= 12) {
|
|
158
|
+
x = 0;
|
|
159
|
+
y += h;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
// Save to database
|
|
163
|
+
if (addedWidgets.length > 0) {
|
|
164
|
+
await this.setWidgetsDB(user.id, {
|
|
165
|
+
widgets: addedWidgets,
|
|
166
|
+
layout: result.layout
|
|
167
|
+
}, false);
|
|
168
|
+
}
|
|
142
169
|
}
|
|
143
170
|
}
|
|
144
171
|
else {
|