Sort listening entity and domain in template dev tools (#6953)

This commit is contained in:
Bram Kragten 2020-09-12 17:48:40 +02:00 committed by GitHub
parent c979cfb912
commit 266f2e763d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,8 +14,8 @@ import { debounce } from "../../../common/util/debounce";
import "../../../components/ha-circular-progress";
import "../../../components/ha-code-editor";
import {
subscribeRenderTemplate,
RenderTemplateResult,
subscribeRenderTemplate,
} from "../../../data/ws-templates";
import { haStyle } from "../../../resources/styles";
import { HomeAssistant } from "../../../types";
@ -151,41 +151,49 @@ class HaPanelDevTemplate extends LitElement {
? ""
: this._templateResult.listeners.all
? html`
<span class="all_listeners">
<h3 class="all_listeners">
${this.hass.localize(
"ui.panel.developer-tools.tabs.templates.all_listeners"
)}
</span>
</h3>
`
: this._templateResult.listeners.domains.length ||
this._templateResult.listeners.entities.length
? html`
${this.hass.localize(
"ui.panel.developer-tools.tabs.templates.listeners"
)}
<h3>
${this.hass.localize(
"ui.panel.developer-tools.tabs.templates.listeners"
)}
</h3>
<ul>
${this._templateResult.listeners.domains.map(
(domain) =>
html`
<li>
${this.hass.localize(
"ui.panel.developer-tools.tabs.templates.domain"
)}:
${domain}
</li>
`
)}
${this._templateResult.listeners.entities.map(
(entity_id) =>
html`
<li>
${this.hass.localize(
"ui.panel.developer-tools.tabs.templates.entity"
)}:
${entity_id}
</li>
`
)}
${this._templateResult.listeners.domains
.sort()
.map(
(domain) =>
html`
<li>
<b
>${this.hass.localize(
"ui.panel.developer-tools.tabs.templates.domain"
)}</b
>: ${domain}
</li>
`
)}
${this._templateResult.listeners.entities
.sort()
.map(
(entity_id) =>
html`
<li>
<b
>${this.hass.localize(
"ui.panel.developer-tools.tabs.templates.entity"
)}</b
>: ${entity_id}
</li>
`
)}
</ul>
`
: html` <span class="all_listeners">