mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Serializing to local storage is working
This commit is contained in:
parent
dc304c824e
commit
3ef76b13e0
@ -16,8 +16,8 @@ export class Dashboard {
|
|||||||
if (this.parentDiv === null) {
|
if (this.parentDiv === null) {
|
||||||
console.log("Dashboard parent not found");
|
console.log("Dashboard parent not found");
|
||||||
}
|
}
|
||||||
let layout = new Layout();
|
this.layout = new Layout();
|
||||||
this.dashletIdentities = layout.dashlets;
|
this.dashletIdentities = this.layout.dashlets;
|
||||||
this.dashlets = [];
|
this.dashlets = [];
|
||||||
this.channels = [];
|
this.channels = [];
|
||||||
this.#editButton();
|
this.#editButton();
|
||||||
@ -135,8 +135,8 @@ export class Dashboard {
|
|||||||
col1.appendChild(this.#buildDashletList());
|
col1.appendChild(this.#buildDashletList());
|
||||||
|
|
||||||
let options = document.createElement("div");
|
let options = document.createElement("div");
|
||||||
options.appendChild(heading5Icon("gear", "Options"))
|
|
||||||
options.appendChild(document.createElement("hr"));
|
options.appendChild(document.createElement("hr"));
|
||||||
|
options.appendChild(heading5Icon("gear", "Options"))
|
||||||
let nuke = document.createElement("button");
|
let nuke = document.createElement("button");
|
||||||
nuke.type = "button";
|
nuke.type = "button";
|
||||||
nuke.classList.add("btn", "btn-danger");
|
nuke.classList.add("btn", "btn-danger");
|
||||||
@ -157,6 +157,10 @@ export class Dashboard {
|
|||||||
col2.classList.add("col-6");
|
col2.classList.add("col-6");
|
||||||
col2.appendChild(this.#buildMenu());
|
col2.appendChild(this.#buildMenu());
|
||||||
|
|
||||||
|
col2.appendChild(document.createElement("hr"));
|
||||||
|
col2.appendChild(heading5Icon("save", "Save"));
|
||||||
|
col2.appendChild(document.createElement("hr"));
|
||||||
|
|
||||||
row.appendChild(col1);
|
row.appendChild(col1);
|
||||||
row.appendChild(col2);
|
row.appendChild(col2);
|
||||||
content.appendChild(row);
|
content.appendChild(row);
|
||||||
@ -177,8 +181,11 @@ export class Dashboard {
|
|||||||
let target = document.getElementById("dashletList");
|
let target = document.getElementById("dashletList");
|
||||||
target.replaceChildren(newList);
|
target.replaceChildren(newList);
|
||||||
|
|
||||||
// Cleanup
|
// Apply
|
||||||
this.build();
|
this.build();
|
||||||
|
|
||||||
|
// Persist
|
||||||
|
this.layout.save(this.dashletIdentities);
|
||||||
}
|
}
|
||||||
|
|
||||||
clickUp(i) {
|
clickUp(i) {
|
||||||
@ -382,7 +389,18 @@ export class Dashboard {
|
|||||||
// Serializable POD for dashboard layout
|
// Serializable POD for dashboard layout
|
||||||
class Layout {
|
class Layout {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.dashlets = DashletMenu;
|
let template = localStorage.getItem("dashboardLayout");
|
||||||
|
if (template !== null) {
|
||||||
|
this.dashlets = JSON.parse(template);
|
||||||
|
} else {
|
||||||
|
this.dashlets = DashletMenu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
save(dashletIdentities) {
|
||||||
|
this.dashlets = dashletIdentities;
|
||||||
|
let template = JSON.stringify(dashletIdentities);
|
||||||
|
localStorage.setItem("dashboardLayout", template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user