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"
|
autocomplete="off"
|
||||||
spellcheck="false"
|
spellcheck="false"
|
||||||
></paper-textarea>
|
></paper-textarea>
|
||||||
<mwc-button on-click="_callService" raised disabled="[[!validJSON]]"
|
<mwc-button on-click="_callService" raised disabled="[[!validJSON]]">
|
||||||
>Call Service</mwc-button
|
Call Service
|
||||||
>
|
</mwc-button>
|
||||||
<template is="dom-if" if="[[!validJSON]]">
|
<template is="dom-if" if="[[!validJSON]]">
|
||||||
<span class="error">Invalid JSON</span>
|
<span class="error">Invalid JSON</span>
|
||||||
</template>
|
</template>
|
||||||
@ -153,6 +153,12 @@ class HaPanelDevService extends PolymerElement {
|
|||||||
</tr>
|
</tr>
|
||||||
</template>
|
</template>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<template is="dom-if" if="[[_attributes.length]]">
|
||||||
|
<mwc-button on-click="_fillExampleData">
|
||||||
|
Fill Example Data
|
||||||
|
</mwc-button>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@ -274,11 +280,17 @@ class HaPanelDevService extends PolymerElement {
|
|||||||
this.hass.callService(this._domain, this._service, this.parsedJSON);
|
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) {
|
_entityPicked(ev) {
|
||||||
this.serviceData = JSON.stringify(
|
this.serviceData = JSON.stringify(
|
||||||
Object.assign({}, this.parsedJSON, {
|
{ ...this.parsedJSON, entity_id: ev.target.value },
|
||||||
entity_id: ev.target.value,
|
|
||||||
}),
|
|
||||||
null,
|
null,
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user