From 30a4daa8842760fbc7888f99b26854e8ce97a2b6 Mon Sep 17 00:00:00 2001 From: bahmcloud Date: Thu, 15 Jan 2026 07:59:28 +0000 Subject: [PATCH] custom_components/bahmcloud_store/panel/panel.js aktualisiert --- .../bahmcloud_store/panel/panel.js | 153 +++++++++++++----- 1 file changed, 113 insertions(+), 40 deletions(-) diff --git a/custom_components/bahmcloud_store/panel/panel.js b/custom_components/bahmcloud_store/panel/panel.js index d351a8d..eef05ca 100644 --- a/custom_components/bahmcloud_store/panel/panel.js +++ b/custom_components/bahmcloud_store/panel/panel.js @@ -40,6 +40,45 @@ class BahmcloudStorePanel extends HTMLElement { } } + // --- Mobile navigation helpers --- + + _toggleMenu() { + // Preferred: HA listens to these events in many builds + try { + window.dispatchEvent(new CustomEvent("hass-toggle-menu", { bubbles: true, composed: true })); + window.dispatchEvent(new CustomEvent("hass-toggle-drawer", { bubbles: true, composed: true })); + } catch (_) {} + + // Fallback: try to find the drawer and toggle it (best-effort) + try { + const ha = document.querySelector("home-assistant"); + const main = ha?.shadowRoot?.querySelector("home-assistant-main"); + const drawerLayout = + main?.shadowRoot?.querySelector("app-drawer-layout") || + main?.shadowRoot?.querySelector("ha-drawer") || + main?.shadowRoot?.querySelector("ha-sidebar"); + + if (drawerLayout?.toggleDrawer) { + drawerLayout.toggleDrawer(); + return; + } + } catch (_) {} + + // If nothing works, show a hint + this._error = "Unable to open the sidebar on this client. Use the browser back button."; + this._update(); + } + + _goBack() { + // Works even if HA chrome is hidden + try { + history.back(); + } catch (_) { + // fallback + window.location.href = "/"; + } + } + async _addCustomRepo() { if (!this._hass) return; @@ -93,13 +132,66 @@ class BahmcloudStorePanel extends HTMLElement { -
-
-
-
Bahmcloud Store
-
BCS — loading…
-
- -
- + +
+
+ +
+
+
Bahmcloud Store
+
BCS — loading…
+
+ +
+
+ +
Store
Manage repositories
@@ -268,6 +339,8 @@ class BahmcloudStorePanel extends HTMLElement { `; root.getElementById("refreshBtn").addEventListener("click", () => this._load()); + root.getElementById("menuBtn").addEventListener("click", () => this._toggleMenu()); + root.getElementById("backBtn").addEventListener("click", () => this._goBack()); for (const tab of root.querySelectorAll(".tab")) { tab.addEventListener("click", () => { @@ -281,8 +354,8 @@ class BahmcloudStorePanel extends HTMLElement { const root = this.shadowRoot; const content = root.getElementById("content"); const err = root.getElementById("error"); - const subtitle = root.getElementById("subtitle"); + const v = this._data?.version ? String(this._data.version) : null; subtitle.textContent = v ? `BCS ${v}` : "BCS — loading…"; @@ -358,7 +431,7 @@ class BahmcloudStorePanel extends HTMLElement {
${this._esc(r.name)}
${this._esc(r.url)}
-
+
@@ -382,7 +455,7 @@ class BahmcloudStorePanel extends HTMLElement {
-
+