Send denormalized data to backend in order to persist dashboard

This commit is contained in:
Stephen Abello
2026-01-13 11:17:54 +01:00
parent dd0ac58643
commit 7ca2c56dad
4 changed files with 31 additions and 8 deletions

View File

@@ -43,10 +43,10 @@ class IboGridSlot extends HTMLElement {
const oDashlet = this.oDashlet;
const aSlotData = {
x: this.iPosX,
y: this.iPostY,
w: this.iWidth,
h: this.iHeight
position_x: this.iPosX,
position_y: this.iPostY,
width: this.iWidth,
height: this.iHeight
};
const aDashletData = oDashlet ? oDashlet.Serialize() : {};

View File

@@ -216,8 +216,9 @@ class IboDashboard extends HTMLElement {
schema_version: this.schemaVersion,
id: this.sId,
title: sDashboardTitle,
refresh_rate: sDashboardRefreshRate,
dashlets: aSerializedGrid
refresh: sDashboardRefreshRate,
dashlets_list: aSerializedGrid,
_token: ":)"
};
}
@@ -226,6 +227,12 @@ class IboDashboard extends HTMLElement {
// TODO 3.3: Implement saving dashboard state to server when backend is ready
// May try to save as serialized PHP if XML format is not yet decided
console.log(aPayload);
// Fetch dashlet form from server
let sSaveUrl = GetAbsoluteUrlAppRoot() + '/pages/UI.php?route=dashboard.save&values='+encodeURIComponent(JSON.stringify(aPayload));
fetch(sSaveUrl)
.then(async data => {
// TODO 3.3 What's returned ?
})
this.SetEditMode(false);
this.aLastSavedState = aPayload;

View File

@@ -50,10 +50,11 @@ class IboDashlet extends HTMLElement {
}
Serialize() {
// TODO 3.3 Should we use getters ?
const aDashletData = {
id: this.sDashletId,
type: this.sType,
formData: this.formData,
class: this.sType,
dashlet: JSON.parse(this.formData),
};
return aDashletData;