Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hassio/src/addon-view/hassio-addon-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class HassioAddonConfig extends PolymerElement {
<div class="card-actions">
<ha-call-api-button
class="warning"
confirmation="Are you sure you want to reset the configuration?"
hass="[[hass]]"
path="hassio/addons/[[addonSlug]]/options"
data="[[resetData]]"
Expand Down
15 changes: 14 additions & 1 deletion src/components/buttons/ha-call-api-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { LitElement, html } from "lit-element";

import "./ha-progress-button";
import { fireEvent } from "../../common/dom/fire_event";
import { showConfirmationDialog } from "../../dialogs/confirmation/show-dialog-confirmation";

class HaCallApiButton extends LitElement {
render() {
Expand Down Expand Up @@ -31,14 +32,15 @@ class HaCallApiButton extends LitElement {
method: String,
data: {},
disabled: Boolean,
confirmation: String,
};
}

get progressButton() {
return this.renderRoot.querySelector("ha-progress-button");
}

async _buttonTapped() {
async _callApi() {
this.progress = true;
const eventData = {
method: this.method,
Expand All @@ -61,6 +63,17 @@ class HaCallApiButton extends LitElement {

fireEvent(this, "hass-api-called", eventData);
}

async _buttonTapped() {
if (this.confirmation) {
showConfirmationDialog(this, {
text: this.confirmation,
confirm: async () => await this._callApi(),
});
} else {
await this._callApi();
}
}
}

customElements.define("ha-call-api-button", HaCallApiButton);