Present confirmation for server restarts/stops (#3564)

Closes https://github.com/home-assistant/home-assistant-polymer/issues/3233
This commit is contained in:
Ian Richardson 2019-09-01 23:51:35 -05:00 committed by Paulus Schoutsen
parent c3e29e359a
commit ba0d7cb156
3 changed files with 12 additions and 1 deletions

View File

@ -42,10 +42,17 @@ class HaCallServiceButton extends EventsMixin(PolymerElement) {
type: Object,
value: {},
},
confirmation: {
type: String,
},
};
}
buttonTapped() {
if (this.confirmation && !window.confirm(this.confirmation)) {
return;
}
this.progress = true;
var el = this;
var eventData = {

View File

@ -150,6 +150,7 @@ class HaConfigSectionServerControl extends LocalizeMixin(PolymerElement) {
hass="[[hass]]"
domain="homeassistant"
service="restart"
confirmation="[[localize('ui.panel.config.server_control.section.server_management.confirm_restart')]]"
>[[localize('ui.panel.config.server_control.section.server_management.restart')]]
</ha-call-service-button>
<ha-call-service-button
@ -157,6 +158,7 @@ class HaConfigSectionServerControl extends LocalizeMixin(PolymerElement) {
hass="[[hass]]"
domain="homeassistant"
service="stop"
confirmation="[[localize('ui.panel.config.server_control.section.server_management.confirm_stop')]]"
>[[localize('ui.panel.config.server_control.section.server_management.stop')]]
</ha-call-service-button>
</div>

View File

@ -649,7 +649,9 @@
"heading": "Server management",
"introduction": "Control your Home Assistant server… from Home Assistant.",
"restart": "Restart",
"stop": "Stop"
"confirm_restart": "Are you sure you want to restart Home Assistant?",
"stop": "Stop",
"confirm_stop": "Are you sure you want to stop Home Assistant?"
}
}
},