mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Merge branch 'dev'
This commit is contained in:
commit
1ddeca3eeb
@ -13,6 +13,7 @@ import {
|
|||||||
mdiDevices,
|
mdiDevices,
|
||||||
mdiDotsVertical,
|
mdiDotsVertical,
|
||||||
mdiDownload,
|
mdiDownload,
|
||||||
|
mdiFileCodeOutline,
|
||||||
mdiHandExtendedOutline,
|
mdiHandExtendedOutline,
|
||||||
mdiOpenInNew,
|
mdiOpenInNew,
|
||||||
mdiPackageVariant,
|
mdiPackageVariant,
|
||||||
@ -329,6 +330,22 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||||||
)}</ha-alert
|
)}</ha-alert
|
||||||
>`
|
>`
|
||||||
: ""}
|
: ""}
|
||||||
|
${normalEntries.length === 0 &&
|
||||||
|
this._manifest &&
|
||||||
|
!this._manifest.config_flow &&
|
||||||
|
this.hass.config.components.find(
|
||||||
|
(comp) => comp.split(".")[0] === this.domain
|
||||||
|
)
|
||||||
|
? html`<ha-alert alert-type="info"
|
||||||
|
><ha-svg-icon
|
||||||
|
slot="icon"
|
||||||
|
path=${mdiFileCodeOutline}
|
||||||
|
></ha-svg-icon
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.integrations.config_entry.no_config_flow"
|
||||||
|
)}</ha-alert
|
||||||
|
>`
|
||||||
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
|
@ -57,9 +57,6 @@ export class HuiBadge extends ReactiveElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _updateElement(config: LovelaceBadgeConfig) {
|
private _updateElement(config: LovelaceBadgeConfig) {
|
||||||
if (config.type === "state-label") {
|
|
||||||
config = { display_type: "complete", ...config, type: "entity" };
|
|
||||||
}
|
|
||||||
if (!this._element) {
|
if (!this._element) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -69,9 +66,6 @@ export class HuiBadge extends ReactiveElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _loadElement(config: LovelaceBadgeConfig) {
|
private _loadElement(config: LovelaceBadgeConfig) {
|
||||||
if (config.type === "state-label") {
|
|
||||||
config = { display_type: "complete", ...config, type: "entity" };
|
|
||||||
}
|
|
||||||
this._element = createBadgeElement(config);
|
this._element = createBadgeElement(config);
|
||||||
this._elementConfig = config;
|
this._elementConfig = config;
|
||||||
if (this.hass) {
|
if (this.hass) {
|
||||||
|
@ -1,71 +1,25 @@
|
|||||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
import { customElement } from "lit/decorators";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
|
||||||
import "../../../components/entity/ha-state-label-badge";
|
import "../../../components/entity/ha-state-label-badge";
|
||||||
import { ActionHandlerEvent } from "../../../data/lovelace/action_handler";
|
import { HuiStateLabelBadgeEditor } from "../editor/config-elements/hui-state-label-badge-editor";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HuiEntityBadge } from "./hui-entity-badge";
|
||||||
import { actionHandler } from "../common/directives/action-handler-directive";
|
import { EntityBadgeConfig, StateLabelBadgeConfig } from "./types";
|
||||||
import { handleAction } from "../common/handle-action";
|
|
||||||
import { hasAction } from "../common/has-action";
|
|
||||||
import { LovelaceBadge } from "../types";
|
|
||||||
import { StateLabelBadgeConfig } from "./types";
|
|
||||||
|
|
||||||
@customElement("hui-state-label-badge")
|
@customElement("hui-state-label-badge")
|
||||||
export class HuiStateLabelBadge extends LitElement implements LovelaceBadge {
|
export class HuiStateLabelBadge extends HuiEntityBadge {
|
||||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
public static async getConfigElement(): Promise<HuiStateLabelBadgeEditor> {
|
||||||
|
await import("../editor/config-elements/hui-state-label-badge-editor");
|
||||||
@state() protected _config?: StateLabelBadgeConfig;
|
return document.createElement("hui-state-label-badge-editor");
|
||||||
|
|
||||||
public setConfig(config: StateLabelBadgeConfig): void {
|
|
||||||
this._config = config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render() {
|
// @ts-ignore
|
||||||
if (!this._config || !this.hass) {
|
public override setConfig(config: StateLabelBadgeConfig): void {
|
||||||
return nothing;
|
const entityBadgeConfig: EntityBadgeConfig = {
|
||||||
}
|
type: "entity",
|
||||||
|
entity: config.entity,
|
||||||
|
display_type: config.show_name === false ? "standard" : "complete",
|
||||||
|
};
|
||||||
|
|
||||||
const stateObj = this.hass.states[this._config.entity!];
|
this._config = entityBadgeConfig;
|
||||||
|
|
||||||
return html`
|
|
||||||
<ha-state-label-badge
|
|
||||||
.hass=${this.hass}
|
|
||||||
.state=${stateObj}
|
|
||||||
.name=${this._config.name}
|
|
||||||
.icon=${this._config.icon}
|
|
||||||
.image=${this._config.image}
|
|
||||||
.showName=${this._config.show_name ?? true}
|
|
||||||
@action=${this._handleAction}
|
|
||||||
.actionHandler=${actionHandler({
|
|
||||||
hasHold: hasAction(this._config!.hold_action),
|
|
||||||
hasDoubleClick: hasAction(this._config!.double_tap_action),
|
|
||||||
})}
|
|
||||||
tabindex=${ifDefined(
|
|
||||||
hasAction(this._config.tap_action) || this._config.entity
|
|
||||||
? "0"
|
|
||||||
: undefined
|
|
||||||
)}
|
|
||||||
></ha-state-label-badge>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _handleAction(ev: ActionHandlerEvent) {
|
|
||||||
handleAction(this, this.hass!, this._config!, ev.detail.action!);
|
|
||||||
}
|
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
|
||||||
return css`
|
|
||||||
ha-state-label-badge:focus {
|
|
||||||
outline: none;
|
|
||||||
background: var(--divider-color);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
ha-state-label-badge {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 4px 2px 4px 2px;
|
|
||||||
margin: -4px -2px -4px -2px;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,6 +430,14 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
|
|||||||
this._config?.show_current !== false &&
|
this._config?.show_current !== false &&
|
||||||
this._config?.show_forecast !== false
|
this._config?.show_forecast !== false
|
||||||
) {
|
) {
|
||||||
|
return {
|
||||||
|
grid_columns: 4,
|
||||||
|
grid_min_columns: 2,
|
||||||
|
grid_rows: 4,
|
||||||
|
grid_min_rows: 4,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (this._config?.show_forecast !== false) {
|
||||||
return {
|
return {
|
||||||
grid_columns: 4,
|
grid_columns: 4,
|
||||||
grid_min_columns: 2,
|
grid_min_columns: 2,
|
||||||
@ -441,7 +449,7 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
|
|||||||
grid_columns: 4,
|
grid_columns: 4,
|
||||||
grid_min_columns: 2,
|
grid_min_columns: 2,
|
||||||
grid_rows: 2,
|
grid_rows: 2,
|
||||||
grid_min_rows: 1,
|
grid_min_rows: 2,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,10 +109,6 @@ export class HuiDialogEditBadge
|
|||||||
this._badgeConfig = badge != null ? ensureBadgeConfig(badge) : badge;
|
this._badgeConfig = badge != null ? ensureBadgeConfig(badge) : badge;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._badgeConfig?.type === "state-label") {
|
|
||||||
this._badgeConfig = { ...this._badgeConfig, type: "entity" };
|
|
||||||
}
|
|
||||||
|
|
||||||
this.large = false;
|
this.large = false;
|
||||||
if (this._badgeConfig && !Object.isFrozen(this._badgeConfig)) {
|
if (this._badgeConfig && !Object.isFrozen(this._badgeConfig)) {
|
||||||
this._badgeConfig = deepFreeze(this._badgeConfig);
|
this._badgeConfig = deepFreeze(this._badgeConfig);
|
||||||
|
@ -235,9 +235,11 @@ export class HaCardConditionEditor extends LitElement {
|
|||||||
? this.hass.localize(
|
? this.hass.localize(
|
||||||
"ui.panel.lovelace.editor.condition-editor.testing_pass"
|
"ui.panel.lovelace.editor.condition-editor.testing_pass"
|
||||||
)
|
)
|
||||||
: this.hass.localize(
|
: this._testingResult === false
|
||||||
"ui.panel.lovelace.editor.condition-editor.testing_error"
|
? this.hass.localize(
|
||||||
)
|
"ui.panel.lovelace.editor.condition-editor.testing_error"
|
||||||
|
)
|
||||||
|
: nothing
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
import { customElement } from "lit/decorators";
|
||||||
|
import { assert, assign, boolean, object, optional, string } from "superstruct";
|
||||||
|
import "../../../../components/ha-form/ha-form";
|
||||||
|
import { EntityBadgeConfig } from "../../badges/types";
|
||||||
|
import "../hui-sub-element-editor";
|
||||||
|
import { actionConfigStruct } from "../structs/action-struct";
|
||||||
|
import { baseLovelaceBadgeConfig } from "../structs/base-badge-struct";
|
||||||
|
import "./hui-card-features-editor";
|
||||||
|
import { HuiEntityBadgeEditor } from "./hui-entity-badge-editor";
|
||||||
|
|
||||||
|
const badgeConfigStruct = assign(
|
||||||
|
baseLovelaceBadgeConfig,
|
||||||
|
object({
|
||||||
|
entity: optional(string()),
|
||||||
|
name: optional(string()),
|
||||||
|
icon: optional(string()),
|
||||||
|
show_entity_picture: optional(boolean()),
|
||||||
|
tap_action: optional(actionConfigStruct),
|
||||||
|
show_name: optional(boolean()),
|
||||||
|
image: optional(string()),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
@customElement("hui-state-label-badge-editor")
|
||||||
|
export class HuiStateLabelBadgeEditor extends HuiEntityBadgeEditor {
|
||||||
|
// @ts-ignore
|
||||||
|
public override setConfig(config: StateLabelBadgeConfig): void {
|
||||||
|
assert(config, badgeConfigStruct);
|
||||||
|
|
||||||
|
const entityBadgeConfig: EntityBadgeConfig = {
|
||||||
|
type: "entity",
|
||||||
|
entity: config.entity,
|
||||||
|
display_type: config.show_name === false ? "standard" : "complete",
|
||||||
|
};
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
this._config = entityBadgeConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"hui-state-label-badge-editor": HuiStateLabelBadgeEditor;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user