Merge pull request #2261 from home-assistant/dev

20181211.0
This commit is contained in:
Paulus Schoutsen 2018-12-11 10:29:13 +01:00 committed by GitHub
commit 3a50d47dd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 79 additions and 9 deletions

View File

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup( setup(
name="home-assistant-frontend", name="home-assistant-frontend",
version="20181210.1", version="20181211.0",
description="The Home Assistant frontend", description="The Home Assistant frontend",
url="https://github.com/home-assistant/home-assistant-polymer", url="https://github.com/home-assistant/home-assistant-polymer",
author="The Home Assistant Authors", author="The Home Assistant Authors",

View File

@ -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";

View File

@ -20,6 +20,7 @@ import {
deleteCloudhook, deleteCloudhook,
CloudWebhook, CloudWebhook,
} from "../../../data/cloud"; } from "../../../data/cloud";
import { ERR_UNKNOWN_COMMAND } from "../../../data/websocket_api";
declare global { declare global {
// for fire event // for fire event
@ -86,7 +87,17 @@ export class CloudWebhooks extends LitElement {
private _renderBody() { private _renderBody() {
if (!this.cloudStatus || !this._localHooks || !this._cloudHooks) { if (!this.cloudStatus || !this._localHooks || !this._cloudHooks) {
return html` return html`
<div class="loading">Loading</div> <div class="body-text">Loading</div>
`;
}
if (this._localHooks.length === 0) {
return html`
<div class="body-text">
Looks like you have no webhooks yet. Get started by configuring a
<a href="/config/integrations">webhook-based integration</a> or by
creating a <a href="/config/automation/new">webhook automation</a>.
</div>
`; `;
} }
@ -188,7 +199,15 @@ export class CloudWebhooks extends LitElement {
} }
private async _fetchData() { 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() { private renderStyle() {
@ -197,7 +216,7 @@ export class CloudWebhooks extends LitElement {
.body { .body {
padding: 0 16px 8px; padding: 0 16px 8px;
} }
.loading { .body-text {
padding: 0 16px; padding: 0 16px;
} }
.webhook { .webhook {
@ -217,6 +236,7 @@ export class CloudWebhooks extends LitElement {
.footer { .footer {
padding: 16px; padding: 16px;
} }
.body-text a,
.footer a { .footer a {
color: var(--primary-color); color: var(--primary-color);
} }

View File

@ -12,6 +12,7 @@ import StateTrigger from "./state";
import SunTrigger from "./sun"; import SunTrigger from "./sun";
import TemplateTrigger from "./template"; import TemplateTrigger from "./template";
import TimeTrigger from "./time"; import TimeTrigger from "./time";
import WebhookTrigger from "./webhook";
import ZoneTrigger from "./zone"; import ZoneTrigger from "./zone";
const TYPES = { const TYPES = {
@ -23,6 +24,7 @@ const TYPES = {
sun: SunTrigger, sun: SunTrigger,
template: TemplateTrigger, template: TemplateTrigger,
time: TimeTrigger, time: TimeTrigger,
webhook: WebhookTrigger,
zone: ZoneTrigger, zone: ZoneTrigger,
}; };

View File

@ -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 (
<div>
<paper-input
label={localize(
"ui.panel.config.automation.editor.triggers.type.webhook.webhook_id"
)}
name="webhook_id"
value={webhookId}
onvalue-changed={this.onChange}
/>
</div>
);
}
}
WebhookTrigger.defaultConfig = {
webhook_id: "",
};

View File

@ -81,7 +81,7 @@ class LovelacePanel extends hassLocalizeLitMixin(LitElement) {
.showMenu="${this.showMenu}" .showMenu="${this.showMenu}"
> >
<paper-button on-click="_forceFetchConfig" <paper-button on-click="_forceFetchConfig"
>Reload ui-lovelace.yaml</paper-button >Reload Lovelace</paper-button
> >
</hass-error-screen> </hass-error-screen>
`; `;

View File

@ -91,13 +91,19 @@ class LovelaceFullConfigEditor extends hassLocalizeLitMixin(LitElement) {
height: 100vh; height: 100vh;
} }
paper-button {
font-size: 16px;
}
.content { .content {
height: calc(100vh - 64px); height: calc(100vh - 68px);
} }
textarea { textarea {
height: calc(100% - 16px); box-sizing: border-box;
height: 100%;
width: 100%; width: 100%;
resize: none;
border: 0; border: 0;
outline: 0; outline: 0;
font-size: 12pt; font-size: 12pt;

View File

@ -614,6 +614,10 @@
"label": "Time", "label": "Time",
"at": "At" "at": "At"
}, },
"webhook": {
"label": "Webhook",
"webhook_id": "Webhook ID"
},
"zone": { "zone": {
"label": "Zone", "label": "Zone",
"entity": "Entity with location", "entity": "Entity with location",

View File

@ -747,8 +747,8 @@
"delete": "Удалить вкладку" "delete": "Удалить вкладку"
}, },
"save_config": { "save_config": {
"header": "Получение контроля над пользовательским интерфейсом Lovelace", "header": "Получение контроля над пользовательским интерфейсом",
"para": "По умолчанию Home Assistant будет обслуживать ваш пользовательский интерфейс, автоматически добавляя новые объекты и новые компоненты Lovelace, если они доступны. Если вы получите контроль над пользовательским интерфейсом, изменения больше не будут вноситься автоматически.", "para": "По умолчанию Home Assistant будет обслуживать Ваш пользовательский интерфейс, автоматически добавляя новые объекты и новые компоненты Lovelace, если они доступны. Если Вы получите контроль над пользовательским интерфейсом, изменения больше не будут вноситься автоматически.",
"para_sure": "Вы уверены, что хотите самостоятельно контролировать пользовательский интерфейс?", "para_sure": "Вы уверены, что хотите самостоятельно контролировать пользовательский интерфейс?",
"cancel": "Оставить как есть", "cancel": "Оставить как есть",
"save": "Получить контроль" "save": "Получить контроль"