mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
20240702.0 (#21255)
This commit is contained in:
commit
28ced4bfd3
@ -244,11 +244,11 @@ const createTranslations = async () => {
|
|||||||
// TODO: This is a naive interpretation of BCP47 that should be improved.
|
// TODO: This is a naive interpretation of BCP47 that should be improved.
|
||||||
// Will be OK for now as long as we don't have anything more complicated
|
// Will be OK for now as long as we don't have anything more complicated
|
||||||
// than a base translation + region.
|
// than a base translation + region.
|
||||||
gulp
|
const masterStream = gulp
|
||||||
.src(`${workDir}/en.json`)
|
.src(`${workDir}/en.json`)
|
||||||
.pipe(new PassThrough({ objectMode: true }))
|
.pipe(new PassThrough({ objectMode: true }));
|
||||||
.pipe(hashStream, { end: false });
|
masterStream.pipe(hashStream, { end: false });
|
||||||
const mergesFinished = [];
|
const mergesFinished = [finished(masterStream)];
|
||||||
for (const translationFile of translationFiles) {
|
for (const translationFile of translationFiles) {
|
||||||
const locale = basename(translationFile, ".json");
|
const locale = basename(translationFile, ".json");
|
||||||
const subtags = locale.split("-");
|
const subtags = locale.split("-");
|
||||||
|
@ -74,6 +74,9 @@ const createWebpackConfig = ({
|
|||||||
resolve: {
|
resolve: {
|
||||||
fullySpecified: false,
|
fullySpecified: false,
|
||||||
},
|
},
|
||||||
|
parser: {
|
||||||
|
worker: ["*context.audioWorklet.addModule()", "..."],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
@ -92,11 +95,15 @@ const createWebpackConfig = ({
|
|||||||
moduleIds: isProdBuild && !isStatsBuild ? "deterministic" : "named",
|
moduleIds: isProdBuild && !isStatsBuild ? "deterministic" : "named",
|
||||||
chunkIds: isProdBuild && !isStatsBuild ? "deterministic" : "named",
|
chunkIds: isProdBuild && !isStatsBuild ? "deterministic" : "named",
|
||||||
splitChunks: {
|
splitChunks: {
|
||||||
// Disable splitting for web workers with ESM output
|
// Disable splitting for web workers and worklets because imports of
|
||||||
// Imports of external chunks are broken
|
// external chunks are broken for:
|
||||||
chunks: latestBuild
|
// - ESM output: https://github.com/webpack/webpack/issues/17014
|
||||||
? (chunk) => !chunk.canBeInitial() && !/^.+-worker$/.test(chunk.name)
|
// - Worklets use `importScripts`: https://github.com/webpack/webpack/issues/11543
|
||||||
: undefined,
|
chunks: (chunk) =>
|
||||||
|
!chunk.canBeInitial() &&
|
||||||
|
!new RegExp(`^.+-work${latestBuild ? "(?:let|er)" : "let"}$`).test(
|
||||||
|
chunk.name
|
||||||
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
@ -232,17 +232,5 @@ http:
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</hc-layout>
|
</hc-layout>
|
||||||
|
|
||||||
<script>
|
|
||||||
var _gaq = [["_setAccount", "UA-57927901-9"], ["_trackPageview"]];
|
|
||||||
(function (d, t) {
|
|
||||||
var g = d.createElement(t),
|
|
||||||
s = d.getElementsByTagName(t)[0];
|
|
||||||
g.src =
|
|
||||||
("https:" == location.protocol ? "//ssl" : "//www") +
|
|
||||||
".google-analytics.com/ga.js";
|
|
||||||
s.parentNode.insertBefore(g, s);
|
|
||||||
})(document, "script");
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -14,12 +14,6 @@
|
|||||||
--background-color: #41bdf5;
|
--background-color: #41bdf5;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
|
||||||
var _gaq=[['_setAccount','UA-57927901-10'],['_trackPageview']];
|
|
||||||
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
|
||||||
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
|
|
||||||
s.parentNode.insertBefore(g,s)}(document,'script'));
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<%= renderTemplate("../../../src/html/_js_base.html.template") %>
|
<%= renderTemplate("../../../src/html/_js_base.html.template") %>
|
||||||
|
@ -11,10 +11,4 @@
|
|||||||
font-size: initial;
|
font-size: initial;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
|
||||||
var _gaq=[['_setAccount','UA-57927901-10'],['_trackPageview']];
|
|
||||||
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
|
||||||
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
|
|
||||||
s.parentNode.insertBefore(g,s)}(document,'script'));
|
|
||||||
</script>
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { isFrontpageEmbed } from "../../util/is_frontpage";
|
||||||
import { DemoConfig } from "../types";
|
import { DemoConfig } from "../types";
|
||||||
|
|
||||||
export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
|
export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
|
||||||
@ -5,36 +6,20 @@ export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
|
|||||||
views: [
|
views: [
|
||||||
{
|
{
|
||||||
type: "sections",
|
type: "sections",
|
||||||
title: "Demo",
|
title: isFrontpageEmbed ? "Home Assistant" : "Demo",
|
||||||
path: "home",
|
path: "home",
|
||||||
icon: "mdi:home-assistant",
|
icon: "mdi:home-assistant",
|
||||||
sections: [
|
sections: [
|
||||||
{
|
...(isFrontpageEmbed
|
||||||
title: "Welcome 👋",
|
? []
|
||||||
cards: [{ type: "custom:ha-demo-card" }],
|
: [
|
||||||
},
|
{
|
||||||
|
title: "Welcome 👋",
|
||||||
|
cards: [{ type: "custom:ha-demo-card" }],
|
||||||
|
},
|
||||||
|
]),
|
||||||
{
|
{
|
||||||
cards: [
|
cards: [
|
||||||
{
|
|
||||||
type: "tile",
|
|
||||||
entity: "cover.living_room_garden_shutter",
|
|
||||||
name: "Garden",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "tile",
|
|
||||||
entity: "cover.living_room_graveyard_shutter",
|
|
||||||
name: "Rear",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "tile",
|
|
||||||
entity: "cover.living_room_left_shutter",
|
|
||||||
name: "Left",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "tile",
|
|
||||||
entity: "cover.living_room_right_shutter",
|
|
||||||
name: "Right",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
type: "tile",
|
type: "tile",
|
||||||
entity: "light.floor_lamp",
|
entity: "light.floor_lamp",
|
||||||
@ -60,6 +45,11 @@ export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
|
|||||||
detail: 1,
|
detail: 1,
|
||||||
name: "Temperature",
|
name: "Temperature",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: "tile",
|
||||||
|
entity: "cover.living_room_garden_shutter",
|
||||||
|
name: "Blinds",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: "tile",
|
type: "tile",
|
||||||
entity: "media_player.living_room_nest_mini",
|
entity: "media_player.living_room_nest_mini",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import "../../src/resources/safari-14-attachshadow-patch";
|
import "../../src/resources/safari-14-attachshadow-patch";
|
||||||
|
import "./util/is_frontpage";
|
||||||
import "./ha-demo";
|
import "./ha-demo";
|
||||||
|
|
||||||
import("../../src/resources/ha-style");
|
import("../../src/resources/ha-style");
|
||||||
|
@ -93,16 +93,5 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<%= renderTemplate("../../../src/html/_script_load_es5.html.template") %>
|
<%= renderTemplate("../../../src/html/_script_load_es5.html.template") %>
|
||||||
<script>
|
|
||||||
var _gaq = [["_setAccount", "UA-57927901-5"], ["_trackPageview"]];
|
|
||||||
(function (d, t) {
|
|
||||||
var g = d.createElement(t),
|
|
||||||
s = d.getElementsByTagName(t)[0];
|
|
||||||
g.src =
|
|
||||||
("https:" == location.protocol ? "//ssl" : "//www") +
|
|
||||||
".google-analytics.com/ga.js";
|
|
||||||
s.parentNode.insertBefore(g, s);
|
|
||||||
})(document, "script");
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
1
demo/src/util/is_frontpage.ts
Normal file
1
demo/src/util/is_frontpage.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export const isFrontpageEmbed = document.location.search === "?frontpage";
|
@ -80,7 +80,7 @@
|
|||||||
"@material/mwc-top-app-bar": "0.27.0",
|
"@material/mwc-top-app-bar": "0.27.0",
|
||||||
"@material/mwc-top-app-bar-fixed": "0.27.0",
|
"@material/mwc-top-app-bar-fixed": "0.27.0",
|
||||||
"@material/top-app-bar": "=14.0.0-canary.53b3cad2f.0",
|
"@material/top-app-bar": "=14.0.0-canary.53b3cad2f.0",
|
||||||
"@material/web": "1.5.0",
|
"@material/web": "1.5.1",
|
||||||
"@mdi/js": "7.4.47",
|
"@mdi/js": "7.4.47",
|
||||||
"@mdi/svg": "7.4.47",
|
"@mdi/svg": "7.4.47",
|
||||||
"@polymer/paper-item": "3.0.1",
|
"@polymer/paper-item": "3.0.1",
|
||||||
@ -200,7 +200,7 @@
|
|||||||
"eslint-import-resolver-webpack": "0.13.8",
|
"eslint-import-resolver-webpack": "0.13.8",
|
||||||
"eslint-plugin-import": "2.29.1",
|
"eslint-plugin-import": "2.29.1",
|
||||||
"eslint-plugin-lit": "1.14.0",
|
"eslint-plugin-lit": "1.14.0",
|
||||||
"eslint-plugin-lit-a11y": "4.1.2",
|
"eslint-plugin-lit-a11y": "4.1.3",
|
||||||
"eslint-plugin-unused-imports": "4.0.0",
|
"eslint-plugin-unused-imports": "4.0.0",
|
||||||
"eslint-plugin-wc": "2.1.0",
|
"eslint-plugin-wc": "2.1.0",
|
||||||
"fancy-log": "2.0.0",
|
"fancy-log": "2.0.0",
|
||||||
|
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "home-assistant-frontend"
|
name = "home-assistant-frontend"
|
||||||
version = "20240628.0"
|
version = "20240702.0"
|
||||||
license = {text = "Apache-2.0"}
|
license = {text = "Apache-2.0"}
|
||||||
description = "The Home Assistant frontend"
|
description = "The Home Assistant frontend"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
@ -7,6 +7,7 @@ import { mdiRestore } from "@mdi/js";
|
|||||||
import { styleMap } from "lit/directives/style-map";
|
import { styleMap } from "lit/directives/style-map";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import { HomeAssistant } from "../types";
|
import { HomeAssistant } from "../types";
|
||||||
|
import { conditionalClamp } from "../common/number/clamp";
|
||||||
|
|
||||||
type GridSizeValue = {
|
type GridSizeValue = {
|
||||||
rows?: number;
|
rows?: number;
|
||||||
@ -42,6 +43,10 @@ export class HaGridSizeEditor extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
|
const disabledColumns =
|
||||||
|
this.columnMin !== undefined && this.columnMin === this.columnMax;
|
||||||
|
const disabledRows =
|
||||||
|
this.rowMin !== undefined && this.rowMin === this.rowMax;
|
||||||
return html`
|
return html`
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<ha-grid-layout-slider
|
<ha-grid-layout-slider
|
||||||
@ -55,6 +60,7 @@ export class HaGridSizeEditor extends LitElement {
|
|||||||
.value=${this.value?.columns}
|
.value=${this.value?.columns}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
@slider-moved=${this._sliderMoved}
|
@slider-moved=${this._sliderMoved}
|
||||||
|
.disabled=${disabledColumns}
|
||||||
></ha-grid-layout-slider>
|
></ha-grid-layout-slider>
|
||||||
<ha-grid-layout-slider
|
<ha-grid-layout-slider
|
||||||
aria-label=${this.hass.localize(
|
aria-label=${this.hass.localize(
|
||||||
@ -68,6 +74,7 @@ export class HaGridSizeEditor extends LitElement {
|
|||||||
.value=${this.value?.rows}
|
.value=${this.value?.rows}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
@slider-moved=${this._sliderMoved}
|
@slider-moved=${this._sliderMoved}
|
||||||
|
.disabled=${disabledRows}
|
||||||
></ha-grid-layout-slider>
|
></ha-grid-layout-slider>
|
||||||
${!this.isDefault
|
${!this.isDefault
|
||||||
? html`
|
? html`
|
||||||
@ -100,17 +107,11 @@ export class HaGridSizeEditor extends LitElement {
|
|||||||
.map((_, index) => {
|
.map((_, index) => {
|
||||||
const row = Math.floor(index / this.columns) + 1;
|
const row = Math.floor(index / this.columns) + 1;
|
||||||
const column = (index % this.columns) + 1;
|
const column = (index % this.columns) + 1;
|
||||||
const disabled =
|
|
||||||
(this.rowMin !== undefined && row < this.rowMin) ||
|
|
||||||
(this.rowMax !== undefined && row > this.rowMax) ||
|
|
||||||
(this.columnMin !== undefined && column < this.columnMin) ||
|
|
||||||
(this.columnMax !== undefined && column > this.columnMax);
|
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
class="cell"
|
class="cell"
|
||||||
data-row=${row}
|
data-row=${row}
|
||||||
data-column=${column}
|
data-column=${column}
|
||||||
?disabled=${disabled}
|
|
||||||
@click=${this._cellClick}
|
@click=${this._cellClick}
|
||||||
></div>
|
></div>
|
||||||
`;
|
`;
|
||||||
@ -126,11 +127,16 @@ export class HaGridSizeEditor extends LitElement {
|
|||||||
|
|
||||||
_cellClick(ev) {
|
_cellClick(ev) {
|
||||||
const cell = ev.currentTarget as HTMLElement;
|
const cell = ev.currentTarget as HTMLElement;
|
||||||
if (cell.getAttribute("disabled") !== null) return;
|
|
||||||
const rows = Number(cell.getAttribute("data-row"));
|
const rows = Number(cell.getAttribute("data-row"));
|
||||||
const columns = Number(cell.getAttribute("data-column"));
|
const columns = Number(cell.getAttribute("data-column"));
|
||||||
|
const clampedRow = conditionalClamp(rows, this.rowMin, this.rowMax);
|
||||||
|
const clampedColumn = conditionalClamp(
|
||||||
|
columns,
|
||||||
|
this.columnMin,
|
||||||
|
this.columnMax
|
||||||
|
);
|
||||||
fireEvent(this, "value-changed", {
|
fireEvent(this, "value-changed", {
|
||||||
value: { rows, columns },
|
value: { rows: clampedRow, columns: clampedColumn },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,6 +394,7 @@ class GroupEntity extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const TYPES = {
|
const TYPES = {
|
||||||
|
automation: ToggleEntity,
|
||||||
alarm_control_panel: AlarmControlPanelEntity,
|
alarm_control_panel: AlarmControlPanelEntity,
|
||||||
climate: ClimateEntity,
|
climate: ClimateEntity,
|
||||||
cover: CoverEntity,
|
cover: CoverEntity,
|
||||||
|
@ -77,12 +77,13 @@ export class HaConfigApplicationCredentials extends LitElement {
|
|||||||
private _filter = "";
|
private _filter = "";
|
||||||
|
|
||||||
private _columns = memoizeOne(
|
private _columns = memoizeOne(
|
||||||
(narrow: boolean, localize: LocalizeFunc): DataTableColumnContainer => {
|
(localize: LocalizeFunc): DataTableColumnContainer => {
|
||||||
const columns: DataTableColumnContainer<ApplicationCredential> = {
|
const columns: DataTableColumnContainer<ApplicationCredential> = {
|
||||||
name: {
|
name: {
|
||||||
title: localize(
|
title: localize(
|
||||||
"ui.panel.config.application_credentials.picker.headers.name"
|
"ui.panel.config.application_credentials.picker.headers.name"
|
||||||
),
|
),
|
||||||
|
main: true,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
direction: "asc",
|
direction: "asc",
|
||||||
@ -94,7 +95,6 @@ export class HaConfigApplicationCredentials extends LitElement {
|
|||||||
),
|
),
|
||||||
filterable: true,
|
filterable: true,
|
||||||
width: "30%",
|
width: "30%",
|
||||||
hidden: narrow,
|
|
||||||
},
|
},
|
||||||
localizedDomain: {
|
localizedDomain: {
|
||||||
title: localize(
|
title: localize(
|
||||||
@ -109,6 +109,9 @@ export class HaConfigApplicationCredentials extends LitElement {
|
|||||||
title: "",
|
title: "",
|
||||||
width: "64px",
|
width: "64px",
|
||||||
type: "overflow-menu",
|
type: "overflow-menu",
|
||||||
|
showNarrow: true,
|
||||||
|
hideable: false,
|
||||||
|
moveable: false,
|
||||||
template: (credential) => html`
|
template: (credential) => html`
|
||||||
<ha-icon-overflow-menu
|
<ha-icon-overflow-menu
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@ -153,7 +156,7 @@ export class HaConfigApplicationCredentials extends LitElement {
|
|||||||
.route=${this.route}
|
.route=${this.route}
|
||||||
back-path="/config"
|
back-path="/config"
|
||||||
.tabs=${configSections.devices}
|
.tabs=${configSections.devices}
|
||||||
.columns=${this._columns(this.narrow, this.hass.localize)}
|
.columns=${this._columns(this.hass.localize)}
|
||||||
.data=${this._getApplicationCredentials(
|
.data=${this._getApplicationCredentials(
|
||||||
this._applicationCredentials,
|
this._applicationCredentials,
|
||||||
this.hass.localize
|
this.hass.localize
|
||||||
@ -356,6 +359,9 @@ export class HaConfigApplicationCredentials extends LitElement {
|
|||||||
margin-inline-start: 8px;
|
margin-inline-start: 8px;
|
||||||
margin-inline-end: initial;
|
margin-inline-end: initial;
|
||||||
}
|
}
|
||||||
|
.warning {
|
||||||
|
--mdc-theme-primary: var(--error-color);
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,6 @@ export class HaBlueprintAutomationEditor extends HaBlueprintGenericEditor {
|
|||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
${this.disabled
|
|
||||||
? html`<ha-alert alert-type="warning">
|
|
||||||
${this.hass.localize("ui.panel.config.automation.editor.read_only")}
|
|
||||||
<mwc-button slot="action" @click=${this._duplicate}>
|
|
||||||
${this.hass.localize("ui.panel.config.automation.editor.migrate")}
|
|
||||||
</mwc-button>
|
|
||||||
</ha-alert>`
|
|
||||||
: nothing}
|
|
||||||
${this.stateObj?.state === "off"
|
${this.stateObj?.state === "off"
|
||||||
? html`
|
? html`
|
||||||
<ha-alert alert-type="info">
|
<ha-alert alert-type="info">
|
||||||
|
@ -81,9 +81,9 @@ declare global {
|
|||||||
unsub?: UnsubscribeFunc;
|
unsub?: UnsubscribeFunc;
|
||||||
};
|
};
|
||||||
"ui-mode-not-available": Error;
|
"ui-mode-not-available": Error;
|
||||||
duplicate: undefined;
|
|
||||||
"move-down": undefined;
|
"move-down": undefined;
|
||||||
"move-up": undefined;
|
"move-up": undefined;
|
||||||
|
duplicate: undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,6 +116,8 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
|
|
||||||
@state() private _validationErrors?: (string | TemplateResult)[];
|
@state() private _validationErrors?: (string | TemplateResult)[];
|
||||||
|
|
||||||
|
@state() private _blueprintConfig?: BlueprintAutomationConfig;
|
||||||
|
|
||||||
private _configSubscriptions: Record<
|
private _configSubscriptions: Record<
|
||||||
string,
|
string,
|
||||||
(config?: AutomationConfig) => void
|
(config?: AutomationConfig) => void
|
||||||
@ -200,7 +202,9 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
<ha-list-item
|
<ha-list-item
|
||||||
graphic="icon"
|
graphic="icon"
|
||||||
@click=${this._promptAutomationAlias}
|
@click=${this._promptAutomationAlias}
|
||||||
.disabled=${!this.automationId || this._mode === "yaml"}
|
.disabled=${this._readOnly ||
|
||||||
|
!this.automationId ||
|
||||||
|
this._mode === "yaml"}
|
||||||
>
|
>
|
||||||
${this.hass.localize("ui.panel.config.automation.editor.rename")}
|
${this.hass.localize("ui.panel.config.automation.editor.rename")}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiRenameBox}></ha-svg-icon>
|
<ha-svg-icon slot="graphic" .path=${mdiRenameBox}></ha-svg-icon>
|
||||||
@ -224,7 +228,8 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
: nothing}
|
: nothing}
|
||||||
|
|
||||||
<ha-list-item
|
<ha-list-item
|
||||||
.disabled=${!this._readOnly && !this.automationId}
|
.disabled=${this._blueprintConfig ||
|
||||||
|
(!this._readOnly && !this.automationId)}
|
||||||
graphic="icon"
|
graphic="icon"
|
||||||
@click=${this._duplicate}
|
@click=${this._duplicate}
|
||||||
>
|
>
|
||||||
@ -244,7 +249,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
<ha-list-item
|
<ha-list-item
|
||||||
graphic="icon"
|
graphic="icon"
|
||||||
@click=${this._takeControl}
|
@click=${this._takeControl}
|
||||||
.disabled=${this._readOnly || this._mode === "yaml"}
|
.disabled=${this._readOnly}
|
||||||
>
|
>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.editor.take_control"
|
"ui.panel.config.automation.editor.take_control"
|
||||||
@ -337,6 +342,32 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
: nothing}
|
: nothing}
|
||||||
</ha-alert>`
|
</ha-alert>`
|
||||||
: ""}
|
: ""}
|
||||||
|
${this._blueprintConfig
|
||||||
|
? html`<ha-alert alert-type="info">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.confirm_take_control"
|
||||||
|
)}
|
||||||
|
<div slot="action" style="display: flex;">
|
||||||
|
<mwc-button @click=${this._takeControlSave}
|
||||||
|
>${this.hass.localize("ui.common.yes")}</mwc-button
|
||||||
|
>
|
||||||
|
<mwc-button @click=${this._revertBlueprint}
|
||||||
|
>${this.hass.localize("ui.common.no")}</mwc-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</ha-alert>`
|
||||||
|
: this._readOnly
|
||||||
|
? html`<ha-alert alert-type="warning" dismissable
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.read_only"
|
||||||
|
)}
|
||||||
|
<mwc-button slot="action" @click=${this._duplicate}>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.migrate"
|
||||||
|
)}
|
||||||
|
</mwc-button>
|
||||||
|
</ha-alert>`
|
||||||
|
: nothing}
|
||||||
${this._mode === "gui"
|
${this._mode === "gui"
|
||||||
? html`
|
? html`
|
||||||
<div
|
<div
|
||||||
@ -354,7 +385,6 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
.config=${this._config}
|
.config=${this._config}
|
||||||
.disabled=${Boolean(this._readOnly)}
|
.disabled=${Boolean(this._readOnly)}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
@duplicate=${this._duplicate}
|
|
||||||
></blueprint-automation-editor>
|
></blueprint-automation-editor>
|
||||||
`
|
`
|
||||||
: html`
|
: html`
|
||||||
@ -366,25 +396,12 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
.config=${this._config}
|
.config=${this._config}
|
||||||
.disabled=${Boolean(this._readOnly)}
|
.disabled=${Boolean(this._readOnly)}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
@duplicate=${this._duplicate}
|
|
||||||
></manual-automation-editor>
|
></manual-automation-editor>
|
||||||
`}
|
`}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: this._mode === "yaml"
|
: this._mode === "yaml"
|
||||||
? html` ${this._readOnly
|
? html`${stateObj?.state === "off"
|
||||||
? html`<ha-alert alert-type="warning">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.read_only"
|
|
||||||
)}
|
|
||||||
<mwc-button slot="action" @click=${this._duplicate}>
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.migrate"
|
|
||||||
)}
|
|
||||||
</mwc-button>
|
|
||||||
</ha-alert>`
|
|
||||||
: nothing}
|
|
||||||
${stateObj?.state === "off"
|
|
||||||
? html`
|
? html`
|
||||||
<ha-alert alert-type="info">
|
<ha-alert alert-type="info">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
@ -409,7 +426,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
</div>
|
</div>
|
||||||
<ha-fab
|
<ha-fab
|
||||||
slot="fab"
|
slot="fab"
|
||||||
class=${classMap({ dirty: this._dirty })}
|
class=${classMap({ dirty: !this._readOnly && this._dirty })}
|
||||||
.label=${this.hass.localize("ui.panel.config.automation.editor.save")}
|
.label=${this.hass.localize("ui.panel.config.automation.editor.save")}
|
||||||
extended
|
extended
|
||||||
@click=${this._saveAutomation}
|
@click=${this._saveAutomation}
|
||||||
@ -651,20 +668,6 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
private async _takeControl() {
|
private async _takeControl() {
|
||||||
const config = this._config as BlueprintAutomationConfig;
|
const config = this._config as BlueprintAutomationConfig;
|
||||||
|
|
||||||
const confirmation = await showConfirmationDialog(this, {
|
|
||||||
title: this.hass!.localize(
|
|
||||||
"ui.panel.config.automation.editor.take_control_confirmation.title"
|
|
||||||
),
|
|
||||||
text: this.hass!.localize(
|
|
||||||
"ui.panel.config.automation.editor.take_control_confirmation.text"
|
|
||||||
),
|
|
||||||
confirmText: this.hass!.localize(
|
|
||||||
"ui.panel.config.automation.editor.take_control_confirmation.action"
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!confirmation) return;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await substituteBlueprint(
|
const result = await substituteBlueprint(
|
||||||
this.hass,
|
this.hass,
|
||||||
@ -675,18 +678,38 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
|
|
||||||
const newConfig = {
|
const newConfig = {
|
||||||
...normalizeAutomationConfig(result.substituted_config),
|
...normalizeAutomationConfig(result.substituted_config),
|
||||||
|
id: config.id,
|
||||||
alias: config.alias,
|
alias: config.alias,
|
||||||
description: config.description,
|
description: config.description,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this._blueprintConfig = config;
|
||||||
this._config = newConfig;
|
this._config = newConfig;
|
||||||
this._dirty = true;
|
if (this._mode === "yaml") {
|
||||||
|
this.renderRoot.querySelector("ha-yaml-editor")?.setValue(this._config);
|
||||||
|
}
|
||||||
|
this._readOnly = true;
|
||||||
this._errors = undefined;
|
this._errors = undefined;
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
this._errors = err.message;
|
this._errors = err.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _revertBlueprint() {
|
||||||
|
this._config = this._blueprintConfig;
|
||||||
|
if (this._mode === "yaml") {
|
||||||
|
this.renderRoot.querySelector("ha-yaml-editor")?.setValue(this._config);
|
||||||
|
}
|
||||||
|
this._blueprintConfig = undefined;
|
||||||
|
this._readOnly = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _takeControlSave() {
|
||||||
|
this._readOnly = false;
|
||||||
|
this._dirty = true;
|
||||||
|
this._blueprintConfig = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
private async _duplicate() {
|
private async _duplicate() {
|
||||||
const result = this._readOnly
|
const result = this._readOnly
|
||||||
? await showConfirmationDialog(this, {
|
? await showConfirmationDialog(this, {
|
||||||
@ -819,10 +842,12 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
}
|
}
|
||||||
manual-automation-editor,
|
manual-automation-editor,
|
||||||
blueprint-automation-editor {
|
blueprint-automation-editor,
|
||||||
|
:not(.yaml-mode) > ha-alert {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
max-width: 1040px;
|
max-width: 1040px;
|
||||||
padding: 28px 20px 0;
|
padding: 28px 20px 0;
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
ha-yaml-editor {
|
ha-yaml-editor {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
@ -38,14 +38,6 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
${this.disabled
|
|
||||||
? html`<ha-alert alert-type="warning">
|
|
||||||
${this.hass.localize("ui.panel.config.automation.editor.read_only")}
|
|
||||||
<mwc-button slot="action" @click=${this._duplicate}>
|
|
||||||
${this.hass.localize("ui.panel.config.automation.editor.migrate")}
|
|
||||||
</mwc-button>
|
|
||||||
</ha-alert>`
|
|
||||||
: nothing}
|
|
||||||
${this.stateObj?.state === "off"
|
${this.stateObj?.state === "off"
|
||||||
? html`
|
? html`
|
||||||
<ha-alert alert-type="info">
|
<ha-alert alert-type="info">
|
||||||
@ -238,10 +230,6 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _duplicate() {
|
|
||||||
fireEvent(this, "duplicate");
|
|
||||||
}
|
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
haStyle,
|
haStyle,
|
||||||
@ -280,12 +268,6 @@ export class HaManualAutomationEditor extends LitElement {
|
|||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
line-height: 0;
|
line-height: 0;
|
||||||
}
|
}
|
||||||
ha-alert.re-order {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
border-radius: var(--ha-card-border-radius, 12px);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
|||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import { nestedArrayMove } from "../../../common/util/array-move";
|
import { nestedArrayMove } from "../../../common/util/array-move";
|
||||||
import "../../../components/ha-alert";
|
|
||||||
import "../../../components/ha-blueprint-picker";
|
import "../../../components/ha-blueprint-picker";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-circular-progress";
|
import "../../../components/ha-circular-progress";
|
||||||
@ -126,14 +125,14 @@ export abstract class HaBlueprintGenericEditor extends LitElement {
|
|||||||
);
|
);
|
||||||
const expanded = !section.collapsed || anyRequired;
|
const expanded = !section.collapsed || anyRequired;
|
||||||
|
|
||||||
return html` <ha-expansion-panel
|
return html`<ha-expansion-panel
|
||||||
outlined
|
outlined
|
||||||
.expanded=${expanded}
|
.expanded=${expanded}
|
||||||
.noCollapse=${anyRequired}
|
.noCollapse=${anyRequired}
|
||||||
>
|
>
|
||||||
<div slot="header" role="heading" aria-level="3" class="section-header">
|
<div slot="header" role="heading" aria-level="3" class="section-header">
|
||||||
${section?.icon
|
${section?.icon
|
||||||
? html` <ha-icon
|
? html`<ha-icon
|
||||||
class="section-header"
|
class="section-header"
|
||||||
.icon=${section.icon}
|
.icon=${section.icon}
|
||||||
></ha-icon>`
|
></ha-icon>`
|
||||||
@ -261,10 +260,6 @@ export abstract class HaBlueprintGenericEditor extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _duplicate() {
|
|
||||||
fireEvent(this, "duplicate");
|
|
||||||
}
|
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
haStyle,
|
haStyle,
|
||||||
@ -318,14 +313,6 @@ export abstract class HaBlueprintGenericEditor extends LitElement {
|
|||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
}
|
}
|
||||||
ha-alert {
|
|
||||||
margin-bottom: 16px;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
ha-alert.re-order {
|
|
||||||
border-radius: var(--ha-card-border-radius, 12px);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
div.section-header {
|
div.section-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
@ -333,6 +320,10 @@ export abstract class HaBlueprintGenericEditor extends LitElement {
|
|||||||
ha-icon.section-header {
|
ha-icon.section-header {
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
}
|
}
|
||||||
|
ha-alert {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import "@material/mwc-button/mwc-button";
|
import "@material/mwc-button/mwc-button";
|
||||||
import { html, nothing } from "lit";
|
import { html, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import "../../../components/ha-alert";
|
|
||||||
import "../../../components/ha-markdown";
|
import "../../../components/ha-markdown";
|
||||||
import { fetchBlueprints } from "../../../data/blueprint";
|
import { fetchBlueprints } from "../../../data/blueprint";
|
||||||
import { BlueprintScriptConfig } from "../../../data/script";
|
import { BlueprintScriptConfig } from "../../../data/script";
|
||||||
@ -17,14 +16,6 @@ export class HaBlueprintScriptEditor extends HaBlueprintGenericEditor {
|
|||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
${this.disabled
|
|
||||||
? html`<ha-alert alert-type="warning">
|
|
||||||
${this.hass.localize("ui.panel.config.script.editor.read_only")}
|
|
||||||
<mwc-button slot="action" @click=${this._duplicate}>
|
|
||||||
${this.hass.localize("ui.panel.config.script.editor.migrate")}
|
|
||||||
</mwc-button>
|
|
||||||
</ha-alert>`
|
|
||||||
: nothing}
|
|
||||||
${this.config.description
|
${this.config.description
|
||||||
? html`<ha-markdown
|
? html`<ha-markdown
|
||||||
class="description"
|
class="description"
|
||||||
|
@ -99,6 +99,8 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
|
|
||||||
@state() private _validationErrors?: (string | TemplateResult)[];
|
@state() private _validationErrors?: (string | TemplateResult)[];
|
||||||
|
|
||||||
|
@state() private _blueprintConfig?: BlueprintScriptConfig;
|
||||||
|
|
||||||
protected render(): TemplateResult | typeof nothing {
|
protected render(): TemplateResult | typeof nothing {
|
||||||
if (!this._config) {
|
if (!this._config) {
|
||||||
return nothing;
|
return nothing;
|
||||||
@ -216,7 +218,8 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
: nothing}
|
: nothing}
|
||||||
|
|
||||||
<ha-list-item
|
<ha-list-item
|
||||||
.disabled=${!this._readOnly && !this.scriptId}
|
.disabled=${this._blueprintConfig ||
|
||||||
|
(!this._readOnly && !this.scriptId)}
|
||||||
graphic="icon"
|
graphic="icon"
|
||||||
@click=${this._duplicate}
|
@click=${this._duplicate}
|
||||||
>
|
>
|
||||||
@ -236,7 +239,7 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
<ha-list-item
|
<ha-list-item
|
||||||
graphic="icon"
|
graphic="icon"
|
||||||
@click=${this._takeControl}
|
@click=${this._takeControl}
|
||||||
.disabled=${this._readOnly || this._mode === "yaml"}
|
.disabled=${this._readOnly}
|
||||||
>
|
>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.script.editor.take_control"
|
"ui.panel.config.script.editor.take_control"
|
||||||
@ -312,6 +315,32 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
: nothing}
|
: nothing}
|
||||||
</ha-alert>`
|
</ha-alert>`
|
||||||
: ""}
|
: ""}
|
||||||
|
${this._blueprintConfig
|
||||||
|
? html`<ha-alert alert-type="info">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.script.editor.confirm_take_control"
|
||||||
|
)}
|
||||||
|
<div slot="action" style="display: flex;">
|
||||||
|
<mwc-button @click=${this._takeControlSave}
|
||||||
|
>${this.hass.localize("ui.common.yes")}</mwc-button
|
||||||
|
>
|
||||||
|
<mwc-button @click=${this._revertBlueprint}
|
||||||
|
>${this.hass.localize("ui.common.no")}</mwc-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</ha-alert>`
|
||||||
|
: this._readOnly
|
||||||
|
? html`<ha-alert alert-type="warning" dismissable
|
||||||
|
>${this.hass.localize(
|
||||||
|
"ui.panel.config.script.editor.read_only"
|
||||||
|
)}
|
||||||
|
<mwc-button slot="action" @click=${this._duplicate}>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.script.editor.migrate"
|
||||||
|
)}
|
||||||
|
</mwc-button>
|
||||||
|
</ha-alert>`
|
||||||
|
: nothing}
|
||||||
${this._mode === "gui"
|
${this._mode === "gui"
|
||||||
? html`
|
? html`
|
||||||
<div
|
<div
|
||||||
@ -328,7 +357,6 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
.config=${this._config}
|
.config=${this._config}
|
||||||
.disabled=${this._readOnly}
|
.disabled=${this._readOnly}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
@duplicate=${this._duplicate}
|
|
||||||
></blueprint-script-editor>
|
></blueprint-script-editor>
|
||||||
`
|
`
|
||||||
: html`
|
: html`
|
||||||
@ -339,31 +367,18 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
.config=${this._config}
|
.config=${this._config}
|
||||||
.disabled=${this._readOnly}
|
.disabled=${this._readOnly}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
@duplicate=${this._duplicate}
|
|
||||||
></manual-script-editor>
|
></manual-script-editor>
|
||||||
`}
|
`}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: this._mode === "yaml"
|
: this._mode === "yaml"
|
||||||
? html` ${this._readOnly
|
? html`<ha-yaml-editor
|
||||||
? html`<ha-alert alert-type="warning">
|
copyClipboard
|
||||||
${this.hass.localize(
|
.hass=${this.hass}
|
||||||
"ui.panel.config.script.editor.read_only"
|
.defaultValue=${this._preprocessYaml()}
|
||||||
)}
|
.readOnly=${this._readOnly}
|
||||||
<mwc-button slot="action" @click=${this._duplicate}>
|
@value-changed=${this._yamlChanged}
|
||||||
${this.hass.localize(
|
></ha-yaml-editor>`
|
||||||
"ui.panel.config.script.editor.migrate"
|
|
||||||
)}
|
|
||||||
</mwc-button>
|
|
||||||
</ha-alert>`
|
|
||||||
: nothing}
|
|
||||||
<ha-yaml-editor
|
|
||||||
copyClipboard
|
|
||||||
.hass=${this.hass}
|
|
||||||
.defaultValue=${this._preprocessYaml()}
|
|
||||||
.readOnly=${this._readOnly}
|
|
||||||
@value-changed=${this._yamlChanged}
|
|
||||||
></ha-yaml-editor>`
|
|
||||||
: nothing}
|
: nothing}
|
||||||
</div>
|
</div>
|
||||||
<ha-fab
|
<ha-fab
|
||||||
@ -625,20 +640,6 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
private async _takeControl() {
|
private async _takeControl() {
|
||||||
const config = this._config as BlueprintScriptConfig;
|
const config = this._config as BlueprintScriptConfig;
|
||||||
|
|
||||||
const confirmation = await showConfirmationDialog(this, {
|
|
||||||
title: this.hass!.localize(
|
|
||||||
"ui.panel.config.script.editor.take_control_confirmation.title"
|
|
||||||
),
|
|
||||||
text: this.hass!.localize(
|
|
||||||
"ui.panel.config.script.editor.take_control_confirmation.text"
|
|
||||||
),
|
|
||||||
confirmText: this.hass!.localize(
|
|
||||||
"ui.panel.config.script.editor.take_control_confirmation.action"
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!confirmation) return;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await substituteBlueprint(
|
const result = await substituteBlueprint(
|
||||||
this.hass,
|
this.hass,
|
||||||
@ -653,14 +654,33 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
description: config.description,
|
description: config.description,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this._blueprintConfig = config;
|
||||||
this._config = newConfig;
|
this._config = newConfig;
|
||||||
this._dirty = true;
|
if (this._mode === "yaml") {
|
||||||
|
this.renderRoot.querySelector("ha-yaml-editor")?.setValue(this._config);
|
||||||
|
}
|
||||||
|
this._readOnly = true;
|
||||||
this._errors = undefined;
|
this._errors = undefined;
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
this._errors = err.message;
|
this._errors = err.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _revertBlueprint() {
|
||||||
|
this._config = this._blueprintConfig;
|
||||||
|
if (this._mode === "yaml") {
|
||||||
|
this.renderRoot.querySelector("ha-yaml-editor")?.setValue(this._config);
|
||||||
|
}
|
||||||
|
this._blueprintConfig = undefined;
|
||||||
|
this._readOnly = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _takeControlSave() {
|
||||||
|
this._readOnly = false;
|
||||||
|
this._dirty = true;
|
||||||
|
this._blueprintConfig = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
private async _duplicate() {
|
private async _duplicate() {
|
||||||
const result = this._readOnly
|
const result = this._readOnly
|
||||||
? await showConfirmationDialog(this, {
|
? await showConfirmationDialog(this, {
|
||||||
@ -812,10 +832,12 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
.config-container,
|
.config-container,
|
||||||
manual-script-editor,
|
manual-script-editor,
|
||||||
blueprint-script-editor {
|
blueprint-script-editor,
|
||||||
|
:not(.yaml-mode) > ha-alert {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
max-width: 1040px;
|
max-width: 1040px;
|
||||||
padding: 28px 20px 0;
|
padding: 28px 20px 0;
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
.config-container ha-alert {
|
.config-container ha-alert {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
|
@ -60,14 +60,6 @@ export class HaManualScriptEditor extends LitElement {
|
|||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
${this.disabled
|
|
||||||
? html`<ha-alert alert-type="warning">
|
|
||||||
${this.hass.localize("ui.panel.config.script.editor.read_only")}
|
|
||||||
<mwc-button slot="action" @click=${this._duplicate}>
|
|
||||||
${this.hass.localize("ui.panel.config.script.editor.migrate")}
|
|
||||||
</mwc-button>
|
|
||||||
</ha-alert>`
|
|
||||||
: nothing}
|
|
||||||
${this.config.description
|
${this.config.description
|
||||||
? html`<ha-markdown
|
? html`<ha-markdown
|
||||||
class="description"
|
class="description"
|
||||||
@ -170,10 +162,6 @@ export class HaManualScriptEditor extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _duplicate() {
|
|
||||||
fireEvent(this, "duplicate");
|
|
||||||
}
|
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
haStyle,
|
haStyle,
|
||||||
@ -205,12 +193,6 @@ export class HaManualScriptEditor extends LitElement {
|
|||||||
.header a {
|
.header a {
|
||||||
color: var(--secondary-text-color);
|
color: var(--secondary-text-color);
|
||||||
}
|
}
|
||||||
ha-alert.re-order {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
border-radius: var(--ha-card-border-radius, 12px);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ export class HaLogbook extends LitElement {
|
|||||||
this._throttleGetLogbookEntries.cancel();
|
this._throttleGetLogbookEntries.cancel();
|
||||||
this._updateTraceContexts.cancel();
|
this._updateTraceContexts.cancel();
|
||||||
this._updateUsers.cancel();
|
this._updateUsers.cancel();
|
||||||
await this._unsubscribeSetLoading();
|
this._unsubscribeSetLoading();
|
||||||
|
|
||||||
if (force) {
|
if (force) {
|
||||||
this._getLogBookData();
|
this._getLogBookData();
|
||||||
@ -206,18 +206,9 @@ export class HaLogbook extends LitElement {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _unsubscribe(): Promise<void> {
|
private _unsubscribe() {
|
||||||
if (this._subscribed) {
|
if (this._subscribed) {
|
||||||
const unsub = await this._subscribed;
|
this._subscribed.then((unsub) => unsub?.());
|
||||||
if (unsub) {
|
|
||||||
try {
|
|
||||||
await unsub();
|
|
||||||
} catch (e) {
|
|
||||||
// The backend will cancel the subscription if
|
|
||||||
// we subscribe to entities that will all be
|
|
||||||
// filtered away
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._subscribed = undefined;
|
this._subscribed = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,8 +230,8 @@ export class HaLogbook extends LitElement {
|
|||||||
* Setting this._logbookEntries to undefined
|
* Setting this._logbookEntries to undefined
|
||||||
* will put the page in a loading state.
|
* will put the page in a loading state.
|
||||||
*/
|
*/
|
||||||
private async _unsubscribeSetLoading() {
|
private _unsubscribeSetLoading() {
|
||||||
await this._unsubscribe();
|
this._unsubscribe();
|
||||||
this._logbookEntries = undefined;
|
this._logbookEntries = undefined;
|
||||||
this._pendingStreamMessages = [];
|
this._pendingStreamMessages = [];
|
||||||
}
|
}
|
||||||
@ -249,8 +240,8 @@ export class HaLogbook extends LitElement {
|
|||||||
* Setting this._logbookEntries to an empty
|
* Setting this._logbookEntries to an empty
|
||||||
* list will show a no results message.
|
* list will show a no results message.
|
||||||
*/
|
*/
|
||||||
private async _unsubscribeNoResults() {
|
private _unsubscribeNoResults() {
|
||||||
await this._unsubscribe();
|
this._unsubscribe();
|
||||||
this._logbookEntries = [];
|
this._logbookEntries = [];
|
||||||
this._pendingStreamMessages = [];
|
this._pendingStreamMessages = [];
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,11 @@ import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
|||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import "../components/hui-image";
|
import "../components/hui-image";
|
||||||
import "../components/hui-warning";
|
import "../components/hui-warning";
|
||||||
import { LovelaceCard, LovelaceCardEditor } from "../types";
|
import {
|
||||||
|
LovelaceCard,
|
||||||
|
LovelaceCardEditor,
|
||||||
|
LovelaceLayoutOptions,
|
||||||
|
} from "../types";
|
||||||
import { AreaCardConfig } from "./types";
|
import { AreaCardConfig } from "./types";
|
||||||
|
|
||||||
export const DEFAULT_ASPECT_RATIO = "16:9";
|
export const DEFAULT_ASPECT_RATIO = "16:9";
|
||||||
@ -102,6 +106,9 @@ export class HuiAreaCard
|
|||||||
|
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
|
@property({ attribute: false })
|
||||||
|
public layout?: string;
|
||||||
|
|
||||||
@state() private _config?: AreaCardConfig;
|
@state() private _config?: AreaCardConfig;
|
||||||
|
|
||||||
@state() private _entities?: EntityRegistryEntry[];
|
@state() private _entities?: EntityRegistryEntry[];
|
||||||
@ -405,13 +412,17 @@ export class HuiAreaCard
|
|||||||
if (this._config.show_camera && "camera" in entitiesByDomain) {
|
if (this._config.show_camera && "camera" in entitiesByDomain) {
|
||||||
cameraEntityId = entitiesByDomain.camera[0].entity_id;
|
cameraEntityId = entitiesByDomain.camera[0].entity_id;
|
||||||
}
|
}
|
||||||
|
cameraEntityId = "camera.demo_camera";
|
||||||
|
|
||||||
const imageClass = area.picture || cameraEntityId;
|
const imageClass = area.picture || cameraEntityId;
|
||||||
|
|
||||||
|
const ignoreAspectRatio = imageClass || this.layout === "grid";
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-card
|
<ha-card
|
||||||
class=${imageClass ? "image" : ""}
|
class=${imageClass ? "image" : ""}
|
||||||
style=${styleMap({
|
style=${styleMap({
|
||||||
paddingBottom: imageClass
|
paddingBottom: ignoreAspectRatio
|
||||||
? "0"
|
? "0"
|
||||||
: `${((100 * this._ratio!.h) / this._ratio!.w).toFixed(2)}%`,
|
: `${((100 * this._ratio!.h) / this._ratio!.w).toFixed(2)}%`,
|
||||||
})}
|
})}
|
||||||
@ -534,12 +545,20 @@ export class HuiAreaCard
|
|||||||
forwardHaptic("light");
|
forwardHaptic("light");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLayoutOptions(): LovelaceLayoutOptions {
|
||||||
|
return {
|
||||||
|
grid_columns: 4,
|
||||||
|
grid_rows: 3,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return css`
|
return css`
|
||||||
ha-card {
|
ha-card {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
|
@ -145,9 +145,16 @@ export class HuiButtonCard extends LitElement implements LovelaceCard {
|
|||||||
this._config?.show_icon &&
|
this._config?.show_icon &&
|
||||||
(this._config?.show_name || this._config?.show_state)
|
(this._config?.show_name || this._config?.show_state)
|
||||||
) {
|
) {
|
||||||
return { grid_rows: 2, grid_columns: 2 };
|
return {
|
||||||
|
grid_rows: 2,
|
||||||
|
grid_columns: 2,
|
||||||
|
grid_min_rows: 2,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return { grid_rows: 1, grid_columns: 1 };
|
return {
|
||||||
|
grid_rows: 1,
|
||||||
|
grid_columns: 1,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public setConfig(config: ButtonCardConfig): void {
|
public setConfig(config: ButtonCardConfig): void {
|
||||||
|
@ -23,14 +23,16 @@ declare global {
|
|||||||
|
|
||||||
@customElement("hui-card")
|
@customElement("hui-card")
|
||||||
export class HuiCard extends ReactiveElement {
|
export class HuiCard extends ReactiveElement {
|
||||||
@property({ type: Boolean }) public preview = false;
|
@property({ attribute: false }) public preview = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public isPanel = false;
|
@property({ attribute: false }) public isPanel = false;
|
||||||
|
|
||||||
@property({ attribute: false }) public config?: LovelaceCardConfig;
|
@property({ attribute: false }) public config?: LovelaceCardConfig;
|
||||||
|
|
||||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public layout?: string;
|
||||||
|
|
||||||
private _elementConfig?: LovelaceCardConfig;
|
private _elementConfig?: LovelaceCardConfig;
|
||||||
|
|
||||||
public load() {
|
public load() {
|
||||||
@ -98,6 +100,7 @@ export class HuiCard extends ReactiveElement {
|
|||||||
if (this.hass) {
|
if (this.hass) {
|
||||||
this._element.hass = this.hass;
|
this._element.hass = this.hass;
|
||||||
}
|
}
|
||||||
|
this._element.layout = this.layout;
|
||||||
this._element.preview = this.preview;
|
this._element.preview = this.preview;
|
||||||
// For backwards compatibility
|
// For backwards compatibility
|
||||||
(this._element as any).editMode = this.preview;
|
(this._element as any).editMode = this.preview;
|
||||||
@ -176,6 +179,9 @@ export class HuiCard extends ReactiveElement {
|
|||||||
if (changedProps.has("isPanel")) {
|
if (changedProps.has("isPanel")) {
|
||||||
this._element.isPanel = this.isPanel;
|
this._element.isPanel = this.isPanel;
|
||||||
}
|
}
|
||||||
|
if (changedProps.has("layout")) {
|
||||||
|
this._element.layout = this.layout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changedProps.has("hass") || changedProps.has("preview")) {
|
if (changedProps.has("hass") || changedProps.has("preview")) {
|
||||||
|
@ -36,7 +36,11 @@ import { findEntities } from "../common/find-entities";
|
|||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
import { createHeaderFooterElement } from "../create-element/create-header-footer-element";
|
import { createHeaderFooterElement } from "../create-element/create-header-footer-element";
|
||||||
import { LovelaceCard, LovelaceHeaderFooter } from "../types";
|
import {
|
||||||
|
LovelaceCard,
|
||||||
|
LovelaceHeaderFooter,
|
||||||
|
LovelaceLayoutOptions,
|
||||||
|
} from "../types";
|
||||||
import { HuiErrorCard } from "./hui-error-card";
|
import { HuiErrorCard } from "./hui-error-card";
|
||||||
import { EntityCardConfig } from "./types";
|
import { EntityCardConfig } from "./types";
|
||||||
|
|
||||||
@ -241,6 +245,15 @@ export class HuiEntityCard extends LitElement implements LovelaceCard {
|
|||||||
fireEvent(this, "hass-more-info", { entityId: this._config!.entity });
|
fireEvent(this, "hass-more-info", { entityId: this._config!.entity });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getLayoutOptions(): LovelaceLayoutOptions {
|
||||||
|
return {
|
||||||
|
grid_columns: 2,
|
||||||
|
grid_rows: 2,
|
||||||
|
grid_min_columns: 2,
|
||||||
|
grid_min_rows: 2,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
iconColorCSS,
|
iconColorCSS,
|
||||||
|
@ -22,7 +22,11 @@ import { HomeAssistant } from "../../../types";
|
|||||||
import "../card-features/hui-card-features";
|
import "../card-features/hui-card-features";
|
||||||
import { findEntities } from "../common/find-entities";
|
import { findEntities } from "../common/find-entities";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
import { LovelaceCard, LovelaceCardEditor } from "../types";
|
import {
|
||||||
|
LovelaceCard,
|
||||||
|
LovelaceCardEditor,
|
||||||
|
LovelaceLayoutOptions,
|
||||||
|
} from "../types";
|
||||||
import { HumidifierCardConfig } from "./types";
|
import { HumidifierCardConfig } from "./types";
|
||||||
|
|
||||||
@customElement("hui-humidifier-card")
|
@customElement("hui-humidifier-card")
|
||||||
@ -173,6 +177,24 @@ export class HuiHumidifierCard extends LitElement implements LovelaceCard {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getLayoutOptions(): LovelaceLayoutOptions {
|
||||||
|
const grid_columns = 4;
|
||||||
|
let grid_rows = 5;
|
||||||
|
let grid_min_rows = 2;
|
||||||
|
const grid_min_columns = 2;
|
||||||
|
if (this._config?.features?.length) {
|
||||||
|
const featureHeight = Math.ceil((this._config.features.length * 2) / 3);
|
||||||
|
grid_rows += featureHeight;
|
||||||
|
grid_min_rows += featureHeight;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
grid_columns,
|
||||||
|
grid_rows,
|
||||||
|
grid_min_rows,
|
||||||
|
grid_min_columns,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return css`
|
return css`
|
||||||
:host {
|
:host {
|
||||||
|
@ -7,7 +7,11 @@ import "../../../components/ha-alert";
|
|||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import { IFRAME_SANDBOX } from "../../../util/iframe";
|
import { IFRAME_SANDBOX } from "../../../util/iframe";
|
||||||
import { LovelaceCard, LovelaceCardEditor } from "../types";
|
import {
|
||||||
|
LovelaceCard,
|
||||||
|
LovelaceCardEditor,
|
||||||
|
LovelaceLayoutOptions,
|
||||||
|
} from "../types";
|
||||||
import { IframeCardConfig } from "./types";
|
import { IframeCardConfig } from "./types";
|
||||||
|
|
||||||
@customElement("hui-iframe-card")
|
@customElement("hui-iframe-card")
|
||||||
@ -28,6 +32,9 @@ export class HuiIframeCard extends LitElement implements LovelaceCard {
|
|||||||
@property({ type: Boolean, reflect: true })
|
@property({ type: Boolean, reflect: true })
|
||||||
public isPanel = false;
|
public isPanel = false;
|
||||||
|
|
||||||
|
@property({ attribute: false })
|
||||||
|
public layout?: string;
|
||||||
|
|
||||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||||
|
|
||||||
@state() protected _config?: IframeCardConfig;
|
@state() protected _config?: IframeCardConfig;
|
||||||
@ -56,13 +63,16 @@ export class HuiIframeCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let padding = "";
|
let padding = "";
|
||||||
if (!this.isPanel && this._config.aspect_ratio) {
|
const ignoreAspectRatio = this.isPanel || this.layout === "grid";
|
||||||
const ratio = parseAspectRatio(this._config.aspect_ratio);
|
if (!ignoreAspectRatio) {
|
||||||
if (ratio && ratio.w > 0 && ratio.h > 0) {
|
if (this._config.aspect_ratio) {
|
||||||
padding = `${((100 * ratio.h) / ratio.w).toFixed(2)}%`;
|
const ratio = parseAspectRatio(this._config.aspect_ratio);
|
||||||
|
if (ratio && ratio.w > 0 && ratio.h > 0) {
|
||||||
|
padding = `${((100 * ratio.h) / ratio.w).toFixed(2)}%`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
padding = "50%";
|
||||||
}
|
}
|
||||||
} else if (!this.isPanel) {
|
|
||||||
padding = "50%";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const target_protocol = new URL(this._config.url, location.toString())
|
const target_protocol = new URL(this._config.url, location.toString())
|
||||||
@ -105,24 +115,26 @@ export class HuiIframeCard extends LitElement implements LovelaceCard {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getLayoutOptions(): LovelaceLayoutOptions {
|
||||||
|
return {
|
||||||
|
grid_columns: 4,
|
||||||
|
grid_rows: 4,
|
||||||
|
grid_min_rows: 2,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return css`
|
return css`
|
||||||
:host([ispanel]) ha-card {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
ha-card {
|
ha-card {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#root {
|
#root {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
:host([ispanel]) #root {
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
iframe {
|
iframe {
|
||||||
|
@ -39,7 +39,7 @@ import { HomeAssistant } from "../../../types";
|
|||||||
import { findEntities } from "../common/find-entities";
|
import { findEntities } from "../common/find-entities";
|
||||||
import { processConfigEntities } from "../common/process-config-entities";
|
import { processConfigEntities } from "../common/process-config-entities";
|
||||||
import { EntityConfig } from "../entity-rows/types";
|
import { EntityConfig } from "../entity-rows/types";
|
||||||
import { LovelaceCard } from "../types";
|
import { LovelaceCard, LovelaceLayoutOptions } from "../types";
|
||||||
import { MapCardConfig } from "./types";
|
import { MapCardConfig } from "./types";
|
||||||
|
|
||||||
export const DEFAULT_HOURS_TO_SHOW = 0;
|
export const DEFAULT_HOURS_TO_SHOW = 0;
|
||||||
@ -57,6 +57,9 @@ class HuiMapCard extends LitElement implements LovelaceCard {
|
|||||||
@property({ type: Boolean, reflect: true })
|
@property({ type: Boolean, reflect: true })
|
||||||
public isPanel = false;
|
public isPanel = false;
|
||||||
|
|
||||||
|
@property({ attribute: false })
|
||||||
|
public layout?: string;
|
||||||
|
|
||||||
@state() private _stateHistory?: HistoryStates;
|
@state() private _stateHistory?: HistoryStates;
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
@ -297,7 +300,9 @@ class HuiMapCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
private _computePadding(): void {
|
private _computePadding(): void {
|
||||||
const root = this.shadowRoot!.getElementById("root");
|
const root = this.shadowRoot!.getElementById("root");
|
||||||
if (!this._config || this.isPanel || !root) {
|
|
||||||
|
const ignoreAspectRatio = this.isPanel || this.layout === "grid";
|
||||||
|
if (!this._config || ignoreAspectRatio || !root) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,6 +428,15 @@ class HuiMapCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public getLayoutOptions(): LovelaceLayoutOptions {
|
||||||
|
return {
|
||||||
|
grid_columns: 4,
|
||||||
|
grid_rows: 4,
|
||||||
|
grid_min_columns: 2,
|
||||||
|
grid_min_rows: 2,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return css`
|
return css`
|
||||||
ha-card {
|
ha-card {
|
||||||
|
@ -40,7 +40,11 @@ import { findEntities } from "../common/find-entities";
|
|||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import "../components/hui-marquee";
|
import "../components/hui-marquee";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
import type { LovelaceCard, LovelaceCardEditor } from "../types";
|
import type {
|
||||||
|
LovelaceCard,
|
||||||
|
LovelaceCardEditor,
|
||||||
|
LovelaceLayoutOptions,
|
||||||
|
} from "../types";
|
||||||
import { MediaControlCardConfig } from "./types";
|
import { MediaControlCardConfig } from "./types";
|
||||||
|
|
||||||
@customElement("hui-media-control-card")
|
@customElement("hui-media-control-card")
|
||||||
@ -582,6 +586,15 @@ export class HuiMediaControlCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getLayoutOptions(): LovelaceLayoutOptions {
|
||||||
|
return {
|
||||||
|
grid_columns: 4,
|
||||||
|
grid_min_columns: 2,
|
||||||
|
grid_rows: 3,
|
||||||
|
grid_min_rows: 3,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return css`
|
return css`
|
||||||
ha-card {
|
ha-card {
|
||||||
|
@ -76,6 +76,8 @@ class HuiSensorCard extends HuiEntityCard {
|
|||||||
return {
|
return {
|
||||||
grid_columns: 2,
|
grid_columns: 2,
|
||||||
grid_rows: 2,
|
grid_rows: 2,
|
||||||
|
grid_min_columns: 2,
|
||||||
|
grid_min_rows: 2,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import {
|
import {
|
||||||
css,
|
|
||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
html,
|
|
||||||
LitElement,
|
LitElement,
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
|
css,
|
||||||
|
html,
|
||||||
nothing,
|
nothing,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
@ -16,12 +16,12 @@ import "../../../components/ha-alert";
|
|||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-state-icon";
|
import "../../../components/ha-state-icon";
|
||||||
import {
|
import {
|
||||||
|
StatisticsMetaData,
|
||||||
fetchStatistic,
|
fetchStatistic,
|
||||||
getDisplayUnit,
|
getDisplayUnit,
|
||||||
getStatisticLabel,
|
getStatisticLabel,
|
||||||
getStatisticMetadata,
|
getStatisticMetadata,
|
||||||
isExternalStatistic,
|
isExternalStatistic,
|
||||||
StatisticsMetaData,
|
|
||||||
} from "../../../data/recorder";
|
} from "../../../data/recorder";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { computeCardSize } from "../common/compute-card-size";
|
import { computeCardSize } from "../common/compute-card-size";
|
||||||
@ -32,6 +32,7 @@ import {
|
|||||||
LovelaceCard,
|
LovelaceCard,
|
||||||
LovelaceCardEditor,
|
LovelaceCardEditor,
|
||||||
LovelaceHeaderFooter,
|
LovelaceHeaderFooter,
|
||||||
|
LovelaceLayoutOptions,
|
||||||
} from "../types";
|
} from "../types";
|
||||||
import { HuiErrorCard } from "./hui-error-card";
|
import { HuiErrorCard } from "./hui-error-card";
|
||||||
import { EntityCardConfig, StatisticCardConfig } from "./types";
|
import { EntityCardConfig, StatisticCardConfig } from "./types";
|
||||||
@ -254,6 +255,15 @@ export class HuiStatisticCard extends LitElement implements LovelaceCard {
|
|||||||
fireEvent(this, "hass-more-info", { entityId: this._config!.entity });
|
fireEvent(this, "hass-more-info", { entityId: this._config!.entity });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getLayoutOptions(): LovelaceLayoutOptions {
|
||||||
|
return {
|
||||||
|
grid_columns: 2,
|
||||||
|
grid_rows: 2,
|
||||||
|
grid_min_columns: 2,
|
||||||
|
grid_min_rows: 2,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
css`
|
css`
|
||||||
|
@ -22,7 +22,11 @@ import { HomeAssistant } from "../../../types";
|
|||||||
import "../card-features/hui-card-features";
|
import "../card-features/hui-card-features";
|
||||||
import { findEntities } from "../common/find-entities";
|
import { findEntities } from "../common/find-entities";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
import { LovelaceCard, LovelaceCardEditor } from "../types";
|
import {
|
||||||
|
LovelaceCard,
|
||||||
|
LovelaceCardEditor,
|
||||||
|
LovelaceLayoutOptions,
|
||||||
|
} from "../types";
|
||||||
import { ThermostatCardConfig } from "./types";
|
import { ThermostatCardConfig } from "./types";
|
||||||
|
|
||||||
@customElement("hui-thermostat-card")
|
@customElement("hui-thermostat-card")
|
||||||
@ -165,6 +169,24 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getLayoutOptions(): LovelaceLayoutOptions {
|
||||||
|
const grid_columns = 4;
|
||||||
|
let grid_rows = 5;
|
||||||
|
let grid_min_rows = 2;
|
||||||
|
const grid_min_columns = 2;
|
||||||
|
if (this._config?.features?.length) {
|
||||||
|
const featureHeight = Math.ceil((this._config.features.length * 2) / 3);
|
||||||
|
grid_rows += featureHeight;
|
||||||
|
grid_min_rows += featureHeight;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
grid_columns,
|
||||||
|
grid_rows,
|
||||||
|
grid_min_rows,
|
||||||
|
grid_min_columns,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return css`
|
return css`
|
||||||
:host {
|
:host {
|
||||||
|
@ -122,17 +122,21 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getLayoutOptions(): LovelaceLayoutOptions {
|
public getLayoutOptions(): LovelaceLayoutOptions {
|
||||||
const options = {
|
const grid_columns = 2;
|
||||||
grid_columns: 2,
|
let grid_rows = 1;
|
||||||
grid_rows: 1,
|
|
||||||
};
|
|
||||||
if (this._config?.features?.length) {
|
if (this._config?.features?.length) {
|
||||||
options.grid_rows += Math.ceil((this._config.features.length * 2) / 3);
|
const featureHeight = Math.ceil((this._config.features.length * 2) / 3);
|
||||||
|
grid_rows += featureHeight;
|
||||||
}
|
}
|
||||||
if (this._config?.vertical) {
|
if (this._config?.vertical) {
|
||||||
options.grid_rows++;
|
grid_rows!++;
|
||||||
}
|
}
|
||||||
return options;
|
return {
|
||||||
|
grid_columns,
|
||||||
|
grid_rows,
|
||||||
|
grid_min_rows: grid_rows,
|
||||||
|
grid_min_columns: grid_columns,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleAction(ev: ActionHandlerEvent) {
|
private _handleAction(ev: ActionHandlerEvent) {
|
||||||
|
@ -38,7 +38,11 @@ import { handleAction } from "../common/handle-action";
|
|||||||
import { hasAction } from "../common/has-action";
|
import { hasAction } from "../common/has-action";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||||
import type { LovelaceCard, LovelaceCardEditor } from "../types";
|
import type {
|
||||||
|
LovelaceCard,
|
||||||
|
LovelaceCardEditor,
|
||||||
|
LovelaceLayoutOptions,
|
||||||
|
} from "../types";
|
||||||
import type { WeatherForecastCardConfig } from "./types";
|
import type { WeatherForecastCardConfig } from "./types";
|
||||||
|
|
||||||
@customElement("hui-weather-forecast-card")
|
@customElement("hui-weather-forecast-card")
|
||||||
@ -421,6 +425,26 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
|
|||||||
return typeof item !== "undefined" && item !== null;
|
return typeof item !== "undefined" && item !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getLayoutOptions(): LovelaceLayoutOptions {
|
||||||
|
if (
|
||||||
|
this._config?.show_current !== false &&
|
||||||
|
this._config?.show_forecast !== false
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
grid_columns: 4,
|
||||||
|
grid_min_columns: 2,
|
||||||
|
grid_rows: 3,
|
||||||
|
grid_min_rows: 3,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
grid_columns: 4,
|
||||||
|
grid_min_columns: 2,
|
||||||
|
grid_rows: 2,
|
||||||
|
grid_min_rows: 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return [
|
return [
|
||||||
weatherSVGStyles,
|
weatherSVGStyles,
|
||||||
|
@ -255,15 +255,14 @@ export class HaGridLayoutSlider extends LitElement {
|
|||||||
>
|
>
|
||||||
<div id="slider" class="slider">
|
<div id="slider" class="slider">
|
||||||
<div class="track">
|
<div class="track">
|
||||||
<div class="background">
|
<div class="background"></div>
|
||||||
<div
|
<div
|
||||||
class="active"
|
class="active"
|
||||||
style=${styleMap({
|
style=${styleMap({
|
||||||
"--min": `${this.min / this._range}`,
|
"--min": `${this.min / this._range}`,
|
||||||
"--max": `${1 - this.max / this._range}`,
|
"--max": `${1 - this.max / this._range}`,
|
||||||
})}
|
})}
|
||||||
></div>
|
></div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
${this.value !== undefined
|
${this.value !== undefined
|
||||||
? html`<div class="handle"></div>`
|
? html`<div class="handle"></div>`
|
||||||
@ -323,11 +322,12 @@ export class HaGridLayoutSlider extends LitElement {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
background: var(--disabled-color);
|
background: var(--disabled-color);
|
||||||
opacity: 0.5;
|
opacity: 0.2;
|
||||||
}
|
}
|
||||||
.active {
|
.active {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background: grey;
|
background: grey;
|
||||||
|
opacity: 0.7;
|
||||||
top: 0;
|
top: 0;
|
||||||
right: calc(var(--max) * 100%);
|
right: calc(var(--max) * 100%);
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
@ -375,6 +375,9 @@ export class HaGridLayoutSlider extends LitElement {
|
|||||||
:host(:disabled) .slider {
|
:host(:disabled) .slider {
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
:host(:disabled) .handle:after {
|
||||||
|
background: var(--disabled-color);
|
||||||
|
}
|
||||||
.pressed .handle {
|
.pressed .handle {
|
||||||
transition: none;
|
transition: none;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
|||||||
import { haStyle } from "../../../../resources/styles";
|
import { haStyle } from "../../../../resources/styles";
|
||||||
import { HomeAssistant } from "../../../../types";
|
import { HomeAssistant } from "../../../../types";
|
||||||
import { HuiCard } from "../../cards/hui-card";
|
import { HuiCard } from "../../cards/hui-card";
|
||||||
import { DEFAULT_GRID_OPTIONS } from "../../sections/hui-grid-section";
|
import { computeSizeOnGrid } from "../../sections/hui-grid-section";
|
||||||
import { LovelaceLayoutOptions } from "../../types";
|
import { LovelaceLayoutOptions } from "../../types";
|
||||||
|
|
||||||
@customElement("hui-card-layout-editor")
|
@customElement("hui-card-layout-editor")
|
||||||
@ -38,28 +38,29 @@ export class HuiCardLayoutEditor extends LitElement {
|
|||||||
|
|
||||||
private _cardElement?: HuiCard;
|
private _cardElement?: HuiCard;
|
||||||
|
|
||||||
private _gridSizeValue = memoizeOne(
|
private _mergedOptions = memoizeOne(
|
||||||
(
|
(
|
||||||
options?: LovelaceLayoutOptions,
|
options?: LovelaceLayoutOptions,
|
||||||
defaultOptions?: LovelaceLayoutOptions
|
defaultOptions?: LovelaceLayoutOptions
|
||||||
) => ({
|
) => ({
|
||||||
rows:
|
...defaultOptions,
|
||||||
options?.grid_rows ??
|
...options,
|
||||||
defaultOptions?.grid_rows ??
|
|
||||||
DEFAULT_GRID_OPTIONS.grid_rows,
|
|
||||||
columns:
|
|
||||||
options?.grid_columns ??
|
|
||||||
defaultOptions?.grid_columns ??
|
|
||||||
DEFAULT_GRID_OPTIONS.grid_columns,
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private _gridSizeValue = memoizeOne(computeSizeOnGrid);
|
||||||
|
|
||||||
private _isDefault = memoizeOne(
|
private _isDefault = memoizeOne(
|
||||||
(options?: LovelaceLayoutOptions) =>
|
(options?: LovelaceLayoutOptions) =>
|
||||||
options?.grid_columns === undefined && options?.grid_rows === undefined
|
options?.grid_columns === undefined && options?.grid_rows === undefined
|
||||||
);
|
);
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const options = this._mergedOptions(
|
||||||
|
this.config.layout_options,
|
||||||
|
this._defaultLayoutOptions
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<p class="intro">
|
<p class="intro">
|
||||||
@ -123,12 +124,13 @@ export class HuiCardLayoutEditor extends LitElement {
|
|||||||
: html`
|
: html`
|
||||||
<ha-grid-size-picker
|
<ha-grid-size-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this._gridSizeValue(
|
.value=${this._gridSizeValue(options)}
|
||||||
this.config.layout_options,
|
|
||||||
this._defaultLayoutOptions
|
|
||||||
)}
|
|
||||||
.isDefault=${this._isDefault(this.config.layout_options)}
|
.isDefault=${this._isDefault(this.config.layout_options)}
|
||||||
@value-changed=${this._gridSizeChanged}
|
@value-changed=${this._gridSizeChanged}
|
||||||
|
.rowMin=${options.grid_min_rows}
|
||||||
|
.rowMax=${options.grid_max_rows}
|
||||||
|
.columnMin=${options.grid_min_columns}
|
||||||
|
.columnMax=${options.grid_max_columns}
|
||||||
></ha-grid-size-picker>
|
></ha-grid-size-picker>
|
||||||
`}
|
`}
|
||||||
`;
|
`;
|
||||||
|
@ -15,6 +15,7 @@ import { HuiCard } from "../cards/hui-card";
|
|||||||
import "../components/hui-card-edit-mode";
|
import "../components/hui-card-edit-mode";
|
||||||
import { moveCard } from "../editor/config-util";
|
import { moveCard } from "../editor/config-util";
|
||||||
import type { Lovelace, LovelaceLayoutOptions } from "../types";
|
import type { Lovelace, LovelaceLayoutOptions } from "../types";
|
||||||
|
import { conditionalClamp } from "../../../common/number/clamp";
|
||||||
|
|
||||||
const CARD_SORTABLE_OPTIONS: HaSortableOptions = {
|
const CARD_SORTABLE_OPTIONS: HaSortableOptions = {
|
||||||
delay: 100,
|
delay: 100,
|
||||||
@ -23,9 +24,41 @@ const CARD_SORTABLE_OPTIONS: HaSortableOptions = {
|
|||||||
invertedSwapThreshold: 0.7,
|
invertedSwapThreshold: 0.7,
|
||||||
} as HaSortableOptions;
|
} as HaSortableOptions;
|
||||||
|
|
||||||
export const DEFAULT_GRID_OPTIONS: LovelaceLayoutOptions = {
|
export const DEFAULT_GRID_OPTIONS = {
|
||||||
grid_columns: 4,
|
grid_columns: 4,
|
||||||
grid_rows: 1,
|
grid_rows: 1,
|
||||||
|
} as const satisfies LovelaceLayoutOptions;
|
||||||
|
|
||||||
|
type GridSizeValue = {
|
||||||
|
rows?: number;
|
||||||
|
columns?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const computeSizeOnGrid = (
|
||||||
|
options: LovelaceLayoutOptions
|
||||||
|
): GridSizeValue => {
|
||||||
|
const rows =
|
||||||
|
typeof options.grid_rows === "number"
|
||||||
|
? conditionalClamp(
|
||||||
|
options.grid_rows,
|
||||||
|
options.grid_min_rows,
|
||||||
|
options.grid_max_rows
|
||||||
|
)
|
||||||
|
: DEFAULT_GRID_OPTIONS.grid_rows;
|
||||||
|
|
||||||
|
const columns =
|
||||||
|
typeof options.grid_columns === "number"
|
||||||
|
? conditionalClamp(
|
||||||
|
options.grid_columns,
|
||||||
|
options.grid_min_columns,
|
||||||
|
options.grid_max_columns
|
||||||
|
)
|
||||||
|
: DEFAULT_GRID_OPTIONS.grid_columns;
|
||||||
|
|
||||||
|
return {
|
||||||
|
rows,
|
||||||
|
columns,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export class GridSection extends LitElement implements LovelaceSectionElement {
|
export class GridSection extends LitElement implements LovelaceSectionElement {
|
||||||
@ -98,17 +131,16 @@ export class GridSection extends LitElement implements LovelaceSectionElement {
|
|||||||
(cardConfig) => this._getKey(cardConfig),
|
(cardConfig) => this._getKey(cardConfig),
|
||||||
(_cardConfig, idx) => {
|
(_cardConfig, idx) => {
|
||||||
const card = this.cards![idx];
|
const card = this.cards![idx];
|
||||||
|
card.layout = "grid";
|
||||||
const layoutOptions = card.getLayoutOptions();
|
const layoutOptions = card.getLayoutOptions();
|
||||||
|
|
||||||
const columnSize =
|
const { rows, columns } = computeSizeOnGrid(layoutOptions);
|
||||||
layoutOptions.grid_columns ?? DEFAULT_GRID_OPTIONS.grid_columns;
|
|
||||||
const rowSize =
|
|
||||||
layoutOptions.grid_rows ?? DEFAULT_GRID_OPTIONS.grid_rows;
|
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
style=${styleMap({
|
style=${styleMap({
|
||||||
"--column-size": columnSize,
|
"--column-size": columns,
|
||||||
"--row-size": rowSize,
|
"--row-size": rows,
|
||||||
})}
|
})}
|
||||||
class="card ${classMap({
|
class="card ${classMap({
|
||||||
"fit-rows": typeof layoutOptions?.grid_rows === "number",
|
"fit-rows": typeof layoutOptions?.grid_rows === "number",
|
||||||
|
@ -43,12 +43,17 @@ export interface LovelaceBadge extends HTMLElement {
|
|||||||
export type LovelaceLayoutOptions = {
|
export type LovelaceLayoutOptions = {
|
||||||
grid_columns?: number;
|
grid_columns?: number;
|
||||||
grid_rows?: number;
|
grid_rows?: number;
|
||||||
|
grid_max_columns?: number;
|
||||||
|
grid_min_columns?: number;
|
||||||
|
grid_min_rows?: number;
|
||||||
|
grid_max_rows?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface LovelaceCard extends HTMLElement {
|
export interface LovelaceCard extends HTMLElement {
|
||||||
hass?: HomeAssistant;
|
hass?: HomeAssistant;
|
||||||
isPanel?: boolean;
|
isPanel?: boolean;
|
||||||
preview?: boolean;
|
preview?: boolean;
|
||||||
|
layout?: string;
|
||||||
getCardSize(): number | Promise<number>;
|
getCardSize(): number | Promise<number>;
|
||||||
getLayoutOptions?(): LovelaceLayoutOptions;
|
getLayoutOptions?(): LovelaceLayoutOptions;
|
||||||
setConfig(config: LovelaceCardConfig): void;
|
setConfig(config: LovelaceCardConfig): void;
|
||||||
|
@ -2771,11 +2771,7 @@
|
|||||||
"migrate": "Migrate",
|
"migrate": "Migrate",
|
||||||
"duplicate": "[%key:ui::common::duplicate%]",
|
"duplicate": "[%key:ui::common::duplicate%]",
|
||||||
"take_control": "Take control",
|
"take_control": "Take control",
|
||||||
"take_control_confirmation": {
|
"confirm_take_control": "Your are viewing a preview of the automation config, do you want to take control?",
|
||||||
"title": "Take control of automation?",
|
|
||||||
"text": "This automation is using a blueprint. By taking control, your automation will be converted into a regular automation using triggers, conditions and actions. You will be able to edit it directly and you won't be able to convert it back to a blueprint.",
|
|
||||||
"action": "Take control"
|
|
||||||
},
|
|
||||||
"run": "[%key:ui::panel::config::automation::editor::actions::run%]",
|
"run": "[%key:ui::panel::config::automation::editor::actions::run%]",
|
||||||
"rename": "[%key:ui::panel::config::automation::editor::triggers::rename%]",
|
"rename": "[%key:ui::panel::config::automation::editor::triggers::rename%]",
|
||||||
"show_trace": "Traces",
|
"show_trace": "Traces",
|
||||||
@ -3648,11 +3644,7 @@
|
|||||||
"rename": "[%key:ui::panel::config::automation::editor::triggers::rename%]",
|
"rename": "[%key:ui::panel::config::automation::editor::triggers::rename%]",
|
||||||
"change_mode": "[%key:ui::panel::config::automation::editor::change_mode%]",
|
"change_mode": "[%key:ui::panel::config::automation::editor::change_mode%]",
|
||||||
"take_control": "[%key:ui::panel::config::automation::editor::take_control%]",
|
"take_control": "[%key:ui::panel::config::automation::editor::take_control%]",
|
||||||
"take_control_confirmation": {
|
"confirm_take_control": "Your are viewing a preview of the script config, do you want to take control?",
|
||||||
"title": "Take control of script?",
|
|
||||||
"text": "This script is using a blueprint. By taking control, your script will be converted into a regular automation using actions. You will be able to edit it directly and you won't be able to convert it back to a blueprint.",
|
|
||||||
"action": "[%key:ui::panel::config::automation::editor::take_control_confirmation::action%]"
|
|
||||||
},
|
|
||||||
"read_only": "This script cannot be edited from the UI, because it is not stored in the ''scripts.yaml'' file.",
|
"read_only": "This script cannot be edited from the UI, because it is not stored in the ''scripts.yaml'' file.",
|
||||||
"unavailable": "Script is unavailable",
|
"unavailable": "Script is unavailable",
|
||||||
"migrate": "Migrate",
|
"migrate": "Migrate",
|
||||||
|
@ -70,17 +70,18 @@ export class AudioRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _createContext() {
|
private async _createContext() {
|
||||||
// @ts-ignore-next-line
|
// @ts-expect-error webkitAudioContext is not recognized
|
||||||
this._context = new (window.AudioContext || window.webkitAudioContext)();
|
const context = new (AudioContext || webkitAudioContext)();
|
||||||
this._stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
this._stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||||
|
// Syntax here must match an item of `parser.worker` in Webpack config in
|
||||||
await this._context.audioWorklet.addModule(
|
// order for module to be parsed and a chunk to be properly created.
|
||||||
new URL("./recorder.worklet.js", import.meta.url)
|
await context.audioWorklet.addModule(
|
||||||
|
/* webpackChunkName: "recorder-worklet" */
|
||||||
|
new URL("./recorder-worklet.js", import.meta.url)
|
||||||
);
|
);
|
||||||
|
this._context = context;
|
||||||
this._source = this._context.createMediaStreamSource(this._stream);
|
this._source = this._context.createMediaStreamSource(this._stream);
|
||||||
this._recorder = new AudioWorkletNode(this._context, "recorder.worklet");
|
this._recorder = new AudioWorkletNode(this._context, "recorder-worklet");
|
||||||
|
|
||||||
this._recorder.port.onmessage = (e) => {
|
this._recorder.port.onmessage = (e) => {
|
||||||
if (!this._active) {
|
if (!this._active) {
|
||||||
return;
|
return;
|
||||||
|
@ -18,4 +18,4 @@ class RecorderProcessor extends AudioWorkletProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
registerProcessor("recorder.worklet", RecorderProcessor);
|
registerProcessor("recorder-worklet", RecorderProcessor);
|
38
yarn.lock
38
yarn.lock
@ -3235,13 +3235,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@material/web@npm:1.5.0":
|
"@material/web@npm:1.5.1":
|
||||||
version: 1.5.0
|
version: 1.5.1
|
||||||
resolution: "@material/web@npm:1.5.0"
|
resolution: "@material/web@npm:1.5.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
lit: "npm:^2.7.4 || ^3.0.0"
|
lit: "npm:^2.7.4 || ^3.0.0"
|
||||||
tslib: "npm:^2.4.0"
|
tslib: "npm:^2.4.0"
|
||||||
checksum: 10/6bf651e8eaf33332b7f83aa04d473f6844a1f8280d5a2025a30583fbe03aa718de348260c5b9466d587f166772759aba0d100137e3e13d4d7c6fba6ffb79efa4
|
checksum: 10/9be6019068fbc4ed6873837ad549fd672c24beaacd9123bc9f3d72b7dfd67a1acdafab43bd484b50d40300e27e3742314915f4d6e6723b38be223b4547ae206f
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@ -3974,6 +3974,15 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@thepassle/axobject-query@npm:^4.0.0":
|
||||||
|
version: 4.0.0
|
||||||
|
resolution: "@thepassle/axobject-query@npm:4.0.0"
|
||||||
|
dependencies:
|
||||||
|
dequal: "npm:^2.0.3"
|
||||||
|
checksum: 10/919cb6ed90259cd0398b7e485dfbacae42423ff4202d5753c6545d3dfa9dc3d63e7f34941d6b94608c2730ec1539d30805411d9501c86951966e0d4aa0c4ae44
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@thomasloven/round-slider@npm:0.6.0":
|
"@thomasloven/round-slider@npm:0.6.0":
|
||||||
version: 0.6.0
|
version: 0.6.0
|
||||||
resolution: "@thomasloven/round-slider@npm:0.6.0"
|
resolution: "@thomasloven/round-slider@npm:0.6.0"
|
||||||
@ -5825,13 +5834,6 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"axobject-query@npm:^2.2.0":
|
|
||||||
version: 2.2.0
|
|
||||||
resolution: "axobject-query@npm:2.2.0"
|
|
||||||
checksum: 10/25de4b5ba6b28f5856fab60d86ea20fea941586bc38f33c81b78d66cd7e9c5792a9b9a9e60a38407aa634e01fee6a34133fbbd1d1d3d24cc686de83c6bb1e634
|
|
||||||
languageName: node
|
|
||||||
linkType: hard
|
|
||||||
|
|
||||||
"b4a@npm:^1.6.4":
|
"b4a@npm:^1.6.4":
|
||||||
version: 1.6.6
|
version: 1.6.6
|
||||||
resolution: "b4a@npm:1.6.6"
|
resolution: "b4a@npm:1.6.6"
|
||||||
@ -7579,13 +7581,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"eslint-plugin-lit-a11y@npm:4.1.2":
|
"eslint-plugin-lit-a11y@npm:4.1.3":
|
||||||
version: 4.1.2
|
version: 4.1.3
|
||||||
resolution: "eslint-plugin-lit-a11y@npm:4.1.2"
|
resolution: "eslint-plugin-lit-a11y@npm:4.1.3"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
"@thepassle/axobject-query": "npm:^4.0.0"
|
||||||
aria-query: "npm:^5.1.3"
|
aria-query: "npm:^5.1.3"
|
||||||
axe-core: "npm:^4.3.3"
|
axe-core: "npm:^4.3.3"
|
||||||
axobject-query: "npm:^2.2.0"
|
|
||||||
dom5: "npm:^3.0.1"
|
dom5: "npm:^3.0.1"
|
||||||
emoji-regex: "npm:^10.2.1"
|
emoji-regex: "npm:^10.2.1"
|
||||||
eslint-plugin-lit: "npm:^1.10.1"
|
eslint-plugin-lit: "npm:^1.10.1"
|
||||||
@ -7596,7 +7598,7 @@ __metadata:
|
|||||||
requireindex: "npm:~1.2.0"
|
requireindex: "npm:~1.2.0"
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
eslint: ">= 5"
|
eslint: ">= 5"
|
||||||
checksum: 10/2d70f0b9fa6afc7f259877acd7e69c14f0104a69a019efb594d5de603e12b982e4a96fec5b169005fab244655951f85bff77f469d9aeadb885974f963a7d9996
|
checksum: 10/730a82cfefbeba87e604172db8c29fc18d3361b5c913531c05e83af26edbe612df955d5f124daf6066c3703b0e25f2352a8ea9cae8b2f8a3e6121937c297d3a9
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@ -8949,7 +8951,7 @@ __metadata:
|
|||||||
"@material/mwc-top-app-bar": "npm:0.27.0"
|
"@material/mwc-top-app-bar": "npm:0.27.0"
|
||||||
"@material/mwc-top-app-bar-fixed": "npm:0.27.0"
|
"@material/mwc-top-app-bar-fixed": "npm:0.27.0"
|
||||||
"@material/top-app-bar": "npm:=14.0.0-canary.53b3cad2f.0"
|
"@material/top-app-bar": "npm:=14.0.0-canary.53b3cad2f.0"
|
||||||
"@material/web": "npm:1.5.0"
|
"@material/web": "npm:1.5.1"
|
||||||
"@mdi/js": "npm:7.4.47"
|
"@mdi/js": "npm:7.4.47"
|
||||||
"@mdi/svg": "npm:7.4.47"
|
"@mdi/svg": "npm:7.4.47"
|
||||||
"@octokit/auth-oauth-device": "npm:7.1.1"
|
"@octokit/auth-oauth-device": "npm:7.1.1"
|
||||||
@ -9018,7 +9020,7 @@ __metadata:
|
|||||||
eslint-import-resolver-webpack: "npm:0.13.8"
|
eslint-import-resolver-webpack: "npm:0.13.8"
|
||||||
eslint-plugin-import: "npm:2.29.1"
|
eslint-plugin-import: "npm:2.29.1"
|
||||||
eslint-plugin-lit: "npm:1.14.0"
|
eslint-plugin-lit: "npm:1.14.0"
|
||||||
eslint-plugin-lit-a11y: "npm:4.1.2"
|
eslint-plugin-lit-a11y: "npm:4.1.3"
|
||||||
eslint-plugin-unused-imports: "npm:4.0.0"
|
eslint-plugin-unused-imports: "npm:4.0.0"
|
||||||
eslint-plugin-wc: "npm:2.1.0"
|
eslint-plugin-wc: "npm:2.1.0"
|
||||||
fancy-log: "npm:2.0.0"
|
fancy-log: "npm:2.0.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user