mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Allow toggling cloud integrations (#1690)
This commit is contained in:
parent
8dc202af92
commit
03525c010f
@ -1,6 +1,7 @@
|
|||||||
import '@polymer/paper-button/paper-button.js';
|
import '@polymer/paper-button/paper-button.js';
|
||||||
import '@polymer/paper-card/paper-card.js';
|
import '@polymer/paper-card/paper-card.js';
|
||||||
import '@polymer/paper-item/paper-item-body.js';
|
import '@polymer/paper-item/paper-item-body.js';
|
||||||
|
import '@polymer/paper-toggle-button/paper-toggle-button.js';
|
||||||
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
||||||
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
||||||
|
|
||||||
@ -61,6 +62,11 @@ class HaConfigCloudAccount extends EventsMixin(PolymerElement) {
|
|||||||
a {
|
a {
|
||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
}
|
}
|
||||||
|
paper-card > paper-toggle-button {
|
||||||
|
position: absolute;
|
||||||
|
right: 8px;
|
||||||
|
top: 16px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<hass-subpage header="Home Assistant Cloud">
|
<hass-subpage header="Home Assistant Cloud">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
@ -108,6 +114,10 @@ class HaConfigCloudAccount extends EventsMixin(PolymerElement) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<paper-card heading="Alexa">
|
<paper-card heading="Alexa">
|
||||||
|
<paper-toggle-button
|
||||||
|
checked='[[cloudStatus.alexa_enabled]]'
|
||||||
|
on-change='_alexaChanged'
|
||||||
|
></paper-toggle-button>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
With the Alexa integration for Home Assistant Cloud you'll be able to control all your Home Assistant devices via any Alexa-enabled device.
|
With the Alexa integration for Home Assistant Cloud you'll be able to control all your Home Assistant devices via any Alexa-enabled device.
|
||||||
<ul>
|
<ul>
|
||||||
@ -125,6 +135,10 @@ class HaConfigCloudAccount extends EventsMixin(PolymerElement) {
|
|||||||
</paper-card>
|
</paper-card>
|
||||||
|
|
||||||
<paper-card heading="Google Assistant">
|
<paper-card heading="Google Assistant">
|
||||||
|
<paper-toggle-button
|
||||||
|
checked='[[cloudStatus.google_enabled]]'
|
||||||
|
on-change='_googleChanged'
|
||||||
|
></paper-toggle-button>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
With the Google Assistant integration for Home Assistant Cloud you'll be able to control all your Home Assistant devices via any Google Assistant-enabled device.
|
With the Google Assistant integration for Home Assistant Cloud you'll be able to control all your Home Assistant devices via any Google Assistant-enabled device.
|
||||||
<ul>
|
<ul>
|
||||||
@ -142,7 +156,11 @@ class HaConfigCloudAccount extends EventsMixin(PolymerElement) {
|
|||||||
<p><em>This integration requires a Google Assistant-enabled device like the Google Home or Android phone.</em></p>
|
<p><em>This integration requires a Google Assistant-enabled device like the Google Home or Android phone.</em></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<ha-call-api-button hass="[[hass]]" path="cloud/google_actions/sync">Sync devices</ha-call-api-button>
|
<ha-call-api-button
|
||||||
|
hass="[[hass]]"
|
||||||
|
disabled='[[!cloudStatus.google_enabled]]'
|
||||||
|
path="cloud/google_actions/sync"
|
||||||
|
>Sync devices</ha-call-api-button>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</paper-card>
|
||||||
</ha-config-section>
|
</ha-config-section>
|
||||||
@ -214,6 +232,26 @@ class HaConfigCloudAccount extends EventsMixin(PolymerElement) {
|
|||||||
|
|
||||||
return 'Unable to determine subscription status.';
|
return 'Unable to determine subscription status.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_alexaChanged(ev) {
|
||||||
|
this._handleToggleChange('alexa_enabled', ev.target);
|
||||||
|
}
|
||||||
|
|
||||||
|
_googleChanged(ev) {
|
||||||
|
this._handleToggleChange('google_enabled', ev.target);
|
||||||
|
}
|
||||||
|
|
||||||
|
async _handleToggleChange(property, element) {
|
||||||
|
try {
|
||||||
|
await this.hass.callWS({
|
||||||
|
type: 'cloud/update_prefs',
|
||||||
|
[property]: element.checked,
|
||||||
|
});
|
||||||
|
this.fire('ha-refresh-cloud-status');
|
||||||
|
} catch (err) {
|
||||||
|
element.checked = !element.checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define('ha-config-cloud-account', HaConfigCloudAccount);
|
customElements.define('ha-config-cloud-account', HaConfigCloudAccount);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user