feat: add room name switches to 3D view and editor toolbars
This commit is contained in:
1 parent
7a9b2c0a38
commit
3f6cca056c
13 files changed
+695
-585
No files matched your search
@@ -50,6 +50,7 @@ export class NextFloorCard extends LitElement {
|
||||
_clean: { state: true },
|
||||
_night: { state: true },
|
||||
_orbit: { state: true },
|
||||
_roomNames: { state: true },
|
||||
};
|
||||
|
||||
declare hass: HomeAssistant;
|
||||
@@ -72,6 +73,7 @@ export class NextFloorCard extends LitElement {
|
||||
/** Kiosk: the night dimming is on, and the screensaver turn runs (after an idle return). */
|
||||
private declare _night: boolean;
|
||||
private declare _orbit: boolean;
|
||||
private declare _roomNames: boolean | null;
|
||||
|
||||
private readonly data = new BuildingController(this);
|
||||
private readonly kiosk = new KioskTimers({
|
||||
@@ -96,6 +98,7 @@ export class NextFloorCard extends LitElement {
|
||||
this._clean = false;
|
||||
this._night = false;
|
||||
this._orbit = false;
|
||||
this._roomNames = null;
|
||||
}
|
||||
|
||||
private view3d() {
|
||||
@@ -147,6 +150,7 @@ export class NextFloorCard extends LitElement {
|
||||
|
||||
setConfig(config: CardConfig): void {
|
||||
if (config.height !== undefined && !(config.height > 100)) throw new Error("height must be a number of pixels above 100");
|
||||
this._roomNames = null;
|
||||
this._own = config;
|
||||
this._config = withTemplate(config, this.data.building?.settings.card_templates as CardTemplates | undefined);
|
||||
this._floorId = undefined;
|
||||
@@ -353,7 +357,9 @@ export class NextFloorCard extends LitElement {
|
||||
.flows=${c?.flows ?? null}
|
||||
.holograms=${c?.holograms ?? null}
|
||||
.floorThumbs=${this.thumbs}
|
||||
.roomLabels=${c?.room_names !== false}
|
||||
.roomLabels=${this._roomNames ?? (c?.room_names !== false)}
|
||||
.roomNamesButton=${true}
|
||||
@room-names-change=${(e: CustomEvent<{ value: boolean }>) => (this._roomNames = e.detail.value)}
|
||||
.floorStack=${c?.floor_stack ?? "dim"}
|
||||
.panelOpen=${!!this._roomId && c?.room_panel !== false}
|
||||
.alerts=${c?.alerts !== false}
|
||||
|
||||
@@ -184,6 +184,7 @@ export class NfEditor extends LitElement {
|
||||
hass: { attribute: false },
|
||||
building: { attribute: false },
|
||||
narrow: { type: Boolean },
|
||||
roomLabels: { attribute: false },
|
||||
packs: { attribute: false },
|
||||
loadCardEditor: { attribute: false },
|
||||
_doc: { state: true },
|
||||
@@ -223,6 +224,8 @@ export class NfEditor extends LitElement {
|
||||
declare hass: HomeAssistant;
|
||||
declare building: Building;
|
||||
declare narrow: boolean;
|
||||
/** Show room names in the 3D preview; the host remembers this view preference. */
|
||||
declare roomLabels: boolean;
|
||||
/** Imported furniture packs (from the panel's controller). */
|
||||
declare packs: FurniturePack[] | undefined;
|
||||
/** Loads the card's settings dialog, for the card templates (set by the panel). */
|
||||
@@ -319,6 +322,7 @@ export class NfEditor extends LitElement {
|
||||
constructor() {
|
||||
super();
|
||||
this.narrow = false;
|
||||
this.roomLabels = true;
|
||||
this._floorId = null;
|
||||
this._arcEdit = null;
|
||||
this._routeDraft = null;
|
||||
@@ -1067,7 +1071,7 @@ export class NfEditor extends LitElement {
|
||||
.selectedDevice=${this.sel.device}
|
||||
.quality=${"auto"}
|
||||
.floorThumbs=${false}
|
||||
.roomLabels=${true}
|
||||
.roomLabels=${this.roomLabels}
|
||||
.floorStack=${this.houseTool ? "stacked" : "single"}
|
||||
.panelOpen=${false}
|
||||
.alerts=${false}
|
||||
@@ -3184,6 +3188,10 @@ export class NfEditor extends LitElement {
|
||||
</button>`,
|
||||
)}
|
||||
</div>
|
||||
<button class="nf-chip nf-room-names-toggle" aria-pressed=${this.roomLabels} title=${this.t("room_names_toggle_hint")} @click=${() => {
|
||||
this.roomLabels = !this.roomLabels;
|
||||
this.dispatchEvent(new CustomEvent("room-names-change", { detail: { value: this.roomLabels }, bubbles: true, composed: true }));
|
||||
}}>${this.t("room_names_short")}</button>
|
||||
<div class="nf-seg">
|
||||
<button ?disabled=${!this._canUndo} @click=${() => this.undo()} title="Ctrl+Z">${this.t("undo")}</button>
|
||||
<button ?disabled=${!this._canRedo} @click=${() => this.redo()} title="Ctrl+Y">${this.t("redo")}</button>
|
||||
|
||||
@@ -157,6 +157,7 @@ export class NfView3d extends LitElement {
|
||||
_locked: { state: true },
|
||||
_now: { state: true },
|
||||
roomLabels: { attribute: false },
|
||||
roomNamesButton: { attribute: false },
|
||||
floorStack: { attribute: false },
|
||||
panelOpen: { attribute: false },
|
||||
alerts: { attribute: false },
|
||||
@@ -304,6 +305,8 @@ export class NfView3d extends LitElement {
|
||||
private clockTimer: ReturnType<typeof setInterval> | undefined;
|
||||
/** Room names in 3D (cards can switch them off). */
|
||||
declare roomLabels: boolean;
|
||||
/** Cards expose the room-name switch in their own 3D top bar. The designer has its toolbar switch. */
|
||||
declare roomNamesButton: boolean;
|
||||
/** Floors below an opened floor: dimmed, stacked (the house up to it) or hidden. */
|
||||
declare floorStack: FloorStack;
|
||||
private declare _thumbs: { floorId: string; url: string }[];
|
||||
@@ -490,6 +493,7 @@ export class NfView3d extends LitElement {
|
||||
}
|
||||
})();
|
||||
this.roomLabels = true;
|
||||
this.roomNamesButton = false;
|
||||
this.floorStack = "dim";
|
||||
this._low = false;
|
||||
this.panelOpen = false;
|
||||
@@ -2696,7 +2700,11 @@ export class NfView3d extends LitElement {
|
||||
const energy = !!e && !this.roomId && this.showEnergy && !!this.hass && !(e.consumption === null && e.grid === null && e.solar === null && e.battery === null);
|
||||
const climate = this.building?.floors.some((f) => f.rooms.some((r) => r.climate_card));
|
||||
const climateToggle = climate ? this.renderCardToggle() : nothing;
|
||||
if (!energy) return own.length || climateToggle !== nothing ? html`<div class="nf-energy" aria-live="off">${own}${climateToggle}</div>` : nothing;
|
||||
const roomNames = this.roomNamesButton ? html`<button class="nf-energy-item nf-flow-toggle nf-room-names-toggle" aria-pressed=${this.roomLabels} title=${translate(this.hass, "room_names_toggle_hint")} @click=${() => {
|
||||
this.roomLabels = !this.roomLabels;
|
||||
this.dispatchEvent(new CustomEvent("room-names-change", { detail: { value: this.roomLabels }, bubbles: true, composed: true }));
|
||||
}}><span>${translate(this.hass, "room_names_short")}</span><b aria-hidden="true">Aa</b></button>` : nothing;
|
||||
if (!energy) return own.length || climateToggle !== nothing || roomNames !== nothing ? html`<div class="nf-energy" aria-live="off">${roomNames}${own}${climateToggle}</div>` : nothing;
|
||||
const t = (k: Parameters<typeof translate>[1]) => translate(this.hass, k);
|
||||
const items: { cls: string; label: string; value: string }[] = [];
|
||||
if (e.solar !== null) items.push({ cls: "solar", label: t("energy_solar"), value: formatPower(this.hass, e.solar) });
|
||||
@@ -2713,6 +2721,7 @@ export class NfView3d extends LitElement {
|
||||
if (e.tariff) items.push({ cls: "tariff", label: t("energy_tariff"), value: `${formatNumber(this.hass, e.tariff.value, 3)} ${e.tariff.unit}`.trim() });
|
||||
if (this.building) for (const m of this.meterRows(this.building)) items.push({ cls: "meter", label: `${m.icon} ${m.label}`, value: m.value });
|
||||
return html`<div class="nf-energy" aria-live="off">
|
||||
${roomNames}
|
||||
${this.liveCardsOn && this._liveCards.some((c) => c.kind === "house") ? nothing : items.map((i) => html`<div class="nf-energy-item nf-energy-${i.cls}"><span>${i.label}</span><b>${i.value}</b></div>`)}
|
||||
${this.flows !== null
|
||||
? nothing
|
||||
@@ -3148,7 +3157,7 @@ export class NfView3d extends LitElement {
|
||||
.nf-person[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.nf-no-room-names .nf-pin {
|
||||
.nf-no-room-names .nf-pin[data-room] {
|
||||
display: none !important;
|
||||
}
|
||||
/* tablet level: blur over the canvas and glowing shadows are expensive on weak GPUs */
|
||||
|
||||
@@ -769,6 +769,7 @@ const DE = {
|
||||
sill_boards_inside: "Nur innen",
|
||||
sill_boards_outside: "Nur außen",
|
||||
room_names_short: "Raumnamen",
|
||||
room_names_toggle_hint: "Raumnamen in der 3D-Ansicht ein- oder ausblenden",
|
||||
floor_stack_short_dim: "Abgedunkelt",
|
||||
floor_stack_short_stacked: "Gestapelt",
|
||||
floor_stack_short_single: "Einzeln",
|
||||
@@ -2811,6 +2812,7 @@ const EN: Record<Key, string> = {
|
||||
sill_boards_inside: "Inside only",
|
||||
sill_boards_outside: "Outside only",
|
||||
room_names_short: "Room names",
|
||||
room_names_toggle_hint: "Show or hide room names in the 3D view",
|
||||
floor_stack_short_dim: "Dimmed",
|
||||
floor_stack_short_stacked: "Stacked",
|
||||
floor_stack_short_single: "Alone",
|
||||
|
||||
@@ -381,6 +381,7 @@ export class NextFloorPanel extends LitElement {
|
||||
<h1>${NEXTFLOOR_MARK}NextFloor</h1>
|
||||
${this.isAdmin ? html`<div class="nf-seg" role="tablist">${tab("view", this.t("view"))}${tab("editor", this.t("editor"))}${tab("extensions", `✦ ${this.t("ext_tab")}`, "nf-tab-ext")}</div>` : nothing}
|
||||
<span class="nf-grow"></span>
|
||||
${this._mode === "view" && building?.floors.some((f) => f.rooms.length) ? html`<button class="nf-chip nf-room-names-toggle" aria-pressed=${this._prefs.roomNames} title=${this.t("room_names_toggle_hint")} @click=${() => this.setPref("roomNames", !this._prefs.roomNames)}>${this.t("room_names_short")}</button>` : nothing}
|
||||
${this.isAdmin && this.hass.symconRefresh ? html`<button class="nf-btn nf-reload-variables" ?disabled=${this._variablesLoading} aria-busy=${this._variablesLoading} @click=${() => void this.reloadVariables()}>↻ ${this.t(this._variablesLoading ? "symcon_variables_loading" : "symcon_variables_reload")}</button>` : nothing}
|
||||
${this._mode === "view" && building?.floors.some((f) => f.rooms.length) ? this.renderViewOptions() : nothing}
|
||||
${this._mode === "editor" && saveState !== "idle" ? html`<span class="nf-save nf-save-${saveState}">${this.t(saveLabel)}</span>` : nothing}
|
||||
@@ -439,6 +440,8 @@ export class NextFloorPanel extends LitElement {
|
||||
.hass=${this.hass}
|
||||
.building=${building}
|
||||
.narrow=${this.narrow}
|
||||
.roomLabels=${this._prefs.roomNames}
|
||||
@room-names-change=${(e: CustomEvent<{ value: boolean }>) => this.setPref("roomNames", e.detail.value)}
|
||||
.packs=${this.data.packs}
|
||||
.loadCardEditor=${loadCardEditor}
|
||||
@packs-changed=${() => void this.data.reloadPacks()}
|
||||
|
||||
Reference in new issue
Block a user