From 3de9c679f1af7a062a93924ba4dc80260b06af62 Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Tue, 19 Dec 2023 12:35:44 +0100 Subject: [PATCH 01/14] Make allow attribute configurable in iframe panel --- .vscode/settings.json | 5 +++++ src/panels/iframe/ha-panel-iframe.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000000..dbd7eb1948a2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "githubPullRequests.ignoredPullRequestBranches": [ + "dev" + ] +} \ No newline at end of file diff --git a/src/panels/iframe/ha-panel-iframe.ts b/src/panels/iframe/ha-panel-iframe.ts index 98080afac4d7..99e4d2d1e1d1 100644 --- a/src/panels/iframe/ha-panel-iframe.ts +++ b/src/panels/iframe/ha-panel-iframe.ts @@ -11,6 +11,8 @@ class HaPanelIframe extends LitElement { @property({ type: Boolean }) narrow!: boolean; + @property() panel!: PanelInfo<{ allow: string }>; + @property() panel!: PanelInfo<{ url: string }>; render() { @@ -41,7 +43,9 @@ class HaPanelIframe extends LitElement { )} src=${this.panel.config.url} sandbox="allow-forms allow-popups allow-pointer-lock allow-same-origin allow-scripts allow-modals allow-downloads" - allow="fullscreen" + allow="${ifDefined( + this.panel.config.allow === null ? 'fullscreen' : this.panel.config.allow + )}" > `; From 13df473e62a8e82034bd72d45bc5088706939cbc Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Tue, 19 Dec 2023 12:51:21 +0100 Subject: [PATCH 02/14] Delete .vscode/settings.json --- .vscode/settings.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index dbd7eb1948a2..000000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "githubPullRequests.ignoredPullRequestBranches": [ - "dev" - ] -} \ No newline at end of file From edd6c5c351048fceaadfe98145143b60c55605a0 Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Tue, 19 Dec 2023 14:19:59 +0100 Subject: [PATCH 03/14] Update ha-panel-iframe.ts --- src/panels/iframe/ha-panel-iframe.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/panels/iframe/ha-panel-iframe.ts b/src/panels/iframe/ha-panel-iframe.ts index 99e4d2d1e1d1..30a16e69f1e9 100644 --- a/src/panels/iframe/ha-panel-iframe.ts +++ b/src/panels/iframe/ha-panel-iframe.ts @@ -11,9 +11,7 @@ class HaPanelIframe extends LitElement { @property({ type: Boolean }) narrow!: boolean; - @property() panel!: PanelInfo<{ allow: string }>; - - @property() panel!: PanelInfo<{ url: string }>; + @property() panel!: PanelInfo<{ url: string, allow: string }>; render() { if ( From 3bdfa31eed7d530df2dd413716dd24008bbc7d69 Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Tue, 19 Dec 2023 20:50:06 +0100 Subject: [PATCH 04/14] Don't quote --- src/panels/iframe/ha-panel-iframe.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/panels/iframe/ha-panel-iframe.ts b/src/panels/iframe/ha-panel-iframe.ts index 30a16e69f1e9..8ea9e7104dcd 100644 --- a/src/panels/iframe/ha-panel-iframe.ts +++ b/src/panels/iframe/ha-panel-iframe.ts @@ -41,9 +41,9 @@ class HaPanelIframe extends LitElement { )} src=${this.panel.config.url} sandbox="allow-forms allow-popups allow-pointer-lock allow-same-origin allow-scripts allow-modals allow-downloads" - allow="${ifDefined( + allow=${ifDefined( this.panel.config.allow === null ? 'fullscreen' : this.panel.config.allow - )}" + )} > `; From e628d09bc3d4f5b324b052d371b4135aedb55bb4 Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Mon, 8 Jan 2024 18:09:02 +0100 Subject: [PATCH 05/14] Update src/panels/iframe/ha-panel-iframe.ts Co-authored-by: Quentame --- src/panels/iframe/ha-panel-iframe.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/iframe/ha-panel-iframe.ts b/src/panels/iframe/ha-panel-iframe.ts index 8ea9e7104dcd..15cce83beee8 100644 --- a/src/panels/iframe/ha-panel-iframe.ts +++ b/src/panels/iframe/ha-panel-iframe.ts @@ -42,7 +42,7 @@ class HaPanelIframe extends LitElement { src=${this.panel.config.url} sandbox="allow-forms allow-popups allow-pointer-lock allow-same-origin allow-scripts allow-modals allow-downloads" allow=${ifDefined( - this.panel.config.allow === null ? 'fullscreen' : this.panel.config.allow + this.panel.config.allow ?? 'fullscreen' )} > From 791e4459c55ea899916cb6b7255eff2ab59cc118 Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Mon, 8 Jan 2024 18:33:42 +0100 Subject: [PATCH 06/14] Make `allow` configurable for `hui-iframe-card` --- src/panels/lovelace/cards/hui-iframe-card.ts | 4 +++- src/panels/lovelace/cards/types.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/panels/lovelace/cards/hui-iframe-card.ts b/src/panels/lovelace/cards/hui-iframe-card.ts index f151501bcdeb..1e18a6061a79 100644 --- a/src/panels/lovelace/cards/hui-iframe-card.ts +++ b/src/panels/lovelace/cards/hui-iframe-card.ts @@ -97,7 +97,9 @@ export class HuiIframeCard extends LitElement implements LovelaceCard { title=${ifDefined(this._config.title)} src=${this._config.url} sandbox="${sandbox_user_params} allow-forms allow-modals allow-popups allow-pointer-lock allow-same-origin allow-scripts" - allow="fullscreen" + allow=${ifDefined( + this._config.allow ?? 'fullscreen' + )} > diff --git a/src/panels/lovelace/cards/types.ts b/src/panels/lovelace/cards/types.ts index 0b4b6f04631c..72f8e5bfe125 100644 --- a/src/panels/lovelace/cards/types.ts +++ b/src/panels/lovelace/cards/types.ts @@ -269,6 +269,7 @@ export interface IframeCardConfig extends LovelaceCardConfig { allow_open_top_navigation?: boolean; aspect_ratio?: string; title?: string; + allow?: string; url: string; } From 8d5686ca25687d5b9138ba0e57ee696392ca5e06 Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Wed, 10 Jan 2024 11:11:36 +0100 Subject: [PATCH 07/14] Update src/panels/iframe/ha-panel-iframe.ts Co-authored-by: Quentame --- src/panels/iframe/ha-panel-iframe.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/panels/iframe/ha-panel-iframe.ts b/src/panels/iframe/ha-panel-iframe.ts index 15cce83beee8..d5618c1f64cc 100644 --- a/src/panels/iframe/ha-panel-iframe.ts +++ b/src/panels/iframe/ha-panel-iframe.ts @@ -41,9 +41,7 @@ class HaPanelIframe extends LitElement { )} src=${this.panel.config.url} sandbox="allow-forms allow-popups allow-pointer-lock allow-same-origin allow-scripts allow-modals allow-downloads" - allow=${ifDefined( - this.panel.config.allow ?? 'fullscreen' - )} + allow=${this.panel.config.allow ?? 'fullscreen'} > `; From 0cd3a109c0cfe5540ea1a99e23323fd8a903d45f Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Wed, 10 Jan 2024 11:11:44 +0100 Subject: [PATCH 08/14] Update src/panels/lovelace/cards/hui-iframe-card.ts Co-authored-by: Quentame --- src/panels/lovelace/cards/hui-iframe-card.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/panels/lovelace/cards/hui-iframe-card.ts b/src/panels/lovelace/cards/hui-iframe-card.ts index 1e18a6061a79..8652de25eecc 100644 --- a/src/panels/lovelace/cards/hui-iframe-card.ts +++ b/src/panels/lovelace/cards/hui-iframe-card.ts @@ -97,9 +97,7 @@ export class HuiIframeCard extends LitElement implements LovelaceCard { title=${ifDefined(this._config.title)} src=${this._config.url} sandbox="${sandbox_user_params} allow-forms allow-modals allow-popups allow-pointer-lock allow-same-origin allow-scripts" - allow=${ifDefined( - this._config.allow ?? 'fullscreen' - )} + allow=${this.panel.config.allow ?? 'fullscreen'} > From 8bf62c64747b73da70a27efa79c8b3a4af77f4e6 Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Wed, 10 Jan 2024 11:12:11 +0100 Subject: [PATCH 09/14] Update src/panels/iframe/ha-panel-iframe.ts Co-authored-by: Quentame --- src/panels/iframe/ha-panel-iframe.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/iframe/ha-panel-iframe.ts b/src/panels/iframe/ha-panel-iframe.ts index d5618c1f64cc..de6bd9053b1c 100644 --- a/src/panels/iframe/ha-panel-iframe.ts +++ b/src/panels/iframe/ha-panel-iframe.ts @@ -11,7 +11,7 @@ class HaPanelIframe extends LitElement { @property({ type: Boolean }) narrow!: boolean; - @property() panel!: PanelInfo<{ url: string, allow: string }>; + @property() panel!: PanelInfo<{ url: string, allow?: string }>; render() { if ( From 43b3b15254b7680de0ea2e1e64772bbb450603dc Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Wed, 17 Jan 2024 11:44:56 +0100 Subject: [PATCH 10/14] Update src/panels/lovelace/cards/hui-iframe-card.ts Co-authored-by: Bram Kragten --- src/panels/lovelace/cards/hui-iframe-card.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/lovelace/cards/hui-iframe-card.ts b/src/panels/lovelace/cards/hui-iframe-card.ts index 8652de25eecc..ceb4f274836f 100644 --- a/src/panels/lovelace/cards/hui-iframe-card.ts +++ b/src/panels/lovelace/cards/hui-iframe-card.ts @@ -97,7 +97,7 @@ export class HuiIframeCard extends LitElement implements LovelaceCard { title=${ifDefined(this._config.title)} src=${this._config.url} sandbox="${sandbox_user_params} allow-forms allow-modals allow-popups allow-pointer-lock allow-same-origin allow-scripts" - allow=${this.panel.config.allow ?? 'fullscreen'} + allow=${this._config.allow ?? 'fullscreen'} > From c9d48c9a3e2e32f04faa67096b2b7e85f3379c95 Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Fri, 12 Apr 2024 17:29:00 +0200 Subject: [PATCH 11/14] Delete src/panels/iframe/ha-panel-iframe.ts --- src/panels/iframe/ha-panel-iframe.ts | 66 ---------------------------- 1 file changed, 66 deletions(-) delete mode 100644 src/panels/iframe/ha-panel-iframe.ts diff --git a/src/panels/iframe/ha-panel-iframe.ts b/src/panels/iframe/ha-panel-iframe.ts deleted file mode 100644 index c5dd7f994775..000000000000 --- a/src/panels/iframe/ha-panel-iframe.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { html, css, LitElement } from "lit"; -import { customElement, property } from "lit/decorators"; -import { ifDefined } from "lit/directives/if-defined"; -import "../../layouts/hass-error-screen"; -import "../../layouts/hass-subpage"; -import { HomeAssistant, PanelInfo } from "../../types"; -import { IFRAME_SANDBOX } from "../../util/iframe"; - -@customElement("ha-panel-iframe") -class HaPanelIframe extends LitElement { - @property({ attribute: false }) public hass!: HomeAssistant; - - @property({ type: Boolean }) public narrow = false; - - @property({ attribute: false }) panel!: PanelInfo<{ url: string, allow?: string }>; - - render() { - if ( - location.protocol === "https:" && - new URL(this.panel.config.url, location.toString()).protocol !== "https:" - ) { - return html` - - `; - } - - return html` - - - - `; - } - - static styles = css` - iframe { - border: 0; - width: 100%; - position: absolute; - height: 100%; - background-color: var(--primary-background-color); - } - `; -} - -declare global { - interface HTMLElementTagNameMap { - "ha-panel-iframe": HaPanelIframe; - } -} From 5c9db5b553c05963aa11c076785ca98301ab0116 Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Fri, 12 Apr 2024 17:36:53 +0200 Subject: [PATCH 12/14] Restore dev --- src/panels/iframe/ha-panel-iframe.ts | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/panels/iframe/ha-panel-iframe.ts diff --git a/src/panels/iframe/ha-panel-iframe.ts b/src/panels/iframe/ha-panel-iframe.ts new file mode 100644 index 000000000000..2d458f77d9e8 --- /dev/null +++ b/src/panels/iframe/ha-panel-iframe.ts @@ -0,0 +1,66 @@ +import { html, css, LitElement } from "lit"; +import { customElement, property } from "lit/decorators"; +import { ifDefined } from "lit/directives/if-defined"; +import "../../layouts/hass-error-screen"; +import "../../layouts/hass-subpage"; +import { HomeAssistant, PanelInfo } from "../../types"; +import { IFRAME_SANDBOX } from "../../util/iframe"; + +@customElement("ha-panel-iframe") +class HaPanelIframe extends LitElement { + @property({ attribute: false }) public hass!: HomeAssistant; + + @property({ type: Boolean }) public narrow = false; + + @property({ attribute: false }) panel!: PanelInfo<{ url: string }>; + + render() { + if ( + location.protocol === "https:" && + new URL(this.panel.config.url, location.toString()).protocol !== "https:" + ) { + return html` + + `; + } + + return html` + + + + `; + } + + static styles = css` + iframe { + border: 0; + width: 100%; + position: absolute; + height: 100%; + background-color: var(--primary-background-color); + } + `; +} + +declare global { + interface HTMLElementTagNameMap { + "ha-panel-iframe": HaPanelIframe; + } +} \ No newline at end of file From b94f313823b56366cc7f46d4ed5f0de872bfb02e Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Fri, 12 Apr 2024 17:37:34 +0200 Subject: [PATCH 13/14] Update ha-panel-iframe.ts --- src/panels/iframe/ha-panel-iframe.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/iframe/ha-panel-iframe.ts b/src/panels/iframe/ha-panel-iframe.ts index 2d458f77d9e8..60d4f99742e1 100644 --- a/src/panels/iframe/ha-panel-iframe.ts +++ b/src/panels/iframe/ha-panel-iframe.ts @@ -63,4 +63,4 @@ declare global { interface HTMLElementTagNameMap { "ha-panel-iframe": HaPanelIframe; } -} \ No newline at end of file +} From e75c18dc63651e9bab729dff5e9c4c71cd8409fb Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Mon, 15 Apr 2024 09:47:41 +0200 Subject: [PATCH 14/14] Prettier --- src/panels/lovelace/cards/hui-iframe-card.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/lovelace/cards/hui-iframe-card.ts b/src/panels/lovelace/cards/hui-iframe-card.ts index 0ebf9e3880da..7b4888819100 100644 --- a/src/panels/lovelace/cards/hui-iframe-card.ts +++ b/src/panels/lovelace/cards/hui-iframe-card.ts @@ -98,7 +98,7 @@ export class HuiIframeCard extends LitElement implements LovelaceCard { title=${ifDefined(this._config.title)} src=${this._config.url} .sandbox=${`${sandbox_user_params} ${IFRAME_SANDBOX}`} - allow=${this._config.allow ?? 'fullscreen'} + allow=${this._config.allow ?? "fullscreen"} >