diff --git a/setup.py b/setup.py index 42f74be931..592d744e5b 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20181210.1", + version="20181211.0", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", diff --git a/src/data/websocket_api.ts b/src/data/websocket_api.ts new file mode 100644 index 0000000000..b67ab65740 --- /dev/null +++ b/src/data/websocket_api.ts @@ -0,0 +1,6 @@ +export const ERR_ID_REUSE = "id_reuse"; +export const ERR_INVALID_FORMAT = "invalid_format"; +export const ERR_NOT_FOUND = "not_found"; +export const ERR_UNKNOWN_COMMAND = "unknown_command"; +export const ERR_UNKNOWN_ERROR = "unknown_error"; +export const ERR_UNAUTHORIZED = "unauthorized"; diff --git a/src/panels/config/cloud/cloud-webhooks.ts b/src/panels/config/cloud/cloud-webhooks.ts index bec6948ab3..db0d3a1dad 100644 --- a/src/panels/config/cloud/cloud-webhooks.ts +++ b/src/panels/config/cloud/cloud-webhooks.ts @@ -20,6 +20,7 @@ import { deleteCloudhook, CloudWebhook, } from "../../../data/cloud"; +import { ERR_UNKNOWN_COMMAND } from "../../../data/websocket_api"; declare global { // for fire event @@ -86,7 +87,17 @@ export class CloudWebhooks extends LitElement { private _renderBody() { if (!this.cloudStatus || !this._localHooks || !this._cloudHooks) { return html` -
Loading…
+
Loading…
+ `; + } + + if (this._localHooks.length === 0) { + return html` +
+ Looks like you have no webhooks yet. Get started by configuring a + webhook-based integration or by + creating a webhook automation. +
`; } @@ -188,7 +199,15 @@ export class CloudWebhooks extends LitElement { } private async _fetchData() { - this._localHooks = await fetchWebhooks(this.hass!); + try { + this._localHooks = await fetchWebhooks(this.hass!); + } catch (err) { + if (err.code === ERR_UNKNOWN_COMMAND) { + this._localHooks = []; + } else { + throw err; + } + } } private renderStyle() { @@ -197,7 +216,7 @@ export class CloudWebhooks extends LitElement { .body { padding: 0 16px 8px; } - .loading { + .body-text { padding: 0 16px; } .webhook { @@ -217,6 +236,7 @@ export class CloudWebhooks extends LitElement { .footer { padding: 16px; } + .body-text a, .footer a { color: var(--primary-color); } diff --git a/src/panels/config/js/trigger/trigger_edit.js b/src/panels/config/js/trigger/trigger_edit.js index 6af80b3dea..fc65420014 100644 --- a/src/panels/config/js/trigger/trigger_edit.js +++ b/src/panels/config/js/trigger/trigger_edit.js @@ -12,6 +12,7 @@ import StateTrigger from "./state"; import SunTrigger from "./sun"; import TemplateTrigger from "./template"; import TimeTrigger from "./time"; +import WebhookTrigger from "./webhook"; import ZoneTrigger from "./zone"; const TYPES = { @@ -23,6 +24,7 @@ const TYPES = { sun: SunTrigger, template: TemplateTrigger, time: TimeTrigger, + webhook: WebhookTrigger, zone: ZoneTrigger, }; diff --git a/src/panels/config/js/trigger/webhook.js b/src/panels/config/js/trigger/webhook.js new file mode 100644 index 0000000000..8ce125559f --- /dev/null +++ b/src/panels/config/js/trigger/webhook.js @@ -0,0 +1,32 @@ +import { h, Component } from "preact"; +import "@polymer/paper-input/paper-input"; + +import { onChangeEvent } from "../../../../common/preact/event"; + +export default class WebhookTrigger extends Component { + constructor() { + super(); + + this.onChange = onChangeEvent.bind(this, "trigger"); + } + + render({ trigger, localize }) { + const { webhook_id: webhookId } = trigger; + return ( +
+ +
+ ); + } +} + +WebhookTrigger.defaultConfig = { + webhook_id: "", +}; diff --git a/src/panels/lovelace/ha-panel-lovelace.ts b/src/panels/lovelace/ha-panel-lovelace.ts index 4edf80b331..136a9283b5 100644 --- a/src/panels/lovelace/ha-panel-lovelace.ts +++ b/src/panels/lovelace/ha-panel-lovelace.ts @@ -81,7 +81,7 @@ class LovelacePanel extends hassLocalizeLitMixin(LitElement) { .showMenu="${this.showMenu}" > Reload ui-lovelace.yamlReload Lovelace `; diff --git a/src/panels/lovelace/hui-editor.ts b/src/panels/lovelace/hui-editor.ts index b1e7ace684..202de5b0bb 100644 --- a/src/panels/lovelace/hui-editor.ts +++ b/src/panels/lovelace/hui-editor.ts @@ -91,13 +91,19 @@ class LovelaceFullConfigEditor extends hassLocalizeLitMixin(LitElement) { height: 100vh; } + paper-button { + font-size: 16px; + } + .content { - height: calc(100vh - 64px); + height: calc(100vh - 68px); } textarea { - height: calc(100% - 16px); + box-sizing: border-box; + height: 100%; width: 100%; + resize: none; border: 0; outline: 0; font-size: 12pt; diff --git a/src/translations/en.json b/src/translations/en.json index 7059894f28..6b85bcad9f 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -614,6 +614,10 @@ "label": "Time", "at": "At" }, + "webhook": { + "label": "Webhook", + "webhook_id": "Webhook ID" + }, "zone": { "label": "Zone", "entity": "Entity with location", diff --git a/translations/ru.json b/translations/ru.json index 3ff64caac7..1f0489d37e 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -747,8 +747,8 @@ "delete": "Удалить вкладку" }, "save_config": { - "header": "Получение контроля над пользовательским интерфейсом Lovelace", - "para": "По умолчанию Home Assistant будет обслуживать ваш пользовательский интерфейс, автоматически добавляя новые объекты и новые компоненты Lovelace, если они доступны. Если вы получите контроль над пользовательским интерфейсом, изменения больше не будут вноситься автоматически.", + "header": "Получение контроля над пользовательским интерфейсом", + "para": "По умолчанию Home Assistant будет обслуживать Ваш пользовательский интерфейс, автоматически добавляя новые объекты и новые компоненты Lovelace, если они доступны. Если Вы получите контроль над пользовательским интерфейсом, изменения больше не будут вноситься автоматически.", "para_sure": "Вы уверены, что хотите самостоятельно контролировать пользовательский интерфейс?", "cancel": "Оставить как есть", "save": "Получить контроль"