mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 12:16:39 +00:00
Fill example data for services in dev tools (#3596)
* Fill example data * Align indents * Comments
This commit is contained in:
parent
3927eb53ac
commit
460a56aa0a
@ -115,9 +115,9 @@ class HaPanelDevService extends PolymerElement {
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
></paper-textarea>
|
||||
<mwc-button on-click="_callService" raised disabled="[[!validJSON]]"
|
||||
>Call Service</mwc-button
|
||||
>
|
||||
<mwc-button on-click="_callService" raised disabled="[[!validJSON]]">
|
||||
Call Service
|
||||
</mwc-button>
|
||||
<template is="dom-if" if="[[!validJSON]]">
|
||||
<span class="error">Invalid JSON</span>
|
||||
</template>
|
||||
@ -153,6 +153,12 @@ class HaPanelDevService extends PolymerElement {
|
||||
</tr>
|
||||
</template>
|
||||
</table>
|
||||
|
||||
<template is="dom-if" if="[[_attributes.length]]">
|
||||
<mwc-button on-click="_fillExampleData">
|
||||
Fill Example Data
|
||||
</mwc-button>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
@ -274,11 +280,17 @@ class HaPanelDevService extends PolymerElement {
|
||||
this.hass.callService(this._domain, this._service, this.parsedJSON);
|
||||
}
|
||||
|
||||
_fillExampleData() {
|
||||
const example = {};
|
||||
for (const attribute of this._attributes) {
|
||||
example[attribute.key] = attribute.example;
|
||||
}
|
||||
this.serviceData = JSON.stringify(example, null, 2);
|
||||
}
|
||||
|
||||
_entityPicked(ev) {
|
||||
this.serviceData = JSON.stringify(
|
||||
Object.assign({}, this.parsedJSON, {
|
||||
entity_id: ev.target.value,
|
||||
}),
|
||||
{ ...this.parsedJSON, entity_id: ev.target.value },
|
||||
null,
|
||||
2
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user