This commit is contained in:
42
www/app.js
42
www/app.js
@@ -123,6 +123,10 @@ const state = {
|
||||
function setActivePage(page) {
|
||||
const valid = ["dashboard", "config", "missions", "integrations"];
|
||||
let p = valid.includes(page) ? page : "config";
|
||||
if (window.AuthApp && !window.AuthApp.canAccessPage(p)) {
|
||||
const fallback = valid.find((v) => window.AuthApp.canAccessPage(v));
|
||||
p = fallback || "dashboard";
|
||||
}
|
||||
if (page === "overview") p = "dashboard";
|
||||
navItemEls.forEach((a) => {
|
||||
const on = (a.dataset.page || "") === p;
|
||||
@@ -562,6 +566,7 @@ function setStatus(msg) {
|
||||
|
||||
async function api(path, opts = {}) {
|
||||
const res = await fetch(path, {
|
||||
credentials: "include",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
...opts,
|
||||
});
|
||||
@@ -3359,7 +3364,8 @@ function initRobotModelPanelCollapse() {
|
||||
}
|
||||
|
||||
initLayoutManagerEvents();
|
||||
initNavigation();
|
||||
if (window.AuthApp?.isReady()) initNavigation();
|
||||
else window.addEventListener("lm:auth-ready", () => initNavigation(), { once: true });
|
||||
initSplitPane();
|
||||
initLidarForm();
|
||||
initMotorWheelsEvents();
|
||||
@@ -3402,21 +3408,25 @@ saveLayoutBtn.addEventListener("click", async () => {
|
||||
});
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await api("/api/health");
|
||||
await loadMotorCatalog();
|
||||
await loadAll();
|
||||
selectedText.textContent = "none";
|
||||
selectedRelText.textContent = "—";
|
||||
setStatus("Sẵn sàng");
|
||||
} catch (e) {
|
||||
const msg = String(e.message || e);
|
||||
if (overviewBackendEl) overviewBackendEl.textContent = `Lỗi: ${msg}`;
|
||||
if (msg.includes("stack") || msg.includes("Maximum call")) {
|
||||
setStatus(`Lỗi JavaScript: ${msg}`);
|
||||
} else {
|
||||
setStatus(`Không kết nối được backend: ${msg}`);
|
||||
const boot = async () => {
|
||||
try {
|
||||
await api("/api/health");
|
||||
await loadMotorCatalog();
|
||||
await loadAll();
|
||||
selectedText.textContent = "none";
|
||||
selectedRelText.textContent = "—";
|
||||
setStatus("Sẵn sàng");
|
||||
} catch (e) {
|
||||
const msg = String(e.message || e);
|
||||
if (overviewBackendEl) overviewBackendEl.textContent = `Lỗi: ${msg}`;
|
||||
if (msg.includes("stack") || msg.includes("Maximum call")) {
|
||||
setStatus(`Lỗi JavaScript: ${msg}`);
|
||||
} else {
|
||||
setStatus(`Không kết nối được backend: ${msg}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if (window.AuthApp?.isReady()) await boot();
|
||||
else window.AuthApp?.whenReady(() => { boot(); });
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user