Use ha-card for dev tool "Services" + visual tweaks (#7364)

This commit is contained in:
Philip Allgaier 2020-10-19 11:15:12 +02:00 committed by GitHub
parent 1ebf1c00d6
commit a73754c1b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 62 deletions

View File

@ -7,6 +7,7 @@ import "../../../components/buttons/ha-progress-button";
import "../../../components/entity/ha-entity-picker";
import "../../../components/ha-code-editor";
import "../../../components/ha-service-picker";
import "../../../components/ha-card";
import { ENTITY_COMPONENT_DOMAINS } from "../../../data/entity";
import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
import LocalizeMixin from "../../../mixins/localize-mixin";
@ -38,17 +39,19 @@ class HaPanelDevService extends LocalizeMixin(PolymerElement) {
margin-top: 8px;
}
.description {
margin-top: 24px;
white-space: pre-wrap;
ha-card {
margin-top: 12px;
}
.header {
@apply --paper-font-title;
.description {
margin-top: 12px;
white-space: pre-wrap;
}
.attributes th {
text-align: left;
background-color: var(--card-background-color);
border-bottom: 1px solid var(--primary-text-color);
}
:host([rtl]) .attributes th {
@ -78,10 +81,6 @@ class HaPanelDevService extends LocalizeMixin(PolymerElement) {
font-family: var(--code-font-family, monospace);
}
h1 {
white-space: normal;
}
td {
padding: 4px;
}
@ -105,7 +104,7 @@ class HaPanelDevService extends LocalizeMixin(PolymerElement) {
>
</app-localstorage-document>
<app-localstorage-document
key="[[_computeServicedataKey(domainService)]]"
key="[[_computeServiceDataKey(domainService)]]"
data="{{serviceData}}"
>
</app-localstorage-document>
@ -146,58 +145,59 @@ class HaPanelDevService extends LocalizeMixin(PolymerElement) {
</ha-progress-button>
</div>
<template is="dom-if" if="[[!domainService]]">
<h1>
[[localize('ui.panel.developer-tools.tabs.services.select_service')]]
</h1>
</template>
<ha-card>
<div class="card-header">
<template is="dom-if" if="[[!domainService]]">
[[localize('ui.panel.developer-tools.tabs.services.select_service')]]
</template>
<template is="dom-if" if="[[domainService]]">
<template is="dom-if" if="[[!_description]]">
<h1>
[[localize('ui.panel.developer-tools.tabs.services.no_description')]]
</h1>
</template>
<template is="dom-if" if="[[_description]]">
<div class="desc-container">
<h3>[[_description]]</h3>
</div>
<table class="attributes">
<tr>
<th>
[[localize('ui.panel.developer-tools.tabs.services.column_parameter')]]
</th>
<th>
[[localize('ui.panel.developer-tools.tabs.services.column_description')]]
</th>
<th>
[[localize('ui.panel.developer-tools.tabs.services.column_example')]]
</th>
</tr>
<template is="dom-if" if="[[domainService]]">
<template is="dom-if" if="[[!_description]]">
[[localize('ui.panel.developer-tools.tabs.services.no_description')]]
</template>
<template is="dom-if" if="[[_description]]">
[[_description]]
</template>
</template>
</div>
<div class="card-content">
<template is="dom-if" if="[[_description]]">
<template is="dom-if" if="[[!_attributes.length]]">
<tr>
<td colspan="3">
[[localize('ui.panel.developer-tools.tabs.services.no_parameters')]]
</td>
</tr>
[[localize('ui.panel.developer-tools.tabs.services.no_parameters')]]
</template>
<template is="dom-repeat" items="[[_attributes]]" as="attribute">
<tr>
<td><pre>[[attribute.key]]</pre></td>
<td>[[attribute.description]]</td>
<td>[[attribute.example]]</td>
</tr>
</template>
</table>
<template is="dom-if" if="[[_attributes.length]]">
<mwc-button on-click="_fillExampleData">
[[localize('ui.panel.developer-tools.tabs.services.fill_example_data')]]
</mwc-button>
<template is="dom-if" if="[[_attributes.length]]">
<table class="attributes">
<tr>
<th>
[[localize('ui.panel.developer-tools.tabs.services.column_parameter')]]
</th>
<th>
[[localize('ui.panel.developer-tools.tabs.services.column_description')]]
</th>
<th>
[[localize('ui.panel.developer-tools.tabs.services.column_example')]]
</th>
</tr>
<template is="dom-repeat" items="[[_attributes]]" as="attribute">
<tr>
<td><pre>[[attribute.key]]</pre></td>
<td>[[attribute.description]]</td>
<td>[[attribute.example]]</td>
</tr>
</template>
</table>
</template>
<template is="dom-if" if="[[_attributes.length]]">
<mwc-button on-click="_fillExampleData">
[[localize('ui.panel.developer-tools.tabs.services.fill_example_data')]]
</mwc-button>
</template>
</template>
</template>
</template>
</div>
</ha-card>
</div>
`;
}
@ -247,6 +247,7 @@ class HaPanelDevService extends LocalizeMixin(PolymerElement) {
type: String,
computed: "_computeDescription(hass, _domain, _service)",
},
rtl: {
reflectToAttribute: true,
computed: "_computeRTL(hass)",
@ -276,7 +277,7 @@ class HaPanelDevService extends LocalizeMixin(PolymerElement) {
return serviceDomains[domain][service].description;
}
_computeServicedataKey(domainService) {
_computeServiceDataKey(domainService) {
return `panel-dev-service-state-servicedata.${domainService}`;
}

View File

@ -237,6 +237,7 @@ class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) {
computed:
"computeEntities(hass, _entityFilter, _stateFilter, _attributeFilter)",
},
rtl: {
reflectToAttribute: true,
computed: "_computeRTL(hass)",

View File

@ -155,20 +155,20 @@ class HaPanelDevTemplate extends LitElement {
? ""
: this._templateResult.listeners.all
? html`
<h3 class="all_listeners">
<p class="all_listeners">
${this.hass.localize(
"ui.panel.developer-tools.tabs.templates.all_listeners"
)}
</h3>
</p>
`
: this._templateResult.listeners.domains.length ||
this._templateResult.listeners.entities.length
? html`
<h3>
<p>
${this.hass.localize(
"ui.panel.developer-tools.tabs.templates.listeners"
)}
</h3>
</p>
<ul>
${this._templateResult.listeners.domains
.sort()

View File

@ -3,7 +3,7 @@ import { css } from "lit-element";
export const darkStyles = {
"primary-background-color": "#111111",
"card-background-color": "#1c1c1c",
"secondary-background-color": "#1e1e1e",
"secondary-background-color": "#202020",
"primary-text-color": "#e1e1e1",
"secondary-text-color": "#9b9b9b",
"disabled-text-color": "#6f6f6f",