mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 23:06:40 +00:00
Hassio: confirm add-on uninstall (#977)
* Hassio: confirm add-on uninstall * Travis
This commit is contained in:
parent
964b048a93
commit
b52d2967df
@ -9,6 +9,7 @@
|
||||
<link rel='import' href='../../src/components/ha-markdown.html'>
|
||||
<link rel='import' href='../../src/resources/ha-style.html'>
|
||||
<link rel='import' href='../../src/components/hassio-card-content.html'>
|
||||
<link rel='import' href='../../src/util/hass-mixins.html'>
|
||||
|
||||
<link rel='import' href='./hassio-addon-more-info.html'>
|
||||
|
||||
@ -142,11 +143,10 @@
|
||||
</div>
|
||||
<div class='card-actions'>
|
||||
<template is='dom-if' if='[[addon.version]]'>
|
||||
<ha-call-api-button
|
||||
<paper-button
|
||||
class='warning'
|
||||
hass='[[hass]]'
|
||||
path='hassio/addons/[[addonSlug]]/uninstall'
|
||||
>Uninstall</ha-call-api-button>
|
||||
on-click='_unistallClicked'
|
||||
>Uninstall</paper-button>
|
||||
<template is='dom-if' if='[[addon.build]]'>
|
||||
<ha-call-api-button
|
||||
class='warning'
|
||||
@ -200,7 +200,7 @@
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
class HassioAddonInfo extends Polymer.Element {
|
||||
class HassioAddonInfo extends window.hassMixins.EventsMixin(Polymer.Element) {
|
||||
static get is() { return 'hassio-addon-info'; }
|
||||
|
||||
static get properties() {
|
||||
@ -255,6 +255,25 @@ class HassioAddonInfo extends Polymer.Element {
|
||||
});
|
||||
this.shadowRoot.querySelector('hassio-addon-more-info').openDialog();
|
||||
}
|
||||
|
||||
_unistallClicked() {
|
||||
if (!confirm('Are you sure you want to uninstall this add-on?')) {
|
||||
return;
|
||||
}
|
||||
const path = `hassio/addons/${this.addonSlug}/uninstall`;
|
||||
const eventData = {
|
||||
path: path,
|
||||
};
|
||||
this.hass.callApi('post', path).then((resp) => {
|
||||
eventData.success = true;
|
||||
eventData.response = resp;
|
||||
}, (resp) => {
|
||||
eventData.success = false;
|
||||
eventData.response = resp;
|
||||
}).then(() => {
|
||||
this.fire('hass-api-called', eventData);
|
||||
});
|
||||
}
|
||||
}
|
||||
customElements.define(HassioAddonInfo.is, HassioAddonInfo);
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user