Files

29 lines
1.3 KiB
JavaScript

import { DEBUG_ICON } from "/js/icons.js";
import { notifySidePanelOpen, onlyOneSidePanelOpen } from "/js/panels.js";
// Sidebar icon pinned to the bottom of the rail, logged-in only (map.js):
// a panel of links — every endpoint's state on the full-screen
// /status.html, the CANopen diagnostics — and the update check.
export class DebugControl {
mount(sidebar) {
this._container = document.createElement("div");
this._container.className = "sidebar-item sidebar-item--bottom";
this._container.innerHTML = `<button type="button" class="sidebar-icon" title="Status / debug" aria-label="Status / debug">${DEBUG_ICON}</button>`;
this._icon = this._container.querySelector(".sidebar-icon");
this._icon.addEventListener("click", () => this._togglePanel());
this._panel = document.getElementById("debug-panel");
this._panel.querySelector(".basemap-panel__close").addEventListener("click", () => this._togglePanel(false));
onlyOneSidePanelOpen(this._panel, () => this._icon.classList.remove("active"));
sidebar.appendChild(this._container);
}
_togglePanel(force) {
const open = force === undefined ? this._panel.hidden : force;
this._panel.hidden = !open;
this._icon.classList.toggle("active", open);
if (open) notifySidePanelOpen(this._panel);
}
}