mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 08:16:36 +00:00
Show AI Task pref but disabled if not done loading
This commit is contained in:
parent
a8f6589ce0
commit
881727ad27
@ -1,6 +1,6 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import { mdiHelpCircle, mdiStarFourPoints } from "@mdi/js";
|
import { mdiHelpCircle, mdiStarFourPoints } from "@mdi/js";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-settings-row";
|
import "../../../components/ha-settings-row";
|
||||||
@ -14,6 +14,7 @@ import {
|
|||||||
type AITaskPreferences,
|
type AITaskPreferences,
|
||||||
} from "../../../data/ai_task";
|
} from "../../../data/ai_task";
|
||||||
import { documentationUrl } from "../../../util/documentation-url";
|
import { documentationUrl } from "../../../util/documentation-url";
|
||||||
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
|
|
||||||
@customElement("ai-task-pref")
|
@customElement("ai-task-pref")
|
||||||
export class AITaskPref extends LitElement {
|
export class AITaskPref extends LitElement {
|
||||||
@ -25,16 +26,15 @@ export class AITaskPref extends LitElement {
|
|||||||
|
|
||||||
protected firstUpdated(changedProps) {
|
protected firstUpdated(changedProps) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
|
if (!this.hass || !isComponentLoaded(this.hass, "ai_task")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
fetchAITaskPreferences(this.hass).then((prefs) => {
|
fetchAITaskPreferences(this.hass).then((prefs) => {
|
||||||
this._prefs = prefs;
|
this._prefs = prefs;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (!this._prefs) {
|
|
||||||
return nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-card outlined>
|
<ha-card outlined>
|
||||||
<h1 class="card-header">
|
<h1 class="card-header">
|
||||||
@ -84,7 +84,9 @@ export class AITaskPref extends LitElement {
|
|||||||
<ha-entity-picker
|
<ha-entity-picker
|
||||||
data-name="gen_data_entity_id"
|
data-name="gen_data_entity_id"
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this._prefs.gen_data_entity_id}
|
.disabled=${this._prefs === undefined &&
|
||||||
|
isComponentLoaded(this.hass, "ai_task")}
|
||||||
|
.value=${this._prefs?.gen_data_entity_id}
|
||||||
.includeDomains=${["ai_task"]}
|
.includeDomains=${["ai_task"]}
|
||||||
@value-changed=${this._handlePrefChange}
|
@value-changed=${this._handlePrefChange}
|
||||||
></ha-entity-picker>
|
></ha-entity-picker>
|
||||||
|
@ -28,7 +28,6 @@ import "../../../layouts/hass-subpage";
|
|||||||
import "./ai-task-pref";
|
import "./ai-task-pref";
|
||||||
import { haStyle } from "../../../resources/styles";
|
import { haStyle } from "../../../resources/styles";
|
||||||
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
import type { HomeAssistant, ValueChangedEvent } from "../../../types";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
|
||||||
|
|
||||||
@customElement("ha-config-section-general")
|
@customElement("ha-config-section-general")
|
||||||
class HaConfigSectionGeneral extends LitElement {
|
class HaConfigSectionGeneral extends LitElement {
|
||||||
@ -267,12 +266,10 @@ class HaConfigSectionGeneral extends LitElement {
|
|||||||
</ha-progress-button>
|
</ha-progress-button>
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
${isComponentLoaded(this.hass, "ai_task")
|
<ai-task-pref
|
||||||
? html`<ai-task-pref
|
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
></ai-task-pref>`
|
></ai-task-pref>
|
||||||
: nothing}
|
|
||||||
</div>
|
</div>
|
||||||
</hass-subpage>
|
</hass-subpage>
|
||||||
`;
|
`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user