- More info screens show up when an entity is clicked. -
-- Test pages for our utility functions. -
-- ${this._action === "update" - ? `Updating Home Assistant Core to version ${this.core.version_latest}` - : "Creating snapshot of Home Assistant Core"} -
`} - ${this._error ? html`${this._error}
` : ""} -${this._action === "update" - ? `Updating ${this.addon.name} to version ${this.addon.version_latest}` - : "Creating snapshot of Home Assistant Core"} + ? this._dialogParams.supervisor.localize( + "dialog.update.updating", + "name", + this._dialogParams.name, + "version", + this._dialogParams.version + ) + : this._dialogParams.supervisor.localize( + "dialog.update.snapshotting", + "name", + this._dialogParams.name + )}
`} ${this._error ? html`${this._error}
` : ""}+ ${this.hass.localize( + "ui.panel.config.core.section.core.analytics.instance_id", + "huuid", + this.analytics.huuid + )} +
++ + ${this.hass.localize( + "ui.panel.config.core.section.core.analytics.learn_more" + )} + +
+ `; + } + + private _handleRowCheckboxClick(ev: Event) { + const checkbox = ev.currentTarget as HaCheckbox; + const preference = (checkbox as any).preference; + const preferences = { ...this.analytics.preferences }; + + if (checkbox.checked) { + if (preferences[preference]) { + return; + } + preferences[preference] = true; + } else { + preferences[preference] = false; + } + + fireEvent(this, "analytics-preferences-changed", { preferences }); + } + + static get styles(): CSSResult[] { + return [ + haStyle, + css` + .error { + color: var(--error-color); + } + + ha-settings-row { + padding: 0; + } + `, + ]; + } +} + +declare global { + interface HTMLElementTagNameMap { + "ha-analytics": HaAnalytics; + } +} diff --git a/src/components/ha-area-picker.ts b/src/components/ha-area-picker.ts index 0bf8fb199f..45096550a4 100644 --- a/src/components/ha-area-picker.ts +++ b/src/components/ha-area-picker.ts @@ -127,7 +127,7 @@ export class HaAreaPicker extends SubscribeMixin(LitElement) { @internalProperty() private _opened?: boolean; - @query("vaadin-combo-box-light", true) private _comboBox!: HTMLElement; + @query("vaadin-combo-box-light", true) public comboBox!: HTMLElement; private _init = false; @@ -140,7 +140,7 @@ export class HaAreaPicker extends SubscribeMixin(LitElement) { this._devices = devices; }), subscribeEntityRegistry(this.hass.connection!, (entities) => { - this._entities = entities.filter((entity) => entity.area_id); + this._entities = entities; }), ]; } @@ -193,13 +193,13 @@ export class HaAreaPicker extends SubscribeMixin(LitElement) { deviceEntityLookup[entity.device_id].push(entity); } inputDevices = devices; - inputEntities = entities; + inputEntities = entities.filter((entity) => entity.area_id); } else { if (deviceFilter) { inputDevices = devices; } if (entityFilter) { - inputEntities = entities; + inputEntities = entities.filter((entity) => entity.area_id); } } @@ -319,7 +319,7 @@ export class HaAreaPicker extends SubscribeMixin(LitElement) { (changedProps.has("_opened") && this._opened) ) { this._init = true; - (this._comboBox as any).items = this._getAreas( + (this.comboBox as any).items = this._getAreas( this._areas!, this._devices!, this._entities!, diff --git a/src/components/ha-button-menu.ts b/src/components/ha-button-menu.ts index 5aafc86d78..de50f7bd42 100644 --- a/src/components/ha-button-menu.ts +++ b/src/components/ha-button-menu.ts @@ -1,4 +1,3 @@ -import "@material/mwc-button"; import "@material/mwc-menu"; import type { Corner, Menu } from "@material/mwc-menu"; import { @@ -11,8 +10,6 @@ import { query, TemplateResult, } from "lit-element"; -import "./ha-icon-button"; - @customElement("ha-button-menu") export class HaButtonMenu extends LitElement { @property() public corner: Corner = "TOP_START"; diff --git a/src/components/ha-button-related-filter-menu.ts b/src/components/ha-button-related-filter-menu.ts new file mode 100644 index 0000000000..fa2c580735 --- /dev/null +++ b/src/components/ha-button-related-filter-menu.ts @@ -0,0 +1,163 @@ +import "@material/mwc-icon-button"; +import type { Corner } from "@material/mwc-menu"; +import { mdiFilterVariant } from "@mdi/js"; +import { + css, + CSSResult, + customElement, + html, + internalProperty, + LitElement, + property, + TemplateResult, +} from "lit-element"; +import "@material/mwc-menu/mwc-menu-surface"; +import { fireEvent } from "../common/dom/fire_event"; +import { findRelated, RelatedResult } from "../data/search"; +import type { HomeAssistant } from "../types"; +import "./ha-svg-icon"; +import "./ha-area-picker"; +import "./device/ha-device-picker"; + +declare global { + // for fire event + interface HASSDomEvents { + "related-changed": { + value?: FilterValue; + items?: RelatedResult; + filter?: string; + }; + } +} + +interface FilterValue { + area?: string; + device?: string; +} + +@customElement("ha-button-related-filter-menu") +export class HaRelatedFilterButtonMenu extends LitElement { + @property() public hass!: HomeAssistant; + + @property() public corner: Corner = "TOP_START"; + + @property({ type: Boolean, reflect: true }) public narrow = false; + + @property({ type: Boolean }) public disabled = false; + + @property({ attribute: false }) public value?: FilterValue; + + @internalProperty() private _open = false; + + protected render(): TemplateResult { + return html` +${this._serviceData?.description}
- ${this._serviceData && "target" in this._serviceData +${serviceData?.description}
+ ${serviceData && "target" in serviceData ? html`