Skip to content

Commit 4f5c9dc

Browse files
authored
Merge pull request #1086 from thomasloven/dev
v2.6.4
2 parents 7a805d6 + dfcd5bc commit 4f5c9dc

File tree

11 files changed

+72
-27
lines changed

11 files changed

+72
-27
lines changed

custom_components/browser_mod/browser_mod.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

custom_components/browser_mod/browser_mod_panel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ function e(e,t,i,s){var o,n=arguments.length,r=n<3?t:null===s?s=Object.getOwnPro
546546
display: flex;
547547
align-items: center;
548548
}
549-
`}}e([ae()],Ee.prototype,"hass",void 0),e([le()],Ee.prototype,"_dashboards",void 0),e([le()],Ee.prototype,"_panels",void 0),e([le()],Ee.prototype,"_editSidebar",void 0),e([le()],Ee.prototype,"_hassUserHasSidebarSettings",void 0),customElements.define("browser-mod-frontend-settings-card",Ee);var xe="2.6.3";(async()=>{var e,t,i,s,o,n,r,a,l,d,h,c,u,p,g;await customElements.whenDefined("partial-panel-resolver");const b=document.createElement("partial-panel-resolver")._getRoutes([{component_name:"config",url_path:"a"}]);await(null===(i=null===(t=null===(e=null==b?void 0:b.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===i?void 0:i.call(t)),await customElements.whenDefined("ha-panel-config");const v=document.createElement("ha-panel-config");await(null===(r=null===(n=null===(o=null===(s=null==v?void 0:v.routerOptions)||void 0===s?void 0:s.routes)||void 0===o?void 0:o.dashboard)||void 0===n?void 0:n.load)||void 0===r?void 0:r.call(n)),await(null===(h=null===(d=null===(l=null===(a=null==v?void 0:v.routerOptions)||void 0===a?void 0:a.routes)||void 0===l?void 0:l.general)||void 0===d?void 0:d.load)||void 0===h?void 0:h.call(d)),await(null===(g=null===(p=null===(u=null===(c=null==v?void 0:v.routerOptions)||void 0===c?void 0:c.routes)||void 0===u?void 0:u.entities)||void 0===p?void 0:p.load)||void 0===g?void 0:g.call(p)),await customElements.whenDefined("ha-config-dashboard")})().then((()=>{class t extends se{firstUpdated(){window.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}render(){var e;return window.browser_mod?j`
549+
`}}e([ae()],Ee.prototype,"hass",void 0),e([le()],Ee.prototype,"_dashboards",void 0),e([le()],Ee.prototype,"_panels",void 0),e([le()],Ee.prototype,"_editSidebar",void 0),e([le()],Ee.prototype,"_hassUserHasSidebarSettings",void 0),customElements.define("browser-mod-frontend-settings-card",Ee);var xe="2.6.4";(async()=>{var e,t,i,s,o,n,r,a,l,d,h,c,u,p,g;await customElements.whenDefined("partial-panel-resolver");const b=document.createElement("partial-panel-resolver")._getRoutes([{component_name:"config",url_path:"a"}]);await(null===(i=null===(t=null===(e=null==b?void 0:b.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===i?void 0:i.call(t)),await customElements.whenDefined("ha-panel-config");const v=document.createElement("ha-panel-config");await(null===(r=null===(n=null===(o=null===(s=null==v?void 0:v.routerOptions)||void 0===s?void 0:s.routes)||void 0===o?void 0:o.dashboard)||void 0===n?void 0:n.load)||void 0===r?void 0:r.call(n)),await(null===(h=null===(d=null===(l=null===(a=null==v?void 0:v.routerOptions)||void 0===a?void 0:a.routes)||void 0===l?void 0:l.general)||void 0===d?void 0:d.load)||void 0===h?void 0:h.call(d)),await(null===(g=null===(p=null===(u=null===(c=null==v?void 0:v.routerOptions)||void 0===c?void 0:c.routes)||void 0===u?void 0:u.entities)||void 0===p?void 0:p.load)||void 0===g?void 0:g.call(p)),await customElements.whenDefined("ha-config-dashboard")})().then((()=>{class t extends se{firstUpdated(){window.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}render(){var e;return window.browser_mod?j`
550550
<ha-top-app-bar-fixed>
551551
<ha-menu-button
552552
slot="navigationIcon"

custom_components/browser_mod/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
"documentation": "https://github.com/thomasloven/hass-browser_mod/blob/master/README.md",
1414
"iot_class": "local_push",
1515
"requirements": [],
16-
"version": "2.6.3"
16+
"version": "2.6.4"
1717
}

custom_components/browser_mod/services.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ popup:
8484
content:
8585
name: Content
8686
required: true
87-
description: "Popup content (Test or lovelace card configuration)"
87+
description: "Popup content (Text or lovelace card configuration)"
8888
selector:
8989
object:
9090
initial_style:
@@ -305,6 +305,12 @@ more_info:
305305
default: false
306306
selector:
307307
boolean:
308+
close:
309+
name: Close existing more-info dialog
310+
description: Close the more-info dialog if open
311+
default: false
312+
selector:
313+
boolean:
308314

309315
close_popup:
310316
name: close_popup
@@ -634,4 +640,4 @@ deregister_browser:
634640
area:
635641
multiple: true
636642
entity:
637-
integration: "browser_mod"
643+
integration: "browser_mod"

documentation/services.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ data:
188188
[view: <INFO/history/settings/related]
189189
[large: <true/FALSE>]
190190
[ignore_popup_card: <true/FALSE>]
191+
[close: true/FALSE>]
191192
[browser_id: <Browser IDs>]
192193
[user_id: <User IDs>]
193194
```
@@ -198,11 +199,10 @@ data:
198199
|`view`| The more-info view to open. The view opened will always have a close icon. Setting the view to anything other than `info` will always ignore custom popup-cards. |
199200
|`large`| If true, the dialog will be displayed wider, as if you had clicked the title of the dialog. |
200201
|`ignore_popup_card` | If true the more-info dialog will be shown even if there's currently a popup-card in the view/dashboard(*) which would override it. |
202+
|`close` | If true the more-into dialog will be closed if open. All other parameters are ignored. |
201203

202204
*\* Dashboard when popup-card config has `popup_card_all_views: true`.*
203205

204-
> NOTE: You can close an open more-info dialog by calling `browser_mod.more_info` with no entity.
205-
206206
## `browser_mod.popup`
207207

208208
Display a popup dialog. You can use a `custom:popup-card` as a template and optionally override parameters, or start from scratch specifying `content` and parameters. To display plaintext, HTML or a form, you need to use `content` as these are not avaulable using a `custom:popup-card`.

js/plugin/panel.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,22 @@ export const PanelStateMixin = (SuperClass) => {
8484
_panelAttributes(panel) {
8585
return {
8686
panelTitle: this._panelTitle(panel),
87-
panelUrlPath: panel?.panel?.url_path || "",
87+
panelUrlPath: panel?.route?.prefix?.replace(/^\/|\/$/g, "") || "",
8888
panelComponentName: panel?.panel?.component_name || "",
8989
panelIcon: panel?.panel?.icon || "",
90+
panelNarrow: panel?.narrow || false,
91+
panelRequireAdmin: panel?.panel?.require_admin || false,
9092
};
9193
}
9294

9395
async _viewAttributes(panel) {
94-
if (panel?.panel?.component_name !== "lovelace") return {};
96+
if (panel?.panel?.component_name !== "lovelace") {
97+
return {
98+
viewTitle: "",
99+
viewUrlPath: panel?.route?.path?.replace(/^\/|\/$/g, "") || "",
100+
viewNarrow: panel?.narrow || false,
101+
};
102+
}
95103
let cnt = 0;
96104
while (!panel.shadowRoot?.querySelector("hui-root") && cnt < 10) {
97105
await new Promise((resolve) => setTimeout(resolve, 1000));
@@ -102,7 +110,7 @@ export const PanelStateMixin = (SuperClass) => {
102110
const _curView = lovelace._curView || 0;
103111
return {
104112
viewTitle: lovelace.config?.views?.[_curView]?.title || "",
105-
viewUrlPath: lovelace.config?.views?.[_curView]?.path || "",
113+
viewUrlPath: lovelace.config?.views?.[_curView]?.path || `${_curView}`,
106114
viewNarrow: lovelace.narrow,
107115
};
108116
}
@@ -113,16 +121,29 @@ export const PanelStateMixin = (SuperClass) => {
113121
const panel = await this._getPanel(document);
114122
const panelAttributes = this._panelAttributes(panel);
115123
const viewAttributes = await this._viewAttributes(panel);
116-
const fullTitle = panelAttributes.panelTitle + (viewAttributes.viewTitle ? ` - ${viewAttributes.viewTitle}` : "");
117-
const fullUrlPath = panelAttributes.panelUrlPath + (viewAttributes.viewUrlPath ? `/${viewAttributes.viewUrlPath}` : "");
124+
const fullTitle = [];
125+
if (panelAttributes.panelTitle) {
126+
fullTitle.push(panelAttributes.panelTitle);
127+
}
128+
if (viewAttributes.viewTitle) {
129+
fullTitle.push(viewAttributes.viewTitle);
130+
}
131+
const fullUrlPath = [];
132+
if (panelAttributes.panelUrlPath) {
133+
fullUrlPath.push(panelAttributes.panelUrlPath);
134+
}
135+
if (viewAttributes.viewUrlPath) {
136+
fullUrlPath.push(viewAttributes.viewUrlPath);
137+
}
118138
this.sendUpdate({
119139
panel: {
120-
title: fullTitle,
140+
title: fullTitle.join(" - "),
121141
attributes: {
122142
...panelAttributes,
123143
...viewAttributes,
124-
fullUrlPath: fullUrlPath,
125-
popupOpen: window.browser_mod?.popupState
144+
fullUrlPath: fullUrlPath.join("/"),
145+
popupOpen: window.browser_mod?.popupState,
146+
openPopups: window.browser_mod?.openPopups,
126147
}
127148
}
128149
});

js/plugin/popup-dialog.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ export class BrowserModPopup extends LitElement {
5858
this,
5959
(value: boolean) => { this._formDataValid = value }
6060
);
61+
// When reopening popup, keep style attributes
62+
// but make sure they are all set to false
63+
this._styleAttributes = this._styleAttributes || [];
64+
Object.keys(this._styleAttributes).forEach((key) => {
65+
this._styleAttributes[key] = false;
66+
});
6167
}
6268

6369
updated(_changedProperties: PropertyValues): void {
@@ -112,7 +118,6 @@ export class BrowserModPopup extends LitElement {
112118
Object.keys(this._styleAttributes).forEach((key) => {
113119
key.split(" ").forEach((k) => this.removeAttribute(k));
114120
});
115-
this._styleAttributes = [];
116121
this._styleSequenceIndex = undefined;
117122
return true;
118123
}
@@ -288,7 +293,6 @@ export class BrowserModPopup extends LitElement {
288293
this.card = undefined;
289294
this.card_mod = card_mod;
290295
this._initialStyle = initial_style ?? size ?? "normal";
291-
this._styleAttributes = [];
292296
this._popupStyles = popup_styles;
293297
this._styleSequence = ensureArray(style_sequence ?? []);
294298
this._styleSequence = this._styleSequence.length > 0 ? this._styleSequence : ["wide", "normal"];

js/plugin/popups.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { LitElement } from "lit";
21
import {
32
loadLoadCardHelpers,
43
hass_base_el,
@@ -19,6 +18,12 @@ export const PopupMixin = (SuperClass) => {
1918
this._popupState = false;
2019
}
2120

21+
get openPopups(): string[] {
22+
return this._popupElements
23+
.filter((popup) => popup.open === true)
24+
.map((popup) => popup.tag !== undefined ? popup.tag : "standard");
25+
}
26+
2227
get popupState() {
2328
return this._popupElements.some((popup) => popup.open === true);
2429
}
@@ -64,8 +69,17 @@ export const PopupMixin = (SuperClass) => {
6469
}
6570
}
6671

67-
async showMoreInfo(entityId, view = "info", large = false, ignore_popup_card = undefined) {
72+
async showMoreInfo(entityId, view = "info", large = false, ignore_popup_card = undefined, close = false) {
6873
const base = await hass_base_el();
74+
if (close) {
75+
// Provide a close option as the empty entity id method can cause issues
76+
// with camera stream audio tracks staying active
77+
const dialog: any = base.shadowRoot.querySelector(
78+
"ha-more-info-dialog"
79+
);
80+
if (dialog) dialog.closeDialog();
81+
return;
82+
}
6983
base.dispatchEvent(
7084
new CustomEvent("hass-more-info", {
7185
bubbles: true,

js/plugin/services.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ export const ServicesMixin = (SuperClass) => {
7474
break;
7575

7676
case "more_info":
77-
const { entity, view, large, ignore_popup_card } = data;
78-
this.showMoreInfo(entity, view, large, ignore_popup_card);
77+
const { entity, view, large, ignore_popup_card, close } = data;
78+
this.showMoreInfo(entity, view, large, ignore_popup_card, close);
7979
break;
8080

8181
case "popup":

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)