Update typescript, prettier, tslint -> eslint (#5536)
* Update typescript, prettier, tslint -> eslint * Organize imports * Use glob for eslint fix react import
This commit is contained in:
parent
b17490f0de
commit
82f80db558
@ -1,80 +0,0 @@
|
||||
{
|
||||
"extends": ["airbnb-base", "prettier"],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "2020",
|
||||
"ecmaFeatures": {
|
||||
"jsx": true,
|
||||
"modules": true
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"react": {
|
||||
"pragma": "h",
|
||||
"version": "15.0"
|
||||
},
|
||||
"import/resolver": {
|
||||
"webpack": {
|
||||
"config": "webpack.config.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"globals": {
|
||||
"__DEV__": false,
|
||||
"__DEMO__": false,
|
||||
"__BUILD__": false,
|
||||
"__VERSION__": false,
|
||||
"__STATIC_PATH__": false,
|
||||
"Polymer": true,
|
||||
"webkitSpeechRecognition": false,
|
||||
"ResizeObserver": false
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"mocha": true
|
||||
},
|
||||
"rules": {
|
||||
"class-methods-use-this": 0,
|
||||
"new-cap": 0,
|
||||
"prefer-template": 0,
|
||||
"object-shorthand": 0,
|
||||
"func-names": 0,
|
||||
"prefer-arrow-callback": 0,
|
||||
"no-underscore-dangle": 0,
|
||||
"no-var": 0,
|
||||
"strict": 0,
|
||||
"prefer-spread": 0,
|
||||
"no-plusplus": 0,
|
||||
"no-bitwise": 0,
|
||||
"comma-dangle": 0,
|
||||
"vars-on-top": 0,
|
||||
"no-continue": 0,
|
||||
"no-param-reassign": 0,
|
||||
"no-multi-assign": 0,
|
||||
"radix": 0,
|
||||
"no-alert": 0,
|
||||
"no-return-await": 0,
|
||||
"prefer-destructuring": 0,
|
||||
"no-restricted-globals": [2, "event"],
|
||||
"prefer-promise-reject-errors": 0,
|
||||
"import/prefer-default-export": 0,
|
||||
"import/no-unresolved": 0,
|
||||
"import/extensions": [2, "ignorePackages"],
|
||||
"object-curly-newline": 0,
|
||||
"default-case": 0,
|
||||
"react/jsx-no-bind": [2, { "ignoreRefs": true }],
|
||||
"react/jsx-no-duplicate-props": 2,
|
||||
"react/self-closing-comp": 2,
|
||||
"react/prefer-es6-class": 2,
|
||||
"react/no-string-refs": 2,
|
||||
"react/require-render-return": 2,
|
||||
"react/no-find-dom-node": 2,
|
||||
"react/no-is-mounted": 2,
|
||||
"react/jsx-no-comment-textnodes": 2,
|
||||
"react/jsx-no-undef": 2,
|
||||
"react/jsx-uses-react": 2,
|
||||
"react/jsx-uses-vars": 2,
|
||||
"no-restricted-syntax": [0, "ForOfStatement"],
|
||||
"prettier/prettier": "error"
|
||||
},
|
||||
"plugins": ["react", "prettier"]
|
||||
}
|
||||
102
.eslintrc.json
102
.eslintrc.json
@ -1,12 +1,100 @@
|
||||
{
|
||||
"extends": "./.eslintrc-hound.json",
|
||||
"plugins": ["react"],
|
||||
"extends": [
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"airbnb-typescript/base",
|
||||
"plugin:wc/recommended",
|
||||
"plugin:lit/recommended",
|
||||
"prettier",
|
||||
"prettier/@typescript-eslint"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020,
|
||||
"ecmaFeatures": {
|
||||
"jsx": true,
|
||||
"modules": true
|
||||
},
|
||||
"sourceType": "module",
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"settings": {
|
||||
"react": {
|
||||
"pragma": "h",
|
||||
"version": "15.0"
|
||||
},
|
||||
"import/resolver": {
|
||||
"webpack": {
|
||||
"config": "./webpack.config.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"globals": {
|
||||
"__DEV__": false,
|
||||
"__DEMO__": false,
|
||||
"__BUILD__": false,
|
||||
"__VERSION__": false,
|
||||
"__STATIC_PATH__": false,
|
||||
"Polymer": true,
|
||||
"webkitSpeechRecognition": false,
|
||||
"ResizeObserver": false
|
||||
},
|
||||
"env": {
|
||||
"browser": true
|
||||
"browser": true,
|
||||
"es6": true
|
||||
},
|
||||
"rules": {
|
||||
"import/no-unresolved": 2,
|
||||
"linebreak-style": 0,
|
||||
"implicit-arrow-linebreak": 0
|
||||
}
|
||||
"class-methods-use-this": 0,
|
||||
"new-cap": 0,
|
||||
"prefer-template": 0,
|
||||
"object-shorthand": 0,
|
||||
"func-names": 0,
|
||||
"prefer-arrow-callback": 0,
|
||||
"no-underscore-dangle": 0,
|
||||
"no-var": 0,
|
||||
"strict": 0,
|
||||
"prefer-spread": 0,
|
||||
"no-plusplus": 0,
|
||||
"no-bitwise": 0,
|
||||
"comma-dangle": 0,
|
||||
"vars-on-top": 0,
|
||||
"no-continue": 0,
|
||||
"no-param-reassign": 0,
|
||||
"no-multi-assign": 0,
|
||||
"radix": 0,
|
||||
"no-alert": 0,
|
||||
"no-return-await": 0,
|
||||
"no-nested-ternary": 0,
|
||||
"prefer-destructuring": 0,
|
||||
"no-restricted-globals": [2, "event"],
|
||||
"prefer-promise-reject-errors": 0,
|
||||
"import/order": 0,
|
||||
"import/prefer-default-export": 0,
|
||||
"import/no-unresolved": 0,
|
||||
"import/no-cycle": 0,
|
||||
"import/extensions": [
|
||||
2,
|
||||
"ignorePackages",
|
||||
{ "ts": "never", "js": "never" }
|
||||
],
|
||||
"no-restricted-syntax": ["error", "LabeledStatement", "WithStatement"],
|
||||
"object-curly-newline": 0,
|
||||
"default-case": 0,
|
||||
"wc/no-self-class": 0,
|
||||
"@typescript-eslint/camelcase": 0,
|
||||
"@typescript-eslint/ban-ts-ignore": 0,
|
||||
"@typescript-eslint/no-use-before-define": 0,
|
||||
"@typescript-eslint/no-non-null-assertion": 0,
|
||||
"@typescript-eslint/no-explicit-any": 0,
|
||||
"@typescript-eslint/no-unused-vars": 0,
|
||||
"@typescript-eslint/explicit-function-return-type": 0
|
||||
},
|
||||
"plugins": [
|
||||
"disable",
|
||||
"import",
|
||||
"react",
|
||||
"lit",
|
||||
"prettier",
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"processor": "disable/disable"
|
||||
}
|
||||
|
||||
9
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
9
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
@ -3,23 +3,24 @@ name: Request a feature for the UI, Frontend or Lovelace
|
||||
about: Request an new feature for the Home Assistant frontend.
|
||||
labels: feature request
|
||||
---
|
||||
|
||||
<!--
|
||||
DO NOT DELETE ANY TEXT from this template!
|
||||
Otherwise, your request may be closed without comment.
|
||||
-->
|
||||
|
||||
## The request
|
||||
<!--
|
||||
|
||||
<!--
|
||||
Describe to our maintainers, the feature you would like to be added.
|
||||
Please be clear and concise and, if possible, provide a screenshot or mockup.
|
||||
-->
|
||||
|
||||
|
||||
## The alternatives
|
||||
|
||||
<!--
|
||||
Are you currently using, or have you considered alternatives?
|
||||
If so, could you please describe those?
|
||||
-->
|
||||
|
||||
|
||||
## Additional information
|
||||
|
||||
|
||||
18
.github/PULL_REQUEST_TEMPLATE.md
vendored
18
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -2,7 +2,9 @@
|
||||
You are amazing! Thanks for contributing to our project!
|
||||
Please, DO NOT DELETE ANY TEXT from this template! (unless instructed).
|
||||
-->
|
||||
|
||||
## Breaking change
|
||||
|
||||
<!--
|
||||
If your PR contains a breaking change for existing users, it is important
|
||||
to tell them what breaks, how to make it work again and why we did this.
|
||||
@ -11,20 +13,20 @@
|
||||
Note: Remove this section if this PR is NOT a breaking change.
|
||||
-->
|
||||
|
||||
|
||||
## Proposed change
|
||||
<!--
|
||||
|
||||
<!--
|
||||
Describe the big picture of your changes here to communicate to the
|
||||
maintainers why we should accept this pull request. If it fixes a bug
|
||||
or resolves a feature request, be sure to link to that issue in the
|
||||
additional information section.
|
||||
-->
|
||||
|
||||
|
||||
## Type of change
|
||||
|
||||
<!--
|
||||
What type of change does your PR introduce to the Home Assistant frontend?
|
||||
NOTE: Please, check only 1! box!
|
||||
NOTE: Please, check only 1! box!
|
||||
If your PR requires multiple boxes to be checked, you'll most likely need to
|
||||
split it into multiple PRs. This makes things easier and faster to code review.
|
||||
-->
|
||||
@ -36,6 +38,7 @@
|
||||
- [ ] Code quality improvements to existing code or addition of tests
|
||||
|
||||
## Example configuration
|
||||
|
||||
<!--
|
||||
Supplying a configuration snippet, makes it easier for a maintainer to test
|
||||
your PR.
|
||||
@ -46,16 +49,18 @@
|
||||
```
|
||||
|
||||
## Additional information
|
||||
|
||||
<!--
|
||||
Details are important, and help maintainers processing your PR.
|
||||
Please be sure to fill out additional details, if applicable.
|
||||
-->
|
||||
|
||||
- This PR fixes or closes issue: fixes #
|
||||
- This PR is related to issue:
|
||||
- Link to documentation pull request:
|
||||
- This PR is related to issue:
|
||||
- Link to documentation pull request:
|
||||
|
||||
## Checklist
|
||||
|
||||
<!--
|
||||
Put an `x` in the boxes that apply. You can also fill these out after
|
||||
creating the PR. If you're unsure about any of them, don't hesitate to ask.
|
||||
@ -74,4 +79,5 @@ If user exposed functionality or configuration variables are added/changed:
|
||||
<!--
|
||||
Thank you for contributing <3
|
||||
-->
|
||||
|
||||
[docs-repository]: https://github.com/home-assistant/home-assistant.io
|
||||
|
||||
2
.github/lock.yml
vendored
2
.github/lock.yml
vendored
@ -24,4 +24,4 @@ only: pulls
|
||||
|
||||
# Optionally, specify configuration settings just for `issues` or `pulls`
|
||||
issues:
|
||||
daysUntilLock: 30
|
||||
daysUntilLock: 30
|
||||
|
||||
37
.prettierignore
Normal file
37
.prettierignore
Normal file
@ -0,0 +1,37 @@
|
||||
build
|
||||
build-translations/*
|
||||
translations/*
|
||||
node_modules/*
|
||||
npm-debug.log
|
||||
.DS_Store
|
||||
hass_frontend/*
|
||||
.reify-cache
|
||||
demo/hademo-icons.html
|
||||
|
||||
# Python stuff
|
||||
*.py[cod]
|
||||
*.egg
|
||||
*.egg-info
|
||||
|
||||
# venv stuff
|
||||
pyvenv.cfg
|
||||
pip-selfcheck.json
|
||||
venv
|
||||
.venv
|
||||
lib
|
||||
bin
|
||||
dist
|
||||
|
||||
# vscode
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
|
||||
# Cast dev settings
|
||||
src/cast/dev_const.ts
|
||||
|
||||
# Secrets
|
||||
.lokalise_token
|
||||
yarn-error.log
|
||||
|
||||
#asdf
|
||||
.tool-versions
|
||||
1
.vscode/extensions.json
vendored
1
.vscode/extensions.json
vendored
@ -1,7 +1,6 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"ms-vscode.vscode-typescript-tslint-plugin",
|
||||
"esbenp.prettier-vscode",
|
||||
"bierner.lit-html",
|
||||
"runem.lit-plugin"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import "../../../src/resources/ha-style";
|
||||
import "../../../src/resources/roboto";
|
||||
import "../../../src/components/ha-iconset-svg";
|
||||
import "../../../src/resources/ha-style";
|
||||
import "../../../src/resources/hass-icons";
|
||||
import "../../../src/resources/roboto";
|
||||
import "./layout/hc-connect";
|
||||
|
||||
@ -1,51 +1,53 @@
|
||||
import "@polymer/iron-icon";
|
||||
import "@polymer/paper-item/paper-icon-item";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import { Auth, Connection } from "home-assistant-js-websocket";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
html,
|
||||
CSSResult,
|
||||
css,
|
||||
} from "lit-element";
|
||||
import { Connection, Auth } from "home-assistant-js-websocket";
|
||||
import "@polymer/iron-icon";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import "@polymer/paper-item/paper-icon-item";
|
||||
import "../../../../src/components/ha-icon";
|
||||
import {
|
||||
enableWrite,
|
||||
askWrite,
|
||||
saveTokens,
|
||||
} from "../../../../src/common/auth/token_storage";
|
||||
import {
|
||||
ensureConnectedCastSession,
|
||||
castSendShowLovelaceView,
|
||||
} from "../../../../src/cast/receiver_messages";
|
||||
import "../../../../src/layouts/loading-screen";
|
||||
import { CastManager } from "../../../../src/cast/cast_manager";
|
||||
import {
|
||||
LovelaceConfig,
|
||||
getLovelaceCollection,
|
||||
getLegacyLovelaceCollection,
|
||||
} from "../../../../src/data/lovelace";
|
||||
import "./hc-layout";
|
||||
import { generateDefaultViewConfig } from "../../../../src/panels/lovelace/common/generate-lovelace-config";
|
||||
import { toggleAttribute } from "../../../../src/common/dom/toggle_attribute";
|
||||
castSendShowLovelaceView,
|
||||
ensureConnectedCastSession,
|
||||
} from "../../../../src/cast/receiver_messages";
|
||||
import {
|
||||
askWrite,
|
||||
enableWrite,
|
||||
saveTokens,
|
||||
} from "../../../../src/common/auth/token_storage";
|
||||
import { atLeastVersion } from "../../../../src/common/config/version";
|
||||
import { toggleAttribute } from "../../../../src/common/dom/toggle_attribute";
|
||||
import "../../../../src/components/ha-icon";
|
||||
import {
|
||||
getLegacyLovelaceCollection,
|
||||
getLovelaceCollection,
|
||||
LovelaceConfig,
|
||||
} from "../../../../src/data/lovelace";
|
||||
import "../../../../src/layouts/loading-screen";
|
||||
import { generateDefaultViewConfig } from "../../../../src/panels/lovelace/common/generate-lovelace-config";
|
||||
import "./hc-layout";
|
||||
|
||||
@customElement("hc-cast")
|
||||
class HcCast extends LitElement {
|
||||
@property() public auth!: Auth;
|
||||
|
||||
@property() public connection!: Connection;
|
||||
|
||||
@property() public castManager!: CastManager;
|
||||
|
||||
@property() private askWrite = false;
|
||||
|
||||
@property() private lovelaceConfig?: LovelaceConfig | null;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (this.lovelaceConfig === undefined) {
|
||||
return html`
|
||||
<loading-screen></loading-screen>>
|
||||
`;
|
||||
return html` <loading-screen></loading-screen>> `;
|
||||
}
|
||||
|
||||
const error =
|
||||
@ -75,9 +77,7 @@ class HcCast extends LitElement {
|
||||
`
|
||||
: ""}
|
||||
${error
|
||||
? html`
|
||||
<div class="card-content">${error}</div>
|
||||
`
|
||||
? html` <div class="card-content">${error}</div> `
|
||||
: !this.castManager.status
|
||||
? html`
|
||||
<p class="center-item">
|
||||
|
||||
@ -1,35 +1,35 @@
|
||||
import "@material/mwc-button";
|
||||
import "@polymer/iron-icon";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import {
|
||||
LitElement,
|
||||
Auth,
|
||||
Connection,
|
||||
createConnection,
|
||||
ERR_CANNOT_CONNECT,
|
||||
ERR_HASS_HOST_REQUIRED,
|
||||
ERR_INVALID_AUTH,
|
||||
ERR_INVALID_HTTPS_TO_HTTP,
|
||||
getAuth,
|
||||
getAuthOptions,
|
||||
} from "home-assistant-js-websocket";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
html,
|
||||
CSSResult,
|
||||
css,
|
||||
} from "lit-element";
|
||||
import {
|
||||
getAuth,
|
||||
createConnection,
|
||||
Auth,
|
||||
getAuthOptions,
|
||||
ERR_HASS_HOST_REQUIRED,
|
||||
ERR_INVALID_HTTPS_TO_HTTP,
|
||||
Connection,
|
||||
ERR_CANNOT_CONNECT,
|
||||
ERR_INVALID_AUTH,
|
||||
} from "home-assistant-js-websocket";
|
||||
import "@polymer/iron-icon";
|
||||
import "@material/mwc-button";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import { CastManager, getCastManager } from "../../../../src/cast/cast_manager";
|
||||
import { castSendShowDemo } from "../../../../src/cast/receiver_messages";
|
||||
import {
|
||||
loadTokens,
|
||||
saveTokens,
|
||||
} from "../../../../src/common/auth/token_storage";
|
||||
import "../../../../src/layouts/loading-screen";
|
||||
import { CastManager, getCastManager } from "../../../../src/cast/cast_manager";
|
||||
import "./hc-layout";
|
||||
import { castSendShowDemo } from "../../../../src/cast/receiver_messages";
|
||||
import { registerServiceWorker } from "../../../../src/util/register-service-worker";
|
||||
import "./hc-layout";
|
||||
|
||||
const seeFAQ = (qid) => html`
|
||||
See <a href="./faq.html${qid ? `#${qid}` : ""}">the FAQ</a> for more
|
||||
@ -61,13 +61,19 @@ const INTRO = html`
|
||||
@customElement("hc-connect")
|
||||
export class HcConnect extends LitElement {
|
||||
@property() private loading = false;
|
||||
|
||||
// If we had stored credentials but we cannot connect,
|
||||
// show a screen asking retry or logout.
|
||||
@property() private cannotConnect = false;
|
||||
|
||||
@property() private error?: string | TemplateResult;
|
||||
|
||||
@property() private auth?: Auth;
|
||||
|
||||
@property() private connection?: Connection;
|
||||
|
||||
@property() private castManager?: CastManager | null;
|
||||
|
||||
private openDemo = false;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
@ -92,9 +98,7 @@ export class HcConnect extends LitElement {
|
||||
}
|
||||
|
||||
if (this.castManager === undefined || this.loading) {
|
||||
return html`
|
||||
<loading-screen></loading-screen>
|
||||
`;
|
||||
return html` <loading-screen></loading-screen> `;
|
||||
}
|
||||
|
||||
if (this.castManager === null) {
|
||||
@ -127,11 +131,7 @@ export class HcConnect extends LitElement {
|
||||
@keydown=${this._handleInputKeyDown}
|
||||
></paper-input>
|
||||
</p>
|
||||
${this.error
|
||||
? html`
|
||||
<p class="error">${this.error}</p>
|
||||
`
|
||||
: ""}
|
||||
${this.error ? html` <p class="error">${this.error}</p> ` : ""}
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
<mwc-button @click=${this._handleDemo}>
|
||||
@ -211,7 +211,8 @@ export class HcConnect extends LitElement {
|
||||
if (value === "") {
|
||||
this.error = "Please enter a Home Assistant URL.";
|
||||
return;
|
||||
} else if (value.indexOf("://") === -1) {
|
||||
}
|
||||
if (value.indexOf("://") === -1) {
|
||||
this.error =
|
||||
"Please enter your full URL, including the protocol part (https://).";
|
||||
return;
|
||||
|
||||
@ -1,25 +1,28 @@
|
||||
import {
|
||||
customElement,
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
CSSResult,
|
||||
css,
|
||||
property,
|
||||
} from "lit-element";
|
||||
import {
|
||||
Auth,
|
||||
Connection,
|
||||
HassUser,
|
||||
getUser,
|
||||
HassUser,
|
||||
} from "home-assistant-js-websocket";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import "../../../../src/components/ha-card";
|
||||
|
||||
@customElement("hc-layout")
|
||||
class HcLayout extends LitElement {
|
||||
@property() public subtitle?: string | undefined;
|
||||
|
||||
@property() public auth?: Auth;
|
||||
|
||||
@property() public connection?: Connection;
|
||||
|
||||
@property() public user?: HassUser;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
@ -37,11 +40,7 @@ class HcLayout extends LitElement {
|
||||
this.auth.data.hassUrl.indexOf("//") + 2
|
||||
)}</a
|
||||
>
|
||||
${this.user
|
||||
? html`
|
||||
– ${this.user.name}
|
||||
`
|
||||
: ""}
|
||||
${this.user ? html` – ${this.user.name} ` : ""}
|
||||
</div>
|
||||
`
|
||||
: ""}
|
||||
|
||||
@ -1 +1,2 @@
|
||||
/* eslint-disable no-undef */
|
||||
export const castContext = cast.framework.CastReceiverContext.getInstance();
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Entity, convertEntities } from "../../../../src/fake_data/entity";
|
||||
import { convertEntities, Entity } from "../../../../src/fake_data/entity";
|
||||
|
||||
export const castDemoEntities: () => Entity[] = () =>
|
||||
convertEntities({
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {
|
||||
LovelaceConfig,
|
||||
LovelaceCardConfig,
|
||||
LovelaceConfig,
|
||||
} from "../../../../src/data/lovelace";
|
||||
import { castContext } from "../cast_context";
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/* eslint-disable no-undef */
|
||||
import { CAST_NS } from "../../../src/cast/const";
|
||||
import { HassMessage } from "../../../src/cast/receiver_messages";
|
||||
import "../../../src/resources/custom-card-support";
|
||||
import { castContext } from "./cast_context";
|
||||
import { ReceivedMessage } from "./types";
|
||||
import { HassMessage } from "../../../src/cast/receiver_messages";
|
||||
import { HcMain } from "./layout/hc-main";
|
||||
import { CAST_NS } from "../../../src/cast/const";
|
||||
import { ReceivedMessage } from "./types";
|
||||
|
||||
const controller = new HcMain();
|
||||
document.body.append(controller);
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
import { HassElement } from "../../../../src/state/hass-element";
|
||||
import "./hc-lovelace";
|
||||
import { customElement, TemplateResult, html, property } from "lit-element";
|
||||
import { customElement, html, property, TemplateResult } from "lit-element";
|
||||
import { mockHistory } from "../../../../demo/src/stubs/history";
|
||||
import { LovelaceConfig } from "../../../../src/data/lovelace";
|
||||
import {
|
||||
MockHomeAssistant,
|
||||
provideHass,
|
||||
} from "../../../../src/fake_data/provide_hass";
|
||||
import { HassElement } from "../../../../src/state/hass-element";
|
||||
import { HomeAssistant } from "../../../../src/types";
|
||||
import { LovelaceConfig } from "../../../../src/data/lovelace";
|
||||
import { castDemoEntities } from "../demo/cast-demo-entities";
|
||||
import { castDemoLovelace } from "../demo/cast-demo-lovelace";
|
||||
import { mockHistory } from "../../../../demo/src/stubs/history";
|
||||
import "./hc-lovelace";
|
||||
|
||||
@customElement("hc-demo")
|
||||
class HcDemo extends HassElement {
|
||||
@property() public lovelacePath!: string;
|
||||
|
||||
@property() private _lovelaceConfig?: LovelaceConfig;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
@ -28,6 +29,7 @@ class HcDemo extends HassElement {
|
||||
></hc-lovelace>
|
||||
`;
|
||||
}
|
||||
|
||||
protected firstUpdated(changedProps) {
|
||||
super.firstUpdated(changedProps);
|
||||
this._initialize();
|
||||
|
||||
@ -1,17 +1,18 @@
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
customElement,
|
||||
CSSResult,
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { HomeAssistant } from "../../../../src/types";
|
||||
|
||||
@customElement("hc-launch-screen")
|
||||
class HcLaunchScreen extends LitElement {
|
||||
@property() public hass?: HomeAssistant;
|
||||
|
||||
@property() public error?: string;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
@ -22,11 +23,7 @@ class HcLaunchScreen extends LitElement {
|
||||
/>
|
||||
<div class="status">
|
||||
${this.hass ? "Connected" : "Not Connected"}
|
||||
${this.error
|
||||
? html`
|
||||
<p>Error: ${this.error}</p>
|
||||
`
|
||||
: ""}
|
||||
${this.error ? html` <p>Error: ${this.error}</p> ` : ""}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
customElement,
|
||||
CSSResult,
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { LovelaceConfig } from "../../../../src/data/lovelace";
|
||||
import "../../../../src/panels/lovelace/views/hui-view";
|
||||
import "../../../../src/panels/lovelace/views/hui-panel-view";
|
||||
import { HomeAssistant } from "../../../../src/types";
|
||||
import { Lovelace } from "../../../../src/panels/lovelace/types";
|
||||
import "../../../../src/panels/lovelace/views/hui-panel-view";
|
||||
import "../../../../src/panels/lovelace/views/hui-view";
|
||||
import { HomeAssistant } from "../../../../src/types";
|
||||
import "./hc-launch-screen";
|
||||
|
||||
@customElement("hc-lovelace")
|
||||
|
||||
@ -1,31 +1,31 @@
|
||||
import {
|
||||
getAuth,
|
||||
createConnection,
|
||||
getAuth,
|
||||
UnsubscribeFunc,
|
||||
} from "home-assistant-js-websocket";
|
||||
import { customElement, TemplateResult, html, property } from "lit-element";
|
||||
import { HassElement } from "../../../../src/state/hass-element";
|
||||
import {
|
||||
HassMessage,
|
||||
ConnectMessage,
|
||||
ShowLovelaceViewMessage,
|
||||
GetStatusMessage,
|
||||
ShowDemoMessage,
|
||||
} from "../../../../src/cast/receiver_messages";
|
||||
import {
|
||||
LovelaceConfig,
|
||||
getLovelaceCollection,
|
||||
fetchResources,
|
||||
LegacyLovelaceConfig,
|
||||
getLegacyLovelaceCollection,
|
||||
} from "../../../../src/data/lovelace";
|
||||
import "./hc-launch-screen";
|
||||
import { castContext } from "../cast_context";
|
||||
import { customElement, html, property, TemplateResult } from "lit-element";
|
||||
import { CAST_NS } from "../../../../src/cast/const";
|
||||
import {
|
||||
ConnectMessage,
|
||||
GetStatusMessage,
|
||||
HassMessage,
|
||||
ShowDemoMessage,
|
||||
ShowLovelaceViewMessage,
|
||||
} from "../../../../src/cast/receiver_messages";
|
||||
import { ReceiverStatusMessage } from "../../../../src/cast/sender_messages";
|
||||
import { loadLovelaceResources } from "../../../../src/panels/lovelace/common/load-resources";
|
||||
import { isNavigationClick } from "../../../../src/common/dom/is-navigation-click";
|
||||
import { atLeastVersion } from "../../../../src/common/config/version";
|
||||
import { isNavigationClick } from "../../../../src/common/dom/is-navigation-click";
|
||||
import {
|
||||
fetchResources,
|
||||
getLegacyLovelaceCollection,
|
||||
getLovelaceCollection,
|
||||
LegacyLovelaceConfig,
|
||||
LovelaceConfig,
|
||||
} from "../../../../src/data/lovelace";
|
||||
import { loadLovelaceResources } from "../../../../src/panels/lovelace/common/load-resources";
|
||||
import { HassElement } from "../../../../src/state/hass-element";
|
||||
import { castContext } from "../cast_context";
|
||||
import "./hc-launch-screen";
|
||||
|
||||
let resourcesLoaded = false;
|
||||
|
||||
@ -40,6 +40,7 @@ export class HcMain extends HassElement {
|
||||
@property() private _error?: string;
|
||||
|
||||
private _unsubLovelace?: UnsubscribeFunc;
|
||||
|
||||
private _urlPath?: string | null;
|
||||
|
||||
public processIncomingMessage(msg: HassMessage) {
|
||||
@ -52,16 +53,14 @@ export class HcMain extends HassElement {
|
||||
} else if (msg.type === "show_demo") {
|
||||
this._handleShowDemo(msg);
|
||||
} else {
|
||||
// tslint:disable-next-line: no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn("unknown msg type", msg);
|
||||
}
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (this._showDemo) {
|
||||
return html`
|
||||
<hc-demo .lovelacePath=${this._lovelacePath}></hc-demo>
|
||||
`;
|
||||
return html` <hc-demo .lovelacePath=${this._lovelacePath}></hc-demo> `;
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import "web-animations-js/web-animations-next-lite.min";
|
||||
import "../../../src/components/ha-iconset-svg";
|
||||
import "../../../src/resources/hass-icons";
|
||||
import "../../../src/resources/roboto";
|
||||
import "../../../src/components/ha-iconset-svg";
|
||||
import "./layout/hc-lovelace";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { DemoConfig } from "../types";
|
||||
import { demoLovelaceArsaboo } from "./lovelace";
|
||||
import { demoEntitiesArsaboo } from "./entities";
|
||||
import { demoLovelaceArsaboo } from "./lovelace";
|
||||
import { demoThemeArsaboo } from "./theme";
|
||||
|
||||
export const demoArsaboo: DemoConfig = {
|
||||
|
||||
@ -21,7 +21,9 @@ export const demoConfigs: Array<() => Promise<DemoConfig>> = [
|
||||
),
|
||||
];
|
||||
|
||||
export let selectedDemoConfigIndex: number = 0;
|
||||
// eslint-disable-next-line import/no-mutable-exports
|
||||
export let selectedDemoConfigIndex = 0;
|
||||
// eslint-disable-next-line import/no-mutable-exports
|
||||
export let selectedDemoConfig: Promise<DemoConfig> = demoConfigs[
|
||||
selectedDemoConfigIndex
|
||||
]();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { DemoConfig } from "../types";
|
||||
import { demoLovelaceJimpower } from "./lovelace";
|
||||
import { demoEntitiesJimpower } from "./entities";
|
||||
import { demoLovelaceJimpower } from "./lovelace";
|
||||
import { demoThemeJimpower } from "./theme";
|
||||
|
||||
export const demoJimpower: DemoConfig = {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { DemoConfig } from "../types";
|
||||
import { demoLovelaceKernehed } from "./lovelace";
|
||||
import { demoEntitiesKernehed } from "./entities";
|
||||
import { demoLovelaceKernehed } from "./lovelace";
|
||||
import { demoThemeKernehed } from "./theme";
|
||||
|
||||
export const demoKernehed: DemoConfig = {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { DemoConfig } from "../types";
|
||||
import { demoLovelaceTeachingbirds } from "./lovelace";
|
||||
import { demoEntitiesTeachingbirds } from "./entities";
|
||||
import { demoLovelaceTeachingbirds } from "./lovelace";
|
||||
import { demoThemeTeachingbirds } from "./theme";
|
||||
|
||||
export const demoTeachingbirds: DemoConfig = {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { LocalizeFunc } from "../../../src/common/translations/localize";
|
||||
import { LovelaceConfig } from "../../../src/data/lovelace";
|
||||
import { Entity } from "../../../src/fake_data/entity";
|
||||
import { LocalizeFunc } from "../../../src/common/translations/localize";
|
||||
|
||||
export interface DemoConfig {
|
||||
index?: number;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/* eslint-disable */
|
||||
import { LitElement } from "lit-element";
|
||||
import "./card-tools";
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { LitElement, html } from "lit-element";
|
||||
/* eslint-disable */
|
||||
import { html, LitElement } from "lit-element";
|
||||
|
||||
if (!window.cardTools) {
|
||||
const version = 0.2;
|
||||
|
||||
@ -1,21 +1,20 @@
|
||||
import {
|
||||
html,
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
customElement,
|
||||
property,
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import "../../../src/components/ha-icon";
|
||||
import {
|
||||
LovelaceRow,
|
||||
CastConfig,
|
||||
} from "../../../src/panels/lovelace/entity-rows/types";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { CastManager } from "../../../src/cast/cast_manager";
|
||||
import { castSendShowDemo } from "../../../src/cast/receiver_messages";
|
||||
import "../../../src/components/ha-icon";
|
||||
import {
|
||||
CastConfig,
|
||||
LovelaceRow,
|
||||
} from "../../../src/panels/lovelace/entity-rows/types";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
|
||||
@customElement("cast-demo-row")
|
||||
class CastDemoRow extends LitElement implements LovelaceRow {
|
||||
@ -52,6 +51,7 @@ class CastDemoRow extends LitElement implements LovelaceRow {
|
||||
this.requestUpdate();
|
||||
});
|
||||
mgr.castContext.addEventListener(
|
||||
// eslint-disable-next-line no-undef
|
||||
cast.framework.CastContextEventType.SESSION_STATE_CHANGED,
|
||||
(ev) => {
|
||||
// On Android, opening a new session always results in SESSION_RESUMED.
|
||||
|
||||
@ -1,22 +1,32 @@
|
||||
import { LitElement, html, CSSResult, css, property } from "lit-element";
|
||||
import { until } from "lit-html/directives/until";
|
||||
import "@material/mwc-button";
|
||||
import "@polymer/paper-spinner/paper-spinner-lite";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { until } from "lit-html/directives/until";
|
||||
import "../../../src/components/ha-card";
|
||||
import { LovelaceCard, Lovelace } from "../../../src/panels/lovelace/types";
|
||||
import { LovelaceCardConfig } from "../../../src/data/lovelace";
|
||||
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
import { Lovelace, LovelaceCard } from "../../../src/panels/lovelace/types";
|
||||
import {
|
||||
demoConfigs,
|
||||
selectedDemoConfig,
|
||||
setDemoConfig,
|
||||
selectedDemoConfigIndex,
|
||||
setDemoConfig,
|
||||
} from "../configs/demo-configs";
|
||||
|
||||
export class HADemoCard extends LitElement implements LovelaceCard {
|
||||
@property() public lovelace?: Lovelace;
|
||||
|
||||
@property() public hass!: MockHomeAssistant;
|
||||
|
||||
@property() private _switching?: boolean;
|
||||
|
||||
private _hidden = localStorage.hide_demo_card;
|
||||
|
||||
public getCardSize() {
|
||||
@ -25,22 +35,21 @@ export class HADemoCard extends LitElement implements LovelaceCard {
|
||||
|
||||
public setConfig(
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
config: LovelaceCardConfig
|
||||
// tslint:disable-next-line:no-empty
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
) {}
|
||||
|
||||
protected render() {
|
||||
protected render(): TemplateResult {
|
||||
if (this._hidden) {
|
||||
return;
|
||||
return html``;
|
||||
}
|
||||
return html`
|
||||
<ha-card>
|
||||
<div class="picker">
|
||||
<div class="label">
|
||||
${this._switching
|
||||
? html`
|
||||
<paper-spinner-lite active></paper-spinner-lite>
|
||||
`
|
||||
? html` <paper-spinner-lite active></paper-spinner-lite> `
|
||||
: until(
|
||||
selectedDemoConfig.then(
|
||||
(conf) => html`
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
import "@polymer/paper-styles/typography";
|
||||
import "@polymer/polymer/lib/elements/dom-if";
|
||||
import "@polymer/polymer/lib/elements/dom-repeat";
|
||||
|
||||
import "../../src/resources/hass-icons";
|
||||
import "../../src/resources/ha-style";
|
||||
import "../../src/resources/roboto";
|
||||
import "../../src/components/ha-iconset-svg";
|
||||
|
||||
import "../../src/resources/ha-style";
|
||||
import "../../src/resources/hass-icons";
|
||||
import "../../src/resources/roboto";
|
||||
import "./ha-demo";
|
||||
import "./resources/hademo-icons";
|
||||
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
import { HomeAssistantAppEl } from "../../src/layouts/home-assistant";
|
||||
import {
|
||||
provideHass,
|
||||
MockHomeAssistant,
|
||||
} from "../../src/fake_data/provide_hass";
|
||||
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
|
||||
import { navigate } from "../../src/common/navigate";
|
||||
import { mockLovelace } from "./stubs/lovelace";
|
||||
import { mockAuth } from "./stubs/auth";
|
||||
import {
|
||||
MockHomeAssistant,
|
||||
provideHass,
|
||||
} from "../../src/fake_data/provide_hass";
|
||||
import { HomeAssistantAppEl } from "../../src/layouts/home-assistant";
|
||||
import { HomeAssistant } from "../../src/types";
|
||||
import { selectedDemoConfig } from "./configs/demo-configs";
|
||||
import { mockTranslations } from "./stubs/translations";
|
||||
import { mockAuth } from "./stubs/auth";
|
||||
import { mockEvents } from "./stubs/events";
|
||||
import { mockFrontend } from "./stubs/frontend";
|
||||
import { mockHistory } from "./stubs/history";
|
||||
import { mockLovelace } from "./stubs/lovelace";
|
||||
import { mockMediaPlayer } from "./stubs/media_player";
|
||||
import { mockPersistentNotification } from "./stubs/persistent_notification";
|
||||
import { mockShoppingList } from "./stubs/shopping_list";
|
||||
import { mockSystemLog } from "./stubs/system_log";
|
||||
import { mockTemplate } from "./stubs/template";
|
||||
import { mockEvents } from "./stubs/events";
|
||||
import { mockMediaPlayer } from "./stubs/media_player";
|
||||
import { HomeAssistant } from "../../src/types";
|
||||
import { mockFrontend } from "./stubs/frontend";
|
||||
import { mockPersistentNotification } from "./stubs/persistent_notification";
|
||||
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
|
||||
import { mockTranslations } from "./stubs/translations";
|
||||
|
||||
class HaDemo extends HomeAssistantAppEl {
|
||||
protected async _initialize() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
|
||||
interface HistoryQueryParams {
|
||||
filter_entity_id: string;
|
||||
@ -95,7 +95,7 @@ export const mockHistory = (mockHass: MockHomeAssistant) => {
|
||||
const numberState = Number(state.state);
|
||||
|
||||
if (isNaN(numberState)) {
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
console.log(
|
||||
"Ignoring state with unparsable state but with a unit",
|
||||
entityId,
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
import "../custom-cards/ha-demo-card";
|
||||
import "../custom-cards/cast-demo-row";
|
||||
// Not duplicate, one is for typing.
|
||||
// tslint:disable-next-line
|
||||
import { HADemoCard } from "../custom-cards/ha-demo-card";
|
||||
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
import type { LocalizeFunc } from "../../../src/common/translations/localize";
|
||||
import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
import { selectedDemoConfig } from "../configs/demo-configs";
|
||||
import { LocalizeFunc } from "../../../src/common/translations/localize";
|
||||
import "../custom-cards/cast-demo-row";
|
||||
import "../custom-cards/ha-demo-card";
|
||||
import type { HADemoCard } from "../custom-cards/ha-demo-card";
|
||||
|
||||
export const mockLovelace = (
|
||||
hass: MockHomeAssistant,
|
||||
@ -22,12 +20,12 @@ export const mockLovelace = (
|
||||
};
|
||||
|
||||
customElements.whenDefined("hui-view").then(() => {
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
const HUIView = customElements.get("hui-view");
|
||||
// Patch HUI-VIEW to make the lovelace object available to the demo card
|
||||
const oldCreateCard = HUIView.prototype.createCardElement;
|
||||
|
||||
HUIView.prototype.createCardElement = function(config) {
|
||||
HUIView.prototype.createCardElement = function (config) {
|
||||
const el = oldCreateCard.call(this, config);
|
||||
if (el.tagName === "HA-DEMO-CARD") {
|
||||
(el as HADemoCard).lovelace = this.lovelace;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
import { PersistentNotification } from "../../../src/data/persistent_notification";
|
||||
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
|
||||
export const mockPersistentNotification = (hass: MockHomeAssistant) => {
|
||||
hass.mockWS("persistent_notification/get", () =>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
import { ShoppingListItem } from "../../../src/data/shopping-list";
|
||||
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
|
||||
let items: ShoppingListItem[] = [
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
import { safeLoad } from "js-yaml";
|
||||
|
||||
import { createCardElement } from "../../../src/panels/lovelace/create-element/create-card-element";
|
||||
|
||||
class DemoCard extends PolymerElement {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
import "@polymer/app-layout/app-toolbar/app-toolbar";
|
||||
|
||||
import "./demo-card";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
import "../../../src/components/ha-switch";
|
||||
import "./demo-card";
|
||||
|
||||
class DemoCards extends PolymerElement {
|
||||
static get template() {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "../../../src/state-summary/state-card-content";
|
||||
import "../../../src/dialogs/more-info/controls/more-info-content";
|
||||
import "../../../src/components/ha-card";
|
||||
import "../../../src/dialogs/more-info/controls/more-info-content";
|
||||
import "../../../src/state-summary/state-card-content";
|
||||
|
||||
class DemoMoreInfo extends PolymerElement {
|
||||
static get template() {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
import "@polymer/app-layout/app-toolbar/app-toolbar";
|
||||
|
||||
import "./demo-more-info";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
import "../../../src/components/ha-switch";
|
||||
import "./demo-more-info";
|
||||
|
||||
class DemoMoreInfos extends PolymerElement {
|
||||
static get template() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
@ -219,9 +219,7 @@ const CONFIGS = [
|
||||
|
||||
class DemoEntities extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<demo-cards id="demos" configs="[[_configs]]"></demo-cards>
|
||||
`;
|
||||
return html` <demo-cards id="demos" configs="[[_configs]]"></demo-cards> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
@ -91,9 +91,7 @@ const CONFIGS = [
|
||||
|
||||
class DemoFilter extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<demo-cards id="demos" configs="[[_configs]]"></demo-cards>
|
||||
`;
|
||||
return html` <demo-cards id="demos" configs="[[_configs]]"></demo-cards> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "../components/demo-cards";
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
|
||||
const ENTITIES = [
|
||||
getEntity("sensor", "brightness", "12", {}),
|
||||
@ -78,9 +78,7 @@ const CONFIGS = [
|
||||
|
||||
class DemoGaugeEntity extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<demo-cards id="demos" configs="[[_configs]]"></demo-cards>
|
||||
`;
|
||||
return html` <demo-cards id="demos" configs="[[_configs]]"></demo-cards> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
@ -220,9 +220,7 @@ const CONFIGS = [
|
||||
|
||||
class DemoPicEntity extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<demo-cards id="demos" configs="[[_configs]]"></demo-cards>
|
||||
`;
|
||||
return html` <demo-cards id="demos" configs="[[_configs]]"></demo-cards> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "../components/demo-cards";
|
||||
|
||||
const CONFIGS = [
|
||||
@ -39,9 +39,7 @@ const CONFIGS = [
|
||||
|
||||
class DemoIframe extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<demo-cards configs="[[_configs]]"></demo-cards>
|
||||
`;
|
||||
return html` <demo-cards configs="[[_configs]]"></demo-cards> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
@ -51,9 +51,7 @@ const CONFIGS = [
|
||||
|
||||
class DemoLightEntity extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<demo-cards id="demos" configs="[[_configs]]"></demo-cards>
|
||||
`;
|
||||
return html` <demo-cards id="demos" configs="[[_configs]]"></demo-cards> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "../components/demo-cards";
|
||||
|
||||
const CONFIGS = [
|
||||
@ -254,9 +254,7 @@ const CONFIGS = [
|
||||
|
||||
class DemoMarkdown extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<demo-cards configs="[[_configs]]"></demo-cards>
|
||||
`;
|
||||
return html` <demo-cards configs="[[_configs]]"></demo-cards> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
import { createMediaPlayerEntities } from "../data/media_players";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
import { createMediaPlayerEntities } from "../data/media_players";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
@ -129,9 +129,7 @@ const CONFIGS = [
|
||||
|
||||
class DemoPicElements extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<demo-cards id="demos" configs="[[_configs]]"></demo-cards>
|
||||
`;
|
||||
return html` <demo-cards id="demos" configs="[[_configs]]"></demo-cards> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "../components/demo-cards";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
|
||||
const ENTITIES = [
|
||||
getEntity("light", "kitchen_lights", "on", {
|
||||
@ -82,9 +82,7 @@ const CONFIGS = [
|
||||
|
||||
class DemoPicEntity extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<demo-cards id="demos" configs="[[_configs]]"></demo-cards>
|
||||
`;
|
||||
return html` <demo-cards id="demos" configs="[[_configs]]"></demo-cards> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "../components/demo-cards";
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
|
||||
const ENTITIES = [
|
||||
getEntity("switch", "decorative_lights", "on", {
|
||||
@ -123,9 +123,7 @@ const CONFIGS = [
|
||||
|
||||
class DemoPicGlance extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<demo-cards id="demos" configs="[[_configs]]"></demo-cards>
|
||||
`;
|
||||
return html` <demo-cards id="demos" configs="[[_configs]]"></demo-cards> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
|
||||
@ -22,9 +22,7 @@ const CONFIGS = [
|
||||
|
||||
class DemoShoppingListEntity extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<demo-cards id="demos" configs="[[_configs]]"></demo-cards>
|
||||
`;
|
||||
return html` <demo-cards id="demos" configs="[[_configs]]"></demo-cards> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
@ -93,9 +93,7 @@ const CONFIGS = [
|
||||
|
||||
class DemoStack extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<demo-cards id="demos" configs="[[_configs]]"></demo-cards>
|
||||
`;
|
||||
return html` <demo-cards id="demos" configs="[[_configs]]"></demo-cards> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
import "../components/demo-cards";
|
||||
@ -76,9 +76,7 @@ const CONFIGS = [
|
||||
|
||||
class DemoThermostatEntity extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<demo-cards id="demos" configs="[[_configs]]"></demo-cards>
|
||||
`;
|
||||
return html` <demo-cards id="demos" configs="[[_configs]]"></demo-cards> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "../../../src/dialogs/more-info/controls/more-info-content";
|
||||
import "../../../src/components/ha-card";
|
||||
|
||||
import { SUPPORT_BRIGHTNESS } from "../../../src/data/light";
|
||||
import "../../../src/dialogs/more-info/controls/more-info-content";
|
||||
import { getEntity } from "../../../src/fake_data/entity";
|
||||
import { provideHass } from "../../../src/fake_data/provide_hass";
|
||||
|
||||
import "../components/demo-more-infos";
|
||||
import { SUPPORT_BRIGHTNESS } from "../../../src/data/light";
|
||||
|
||||
const ENTITIES = [
|
||||
getEntity("light", "bed_light", "on", {
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { html, LitElement, TemplateResult } from "lit-element";
|
||||
import "@material/mwc-button";
|
||||
|
||||
import { html, LitElement, TemplateResult } from "lit-element";
|
||||
import "../../../src/components/ha-card";
|
||||
import { actionHandler } from "../../../src/panels/lovelace/common/directives/action-handler-directive";
|
||||
import { ActionHandlerEvent } from "../../../src/data/lovelace";
|
||||
import { actionHandler } from "../../../src/panels/lovelace/common/directives/action-handler-directive";
|
||||
|
||||
export class DemoUtilLongPress extends LitElement {
|
||||
protected render(): TemplateResult {
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
import "@polymer/paper-styles/typography";
|
||||
import "@polymer/polymer/lib/elements/dom-if";
|
||||
import "@polymer/polymer/lib/elements/dom-repeat";
|
||||
|
||||
import "../../src/resources/hass-icons";
|
||||
import "../../src/resources/ha-style";
|
||||
import "../../src/resources/roboto";
|
||||
import "../../src/components/ha-iconset-svg";
|
||||
|
||||
import "../../src/resources/ha-style";
|
||||
import "../../src/resources/hass-icons";
|
||||
import "../../src/resources/roboto";
|
||||
import "./ha-gallery";
|
||||
|
||||
document.body.appendChild(document.createElement("ha-gallery"));
|
||||
|
||||
@ -2,15 +2,16 @@ import "@polymer/app-layout/app-header-layout/app-header-layout";
|
||||
import "@polymer/app-layout/app-header/app-header";
|
||||
import "@polymer/app-layout/app-toolbar/app-toolbar";
|
||||
import "@polymer/iron-icon/iron-icon";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import "@polymer/paper-item/paper-item";
|
||||
import "@polymer/paper-item/paper-item-body";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "../../src/managers/notification-manager";
|
||||
import "../../src/components/ha-card";
|
||||
import "../../src/managers/notification-manager";
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
const DEMOS = require.context("./demos", true, /^(.*\.(ts$))[^.]*$/im);
|
||||
|
||||
const fixPath = (path) => path.substr(2, path.length - 5);
|
||||
|
||||
@ -1,29 +1,31 @@
|
||||
import "@polymer/paper-card/paper-card";
|
||||
import {
|
||||
css,
|
||||
TemplateResult,
|
||||
CSSResultArray,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
CSSResultArray,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import "@polymer/paper-card/paper-card";
|
||||
import memoizeOne from "memoize-one";
|
||||
|
||||
import "../components/hassio-card-content";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { atLeastVersion } from "../../../src/common/config/version";
|
||||
import { navigate } from "../../../src/common/navigate";
|
||||
import {
|
||||
HassioAddonInfo,
|
||||
HassioAddonRepository,
|
||||
} from "../../../src/data/hassio/addon";
|
||||
import { navigate } from "../../../src/common/navigate";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import "../components/hassio-card-content";
|
||||
import { filterAndSort } from "../components/hassio-filter-addons";
|
||||
import { atLeastVersion } from "../../../src/common/config/version";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
|
||||
class HassioAddonRepositoryEl extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public repo!: HassioAddonRepository;
|
||||
|
||||
@property() public addons!: HassioAddonInfo[];
|
||||
|
||||
@property() public filter!: string;
|
||||
|
||||
private _getAddons = memoizeOne(
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
import "./hassio-addon-repository";
|
||||
import "./hassio-repositories-editor";
|
||||
import { TemplateResult, html } from "lit-html";
|
||||
import {
|
||||
LitElement,
|
||||
CSSResult,
|
||||
css,
|
||||
CSSResult,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
} from "lit-element";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { html, TemplateResult } from "lit-html";
|
||||
import {
|
||||
HassioAddonRepository,
|
||||
HassioAddonInfo,
|
||||
fetchHassioAddonsInfo,
|
||||
HassioAddonInfo,
|
||||
HassioAddonRepository,
|
||||
reloadHassioAddons,
|
||||
} from "../../../src/data/hassio/addon";
|
||||
import "../../../src/layouts/loading-screen";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import "../components/hassio-search-input";
|
||||
import "./hassio-addon-repository";
|
||||
import "./hassio-repositories-editor";
|
||||
|
||||
const sortRepos = (a: HassioAddonRepository, b: HassioAddonRepository) => {
|
||||
if (a.slug === "local") {
|
||||
@ -36,8 +36,11 @@ const sortRepos = (a: HassioAddonRepository, b: HassioAddonRepository) => {
|
||||
|
||||
class HassioAddonStore extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() private _addons?: HassioAddonInfo[];
|
||||
|
||||
@property() private _repos?: HassioAddonRepository[];
|
||||
|
||||
@property() private _filter?: string;
|
||||
|
||||
public async refreshData() {
|
||||
@ -50,9 +53,7 @@ class HassioAddonStore extends LitElement {
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (!this._addons || !this._repos) {
|
||||
return html`
|
||||
<loading-screen></loading-screen>
|
||||
`;
|
||||
return html` <loading-screen></loading-screen> `;
|
||||
}
|
||||
const repos: TemplateResult[] = [];
|
||||
|
||||
|
||||
@ -1,30 +1,31 @@
|
||||
import {
|
||||
LitElement,
|
||||
html,
|
||||
CSSResultArray,
|
||||
css,
|
||||
property,
|
||||
TemplateResult,
|
||||
customElement,
|
||||
PropertyValues,
|
||||
} from "lit-element";
|
||||
import "@polymer/iron-icon/iron-icon";
|
||||
import "@polymer/paper-card/paper-card";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import {
|
||||
css,
|
||||
CSSResultArray,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { repeat } from "lit-html/directives/repeat";
|
||||
import memoizeOne from "memoize-one";
|
||||
|
||||
import "../../../src/components/buttons/ha-call-api-button";
|
||||
import "../components/hassio-card-content";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { HassioAddonRepository } from "../../../src/data/hassio/addon";
|
||||
import { PolymerChangedEvent } from "../../../src/polymer-types";
|
||||
import { repeat } from "lit-html/directives/repeat";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import "../components/hassio-card-content";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
|
||||
@customElement("hassio-repositories-editor")
|
||||
class HassioRepositoriesEditor extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public repos!: HassioAddonRepository[];
|
||||
|
||||
@property() private _repoUrl = "";
|
||||
|
||||
private _sortedRepos = memoizeOne((repos: HassioAddonRepository[]) =>
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
import "web-animations-js/web-animations-next-lite.min";
|
||||
|
||||
import "@material/mwc-button";
|
||||
import "@polymer/paper-card/paper-card";
|
||||
import "@polymer/paper-dropdown-menu/paper-dropdown-menu";
|
||||
@ -15,39 +13,41 @@ import {
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import "web-animations-js/web-animations-next-lite.min";
|
||||
import {
|
||||
HassioAddonDetails,
|
||||
setHassioAddonOption,
|
||||
HassioAddonSetOptionParams,
|
||||
setHassioAddonOption,
|
||||
} from "../../../src/data/hassio/addon";
|
||||
import {
|
||||
HassioHardwareAudioDevice,
|
||||
fetchHassioHardwareAudio,
|
||||
HassioHardwareAudioDevice,
|
||||
} from "../../../src/data/hassio/hardware";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
|
||||
@customElement("hassio-addon-audio")
|
||||
class HassioAddonAudio extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public addon!: HassioAddonDetails;
|
||||
|
||||
@property() private _error?: string;
|
||||
|
||||
@property() private _inputDevices?: HassioHardwareAudioDevice[];
|
||||
|
||||
@property() private _outputDevices?: HassioHardwareAudioDevice[];
|
||||
|
||||
@property() private _selectedInput!: null | string;
|
||||
|
||||
@property() private _selectedOutput!: null | string;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<paper-card heading="Audio">
|
||||
<div class="card-content">
|
||||
${this._error
|
||||
? html`
|
||||
<div class="errors">${this._error}</div>
|
||||
`
|
||||
: ""}
|
||||
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
||||
|
||||
<paper-dropdown-menu
|
||||
label="Input"
|
||||
@ -59,13 +59,13 @@ class HassioAddonAudio extends LitElement {
|
||||
.selected=${this._selectedInput}
|
||||
>
|
||||
${this._inputDevices &&
|
||||
this._inputDevices.map((item) => {
|
||||
return html`
|
||||
<paper-item device=${item.device || ""}
|
||||
>${item.name}</paper-item
|
||||
>
|
||||
`;
|
||||
})}
|
||||
this._inputDevices.map((item) => {
|
||||
return html`
|
||||
<paper-item device=${item.device || ""}
|
||||
>${item.name}</paper-item
|
||||
>
|
||||
`;
|
||||
})}
|
||||
</paper-listbox>
|
||||
</paper-dropdown-menu>
|
||||
<paper-dropdown-menu
|
||||
@ -78,13 +78,13 @@ class HassioAddonAudio extends LitElement {
|
||||
.selected=${this._selectedOutput}
|
||||
>
|
||||
${this._outputDevices &&
|
||||
this._outputDevices.map((item) => {
|
||||
return html`
|
||||
<paper-item device=${item.device || ""}
|
||||
>${item.name}</paper-item
|
||||
>
|
||||
`;
|
||||
})}
|
||||
this._outputDevices.map((item) => {
|
||||
return html`
|
||||
<paper-item device=${item.device || ""}
|
||||
>${item.name}</paper-item
|
||||
>
|
||||
`;
|
||||
})}
|
||||
</paper-listbox>
|
||||
</paper-dropdown-menu>
|
||||
</div>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import "@polymer/iron-autogrow-textarea/iron-autogrow-textarea";
|
||||
import "@material/mwc-button";
|
||||
import "@polymer/iron-autogrow-textarea/iron-autogrow-textarea";
|
||||
import "@polymer/paper-card/paper-card";
|
||||
import {
|
||||
css,
|
||||
@ -9,29 +9,30 @@ import {
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import {
|
||||
HassioAddonDetails,
|
||||
setHassioAddonOption,
|
||||
HassioAddonSetOptionParams,
|
||||
} from "../../../src/data/hassio/addon";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||
import "../../../src/components/ha-yaml-editor";
|
||||
// tslint:disable-next-line: no-duplicate-imports
|
||||
import { HaYamlEditor } from "../../../src/components/ha-yaml-editor";
|
||||
import type { HaYamlEditor } from "../../../src/components/ha-yaml-editor";
|
||||
import {
|
||||
HassioAddonDetails,
|
||||
HassioAddonSetOptionParams,
|
||||
setHassioAddonOption,
|
||||
} from "../../../src/data/hassio/addon";
|
||||
import { showConfirmationDialog } from "../../../src/dialogs/generic/show-dialog-box";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import type { HomeAssistant } from "../../../src/types";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
|
||||
@customElement("hassio-addon-config")
|
||||
class HassioAddonConfig extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public addon!: HassioAddonDetails;
|
||||
|
||||
@property() private _error?: string;
|
||||
|
||||
@property({ type: Boolean }) private _configHasChanged = false;
|
||||
|
||||
@query("ha-yaml-editor") private _editor!: HaYamlEditor;
|
||||
@ -47,16 +48,8 @@ class HassioAddonConfig extends LitElement {
|
||||
<ha-yaml-editor
|
||||
@value-changed=${this._configChanged}
|
||||
></ha-yaml-editor>
|
||||
${this._error
|
||||
? html`
|
||||
<div class="errors">${this._error}</div>
|
||||
`
|
||||
: ""}
|
||||
${valid
|
||||
? ""
|
||||
: html`
|
||||
<div class="errors">Invalid YAML</div>
|
||||
`}
|
||||
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
||||
${valid ? "" : html` <div class="errors">Invalid YAML</div> `}
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
<mwc-button class="warning" @click=${this._resetTapped}>
|
||||
@ -140,8 +133,9 @@ class HassioAddonConfig extends LitElement {
|
||||
};
|
||||
fireEvent(this, "hass-api-called", eventdata);
|
||||
} catch (err) {
|
||||
this._error = `Failed to reset addon configuration, ${err.body?.message ||
|
||||
err}`;
|
||||
this._error = `Failed to reset addon configuration, ${
|
||||
err.body?.message || err
|
||||
}`;
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,8 +160,9 @@ class HassioAddonConfig extends LitElement {
|
||||
};
|
||||
fireEvent(this, "hass-api-called", eventdata);
|
||||
} catch (err) {
|
||||
this._error = `Failed to save addon configuration, ${err.body?.message ||
|
||||
err}`;
|
||||
this._error = `Failed to save addon configuration, ${
|
||||
err.body?.message || err
|
||||
}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,31 +12,29 @@ import {
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
|
||||
import { atLeastVersion } from "../../../src/common/config/version";
|
||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||
import { navigate } from "../../../src/common/navigate";
|
||||
import "../../../src/components/buttons/ha-call-api-button";
|
||||
import "../../../src/components/buttons/ha-progress-button";
|
||||
import "../../../src/components/ha-label-badge";
|
||||
import "../../../src/components/ha-markdown";
|
||||
import "../../../src/components/ha-switch";
|
||||
import "../components/hassio-card-content";
|
||||
|
||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||
import {
|
||||
fetchHassioAddonChangelog,
|
||||
HassioAddonDetails,
|
||||
HassioAddonSetOptionParams,
|
||||
HassioAddonSetSecurityParams,
|
||||
installHassioAddon,
|
||||
setHassioAddonOption,
|
||||
setHassioAddonSecurity,
|
||||
uninstallHassioAddon,
|
||||
installHassioAddon,
|
||||
fetchHassioAddonChangelog,
|
||||
} from "../../../src/data/hassio/addon";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { navigate } from "../../../src/common/navigate";
|
||||
import "../components/hassio-card-content";
|
||||
import { showHassioMarkdownDialog } from "../dialogs/markdown/show-dialog-hassio-markdown";
|
||||
import { atLeastVersion } from "../../../src/common/config/version";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
|
||||
const PERMIS_DESC = {
|
||||
rating: {
|
||||
@ -94,8 +92,11 @@ const PERMIS_DESC = {
|
||||
@customElement("hassio-addon-info")
|
||||
class HassioAddonInfo extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public addon!: HassioAddonDetails;
|
||||
|
||||
@property() private _error?: string;
|
||||
|
||||
@property({ type: Boolean }) private _installing = false;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
@ -178,9 +179,7 @@ class HassioAddonInfo extends LitElement {
|
||||
></iron-icon>
|
||||
`}
|
||||
`
|
||||
: html`
|
||||
${this.addon.version_latest}
|
||||
`}
|
||||
: html` ${this.addon.version_latest} `}
|
||||
</div>
|
||||
</div>
|
||||
<div class="description light-color">
|
||||
@ -379,11 +378,7 @@ class HassioAddonInfo extends LitElement {
|
||||
: ""}
|
||||
`
|
||||
: ""}
|
||||
${this._error
|
||||
? html`
|
||||
<div class="errors">${this._error}</div>
|
||||
`
|
||||
: ""}
|
||||
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
${this.addon.version
|
||||
@ -721,8 +716,9 @@ class HassioAddonInfo extends LitElement {
|
||||
};
|
||||
fireEvent(this, "hass-api-called", eventdata);
|
||||
} catch (err) {
|
||||
this._error = `Failed to set addon security option, ${err.body?.message ||
|
||||
err}`;
|
||||
this._error = `Failed to set addon security option, ${
|
||||
err.body?.message || err
|
||||
}`;
|
||||
}
|
||||
}
|
||||
|
||||
@ -756,8 +752,9 @@ class HassioAddonInfo extends LitElement {
|
||||
content,
|
||||
});
|
||||
} catch (err) {
|
||||
this._error = `Failed to get addon changelog, ${err.body?.message ||
|
||||
err}`;
|
||||
this._error = `Failed to get addon changelog, ${
|
||||
err.body?.message || err
|
||||
}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,23 +7,26 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import {
|
||||
HassioAddonDetails,
|
||||
fetchHassioAddonLogs,
|
||||
HassioAddonDetails,
|
||||
} from "../../../src/data/hassio/addon";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { ANSI_HTML_STYLE, parseTextToColoredPre } from "../ansi-to-html";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
|
||||
@customElement("hassio-addon-logs")
|
||||
class HassioAddonLogs extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public addon!: HassioAddonDetails;
|
||||
|
||||
@property() private _error?: string;
|
||||
|
||||
@query("#content") private _logContent!: any;
|
||||
|
||||
public async connectedCallback(): Promise<void> {
|
||||
@ -34,11 +37,7 @@ class HassioAddonLogs extends LitElement {
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<paper-card heading="Log">
|
||||
${this._error
|
||||
? html`
|
||||
<div class="errors">${this._error}</div>
|
||||
`
|
||||
: ""}
|
||||
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
||||
<div class="card-content" id="content"></div>
|
||||
<div class="card-actions">
|
||||
<mwc-button @click=${this._refresh}>Refresh</mwc-button>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import "@polymer/paper-card/paper-card";
|
||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
@ -9,18 +10,15 @@ import {
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||
import {
|
||||
HassioAddonDetails,
|
||||
HassioAddonSetOptionParams,
|
||||
setHassioAddonOption,
|
||||
} from "../../../src/data/hassio/addon";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
|
||||
interface NetworkItem {
|
||||
description: string;
|
||||
@ -35,8 +33,11 @@ interface NetworkItemInput extends PaperInputElement {
|
||||
@customElement("hassio-addon-network")
|
||||
class HassioAddonNetwork extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public addon!: HassioAddonDetails;
|
||||
|
||||
@property() private _error?: string;
|
||||
|
||||
@property() private _config?: NetworkItem[];
|
||||
|
||||
public connectedCallback(): void {
|
||||
@ -52,11 +53,7 @@ class HassioAddonNetwork extends LitElement {
|
||||
return html`
|
||||
<paper-card heading="Network">
|
||||
<div class="card-content">
|
||||
${this._error
|
||||
? html`
|
||||
<div class="errors">${this._error}</div>
|
||||
`
|
||||
: ""}
|
||||
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
@ -164,8 +161,9 @@ class HassioAddonNetwork extends LitElement {
|
||||
};
|
||||
fireEvent(this, "hass-api-called", eventdata);
|
||||
} catch (err) {
|
||||
this._error = `Failed to set addon network configuration, ${err.body
|
||||
?.message || err}`;
|
||||
this._error = `Failed to set addon network configuration, ${
|
||||
err.body?.message || err
|
||||
}`;
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,8 +187,9 @@ class HassioAddonNetwork extends LitElement {
|
||||
};
|
||||
fireEvent(this, "hass-api-called", eventdata);
|
||||
} catch (err) {
|
||||
this._error = `Failed to set addon network configuration, ${err.body
|
||||
?.message || err}`;
|
||||
this._error = `Failed to set addon network configuration, ${
|
||||
err.body?.message || err
|
||||
}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,15 +12,13 @@ import {
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import { HomeAssistant, Route } from "../../../src/types";
|
||||
import {
|
||||
HassioAddonDetails,
|
||||
fetchHassioAddonInfo,
|
||||
HassioAddonDetails,
|
||||
} from "../../../src/data/hassio/addon";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
|
||||
import { HomeAssistant, Route } from "../../../src/types";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import "./hassio-addon-audio";
|
||||
import "./hassio-addon-config";
|
||||
import "./hassio-addon-info";
|
||||
@ -30,14 +28,14 @@ import "./hassio-addon-network";
|
||||
@customElement("hassio-addon-view")
|
||||
class HassioAddonView extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public route!: Route;
|
||||
|
||||
@property() public addon?: HassioAddonDetails;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (!this.addon) {
|
||||
return html`
|
||||
<paper-spinner-lite active></paper-spinner-lite>
|
||||
`;
|
||||
return html` <paper-spinner-lite active></paper-spinner-lite> `;
|
||||
}
|
||||
return html`
|
||||
<hass-subpage header="Hass.io: add-on details" hassio>
|
||||
|
||||
@ -112,7 +112,7 @@ export function parseTextToColoredPre(text) {
|
||||
|
||||
/* eslint-disable no-cond-assign */
|
||||
let match;
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
while ((match = re.exec(text)) !== null) {
|
||||
const j = match!.index;
|
||||
addSpan(text.substring(i, j));
|
||||
|
||||
@ -1,37 +1,44 @@
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
CSSResult,
|
||||
css,
|
||||
property,
|
||||
customElement,
|
||||
} from "lit-element";
|
||||
import "@polymer/iron-icon/iron-icon";
|
||||
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import "../../../src/components/ha-relative-time";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
|
||||
@customElement("hassio-card-content")
|
||||
class HassioCardContent extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public title!: string;
|
||||
|
||||
@property() public description?: string;
|
||||
@property({ type: Boolean }) public available: boolean = true;
|
||||
@property({ type: Boolean }) public showTopbar: boolean = false;
|
||||
|
||||
@property({ type: Boolean }) public available = true;
|
||||
|
||||
@property({ type: Boolean }) public showTopbar = false;
|
||||
|
||||
@property() public topbarClass?: string;
|
||||
|
||||
@property() public datetime?: string;
|
||||
|
||||
@property() public iconTitle?: string;
|
||||
|
||||
@property() public iconClass?: string;
|
||||
|
||||
@property() public icon = "hass:help-circle";
|
||||
|
||||
@property() public iconImage?: string;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
${this.showTopbar
|
||||
? html`
|
||||
<div class="topbar ${this.topbarClass}"></div>
|
||||
`
|
||||
? html` <div class="topbar ${this.topbarClass}"></div> `
|
||||
: ""}
|
||||
${this.iconImage
|
||||
? html`
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { HassioAddonInfo } from "../../../src/data/hassio/addon";
|
||||
import * as Fuse from "fuse.js";
|
||||
import { HassioAddonInfo } from "../../../src/data/hassio/addon";
|
||||
|
||||
export function filterAndSort(addons: HassioAddonInfo[], filter: string) {
|
||||
const options: Fuse.FuseOptions<HassioAddonInfo> = {
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { TemplateResult, html } from "lit-html";
|
||||
import "@material/mwc-button";
|
||||
import "@polymer/iron-icon/iron-icon";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
@ -6,11 +9,8 @@ import {
|
||||
LitElement,
|
||||
property,
|
||||
} from "lit-element";
|
||||
import { html, TemplateResult } from "lit-html";
|
||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||
import "@polymer/iron-icon/iron-icon";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import "@material/mwc-button";
|
||||
|
||||
@customElement("hassio-search-input")
|
||||
class HassioSearchInput extends LitElement {
|
||||
@ -30,16 +30,16 @@ class HassioSearchInput extends LitElement {
|
||||
class="prefix"
|
||||
></iron-icon>
|
||||
${this.filter &&
|
||||
html`
|
||||
<paper-icon-button
|
||||
slot="suffix"
|
||||
class="suffix"
|
||||
@click=${this._clearSearch}
|
||||
icon="hassio:close"
|
||||
alt="Clear"
|
||||
title="Clear"
|
||||
></paper-icon-button>
|
||||
`}
|
||||
html`
|
||||
<paper-icon-button
|
||||
slot="suffix"
|
||||
class="suffix"
|
||||
@click=${this._clearSearch}
|
||||
icon="hassio:close"
|
||||
alt="Clear"
|
||||
title="Clear"
|
||||
></paper-icon-button>
|
||||
`}
|
||||
</paper-input>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@ -8,18 +8,18 @@ import {
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { HassioAddonInfo } from "../../../src/data/hassio/addon";
|
||||
import { navigate } from "../../../src/common/navigate";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import "../components/hassio-card-content";
|
||||
import { atLeastVersion } from "../../../src/common/config/version";
|
||||
import { navigate } from "../../../src/common/navigate";
|
||||
import { HassioAddonInfo } from "../../../src/data/hassio/addon";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import "../components/hassio-card-content";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
|
||||
@customElement("hassio-addons")
|
||||
class HassioAddons extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public addons?: HassioAddonInfo[];
|
||||
|
||||
protected render(): TemplateResult {
|
||||
|
||||
@ -1,27 +1,30 @@
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
CSSResult,
|
||||
css,
|
||||
property,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import "./hassio-addons";
|
||||
import "./hassio-update";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { HassioHassOSInfo } from "../../../src/data/hassio/host";
|
||||
import {
|
||||
HassioSupervisorInfo,
|
||||
HassioHomeAssistantInfo,
|
||||
HassioSupervisorInfo,
|
||||
} from "../../../src/data/hassio/supervisor";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import "./hassio-addons";
|
||||
import "./hassio-update";
|
||||
|
||||
@customElement("hassio-dashboard")
|
||||
class HassioDashboard extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public supervisorInfo!: HassioSupervisorInfo;
|
||||
|
||||
@property() public hassInfo!: HassioHomeAssistantInfo;
|
||||
|
||||
@property() public hassOsInfo!: HassioHassOSInfo;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
|
||||
@ -1,35 +1,36 @@
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
CSSResult,
|
||||
css,
|
||||
property,
|
||||
customElement,
|
||||
} from "lit-element";
|
||||
import "@material/mwc-button";
|
||||
import "@polymer/iron-icon/iron-icon";
|
||||
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import "@polymer/paper-card/paper-card";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import "../../../src/components/buttons/ha-call-api-button";
|
||||
import { HassioHassOSInfo } from "../../../src/data/hassio/host";
|
||||
import {
|
||||
HassioHomeAssistantInfo,
|
||||
HassioSupervisorInfo,
|
||||
} from "../../../src/data/hassio/supervisor";
|
||||
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
|
||||
import "@material/mwc-button";
|
||||
import "@polymer/paper-card/paper-card";
|
||||
import "../../../src/components/buttons/ha-call-api-button";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import "../components/hassio-card-content";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
|
||||
@customElement("hassio-update")
|
||||
export class HassioUpdate extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public hassInfo: HassioHomeAssistantInfo;
|
||||
|
||||
@property() public hassOsInfo?: HassioHassOSInfo;
|
||||
|
||||
@property() public supervisorInfo: HassioSupervisorInfo;
|
||||
|
||||
@property() private _error?: string;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
@ -55,9 +56,7 @@ export class HassioUpdate extends LitElement {
|
||||
return html`
|
||||
<div class="content">
|
||||
${this._error
|
||||
? html`
|
||||
<div class="error">Error: ${this._error}</div>
|
||||
`
|
||||
? html` <div class="error">Error: ${this._error}</div> `
|
||||
: ""}
|
||||
<h1>
|
||||
${updatesAvailable > 1
|
||||
@ -113,7 +112,7 @@ export class HassioUpdate extends LitElement {
|
||||
${icon
|
||||
? html`
|
||||
<div class="icon">
|
||||
<iron-icon .icon="${icon}" />
|
||||
<iron-icon .icon=${icon}></iron-icon>
|
||||
</div>
|
||||
`
|
||||
: ""}
|
||||
@ -138,7 +137,7 @@ export class HassioUpdate extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _apiCalled(ev) {
|
||||
private _apiCalled(ev): void {
|
||||
if (ev.detail.success) {
|
||||
this._error = "";
|
||||
return;
|
||||
@ -146,9 +145,11 @@ export class HassioUpdate extends LitElement {
|
||||
|
||||
const response = ev.detail.response;
|
||||
|
||||
typeof response.body === "object"
|
||||
? (this._error = response.body.message || "Unknown error")
|
||||
: (this._error = response.body);
|
||||
if (typeof response.body === "object") {
|
||||
this._error = response.body.message || "Unknown error";
|
||||
} else {
|
||||
this._error = response.body;
|
||||
}
|
||||
}
|
||||
|
||||
static get styles(): CSSResult[] {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import "@polymer/app-layout/app-toolbar/app-toolbar";
|
||||
import { PaperDialogElement } from "@polymer/paper-dialog";
|
||||
import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import { PaperDialogElement } from "@polymer/paper-dialog";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
@ -9,21 +9,21 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import { hassioStyle } from "../../resources/hassio-style";
|
||||
import { haStyleDialog } from "../../../../src/resources/styles";
|
||||
import { HassioMarkdownDialogParams } from "./show-dialog-hassio-markdown";
|
||||
|
||||
import "../../../../src/components/dialog/ha-paper-dialog";
|
||||
import "../../../../src/components/ha-markdown";
|
||||
import { haStyleDialog } from "../../../../src/resources/styles";
|
||||
import { hassioStyle } from "../../resources/hassio-style";
|
||||
import { HassioMarkdownDialogParams } from "./show-dialog-hassio-markdown";
|
||||
|
||||
@customElement("dialog-hassio-markdown")
|
||||
class HassioMarkdownDialog extends LitElement {
|
||||
@property() public title!: string;
|
||||
|
||||
@property() public content!: string;
|
||||
|
||||
@query("#dialog") private _dialog!: PaperDialogElement;
|
||||
|
||||
public showDialog(params: HassioMarkdownDialogParams) {
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import "@material/mwc-button";
|
||||
import "@polymer/app-layout/app-toolbar/app-toolbar";
|
||||
import "@polymer/iron-icon/iron-icon";
|
||||
import { PaperCheckboxElement } from "@polymer/paper-checkbox/paper-checkbox";
|
||||
import { PaperDialogElement } from "@polymer/paper-dialog";
|
||||
import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import { PaperDialogElement } from "@polymer/paper-dialog";
|
||||
import { PaperCheckboxElement } from "@polymer/paper-checkbox/paper-checkbox";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
@ -13,21 +13,19 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import "../../../../src/components/dialog/ha-paper-dialog";
|
||||
import { getSignedPath } from "../../../../src/data/auth";
|
||||
import {
|
||||
fetchHassioSnapshotInfo,
|
||||
HassioSnapshotDetail,
|
||||
} from "../../../../src/data/hassio/snapshot";
|
||||
import { getSignedPath } from "../../../../src/data/auth";
|
||||
import { HassioSnapshotDialogParams } from "./show-dialog-hassio-snapshot";
|
||||
import { PolymerChangedEvent } from "../../../../src/polymer-types";
|
||||
import { haStyleDialog } from "../../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../../src/types";
|
||||
import { PolymerChangedEvent } from "../../../../src/polymer-types";
|
||||
|
||||
import "../../../../src/components/dialog/ha-paper-dialog";
|
||||
import { HassioSnapshotDialogParams } from "./show-dialog-hassio-snapshot";
|
||||
|
||||
const _computeFolders = (folders) => {
|
||||
const list: Array<{ slug: string; name: string; checked: boolean }> = [];
|
||||
@ -75,13 +73,21 @@ interface FolderItem {
|
||||
@customElement("dialog-hassio-snapshot")
|
||||
class HassioSnapshotDialog extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() private _error?: string;
|
||||
|
||||
@property() private snapshot?: HassioSnapshotDetail;
|
||||
|
||||
@property() private _folders!: FolderItem[];
|
||||
|
||||
@property() private _addons!: AddonItem[];
|
||||
|
||||
@property() private _dialogParams?: HassioSnapshotDialogParams;
|
||||
|
||||
@property() private _snapshotPassword!: string;
|
||||
|
||||
@property() private _restoreHass: boolean | null | undefined = true;
|
||||
|
||||
@query("#dialog") private _dialog!: PaperDialogElement;
|
||||
|
||||
public async showDialog(params: HassioSnapshotDialogParams) {
|
||||
@ -129,8 +135,9 @@ class HassioSnapshotDialog extends LitElement {
|
||||
<div>Home Assistant:</div>
|
||||
<paper-checkbox
|
||||
.checked=${this._restoreHass}
|
||||
@change="${(ev: Event) =>
|
||||
(this._restoreHass = (ev.target as PaperCheckboxElement).checked)}"
|
||||
@change="${(ev: Event) => {
|
||||
this._restoreHass = (ev.target as PaperCheckboxElement).checked;
|
||||
}}"
|
||||
>
|
||||
Home Assistant ${this.snapshot.homeassistant}
|
||||
</paper-checkbox>
|
||||
@ -187,11 +194,7 @@ class HassioSnapshotDialog extends LitElement {
|
||||
></paper-input>
|
||||
`
|
||||
: ""}
|
||||
${this._error
|
||||
? html`
|
||||
<p class="error">Error: ${this._error}</p>
|
||||
`
|
||||
: ""}
|
||||
${this._error ? html` <p class="error">Error: ${this._error}</p> ` : ""}
|
||||
|
||||
<div>Actions:</div>
|
||||
<ul class="buttons">
|
||||
|
||||
@ -1,39 +1,38 @@
|
||||
import { customElement, PropertyValues, property } from "lit-element";
|
||||
import { PolymerElement } from "@polymer/polymer";
|
||||
import "@polymer/paper-icon-button";
|
||||
|
||||
import "../../src/resources/ha-style";
|
||||
import { PolymerElement } from "@polymer/polymer";
|
||||
import { customElement, property, PropertyValues } from "lit-element";
|
||||
import { applyThemesOnElement } from "../../src/common/dom/apply_themes_on_element";
|
||||
import { fireEvent } from "../../src/common/dom/fire_event";
|
||||
import { navigate } from "../../src/common/navigate";
|
||||
import { fetchHassioAddonInfo } from "../../src/data/hassio/addon";
|
||||
import {
|
||||
fetchHassioHassOsInfo,
|
||||
fetchHassioHostInfo,
|
||||
HassioHassOSInfo,
|
||||
HassioHostInfo,
|
||||
} from "../../src/data/hassio/host";
|
||||
import {
|
||||
createHassioSession,
|
||||
fetchHassioHomeAssistantInfo,
|
||||
fetchHassioSupervisorInfo,
|
||||
HassioHomeAssistantInfo,
|
||||
HassioPanelInfo,
|
||||
HassioSupervisorInfo,
|
||||
} from "../../src/data/hassio/supervisor";
|
||||
import {
|
||||
AlertDialogParams,
|
||||
showAlertDialog,
|
||||
} from "../../src/dialogs/generic/show-dialog-box";
|
||||
import { makeDialogManager } from "../../src/dialogs/make-dialog-manager";
|
||||
import {
|
||||
HassRouterPage,
|
||||
RouterOptions,
|
||||
} from "../../src/layouts/hass-router-page";
|
||||
import { HomeAssistant } from "../../src/types";
|
||||
import {
|
||||
fetchHassioSupervisorInfo,
|
||||
fetchHassioHomeAssistantInfo,
|
||||
HassioSupervisorInfo,
|
||||
HassioHomeAssistantInfo,
|
||||
createHassioSession,
|
||||
HassioPanelInfo,
|
||||
} from "../../src/data/hassio/supervisor";
|
||||
import {
|
||||
fetchHassioHostInfo,
|
||||
fetchHassioHassOsInfo,
|
||||
HassioHostInfo,
|
||||
HassioHassOSInfo,
|
||||
} from "../../src/data/hassio/host";
|
||||
import { fetchHassioAddonInfo } from "../../src/data/hassio/addon";
|
||||
import { makeDialogManager } from "../../src/dialogs/make-dialog-manager";
|
||||
import { ProvideHassLitMixin } from "../../src/mixins/provide-hass-lit-mixin";
|
||||
import "../../src/resources/ha-style";
|
||||
import { HomeAssistant } from "../../src/types";
|
||||
// Don't codesplit it, that way the dashboard always loads fast.
|
||||
import "./hassio-pages-with-tabs";
|
||||
import { navigate } from "../../src/common/navigate";
|
||||
import {
|
||||
showAlertDialog,
|
||||
AlertDialogParams,
|
||||
} from "../../src/dialogs/generic/show-dialog-box";
|
||||
|
||||
// The register callback of the IronA11yKeysBehavior inside paper-icon-button
|
||||
// is not called, causing _keyBindings to be uninitiliazed for paper-icon-button,
|
||||
@ -44,7 +43,9 @@ customElements.get("paper-icon-button").prototype._keyBindings = {};
|
||||
@customElement("hassio-main")
|
||||
class HassioMain extends ProvideHassLitMixin(HassRouterPage) {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public panel!: HassioPanelInfo;
|
||||
|
||||
@property() public narrow!: boolean;
|
||||
|
||||
protected routerOptions: RouterOptions = {
|
||||
@ -76,9 +77,13 @@ class HassioMain extends ProvideHassLitMixin(HassRouterPage) {
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@property() private _supervisorInfo: HassioSupervisorInfo;
|
||||
|
||||
@property() private _hostInfo: HassioHostInfo;
|
||||
|
||||
@property() private _hassOsInfo?: HassioHassOSInfo;
|
||||
|
||||
@property() private _hassInfo: HassioHomeAssistantInfo;
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues) {
|
||||
|
||||
@ -1,44 +1,47 @@
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
CSSResultArray,
|
||||
css,
|
||||
customElement,
|
||||
property,
|
||||
} from "lit-element";
|
||||
import "@polymer/app-layout/app-header-layout/app-header-layout";
|
||||
import "@polymer/app-layout/app-header/app-header";
|
||||
import "@polymer/app-layout/app-toolbar/app-toolbar";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import "@polymer/paper-tabs/paper-tab";
|
||||
import "@polymer/paper-tabs/paper-tabs";
|
||||
|
||||
import "../../src/components/ha-menu-button";
|
||||
import "../../src/resources/ha-style";
|
||||
import "./hassio-tabs-router";
|
||||
|
||||
import {
|
||||
css,
|
||||
CSSResultArray,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import scrollToTarget from "../../src/common/dom/scroll-to-target";
|
||||
|
||||
import { navigate } from "../../src/common/navigate";
|
||||
import "../../src/components/ha-menu-button";
|
||||
import { HassioHassOSInfo, HassioHostInfo } from "../../src/data/hassio/host";
|
||||
import {
|
||||
HassioHomeAssistantInfo,
|
||||
HassioSupervisorInfo,
|
||||
} from "../../src/data/hassio/supervisor";
|
||||
import "../../src/resources/ha-style";
|
||||
import { haStyle } from "../../src/resources/styles";
|
||||
import { HomeAssistant, Route } from "../../src/types";
|
||||
import { navigate } from "../../src/common/navigate";
|
||||
import { HassioHostInfo, HassioHassOSInfo } from "../../src/data/hassio/host";
|
||||
import {
|
||||
HassioSupervisorInfo,
|
||||
HassioHomeAssistantInfo,
|
||||
} from "../../src/data/hassio/supervisor";
|
||||
import "./hassio-tabs-router";
|
||||
|
||||
const HAS_REFRESH_BUTTON = ["store", "snapshots"];
|
||||
|
||||
@customElement("hassio-pages-with-tabs")
|
||||
class HassioPagesWithTabs extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public narrow!: boolean;
|
||||
|
||||
@property() public route!: Route;
|
||||
|
||||
@property() public supervisorInfo!: HassioSupervisorInfo;
|
||||
|
||||
@property() public hostInfo!: HassioHostInfo;
|
||||
|
||||
@property() public hassInfo!: HassioHomeAssistantInfo;
|
||||
|
||||
@property() public hassOsInfo!: HassioHassOSInfo;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
|
||||
@ -1,28 +1,32 @@
|
||||
import { PolymerElement } from "@polymer/polymer";
|
||||
import { customElement, property } from "lit-element";
|
||||
import { HassioHassOSInfo, HassioHostInfo } from "../../src/data/hassio/host";
|
||||
import {
|
||||
HassioHomeAssistantInfo,
|
||||
HassioSupervisorInfo,
|
||||
} from "../../src/data/hassio/supervisor";
|
||||
import {
|
||||
HassRouterPage,
|
||||
RouterOptions,
|
||||
} from "../../src/layouts/hass-router-page";
|
||||
import { customElement, property } from "lit-element";
|
||||
import { PolymerElement } from "@polymer/polymer";
|
||||
import { HomeAssistant } from "../../src/types";
|
||||
import "./addon-store/hassio-addon-store";
|
||||
// Don't codesplit it, that way the dashboard always loads fast.
|
||||
import "./dashboard/hassio-dashboard";
|
||||
// Don't codesplit the others, because it breaks the UI when pushed to a Pi
|
||||
import "./snapshots/hassio-snapshots";
|
||||
import "./addon-store/hassio-addon-store";
|
||||
import "./system/hassio-system";
|
||||
import { HassioHostInfo, HassioHassOSInfo } from "../../src/data/hassio/host";
|
||||
import {
|
||||
HassioSupervisorInfo,
|
||||
HassioHomeAssistantInfo,
|
||||
} from "../../src/data/hassio/supervisor";
|
||||
|
||||
@customElement("hassio-tabs-router")
|
||||
class HassioTabsRouter extends HassRouterPage {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public supervisorInfo: HassioSupervisorInfo;
|
||||
|
||||
@property() public hostInfo: HassioHostInfo;
|
||||
|
||||
@property() public hassInfo: HassioHomeAssistantInfo;
|
||||
|
||||
@property() public hassOsInfo!: HassioHassOSInfo;
|
||||
|
||||
protected routerOptions: RouterOptions = {
|
||||
|
||||
@ -1,33 +1,33 @@
|
||||
import {
|
||||
LitElement,
|
||||
customElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
html,
|
||||
PropertyValues,
|
||||
CSSResult,
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { HomeAssistant, Route } from "../../../src/types";
|
||||
import { createHassioSession } from "../../../src/data/hassio/supervisor";
|
||||
import {
|
||||
HassioAddonDetails,
|
||||
fetchHassioAddonInfo,
|
||||
HassioAddonDetails,
|
||||
} from "../../../src/data/hassio/addon";
|
||||
import { createHassioSession } from "../../../src/data/hassio/supervisor";
|
||||
import "../../../src/layouts/hass-loading-screen";
|
||||
import "../../../src/layouts/hass-subpage";
|
||||
import { HomeAssistant, Route } from "../../../src/types";
|
||||
|
||||
@customElement("hassio-ingress-view")
|
||||
class HassioIngressView extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public route!: Route;
|
||||
|
||||
@property() private _addon?: HassioAddonDetails;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (!this._addon) {
|
||||
return html`
|
||||
<hass-loading-screen></hass-loading-screen>
|
||||
`;
|
||||
return html` <hass-loading-screen></hass-loading-screen> `;
|
||||
}
|
||||
|
||||
return html`
|
||||
@ -71,7 +71,7 @@ class HassioIngressView extends LitElement {
|
||||
|
||||
this._addon = addon;
|
||||
} catch (err) {
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
console.error(err);
|
||||
alert(err.message || "Unknown error starting ingress.");
|
||||
history.back();
|
||||
|
||||
@ -1,46 +1,39 @@
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
CSSResultArray,
|
||||
css,
|
||||
property,
|
||||
PropertyValues,
|
||||
customElement,
|
||||
} from "lit-element";
|
||||
import "@material/mwc-button";
|
||||
import "@polymer/paper-card/paper-card";
|
||||
import "@polymer/paper-checkbox/paper-checkbox";
|
||||
import type { PaperCheckboxElement } from "@polymer/paper-checkbox/paper-checkbox";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-radio-button/paper-radio-button";
|
||||
import "@polymer/paper-radio-group/paper-radio-group";
|
||||
|
||||
import "../components/hassio-card-content";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
|
||||
import { showHassioSnapshotDialog } from "../dialogs/snapshot/show-dialog-hassio-snapshot";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import type { PaperRadioGroupElement } from "@polymer/paper-radio-group/paper-radio-group";
|
||||
import {
|
||||
css,
|
||||
CSSResultArray,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||
import {
|
||||
HassioSnapshot,
|
||||
fetchHassioSnapshots,
|
||||
reloadHassioSnapshots,
|
||||
HassioFullSnapshotCreateParams,
|
||||
HassioPartialSnapshotCreateParams,
|
||||
createHassioFullSnapshot,
|
||||
createHassioPartialSnapshot,
|
||||
fetchHassioSnapshots,
|
||||
HassioFullSnapshotCreateParams,
|
||||
HassioPartialSnapshotCreateParams,
|
||||
HassioSnapshot,
|
||||
reloadHassioSnapshots,
|
||||
} from "../../../src/data/hassio/snapshot";
|
||||
import { HassioSupervisorInfo } from "../../../src/data/hassio/supervisor";
|
||||
import { PolymerChangedEvent } from "../../../src/polymer-types";
|
||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||
|
||||
// Not duplicate, used for typing
|
||||
// tslint:disable-next-line
|
||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
// tslint:disable-next-line
|
||||
import { PaperRadioGroupElement } from "@polymer/paper-radio-group/paper-radio-group";
|
||||
// tslint:disable-next-line
|
||||
import { PaperCheckboxElement } from "@polymer/paper-checkbox/paper-checkbox";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import "../components/hassio-card-content";
|
||||
import { showHassioSnapshotDialog } from "../dialogs/snapshot/show-dialog-hassio-snapshot";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
|
||||
interface CheckboxItem {
|
||||
slug: string;
|
||||
@ -51,13 +44,21 @@ interface CheckboxItem {
|
||||
@customElement("hassio-snapshots")
|
||||
class HassioSnapshots extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public supervisorInfo!: HassioSupervisorInfo;
|
||||
|
||||
@property() private _snapshotName = "";
|
||||
|
||||
@property() private _snapshotPassword = "";
|
||||
|
||||
@property() private _snapshotHasPassword = false;
|
||||
|
||||
@property() private _snapshotType: HassioSnapshot["type"] = "full";
|
||||
|
||||
@property() private _snapshots?: HassioSnapshot[] = [];
|
||||
|
||||
@property() private _addonList: CheckboxItem[] = [];
|
||||
|
||||
@property() private _folderList: CheckboxItem[] = [
|
||||
{
|
||||
slug: "homeassistant",
|
||||
@ -68,7 +69,9 @@ class HassioSnapshots extends LitElement {
|
||||
{ slug: "share", name: "Share", checked: true },
|
||||
{ slug: "addons/local", name: "Local add-ons", checked: true },
|
||||
];
|
||||
|
||||
@property() private _creatingSnapshot = false;
|
||||
|
||||
@property() private _error = "";
|
||||
|
||||
public async refreshData() {
|
||||
@ -157,9 +160,7 @@ class HassioSnapshots extends LitElement {
|
||||
`
|
||||
: undefined}
|
||||
${this._error !== ""
|
||||
? html`
|
||||
<p class="error">${this._error}</p>
|
||||
`
|
||||
? html` <p class="error">${this._error}</p> `
|
||||
: undefined}
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
|
||||
@ -9,24 +9,25 @@ import {
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import {
|
||||
HassioHostInfo as HassioHostInfoType,
|
||||
HassioHassOSInfo,
|
||||
} from "../../../src/data/hassio/host";
|
||||
import "../../../src/components/buttons/ha-call-api-button";
|
||||
import { fetchHassioHardwareInfo } from "../../../src/data/hassio/hardware";
|
||||
import {
|
||||
HassioHassOSInfo,
|
||||
HassioHostInfo as HassioHostInfoType,
|
||||
} from "../../../src/data/hassio/host";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { showHassioMarkdownDialog } from "../dialogs/markdown/show-dialog-hassio-markdown";
|
||||
|
||||
import "../../../src/components/buttons/ha-call-api-button";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
|
||||
@customElement("hassio-host-info")
|
||||
class HassioHostInfo extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public hostInfo!: HassioHostInfoType;
|
||||
|
||||
@property() public hassOsInfo!: HassioHassOSInfo;
|
||||
|
||||
@property() private _errors?: string;
|
||||
|
||||
public render(): TemplateResult | void {
|
||||
@ -69,9 +70,7 @@ class HassioHostInfo extends LitElement {
|
||||
`
|
||||
: ""}
|
||||
${this._errors
|
||||
? html`
|
||||
<div class="errors">Error: ${this._errors}</div>
|
||||
`
|
||||
? html` <div class="errors">Error: ${this._errors}</div> `
|
||||
: ""}
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
|
||||
@ -9,23 +9,23 @@ import {
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||
import "../../../src/components/buttons/ha-call-api-button";
|
||||
import {
|
||||
HassioSupervisorInfo as HassioSupervisorInfoType,
|
||||
setSupervisorOption,
|
||||
SupervisorOptions,
|
||||
} from "../../../src/data/hassio/supervisor";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
|
||||
import "../../../src/components/buttons/ha-call-api-button";
|
||||
|
||||
@customElement("hassio-supervisor-info")
|
||||
class HassioSupervisorInfo extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public supervisorInfo!: HassioSupervisorInfoType;
|
||||
|
||||
@property() private _errors?: string;
|
||||
|
||||
public render(): TemplateResult | void {
|
||||
@ -54,9 +54,7 @@ class HassioSupervisorInfo extends LitElement {
|
||||
</tbody>
|
||||
</table>
|
||||
${this._errors
|
||||
? html`
|
||||
<div class="errors">Error: ${this._errors}</div>
|
||||
`
|
||||
? html` <div class="errors">Error: ${this._errors}</div> `
|
||||
: ""}
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
|
||||
@ -7,20 +7,21 @@ import {
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import { ANSI_HTML_STYLE, parseTextToColoredPre } from "../ansi-to-html";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { fetchSupervisorLogs } from "../../../src/data/hassio/supervisor";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
import { fetchSupervisorLogs } from "../../../src/data/hassio/supervisor";
|
||||
import { ANSI_HTML_STYLE, parseTextToColoredPre } from "../ansi-to-html";
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
|
||||
@customElement("hassio-supervisor-log")
|
||||
class HassioSupervisorLog extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() private _error?: string;
|
||||
|
||||
@query("#content") private _logContent!: HTMLDivElement;
|
||||
|
||||
public async connectedCallback(): Promise<void> {
|
||||
@ -31,11 +32,7 @@ class HassioSupervisorLog extends LitElement {
|
||||
public render(): TemplateResult | void {
|
||||
return html`
|
||||
<paper-card>
|
||||
${this._error
|
||||
? html`
|
||||
<div class="errors">${this._error}</div>
|
||||
`
|
||||
: ""}
|
||||
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
||||
<div class="card-content" id="content"></div>
|
||||
<div class="card-actions">
|
||||
<mwc-button @click=${this._refresh}>Refresh</mwc-button>
|
||||
@ -73,8 +70,9 @@ class HassioSupervisorLog extends LitElement {
|
||||
}
|
||||
this._logContent.appendChild(parseTextToColoredPre(content));
|
||||
} catch (err) {
|
||||
this._error = `Failed to get supervisor logs, ${err.body?.message ||
|
||||
err}`;
|
||||
this._error = `Failed to get supervisor logs, ${
|
||||
err.body?.message || err
|
||||
}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,16 +8,14 @@ import {
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import {
|
||||
HassioHostInfo,
|
||||
HassioHassOSInfo,
|
||||
HassioHostInfo,
|
||||
} from "../../../src/data/hassio/host";
|
||||
import { HassioSupervisorInfo } from "../../../src/data/hassio/supervisor";
|
||||
import { haStyle } from "../../../src/resources/styles";
|
||||
import { HomeAssistant } from "../../../src/types";
|
||||
|
||||
import { hassioStyle } from "../resources/hassio-style";
|
||||
import "./hassio-host-info";
|
||||
import "./hassio-supervisor-info";
|
||||
import "./hassio-supervisor-log";
|
||||
@ -25,8 +23,11 @@ import "./hassio-supervisor-log";
|
||||
@customElement("hassio-system")
|
||||
class HassioSystem extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public supervisorInfo!: HassioSupervisorInfo;
|
||||
|
||||
@property() public hostInfo!: HassioHostInfo;
|
||||
|
||||
@property() public hassOsInfo!: HassioHassOSInfo;
|
||||
|
||||
public render(): TemplateResult | void {
|
||||
|
||||
51
package.json
51
package.json
@ -8,8 +8,13 @@
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"build": "script/build_frontend",
|
||||
"lint": "eslint src hassio/src gallery/src && tslint 'src/**/*.ts' 'hassio/src/**/*.ts' 'gallery/src/**/*.ts' 'cast/src/**/*.ts' 'test-mocha/**/*.ts' && tsc",
|
||||
"lint-hassio": "eslint hassio/src && tslint 'hassio/src/**/*.ts'",
|
||||
"lint:eslint": "eslint '{**/src,src}/**/*.{js,ts,html}' --ignore-path .gitignore",
|
||||
"format:eslint": "eslint '{**/src,src}/**/*.{js,ts,html}' --fix --ignore-path .gitignore",
|
||||
"lint:prettier": "prettier '{**/src,src}/**/*.{js,ts,json,css,md}' --check",
|
||||
"format:prettier": "prettier '{**/src,src}/**/*.{js,ts,json,css,md}' --write",
|
||||
"lint:types": "tsc",
|
||||
"lint": "npm run lint:eslint && npm run lint:prettier && npm run lint:types",
|
||||
"format": "npm run format:eslint && npm run format:prettier",
|
||||
"mocha": "node_modules/.bin/ts-mocha -p test-mocha/tsconfig.test.json --opts test-mocha/mocha.opts",
|
||||
"test": "npm run lint && npm run mocha",
|
||||
"docker_build": "sh ./script/docker_run.sh build $npm_package_version",
|
||||
@ -110,17 +115,17 @@
|
||||
"xss": "^1.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.8.4",
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/plugin-external-helpers": "^7.8.3",
|
||||
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
||||
"@babel/plugin-proposal-decorators": "^7.8.3",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.9.5",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
||||
"@babel/plugin-transform-react-jsx": "^7.8.3",
|
||||
"@babel/preset-env": "^7.8.4",
|
||||
"@babel/preset-typescript": "^7.8.3",
|
||||
"@babel/plugin-transform-react-jsx": "^7.9.4",
|
||||
"@babel/preset-env": "^7.9.5",
|
||||
"@babel/preset-typescript": "^7.9.0",
|
||||
"@types/chai": "^4.1.7",
|
||||
"@types/chromecast-caf-receiver": "^3.0.12",
|
||||
"@types/chromecast-caf-sender": "^1.0.1",
|
||||
@ -132,17 +137,22 @@
|
||||
"@types/memoize-one": "4.1.0",
|
||||
"@types/mocha": "^5.2.6",
|
||||
"@types/webspeechapi": "^0.0.29",
|
||||
"babel-loader": "^8.0.5",
|
||||
"@typescript-eslint/eslint-plugin": "^2.28.0",
|
||||
"@typescript-eslint/parser": "^2.28.0",
|
||||
"babel-loader": "^8.1.0",
|
||||
"chai": "^4.2.0",
|
||||
"copy-webpack-plugin": "^5.0.2",
|
||||
"del": "^4.0.0",
|
||||
"eslint": "^6.3.0",
|
||||
"eslint-config-airbnb-base": "^14.0.0",
|
||||
"eslint-config-prettier": "^6.2.0",
|
||||
"eslint-import-resolver-webpack": "^0.11.1",
|
||||
"eslint-plugin-import": "^2.18.2",
|
||||
"eslint-plugin-prettier": "^3.1.0",
|
||||
"eslint-plugin-react": "^7.14.3",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-airbnb-typescript": "^7.2.1",
|
||||
"eslint-config-prettier": "^6.10.1",
|
||||
"eslint-import-resolver-webpack": "^0.12.1",
|
||||
"eslint-plugin-disable": "^2.0.1",
|
||||
"eslint-plugin-import": "^2.20.2",
|
||||
"eslint-plugin-lit": "^1.2.0",
|
||||
"eslint-plugin-prettier": "^3.1.3",
|
||||
"eslint-plugin-react": "^7.19.0",
|
||||
"eslint-plugin-wc": "^1.2.0",
|
||||
"fs-extra": "^7.0.1",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-foreach": "^0.1.0",
|
||||
@ -160,19 +170,16 @@
|
||||
"map-stream": "^0.0.7",
|
||||
"merge-stream": "^1.0.1",
|
||||
"mocha": "^6.0.2",
|
||||
"npm": "^6.14.4",
|
||||
"parse5": "^5.1.0",
|
||||
"prettier": "^1.19.1",
|
||||
"prettier": "^2.0.4",
|
||||
"raw-loader": "^2.0.0",
|
||||
"reify": "^0.18.1",
|
||||
"require-dir": "^1.2.0",
|
||||
"sinon": "^7.3.1",
|
||||
"terser-webpack-plugin": "^1.2.3",
|
||||
"ts-mocha": "^6.0.0",
|
||||
"tslint": "^5.20.1",
|
||||
"tslint-config-prettier": "^1.18.0",
|
||||
"tslint-eslint-rules": "^5.4.0",
|
||||
"tslint-plugin-prettier": "^2.0.1",
|
||||
"typescript": "^3.7.2",
|
||||
"typescript": "^3.8.3",
|
||||
"vinyl-buffer": "^1.0.1",
|
||||
"vinyl-source-stream": "^2.0.0",
|
||||
"web-component-tester": "^6.9.2",
|
||||
|
||||
@ -1,31 +1,39 @@
|
||||
import "@material/mwc-button";
|
||||
import {
|
||||
LitElement,
|
||||
css,
|
||||
CSSResult,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
CSSResult,
|
||||
css,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import "@material/mwc-button";
|
||||
import "../components/ha-form/ha-form";
|
||||
import "../components/ha-markdown";
|
||||
import { litLocalizeLiteMixin } from "../mixins/lit-localize-lite-mixin";
|
||||
import { AuthProvider } from "../data/auth";
|
||||
import {
|
||||
DataEntryFlowStep,
|
||||
DataEntryFlowStepForm,
|
||||
} from "../data/data_entry_flow";
|
||||
import { litLocalizeLiteMixin } from "../mixins/lit-localize-lite-mixin";
|
||||
|
||||
type State = "loading" | "error" | "step";
|
||||
|
||||
class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
||||
@property() public authProvider?: AuthProvider;
|
||||
|
||||
@property() public clientId?: string;
|
||||
|
||||
@property() public redirectUri?: string;
|
||||
|
||||
@property() public oauth2State?: string;
|
||||
|
||||
@property() private _state: State = "loading";
|
||||
|
||||
@property() private _stepData: any = {};
|
||||
|
||||
@property() private _step?: DataEntryFlowStep;
|
||||
|
||||
@property() private _errorMessage?: string;
|
||||
|
||||
protected render() {
|
||||
@ -40,7 +48,7 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
||||
super.firstUpdated(changedProps);
|
||||
|
||||
if (this.clientId == null || this.redirectUri == null) {
|
||||
// tslint:disable-next-line: no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(
|
||||
"clientId and redirectUri must not be null",
|
||||
this.clientId,
|
||||
@ -58,14 +66,14 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
||||
});
|
||||
}
|
||||
|
||||
protected updated(changedProps: PropertyValues) {
|
||||
protected updated(changedProps: PropertyValues): void {
|
||||
super.updated(changedProps);
|
||||
if (changedProps.has("authProvider")) {
|
||||
this._providerChanged(this.authProvider);
|
||||
}
|
||||
}
|
||||
|
||||
private _renderForm() {
|
||||
private _renderForm(): TemplateResult {
|
||||
switch (this._state) {
|
||||
case "step":
|
||||
if (this._step == null) {
|
||||
@ -80,17 +88,15 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
||||
</div>
|
||||
`;
|
||||
case "error":
|
||||
return html`
|
||||
<div class="error">Error: ${this._errorMessage}</div>
|
||||
`;
|
||||
return html` <div class="error">Error: ${this._errorMessage}</div> `;
|
||||
case "loading":
|
||||
return html`
|
||||
${this.localize("ui.panel.page-authorize.form.working")}
|
||||
`;
|
||||
return html` ${this.localize("ui.panel.page-authorize.form.working")} `;
|
||||
default:
|
||||
return html``;
|
||||
}
|
||||
}
|
||||
|
||||
private _renderStep(step: DataEntryFlowStep) {
|
||||
private _renderStep(step: DataEntryFlowStep): TemplateResult {
|
||||
switch (step.type) {
|
||||
case "abort":
|
||||
return html`
|
||||
@ -131,13 +137,13 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
||||
method: "DELETE",
|
||||
credentials: "same-origin",
|
||||
}).catch((err) => {
|
||||
// tslint:disable-next-line: no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.error("Error delete obsoleted auth flow", err);
|
||||
});
|
||||
}
|
||||
|
||||
if (newProvider == null) {
|
||||
// tslint:disable-next-line: no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.error("No auth provider");
|
||||
this._state = "error";
|
||||
this._errorMessage = this._unknownError();
|
||||
@ -170,7 +176,7 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
||||
this._errorMessage = data.message;
|
||||
}
|
||||
} catch (err) {
|
||||
// tslint:disable-next-line: no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.error("Error starting auth flow", err);
|
||||
this._state = "error";
|
||||
this._errorMessage = this._unknownError();
|
||||
@ -287,7 +293,7 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
||||
}
|
||||
await this._updateStep(newStep);
|
||||
} catch (err) {
|
||||
// tslint:disable-next-line: no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.error("Error submitting step", err);
|
||||
this._state = "error";
|
||||
this._errorMessage = this._unknownError();
|
||||
|
||||
@ -1,19 +1,17 @@
|
||||
import { litLocalizeLiteMixin } from "../mixins/lit-localize-lite-mixin";
|
||||
import {
|
||||
LitElement,
|
||||
html,
|
||||
PropertyValues,
|
||||
CSSResult,
|
||||
css,
|
||||
CSSResult,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
} from "lit-element";
|
||||
import "./ha-auth-flow";
|
||||
import { AuthProvider, fetchAuthProviders } from "../data/auth";
|
||||
import { litLocalizeLiteMixin } from "../mixins/lit-localize-lite-mixin";
|
||||
import { registerServiceWorker } from "../util/register-service-worker";
|
||||
import "./ha-auth-flow";
|
||||
|
||||
import(
|
||||
/* webpackChunkName: "pick-auth-provider" */ "../auth/ha-pick-auth-provider"
|
||||
);
|
||||
import(/* webpackChunkName: "pick-auth-provider" */ "./ha-pick-auth-provider");
|
||||
|
||||
interface QueryParams {
|
||||
client_id?: string;
|
||||
@ -23,9 +21,13 @@ interface QueryParams {
|
||||
|
||||
class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
|
||||
@property() public clientId?: string;
|
||||
|
||||
@property() public redirectUri?: string;
|
||||
|
||||
@property() public oauth2State?: string;
|
||||
|
||||
@property() private _authProvider?: AuthProvider;
|
||||
|
||||
@property() private _authProviders?: AuthProvider[];
|
||||
|
||||
constructor() {
|
||||
@ -155,7 +157,7 @@ class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
|
||||
this._authProviders = authProviders;
|
||||
this._authProvider = authProviders[0];
|
||||
} catch (err) {
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
console.error("Error loading auth providers", err);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { LitElement, html, property } from "lit-element";
|
||||
import "@polymer/paper-item/paper-item";
|
||||
import "@polymer/paper-item/paper-item-body";
|
||||
import { litLocalizeLiteMixin } from "../mixins/lit-localize-lite-mixin";
|
||||
import { html, LitElement, property } from "lit-element";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import "../components/ha-icon-next";
|
||||
import { AuthProvider } from "../data/auth";
|
||||
import { litLocalizeLiteMixin } from "../mixins/lit-localize-lite-mixin";
|
||||
|
||||
declare global {
|
||||
interface HASSDomEvents {
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import "@polymer/paper-card/paper-card";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { computeStateName } from "../common/entity/compute_state_name";
|
||||
import "../components/state-history-charts";
|
||||
import "../data/ha-state-history-data";
|
||||
|
||||
import { computeStateName } from "../common/entity/compute_state_name";
|
||||
import { EventsMixin } from "../mixins/events-mixin";
|
||||
|
||||
/*
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
/* eslint-disable no-undef, no-console */
|
||||
import {
|
||||
CastStateEventData,
|
||||
SessionStateEventData,
|
||||
} from "chromecast-caf-receiver/cast.framework";
|
||||
import { Auth } from "home-assistant-js-websocket";
|
||||
import { castApiAvailable } from "./cast_framework";
|
||||
import { CAST_APP_ID, CAST_NS, CAST_DEV } from "./const";
|
||||
import { CAST_APP_ID, CAST_DEV, CAST_NS } from "./const";
|
||||
import { CAST_DEV_HASS_URL } from "./dev_const";
|
||||
import {
|
||||
castSendAuth,
|
||||
HassMessage as ReceiverMessage,
|
||||
} from "./receiver_messages";
|
||||
import {
|
||||
SessionStateEventData,
|
||||
CastStateEventData,
|
||||
// tslint:disable-next-line: no-implicit-dependencies
|
||||
} from "chromecast-caf-receiver/cast.framework";
|
||||
import { SenderMessage, ReceiverStatusMessage } from "./sender_messages";
|
||||
import { Auth } from "home-assistant-js-websocket";
|
||||
import { ReceiverStatusMessage, SenderMessage } from "./sender_messages";
|
||||
|
||||
let managerProm: Promise<CastManager> | undefined;
|
||||
|
||||
@ -29,14 +29,14 @@ a user presses the cast button we send auth if not connected yet, then send
|
||||
command as usual.
|
||||
*/
|
||||
|
||||
/* tslint:disable:no-console */
|
||||
|
||||
type CastEvent = "connection-changed" | "state-changed";
|
||||
|
||||
export class CastManager {
|
||||
public auth?: Auth;
|
||||
|
||||
// If the cast connection is connected to our Hass.
|
||||
public status?: ReceiverStatusMessage;
|
||||
|
||||
private _eventListeners: { [event: string]: CastEventListener[] } = {};
|
||||
|
||||
constructor(auth?: Auth) {
|
||||
|
||||
@ -2,10 +2,9 @@
|
||||
|
||||
import { Auth } from "home-assistant-js-websocket";
|
||||
import { CastManager } from "./cast_manager";
|
||||
|
||||
import { BaseCastMessage } from "./types";
|
||||
import { CAST_DEV } from "./const";
|
||||
import { CAST_DEV_HASS_URL } from "./dev_const";
|
||||
import { BaseCastMessage } from "./types";
|
||||
|
||||
export interface GetStatusMessage extends BaseCastMessage {
|
||||
type: "get_status";
|
||||
@ -60,7 +59,7 @@ export const castSendShowDemo = (cast: CastManager) =>
|
||||
|
||||
export const ensureConnectedCastSession = (cast: CastManager, auth: Auth) => {
|
||||
if (cast.castConnectedToOurHass) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
|
||||
@ -62,7 +62,7 @@ const processTheme = (
|
||||
themes: HomeAssistant["themes"]
|
||||
): ProcessedTheme | undefined => {
|
||||
if (!themes.themes[themeName]) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
const theme: Theme = {
|
||||
...derivedStyles,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { directive, Part, NodePart } from "lit-html";
|
||||
import { directive, NodePart, Part } from "lit-html";
|
||||
|
||||
export const dynamicElement = directive(
|
||||
(tag: string, properties?: { [key: string]: any }) => (part: Part): void => {
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
declare global {
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
interface HASSDomEvents {}
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ export const isNavigationClick = (e: MouseEvent) => {
|
||||
e.ctrlKey ||
|
||||
e.shiftKey
|
||||
) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const anchor = e
|
||||
@ -21,23 +21,23 @@ export const isNavigationClick = (e: MouseEvent) => {
|
||||
anchor.hasAttribute("download") ||
|
||||
anchor.getAttribute("rel") === "external"
|
||||
) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let href = anchor.href;
|
||||
if (!href || href.indexOf("mailto:") !== -1) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const location = window.location;
|
||||
const origin = location.origin || location.protocol + "//" + location.host;
|
||||
if (href.indexOf(origin) !== 0) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
href = href.substr(origin.length);
|
||||
|
||||
if (href === "#") {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
@ -12,7 +12,7 @@ export const setupLeafletMap = async (
|
||||
if (!mapElement.parentNode) {
|
||||
throw new Error("Cannot setup Leaflet map on disconnected element");
|
||||
}
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
const Leaflet = (await import(
|
||||
/* webpackChunkName: "leaflet" */ "leaflet"
|
||||
)) as LeafletModuleType;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-ignore
|
||||
export const SpeechRecognition =
|
||||
// @ts-ignore
|
||||
@ -11,4 +11,4 @@ export const SpeechGrammarList =
|
||||
export const SpeechRecognitionEvent =
|
||||
// @ts-ignore
|
||||
window.SpeechRecognitionEvent || window.webkitSpeechRecognitionEvent;
|
||||
/* tslint:enable */
|
||||
/* eslint-enable */
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { canToggleDomain } from "./can_toggle_domain";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { supportsFeature } from "./supports-feature";
|
||||
|
||||
export const canToggleState = (hass: HomeAssistant, stateObj: HassEntity) => {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
import { formatDateTime } from "../datetime/format_date_time";
|
||||
import { formatDate } from "../datetime/format_date";
|
||||
import { formatDateTime } from "../datetime/format_date_time";
|
||||
import { formatTime } from "../datetime/format_time";
|
||||
import { LocalizeFunc } from "../translations/localize";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
|
||||
export const computeStateDisplay = (
|
||||
localize: LocalizeFunc,
|
||||
|
||||
@ -107,7 +107,7 @@ export const domainIcon = (domain: string, state?: string): string => {
|
||||
}
|
||||
|
||||
default:
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
console.warn(
|
||||
"Unable to find icon for domain " + domain + " (" + state + ")"
|
||||
);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { HassEntities } from "home-assistant-js-websocket";
|
||||
import { DEFAULT_VIEW_ENTITY_ID } from "../const";
|
||||
import { GroupEntity } from "../../types";
|
||||
import { DEFAULT_VIEW_ENTITY_ID } from "../const";
|
||||
|
||||
// Return an ordered array of available views
|
||||
export const extractViews = (entities: HassEntities): GroupEntity[] => {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { HassEntities } from "home-assistant-js-websocket";
|
||||
import { GroupEntity } from "../../types";
|
||||
import { computeDomain } from "./compute_domain";
|
||||
import { getGroupEntities } from "./get_group_entities";
|
||||
import { GroupEntity } from "../../types";
|
||||
|
||||
// Return an object containing all entities that the view will show
|
||||
// including embedded groups.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/** Return an icon representing an input datetime state. */
|
||||
import { domainIcon } from "./domain_icon";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { domainIcon } from "./domain_icon";
|
||||
|
||||
export const inputDateTimeIcon = (state: HassEntity): string => {
|
||||
if (!state.attributes.has_date) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { computeDomain } from "./compute_domain";
|
||||
import { HassEntities } from "home-assistant-js-websocket";
|
||||
import { GroupEntity } from "../../types";
|
||||
import { computeDomain } from "./compute_domain";
|
||||
|
||||
// Split a collection into a list of groups and a 'rest' list of ungrouped
|
||||
// entities.
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { DOMAINS_WITH_CARD } from "../const";
|
||||
import { canToggleState } from "./can_toggle_state";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
import { DOMAINS_WITH_CARD } from "../const";
|
||||
import { HomeAssistant } from "../../types";
|
||||
|
||||
export const stateCardType = (hass: HomeAssistant, stateObj: HassEntity) => {
|
||||
if (stateObj.state === "unavailable") {
|
||||
|
||||
@ -2,12 +2,11 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { DEFAULT_DOMAIN_ICON } from "../const";
|
||||
import { binarySensorIcon } from "./binary_sensor_icon";
|
||||
|
||||
import { computeDomain } from "./compute_domain";
|
||||
import { domainIcon } from "./domain_icon";
|
||||
import { coverIcon } from "./cover_icon";
|
||||
import { sensorIcon } from "./sensor_icon";
|
||||
import { domainIcon } from "./domain_icon";
|
||||
import { inputDateTimeIcon } from "./input_dateteime_icon";
|
||||
import { sensorIcon } from "./sensor_icon";
|
||||
|
||||
const domainIcons = {
|
||||
binary_sensor: binarySensorIcon,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
import { DOMAINS_HIDE_MORE_INFO, DOMAINS_WITH_MORE_INFO } from "../const";
|
||||
import { computeStateDomain } from "./compute_state_domain";
|
||||
|
||||
export const stateMoreInfoType = (stateObj: HassEntity) => {
|
||||
const domain = computeStateDomain(stateObj);
|
||||
|
||||
@ -4,6 +4,6 @@ export const supportsFeature = (
|
||||
stateObj: HassEntity,
|
||||
feature: number
|
||||
): boolean => {
|
||||
// tslint:disable-next-line:no-bitwise
|
||||
// eslint-disable-next-line:no-bitwise
|
||||
return (stateObj.attributes.supported_features! & feature) !== 0;
|
||||
};
|
||||
|
||||
@ -6,7 +6,7 @@ export const isValidEntityId = (entityId: string) =>
|
||||
export const createValidEntityId = (input: string) =>
|
||||
input
|
||||
.toLowerCase()
|
||||
.replace(/\s|\'/g, "_") // replace spaces and quotes with underscore
|
||||
.replace(/\s|'/g, "_") // replace spaces and quotes with underscore
|
||||
.replace(/\W/g, "") // remove not allowed chars
|
||||
.replace(/_{2,}/g, "_") // replace multiple underscores with 1
|
||||
.replace(/_$/, ""); // remove underscores at the end
|
||||
|
||||
@ -9,23 +9,17 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
export const navigate = (
|
||||
_node: any,
|
||||
path: string,
|
||||
replace: boolean = false
|
||||
) => {
|
||||
export const navigate = (_node: any, path: string, replace = false) => {
|
||||
if (__DEMO__) {
|
||||
if (replace) {
|
||||
history.replaceState(null, "", `${location.pathname}#${path}`);
|
||||
} else {
|
||||
window.location.hash = path;
|
||||
}
|
||||
} else if (replace) {
|
||||
history.replaceState(null, "", path);
|
||||
} else {
|
||||
if (replace) {
|
||||
history.replaceState(null, "", path);
|
||||
} else {
|
||||
history.pushState(null, "", path);
|
||||
}
|
||||
history.pushState(null, "", path);
|
||||
}
|
||||
fireEvent(window, "location-changed", {
|
||||
replace,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { TemplateResult, html } from "lit-html";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
@ -6,17 +7,18 @@ import {
|
||||
LitElement,
|
||||
property,
|
||||
} from "lit-element";
|
||||
import { fireEvent } from "../dom/fire_event";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import "../../components/ha-icon";
|
||||
import { html, TemplateResult } from "lit-html";
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
import "../../components/ha-icon";
|
||||
import { fireEvent } from "../dom/fire_event";
|
||||
|
||||
@customElement("search-input")
|
||||
class SearchInput extends LitElement {
|
||||
@property() public filter?: string;
|
||||
|
||||
@property({ type: Boolean, attribute: "no-label-float" })
|
||||
public noLabelFloat? = false;
|
||||
|
||||
@property({ type: Boolean, attribute: "no-underline" })
|
||||
public noUnderline = false;
|
||||
|
||||
@ -44,16 +46,16 @@ class SearchInput extends LitElement {
|
||||
>
|
||||
<ha-icon icon="hass:magnify" slot="prefix" class="prefix"></ha-icon>
|
||||
${this.filter &&
|
||||
html`
|
||||
<paper-icon-button
|
||||
slot="suffix"
|
||||
class="suffix"
|
||||
@click=${this._clearSearch}
|
||||
icon="hass:close"
|
||||
alt="Clear"
|
||||
title="Clear"
|
||||
></paper-icon-button>
|
||||
`}
|
||||
html`
|
||||
<paper-icon-button
|
||||
slot="suffix"
|
||||
class="suffix"
|
||||
@click=${this._clearSearch}
|
||||
icon="hass:close"
|
||||
alt="Clear"
|
||||
title="Clear"
|
||||
></paper-icon-button>
|
||||
`}
|
||||
</paper-input>
|
||||
`;
|
||||
}
|
||||
|
||||
@ -12,8 +12,8 @@ export const slugify = (value: string) => {
|
||||
.replace(/\s+/g, "-") // Replace spaces with -
|
||||
.replace(p, (c) => b.charAt(a.indexOf(c))) // Replace special characters
|
||||
.replace(/&/g, "-and-") // Replace & with 'and'
|
||||
.replace(/[^\w\-]+/g, "") // Remove all non-word characters
|
||||
.replace(/\-\-+/g, "-") // Replace multiple - with single -
|
||||
.replace(/[^\w-]+/g, "") // Remove all non-word characters
|
||||
.replace(/--+/g, "-") // Replace multiple - with single -
|
||||
.replace(/^-+/, "") // Trim - from start of text
|
||||
.replace(/-+$/, ""); // Trim - from end of text
|
||||
};
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
// be triggered. The function will be called after it stops being called for
|
||||
// N milliseconds. If `immediate` is passed, trigger the function on the
|
||||
// leading edge, instead of the trailing.
|
||||
// tslint:disable-next-line: ban-types
|
||||
// eslint-disable-next-line: ban-types
|
||||
export const debounce = <T extends Function>(
|
||||
func: T,
|
||||
wait,
|
||||
@ -12,9 +12,9 @@ export const debounce = <T extends Function>(
|
||||
): T => {
|
||||
let timeout;
|
||||
// @ts-ignore
|
||||
return function(...args) {
|
||||
// tslint:disable:no-this-assignment
|
||||
return function (...args) {
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
const context = this;
|
||||
const later = () => {
|
||||
timeout = null;
|
||||
|
||||
@ -79,8 +79,7 @@ export const deepEqual = (a: any, b: any): boolean => {
|
||||
return a.toString() === b.toString();
|
||||
}
|
||||
|
||||
let keys: string[];
|
||||
keys = Object.keys(a);
|
||||
const keys = Object.keys(a);
|
||||
length = keys.length;
|
||||
if (length !== Object.keys(b).length) {
|
||||
return false;
|
||||
@ -103,5 +102,6 @@ export const deepEqual = (a: any, b: any): boolean => {
|
||||
}
|
||||
|
||||
// true if both NaN, false otherwise
|
||||
// eslint-disable-next-line no-self-compare
|
||||
return a !== a && b !== b;
|
||||
};
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
export const applyPatch = (data, path, value) => {
|
||||
export const applyPatch = (data, path, value): void => {
|
||||
if (path.length === 1) {
|
||||
data[path[0]] = value;
|
||||
} else {
|
||||
if (!data[path[0]]) {
|
||||
data[path[0]] = {};
|
||||
}
|
||||
return applyPatch(data[path[0]], path.slice(1), value);
|
||||
return;
|
||||
}
|
||||
if (!data[path[0]]) {
|
||||
data[path[0]] = {};
|
||||
}
|
||||
// eslint-disable-next-line consistent-return
|
||||
return applyPatch(data[path[0]], path.slice(1), value);
|
||||
};
|
||||
|
||||
export const getPath = (data, path) => {
|
||||
export const getPath = (data, path): any | undefined => {
|
||||
if (path.length === 1) {
|
||||
return data[path[0]];
|
||||
} else {
|
||||
if (data[path[0]] === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return getPath(data[path[0]], path.slice(1));
|
||||
}
|
||||
if (data[path[0]] === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return getPath(data[path[0]], path.slice(1));
|
||||
};
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { UnsubscribeFunc, Connection } from "home-assistant-js-websocket";
|
||||
import { Connection, UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
|
||||
export const subscribeOne = async <T>(
|
||||
conn: Connection,
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { LitElement, html } from "lit-element";
|
||||
|
||||
import "./ha-progress-button";
|
||||
import { html, LitElement } from "lit-element";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import "./ha-progress-button";
|
||||
|
||||
class HaCallApiButton extends LitElement {
|
||||
render() {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "./ha-progress-button";
|
||||
import { EventsMixin } from "../../mixins/events-mixin";
|
||||
import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box";
|
||||
import { EventsMixin } from "../../mixins/events-mixin";
|
||||
import "./ha-progress-button";
|
||||
|
||||
/*
|
||||
* @appliesMixin EventsMixin
|
||||
@ -53,6 +53,7 @@ class HaCallServiceButton extends EventsMixin(PolymerElement) {
|
||||
|
||||
callService() {
|
||||
this.progress = true;
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
var el = this;
|
||||
var eventData = {
|
||||
domain: this.domain,
|
||||
@ -63,18 +64,18 @@ class HaCallServiceButton extends EventsMixin(PolymerElement) {
|
||||
this.hass
|
||||
.callService(this.domain, this.service, this.serviceData)
|
||||
.then(
|
||||
function() {
|
||||
function () {
|
||||
el.progress = false;
|
||||
el.$.progress.actionSuccess();
|
||||
eventData.success = true;
|
||||
},
|
||||
function() {
|
||||
function () {
|
||||
el.progress = false;
|
||||
el.$.progress.actionError();
|
||||
eventData.success = false;
|
||||
}
|
||||
)
|
||||
.then(function() {
|
||||
.then(function () {
|
||||
el.fire("hass-service-called", eventData);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import "@material/mwc-button";
|
||||
import "@polymer/paper-spinner/paper-spinner";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
class HaProgressButton extends PolymerElement {
|
||||
|
||||
@ -1,36 +1,29 @@
|
||||
import deepClone from "deep-clone-simple";
|
||||
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
|
||||
import { scroll } from "lit-virtualizer";
|
||||
|
||||
import {
|
||||
html,
|
||||
query,
|
||||
CSSResult,
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
PropertyValues,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
// eslint-disable-next-line import/no-webpack-loader-syntax
|
||||
// @ts-ignore
|
||||
// tslint:disable-next-line: no-implicit-dependencies
|
||||
import sortFilterWorker from "workerize-loader!./sort_filter_worker";
|
||||
|
||||
import "../ha-icon";
|
||||
import "../../common/search/search-input";
|
||||
import "../ha-checkbox";
|
||||
// tslint:disable-next-line
|
||||
import { HaCheckbox } from "../ha-checkbox";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { nextRender } from "../../common/util/render-status";
|
||||
import { debounce } from "../../common/util/debounce";
|
||||
import { styleMap } from "lit-html/directives/style-map";
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
import { ifDefined } from "lit-html/directives/if-defined";
|
||||
import { styleMap } from "lit-html/directives/style-map";
|
||||
import { scroll } from "lit-virtualizer";
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line import/no-webpack-loader-syntax
|
||||
import sortFilterWorker from "workerize-loader!./sort_filter_worker";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import "../../common/search/search-input";
|
||||
import { debounce } from "../../common/util/debounce";
|
||||
import { nextRender } from "../../common/util/render-status";
|
||||
import "../ha-checkbox";
|
||||
import type { HaCheckbox } from "../ha-checkbox";
|
||||
import "../ha-icon";
|
||||
|
||||
declare global {
|
||||
// for fire event
|
||||
@ -84,28 +77,46 @@ export interface DataTableRowData {
|
||||
@customElement("ha-data-table")
|
||||
export class HaDataTable extends LitElement {
|
||||
@property({ type: Object }) public columns: DataTableColumnContainer = {};
|
||||
|
||||
@property({ type: Array }) public data: DataTableRowData[] = [];
|
||||
|
||||
@property({ type: Boolean }) public selectable = false;
|
||||
|
||||
@property({ type: Boolean }) public hasFab = false;
|
||||
|
||||
@property({ type: Boolean, attribute: "auto-height" })
|
||||
public autoHeight = false;
|
||||
|
||||
@property({ type: String }) public id = "id";
|
||||
|
||||
@property({ type: String }) public noDataText?: string;
|
||||
|
||||
@property({ type: String }) public filter = "";
|
||||
|
||||
@property({ type: Boolean }) private _filterable = false;
|
||||
|
||||
@property({ type: String }) private _filter = "";
|
||||
|
||||
@property({ type: String }) private _sortColumn?: string;
|
||||
|
||||
@property({ type: String }) private _sortDirection: SortingDirection = null;
|
||||
|
||||
@property({ type: Array }) private _filteredData: DataTableRowData[] = [];
|
||||
|
||||
@query("slot[name='header']") private _header!: HTMLSlotElement;
|
||||
|
||||
@query(".mdc-data-table__table") private _table!: HTMLDivElement;
|
||||
|
||||
private _checkableRowsCount?: number;
|
||||
|
||||
private _checkedRows: string[] = [];
|
||||
|
||||
private _sortColumns: {
|
||||
[key: string]: DataTableSortColumnData;
|
||||
} = {};
|
||||
|
||||
private curRequest = 0;
|
||||
|
||||
private _worker: any | undefined;
|
||||
|
||||
private _debounceSearch = debounce(
|
||||
@ -217,9 +228,9 @@ export class HaDataTable extends LitElement {
|
||||
class="mdc-data-table__row-checkbox"
|
||||
@change=${this._handleHeaderRowCheckboxClick}
|
||||
.indeterminate=${this._checkedRows.length &&
|
||||
this._checkedRows.length !== this._checkableRowsCount}
|
||||
this._checkedRows.length !== this._checkableRowsCount}
|
||||
.checked=${this._checkedRows.length ===
|
||||
this._checkableRowsCount}
|
||||
this._checkableRowsCount}
|
||||
>
|
||||
</ha-checkbox>
|
||||
</div>
|
||||
@ -288,9 +299,7 @@ export class HaDataTable extends LitElement {
|
||||
: [...this._filteredData, ...[{ empty: true }]],
|
||||
renderItem: (row: DataTableRowData) => {
|
||||
if (row.empty) {
|
||||
return html`
|
||||
<div class="mdc-data-table__row"></div>
|
||||
`;
|
||||
return html` <div class="mdc-data-table__row"></div> `;
|
||||
}
|
||||
return html`
|
||||
<div
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import memoizeOne from "memoize-one";
|
||||
// eslint-disable-next-line import/no-cycle
|
||||
import {
|
||||
DataTableColumnContainer,
|
||||
DataTableColumnData,
|
||||
@ -5,8 +7,6 @@ import {
|
||||
SortingDirection,
|
||||
} from "./ha-data-table";
|
||||
|
||||
import memoizeOne from "memoize-one";
|
||||
|
||||
export const filterSortData = memoizeOne(
|
||||
async (
|
||||
data: DataTableRowData[],
|
||||
|
||||
@ -1,41 +1,40 @@
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-item/paper-item";
|
||||
import "@polymer/paper-item/paper-item-body";
|
||||
import "@vaadin/vaadin-combo-box/theme/material/vaadin-combo-box-light";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import memoizeOne from "memoize-one";
|
||||
import "@vaadin/vaadin-combo-box/theme/material/vaadin-combo-box-light";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import { SubscribeMixin } from "../../mixins/subscribe-mixin";
|
||||
import "./ha-devices-picker";
|
||||
|
||||
import { HomeAssistant } from "../../types";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import {
|
||||
DeviceRegistryEntry,
|
||||
subscribeDeviceRegistry,
|
||||
DeviceEntityLookup,
|
||||
} from "../../data/device_registry";
|
||||
import { computeDomain } from "../../common/entity/compute_domain";
|
||||
import { compare } from "../../common/string/compare";
|
||||
import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import {
|
||||
AreaRegistryEntry,
|
||||
subscribeAreaRegistry,
|
||||
} from "../../data/area_registry";
|
||||
import {
|
||||
DeviceEntityLookup,
|
||||
DeviceRegistryEntry,
|
||||
subscribeDeviceRegistry,
|
||||
} from "../../data/device_registry";
|
||||
import {
|
||||
EntityRegistryEntry,
|
||||
subscribeEntityRegistry,
|
||||
} from "../../data/entity_registry";
|
||||
import { computeDomain } from "../../common/entity/compute_domain";
|
||||
import { SubscribeMixin } from "../../mixins/subscribe-mixin";
|
||||
import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import "./ha-devices-picker";
|
||||
|
||||
interface DevicesByArea {
|
||||
[areaId: string]: AreaDevices;
|
||||
@ -87,10 +86,15 @@ const rowRenderer = (
|
||||
@customElement("ha-area-devices-picker")
|
||||
export class HaAreaDevicesPicker extends SubscribeMixin(LitElement) {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public label?: string;
|
||||
|
||||
@property() public value?: string;
|
||||
|
||||
@property() public area?: string;
|
||||
|
||||
@property() public devices?: string[];
|
||||
|
||||
/**
|
||||
* Show only devices with entities from specific domains.
|
||||
* @type {Array}
|
||||
@ -98,6 +102,7 @@ export class HaAreaDevicesPicker extends SubscribeMixin(LitElement) {
|
||||
*/
|
||||
@property({ type: Array, attribute: "include-domains" })
|
||||
public includeDomains?: string[];
|
||||
|
||||
/**
|
||||
* Show no devices with entities of these domains.
|
||||
* @type {Array}
|
||||
@ -105,6 +110,7 @@ export class HaAreaDevicesPicker extends SubscribeMixin(LitElement) {
|
||||
*/
|
||||
@property({ type: Array, attribute: "exclude-domains" })
|
||||
public excludeDomains?: string[];
|
||||
|
||||
/**
|
||||
* Show only deviced with entities of these device classes.
|
||||
* @type {Array}
|
||||
@ -112,13 +118,20 @@ export class HaAreaDevicesPicker extends SubscribeMixin(LitElement) {
|
||||
*/
|
||||
@property({ type: Array, attribute: "include-device-classes" })
|
||||
public includeDeviceClasses?: string[];
|
||||
|
||||
@property({ type: Boolean })
|
||||
private _opened?: boolean;
|
||||
|
||||
@property() private _areaPicker = true;
|
||||
|
||||
@property() private _devices?: DeviceRegistryEntry[];
|
||||
|
||||
@property() private _areas?: AreaRegistryEntry[];
|
||||
|
||||
@property() private _entities?: EntityRegistryEntry[];
|
||||
|
||||
private _selectedDevices: string[] = [];
|
||||
|
||||
private _filteredDevices: DeviceRegistryEntry[] = [];
|
||||
|
||||
private _getDevices = memoizeOne(
|
||||
|
||||
@ -4,12 +4,13 @@ import {
|
||||
fetchDeviceActions,
|
||||
localizeDeviceAutomationAction,
|
||||
} from "../../data/device_automation";
|
||||
import "../../components/ha-paper-dropdown-menu";
|
||||
import "../ha-paper-dropdown-menu";
|
||||
import { HaDeviceAutomationPicker } from "./ha-device-automation-picker";
|
||||
|
||||
@customElement("ha-device-action-picker")
|
||||
class HaDeviceActionPicker extends HaDeviceAutomationPicker<DeviceAction> {
|
||||
protected NO_AUTOMATION_TEXT = "No actions";
|
||||
|
||||
protected UNKNOWN_AUTOMATION_TEXT = "Unknown action";
|
||||
|
||||
constructor() {
|
||||
|
||||
@ -3,20 +3,20 @@ import "@polymer/paper-item/paper-item";
|
||||
import "@polymer/paper-item/paper-item-body";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
css,
|
||||
CSSResult,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import {
|
||||
DeviceAutomation,
|
||||
deviceAutomationsEqual,
|
||||
} from "../../data/device_automation";
|
||||
import "../../components/ha-paper-dropdown-menu";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import "../ha-paper-dropdown-menu";
|
||||
|
||||
const NO_AUTOMATION_KEY = "NO_AUTOMATION";
|
||||
const UNKNOWN_AUTOMATION_KEY = "UNKNOWN_AUTOMATION";
|
||||
@ -25,11 +25,17 @@ export abstract class HaDeviceAutomationPicker<
|
||||
T extends DeviceAutomation
|
||||
> extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public label?: string;
|
||||
|
||||
@property() public deviceId?: string;
|
||||
|
||||
@property() public value?: T;
|
||||
|
||||
protected NO_AUTOMATION_TEXT = "No automations";
|
||||
|
||||
protected UNKNOWN_AUTOMATION_TEXT = "Unknown automation";
|
||||
|
||||
@property() private _automations: T[] = [];
|
||||
|
||||
// Trigger an empty render so we start with a clean DOM.
|
||||
@ -40,10 +46,12 @@ export abstract class HaDeviceAutomationPicker<
|
||||
hass: HomeAssistant,
|
||||
automation: T
|
||||
) => string;
|
||||
|
||||
private _fetchDeviceAutomations: (
|
||||
hass: HomeAssistant,
|
||||
deviceId: string
|
||||
) => Promise<T[]>;
|
||||
|
||||
private _createNoAutomation: (deviceId?: string) => T;
|
||||
|
||||
constructor(
|
||||
|
||||
@ -4,7 +4,7 @@ import {
|
||||
fetchDeviceConditions,
|
||||
localizeDeviceAutomationCondition,
|
||||
} from "../../data/device_automation";
|
||||
import "../../components/ha-paper-dropdown-menu";
|
||||
import "../ha-paper-dropdown-menu";
|
||||
import { HaDeviceAutomationPicker } from "./ha-device-automation-picker";
|
||||
|
||||
@customElement("ha-device-condition-picker")
|
||||
@ -12,6 +12,7 @@ class HaDeviceConditionPicker extends HaDeviceAutomationPicker<
|
||||
DeviceCondition
|
||||
> {
|
||||
protected NO_AUTOMATION_TEXT = "No conditions";
|
||||
|
||||
protected UNKNOWN_AUTOMATION_TEXT = "Unknown condition";
|
||||
|
||||
constructor() {
|
||||
|
||||
@ -1,40 +1,39 @@
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-item/paper-item";
|
||||
import "@polymer/paper-item/paper-item-body";
|
||||
import "@vaadin/vaadin-combo-box/theme/material/vaadin-combo-box-light";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import memoizeOne from "memoize-one";
|
||||
import "@vaadin/vaadin-combo-box/theme/material/vaadin-combo-box-light";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import { SubscribeMixin } from "../../mixins/subscribe-mixin";
|
||||
|
||||
import { HomeAssistant } from "../../types";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import {
|
||||
DeviceRegistryEntry,
|
||||
subscribeDeviceRegistry,
|
||||
computeDeviceName,
|
||||
DeviceEntityLookup,
|
||||
} from "../../data/device_registry";
|
||||
import { computeDomain } from "../../common/entity/compute_domain";
|
||||
import { compare } from "../../common/string/compare";
|
||||
import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import {
|
||||
AreaRegistryEntry,
|
||||
subscribeAreaRegistry,
|
||||
} from "../../data/area_registry";
|
||||
import {
|
||||
computeDeviceName,
|
||||
DeviceEntityLookup,
|
||||
DeviceRegistryEntry,
|
||||
subscribeDeviceRegistry,
|
||||
} from "../../data/device_registry";
|
||||
import {
|
||||
EntityRegistryEntry,
|
||||
subscribeEntityRegistry,
|
||||
} from "../../data/entity_registry";
|
||||
import { computeDomain } from "../../common/entity/compute_domain";
|
||||
import { SubscribeMixin } from "../../mixins/subscribe-mixin";
|
||||
import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import { HomeAssistant } from "../../types";
|
||||
|
||||
interface Device {
|
||||
name: string;
|
||||
@ -67,11 +66,17 @@ const rowRenderer = (root: HTMLElement, _owner, model: { item: Device }) => {
|
||||
@customElement("ha-device-picker")
|
||||
export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public label?: string;
|
||||
|
||||
@property() public value?: string;
|
||||
|
||||
@property() public devices?: DeviceRegistryEntry[];
|
||||
|
||||
@property() public areas?: AreaRegistryEntry[];
|
||||
|
||||
@property() public entities?: EntityRegistryEntry[];
|
||||
|
||||
/**
|
||||
* Show only devices with entities from specific domains.
|
||||
* @type {Array}
|
||||
@ -79,6 +84,7 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
||||
*/
|
||||
@property({ type: Array, attribute: "include-domains" })
|
||||
public includeDomains?: string[];
|
||||
|
||||
/**
|
||||
* Show no devices with entities of these domains.
|
||||
* @type {Array}
|
||||
@ -86,6 +92,7 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
||||
*/
|
||||
@property({ type: Array, attribute: "exclude-domains" })
|
||||
public excludeDomains?: string[];
|
||||
|
||||
/**
|
||||
* Show only deviced with entities of these device classes.
|
||||
* @type {Array}
|
||||
@ -93,6 +100,7 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
||||
*/
|
||||
@property({ type: Array, attribute: "include-device-classes" })
|
||||
public includeDeviceClasses?: string[];
|
||||
|
||||
@property({ type: Boolean })
|
||||
private _opened?: boolean;
|
||||
|
||||
|
||||
@ -4,12 +4,13 @@ import {
|
||||
fetchDeviceTriggers,
|
||||
localizeDeviceAutomationTrigger,
|
||||
} from "../../data/device_automation";
|
||||
import "../../components/ha-paper-dropdown-menu";
|
||||
import "../ha-paper-dropdown-menu";
|
||||
import { HaDeviceAutomationPicker } from "./ha-device-automation-picker";
|
||||
|
||||
@customElement("ha-device-trigger-picker")
|
||||
class HaDeviceTriggerPicker extends HaDeviceAutomationPicker<DeviceTrigger> {
|
||||
protected NO_AUTOMATION_TEXT = "No triggers";
|
||||
|
||||
protected UNKNOWN_AUTOMATION_TEXT = "Unknown trigger";
|
||||
|
||||
constructor() {
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
property,
|
||||
html,
|
||||
customElement,
|
||||
} from "lit-element";
|
||||
import "@polymer/paper-icon-button/paper-icon-button-light";
|
||||
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import {
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
|
||||
import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import "./ha-device-picker";
|
||||
|
||||
@customElement("ha-devices-picker")
|
||||
class HaDevicesPicker extends LitElement {
|
||||
@property() public hass?: HomeAssistant;
|
||||
|
||||
@property() public value?: string[];
|
||||
|
||||
/**
|
||||
* Show entities from specific domains.
|
||||
* @type {string}
|
||||
@ -24,6 +24,7 @@ class HaDevicesPicker extends LitElement {
|
||||
*/
|
||||
@property({ type: Array, attribute: "include-domains" })
|
||||
public includeDomains?: string[];
|
||||
|
||||
/**
|
||||
* Show no entities of these domains.
|
||||
* @type {Array}
|
||||
@ -31,10 +32,13 @@ class HaDevicesPicker extends LitElement {
|
||||
*/
|
||||
@property({ type: Array, attribute: "exclude-domains" })
|
||||
public excludeDomains?: string[];
|
||||
|
||||
@property({ attribute: "picked-device-label" })
|
||||
@property({ type: Array, attribute: "include-device-classes" })
|
||||
public includeDeviceClasses?: string[];
|
||||
|
||||
public pickedDeviceLabel?: string;
|
||||
|
||||
@property({ attribute: "pick-device-label" }) public pickDeviceLabel?: string;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
|
||||
@ -11,9 +11,8 @@ found at http://polymer.github.io/PATENTS.txt
|
||||
/*
|
||||
Fixes issue with not using shadow dom properly in iron-overlay-behavior/icon-focusables-helper.js
|
||||
*/
|
||||
import { dom } from "@polymer/polymer/lib/legacy/polymer.dom.js";
|
||||
|
||||
import { IronFocusablesHelper } from "@polymer/iron-overlay-behavior/iron-focusables-helper.js";
|
||||
import { IronFocusablesHelper } from "@polymer/iron-overlay-behavior/iron-focusables-helper";
|
||||
import { dom } from "@polymer/polymer/lib/legacy/polymer.dom";
|
||||
|
||||
export const HaIronFocusablesHelper = {
|
||||
/**
|
||||
@ -23,7 +22,7 @@ export const HaIronFocusablesHelper = {
|
||||
* @param {!Node} node
|
||||
* @return {!Array<!HTMLElement>}
|
||||
*/
|
||||
getTabbableNodes: function(node) {
|
||||
getTabbableNodes: function (node) {
|
||||
var result = [];
|
||||
// If there is at least one element with tabindex > 0, we need to sort
|
||||
// the final array by tabindex.
|
||||
@ -43,7 +42,7 @@ export const HaIronFocusablesHelper = {
|
||||
* @return {boolean}
|
||||
* @private
|
||||
*/
|
||||
_collectTabbableNodes: function(node, result) {
|
||||
_collectTabbableNodes: function (node, result) {
|
||||
// If not an element or not visible, no need to explore children.
|
||||
if (
|
||||
node.nodeType !== Node.ELEMENT_NODE ||
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import "@polymer/paper-dialog/paper-dialog";
|
||||
import type { PaperDialogElement } from "@polymer/paper-dialog/paper-dialog";
|
||||
import { mixinBehaviors } from "@polymer/polymer/lib/legacy/class";
|
||||
import { HaIronFocusablesHelper } from "./ha-iron-focusables-helper.js";
|
||||
// tslint:disable-next-line
|
||||
import { PaperDialogElement } from "@polymer/paper-dialog/paper-dialog";
|
||||
import type { Constructor } from "../../types";
|
||||
import { HaIronFocusablesHelper } from "./ha-iron-focusables-helper";
|
||||
|
||||
const paperDialogClass = customElements.get("paper-dialog");
|
||||
const paperDialogClass = customElements.get("paper-dialog") as Constructor<
|
||||
PaperDialogElement
|
||||
>;
|
||||
|
||||
// behavior that will override existing iron-overlay-behavior and call the fixed implementation
|
||||
const haTabFixBehaviorImpl = {
|
||||
@ -25,4 +27,5 @@ declare global {
|
||||
"ha-paper-dialog": HaPaperDialog;
|
||||
}
|
||||
}
|
||||
// @ts-ignore
|
||||
customElements.define("ha-paper-dialog", HaPaperDialog);
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { IronResizableBehavior } from "@polymer/iron-resizable-behavior/iron-resizable-behavior";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
import { Debouncer } from "@polymer/polymer/lib/utils/debounce";
|
||||
import { timeOut } from "@polymer/polymer/lib/utils/async";
|
||||
import { mixinBehaviors } from "@polymer/polymer/lib/legacy/class";
|
||||
|
||||
import { timeOut } from "@polymer/polymer/lib/utils/async";
|
||||
import { Debouncer } from "@polymer/polymer/lib/utils/debounce";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
import { formatTime } from "../../common/datetime/format_time";
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
/* global Chart moment Color */
|
||||
|
||||
|
||||
@ -1,27 +1,25 @@
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
property,
|
||||
html,
|
||||
customElement,
|
||||
} from "lit-element";
|
||||
import "@polymer/paper-icon-button/paper-icon-button-light";
|
||||
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import {
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { isValidEntityId } from "../../common/entity/valid_entity_id";
|
||||
|
||||
import type { PolymerChangedEvent } from "../../polymer-types";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import "./ha-entity-picker";
|
||||
// Not a duplicate, type import
|
||||
// tslint:disable-next-line
|
||||
import { HaEntityPickerEntityFilterFunc } from "./ha-entity-picker";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import type { HaEntityPickerEntityFilterFunc } from "./ha-entity-picker";
|
||||
|
||||
@customElement("ha-entities-picker")
|
||||
class HaEntitiesPickerLight extends LitElement {
|
||||
@property() public hass?: HomeAssistant;
|
||||
|
||||
@property() public value?: string[];
|
||||
|
||||
/**
|
||||
* Show entities from specific domains.
|
||||
* @type {string}
|
||||
@ -29,6 +27,7 @@ class HaEntitiesPickerLight extends LitElement {
|
||||
*/
|
||||
@property({ type: Array, attribute: "include-domains" })
|
||||
public includeDomains?: string[];
|
||||
|
||||
/**
|
||||
* Show no entities of these domains.
|
||||
* @type {Array}
|
||||
@ -36,8 +35,10 @@ class HaEntitiesPickerLight extends LitElement {
|
||||
*/
|
||||
@property({ type: Array, attribute: "exclude-domains" })
|
||||
public excludeDomains?: string[];
|
||||
|
||||
@property({ attribute: "picked-entity-label" })
|
||||
public pickedEntityLabel?: string;
|
||||
|
||||
@property({ attribute: "pick-entity-label" }) public pickEntityLabel?: string;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
|
||||
@ -3,25 +3,23 @@ import "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-item/paper-icon-item";
|
||||
import "@polymer/paper-item/paper-item-body";
|
||||
import "@vaadin/vaadin-combo-box/theme/material/vaadin-combo-box-light";
|
||||
import memoizeOne from "memoize-one";
|
||||
|
||||
import "./state-badge";
|
||||
|
||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
css,
|
||||
CSSResult,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { computeDomain } from "../../common/entity/compute_domain";
|
||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||
import { PolymerChangedEvent } from "../../polymer-types";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import "./state-badge";
|
||||
|
||||
export type HaEntityPickerEntityFilterFunc = (entityId: HassEntity) => boolean;
|
||||
|
||||
@ -54,13 +52,19 @@ const rowRenderer = (
|
||||
};
|
||||
|
||||
class HaEntityPicker extends LitElement {
|
||||
@property({ type: Boolean }) public autofocus?: boolean;
|
||||
@property({ type: Boolean }) public autofocus = false;
|
||||
|
||||
@property({ type: Boolean }) public disabled?: boolean;
|
||||
|
||||
@property({ type: Boolean, attribute: "allow-custom-entity" })
|
||||
public allowCustomEntity;
|
||||
|
||||
@property() public hass?: HomeAssistant;
|
||||
|
||||
@property() public label?: string;
|
||||
|
||||
@property() public value?: string;
|
||||
|
||||
/**
|
||||
* Show entities from specific domains.
|
||||
* @type {Array}
|
||||
@ -68,6 +72,7 @@ class HaEntityPicker extends LitElement {
|
||||
*/
|
||||
@property({ type: Array, attribute: "include-domains" })
|
||||
public includeDomains?: string[];
|
||||
|
||||
/**
|
||||
* Show no entities of these domains.
|
||||
* @type {Array}
|
||||
@ -75,6 +80,7 @@ class HaEntityPicker extends LitElement {
|
||||
*/
|
||||
@property({ type: Array, attribute: "exclude-domains" })
|
||||
public excludeDomains?: string[];
|
||||
|
||||
/**
|
||||
* Show only entities of these device classes.
|
||||
* @type {Array}
|
||||
@ -82,8 +88,11 @@ class HaEntityPicker extends LitElement {
|
||||
*/
|
||||
@property({ type: Array, attribute: "include-device-classes" })
|
||||
public includeDeviceClasses?: string[];
|
||||
|
||||
@property() public entityFilter?: HaEntityPickerEntityFilterFunc;
|
||||
|
||||
@property({ type: Boolean }) private _opened?: boolean;
|
||||
|
||||
@property() private _hass?: HomeAssistant;
|
||||
|
||||
private _getStates = memoizeOne(
|
||||
|
||||
@ -1,24 +1,21 @@
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
|
||||
import { STATES_OFF } from "../../common/const";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
CSSResult,
|
||||
css,
|
||||
CSSResult,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { forwardHaptic } from "../../data/haptics";
|
||||
|
||||
import { STATES_OFF } from "../../common/const";
|
||||
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||
|
||||
import "../ha-switch";
|
||||
import { UNAVAILABLE_STATES } from "../../data/entity";
|
||||
import { forwardHaptic } from "../../data/haptics";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import "../ha-switch";
|
||||
|
||||
const isOn = (stateObj?: HassEntity) =>
|
||||
stateObj !== undefined &&
|
||||
@ -28,14 +25,14 @@ const isOn = (stateObj?: HassEntity) =>
|
||||
class HaEntityToggle extends LitElement {
|
||||
// hass is not a property so that we only re-render on stateObj changes
|
||||
public hass?: HomeAssistant;
|
||||
|
||||
@property() public stateObj?: HassEntity;
|
||||
@property() private _isOn: boolean = false;
|
||||
|
||||
@property() private _isOn = false;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (!this.stateObj) {
|
||||
return html`
|
||||
<ha-switch disabled></ha-switch>
|
||||
`;
|
||||
return html` <ha-switch disabled></ha-switch> `;
|
||||
}
|
||||
|
||||
if (this.stateObj.attributes.assumed_state) {
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "../ha-icon";
|
||||
import { stateIcon } from "../../common/entity/state_icon";
|
||||
import "../ha-icon";
|
||||
|
||||
class HaStateIcon extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
<ha-icon icon="[[computeIcon(stateObj)]]"></ha-icon>
|
||||
`;
|
||||
return html` <ha-icon icon="[[computeIcon(stateObj)]]"></ha-icon> `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,25 +1,22 @@
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import {
|
||||
LitElement,
|
||||
html,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
import { HomeAssistant } from "../../types";
|
||||
|
||||
import secondsToDuration from "../../common/datetime/seconds_to_duration";
|
||||
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||
import { domainIcon } from "../../common/entity/domain_icon";
|
||||
import { stateIcon } from "../../common/entity/state_icon";
|
||||
import { timerTimeRemaining } from "../../common/entity/timer_time_remaining";
|
||||
import secondsToDuration from "../../common/datetime/seconds_to_duration";
|
||||
|
||||
import { HomeAssistant } from "../../types";
|
||||
import "../ha-label-badge";
|
||||
|
||||
@customElement("ha-state-label-badge")
|
||||
|
||||
@ -1,31 +1,34 @@
|
||||
import type { HassEntity } from "home-assistant-js-websocket";
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
css,
|
||||
CSSResult,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import "../ha-icon";
|
||||
import { ifDefined } from "lit-html/directives/if-defined";
|
||||
import { computeActiveState } from "../../common/entity/compute_active_state";
|
||||
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
||||
import { stateIcon } from "../../common/entity/state_icon";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
// Not duplicate, this is for typing.
|
||||
// tslint:disable-next-line
|
||||
import { HaIcon } from "../ha-icon";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { computeActiveState } from "../../common/entity/compute_active_state";
|
||||
import { ifDefined } from "lit-html/directives/if-defined";
|
||||
import { iconColorCSS } from "../../common/style/icon_color_css";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import "../ha-icon";
|
||||
import type { HaIcon } from "../ha-icon";
|
||||
|
||||
export class StateBadge extends LitElement {
|
||||
public hass?: HomeAssistant;
|
||||
|
||||
@property() public stateObj?: HassEntity;
|
||||
|
||||
@property() public overrideIcon?: string;
|
||||
|
||||
@property() public overrideImage?: string;
|
||||
|
||||
@property({ type: Boolean }) public stateColor?: boolean;
|
||||
|
||||
@query("ha-icon") private _icon!: HaIcon;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
@ -91,7 +94,7 @@ export class StateBadge extends LitElement {
|
||||
const errorMessage = `Type error: state-badge expected number, but type of ${
|
||||
stateObj.entity_id
|
||||
}.attributes.brightness is ${typeof brightness} (${brightness})`;
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
console.warn(errorMessage);
|
||||
}
|
||||
// lowest brighntess will be around 50% (that's pretty dark)
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "../ha-relative-time";
|
||||
import "./state-badge";
|
||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||
import { computeRTL } from "../../common/util/compute_rtl";
|
||||
import "../ha-relative-time";
|
||||
import "./state-badge";
|
||||
|
||||
class StateInfo extends PolymerElement {
|
||||
static get template() {
|
||||
@ -62,9 +62,7 @@ class StateInfo extends PolymerElement {
|
||||
}
|
||||
|
||||
static get stateBadgeTemplate() {
|
||||
return html`
|
||||
<state-badge state-obj="[[stateObj]]"></state-badge>
|
||||
`;
|
||||
return html` <state-badge state-obj="[[stateObj]]"></state-badge> `;
|
||||
}
|
||||
|
||||
static get infoTemplate() {
|
||||
|
||||
@ -1,32 +1,31 @@
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-item/paper-item";
|
||||
import "@polymer/paper-item/paper-item-body";
|
||||
import "@vaadin/vaadin-combo-box/theme/material/vaadin-combo-box-light";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import "@vaadin/vaadin-combo-box/theme/material/vaadin-combo-box-light";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import {
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import { SubscribeMixin } from "../mixins/subscribe-mixin";
|
||||
|
||||
import { HomeAssistant } from "../types";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { PolymerChangedEvent } from "../polymer-types";
|
||||
import {
|
||||
AreaRegistryEntry,
|
||||
subscribeAreaRegistry,
|
||||
createAreaRegistryEntry,
|
||||
subscribeAreaRegistry,
|
||||
} from "../data/area_registry";
|
||||
import {
|
||||
showPromptDialog,
|
||||
showAlertDialog,
|
||||
showPromptDialog,
|
||||
} from "../dialogs/generic/show-dialog-box";
|
||||
import { SubscribeMixin } from "../mixins/subscribe-mixin";
|
||||
import { PolymerChangedEvent } from "../polymer-types";
|
||||
import { HomeAssistant } from "../types";
|
||||
|
||||
const rowRenderer = (
|
||||
root: HTMLElement,
|
||||
@ -62,11 +61,16 @@ const rowRenderer = (
|
||||
@customElement("ha-area-picker")
|
||||
export class HaAreaPicker extends SubscribeMixin(LitElement) {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public label?: string;
|
||||
|
||||
@property() public value?: string;
|
||||
|
||||
@property() public _areas?: AreaRegistryEntry[];
|
||||
|
||||
@property({ type: Boolean, attribute: "no-add" })
|
||||
public noAdd?: boolean;
|
||||
|
||||
@property() private _opened?: boolean;
|
||||
|
||||
public hassSubscribe(): UnsubscribeFunc[] {
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
import {
|
||||
property,
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
CSSResult,
|
||||
css,
|
||||
customElement,
|
||||
} from "lit-element";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
|
||||
import hassAttributeUtil from "../util/hass-attributes-util";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { until } from "lit-html/directives/until";
|
||||
import hassAttributeUtil from "../util/hass-attributes-util";
|
||||
|
||||
let jsYamlPromise: Promise<typeof import("js-yaml")>;
|
||||
|
||||
@customElement("ha-attributes")
|
||||
class HaAttributes extends LitElement {
|
||||
@property() public stateObj?: HassEntity;
|
||||
|
||||
@property() public extraFilters?: string;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
@ -102,9 +102,7 @@ class HaAttributes extends LitElement {
|
||||
jsYamlPromise = import(/* webpackChunkName: "js-yaml" */ "js-yaml");
|
||||
}
|
||||
const yaml = jsYamlPromise.then((jsYaml) => jsYaml.safeDump(value));
|
||||
return html`
|
||||
<pre>${until(yaml, "")}</pre>
|
||||
`;
|
||||
return html` <pre>${until(yaml, "")}</pre> `;
|
||||
}
|
||||
return Array.isArray(value) ? value.join(", ") : value;
|
||||
}
|
||||
|
||||
@ -1,35 +1,39 @@
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
html,
|
||||
CSSResult,
|
||||
css,
|
||||
customElement,
|
||||
} from "lit-element";
|
||||
|
||||
import { computeStateName } from "../common/entity/compute_state_name";
|
||||
import { HomeAssistant, CameraEntity } from "../types";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { computeStateName } from "../common/entity/compute_state_name";
|
||||
import { supportsFeature } from "../common/entity/supports-feature";
|
||||
import {
|
||||
CAMERA_SUPPORT_STREAM,
|
||||
fetchStreamUrl,
|
||||
computeMJPEGStreamUrl,
|
||||
fetchStreamUrl,
|
||||
} from "../data/camera";
|
||||
import { supportsFeature } from "../common/entity/supports-feature";
|
||||
import { CameraEntity, HomeAssistant } from "../types";
|
||||
|
||||
type HLSModule = typeof import("hls.js");
|
||||
|
||||
@customElement("ha-camera-stream")
|
||||
class HaCameraStream extends LitElement {
|
||||
@property() public hass?: HomeAssistant;
|
||||
|
||||
@property() public stateObj?: CameraEntity;
|
||||
|
||||
@property({ type: Boolean }) public showControls = false;
|
||||
|
||||
@property() private _attached = false;
|
||||
|
||||
// We keep track if we should force MJPEG with a string
|
||||
// that way it automatically resets if we change entity.
|
||||
@property() private _forceMJPEG: string | undefined = undefined;
|
||||
|
||||
private _hlsPolyfillInstance?: Hls;
|
||||
|
||||
public connectedCallback() {
|
||||
@ -121,7 +125,7 @@ class HaCameraStream extends LitElement {
|
||||
}
|
||||
|
||||
private async _startHls(): Promise<void> {
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
const Hls = ((await import(
|
||||
/* webpackChunkName: "hls.js" */ "hls.js"
|
||||
)) as any).default as HLSModule;
|
||||
@ -152,7 +156,7 @@ class HaCameraStream extends LitElement {
|
||||
return;
|
||||
} catch (err) {
|
||||
// Fails if we were unable to get a stream
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
console.error(err);
|
||||
this._forceMJPEG = this.stateObj!.entity_id;
|
||||
}
|
||||
@ -168,7 +172,7 @@ class HaCameraStream extends LitElement {
|
||||
|
||||
private async _renderHLSPolyfill(
|
||||
videoEl: HTMLVideoElement,
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
Hls: HLSModule,
|
||||
url: string
|
||||
) {
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
customElement,
|
||||
} from "lit-element";
|
||||
|
||||
@customElement("ha-card")
|
||||
@ -63,9 +63,7 @@ class HaCard extends LitElement {
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
${this.header
|
||||
? html`
|
||||
<div class="card-header">${this.header}</div>
|
||||
`
|
||||
? html` <div class="card-header">${this.header}</div> `
|
||||
: html``}
|
||||
<slot></slot>
|
||||
`;
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import { customElement, CSSResult, css } from "lit-element";
|
||||
import "@material/mwc-checkbox";
|
||||
// tslint:disable-next-line
|
||||
import { Checkbox } from "@material/mwc-checkbox";
|
||||
import type { Checkbox } from "@material/mwc-checkbox";
|
||||
import { style } from "@material/mwc-checkbox/mwc-checkbox-css";
|
||||
import { Constructor } from "../types";
|
||||
// tslint:disable-next-line
|
||||
import { css, CSSResult, customElement } from "lit-element";
|
||||
import type { Constructor } from "../types";
|
||||
|
||||
const MwcCheckbox = customElements.get("mwc-checkbox") as Constructor<Checkbox>;
|
||||
|
||||
@customElement("ha-checkbox")
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
// @ts-ignore
|
||||
import chipStyles from "@material/chips/dist/mdc.chips.min.css";
|
||||
import { ripple } from "@material/mwc-ripple/ripple-directive";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
customElement,
|
||||
unsafeCSS,
|
||||
} from "lit-element";
|
||||
import { ripple } from "@material/mwc-ripple/ripple-directive";
|
||||
// @ts-ignore
|
||||
import chipStyles from "@material/chips/dist/mdc.chips.min.css";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
|
||||
declare global {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import "@polymer/iron-flex-layout/iron-flex-layout-classes";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { EventsMixin } from "../mixins/events-mixin";
|
||||
|
||||
/*
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import LocalizeMixin from "../mixins/localize-mixin";
|
||||
import { CLIMATE_PRESET_NONE } from "../data/climate";
|
||||
import LocalizeMixin from "../mixins/localize-mixin";
|
||||
|
||||
/*
|
||||
* @appliesMixin LocalizeMixin
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { loadCodeMirror } from "../resources/codemirror.ondemand";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import {
|
||||
UpdatingElement,
|
||||
property,
|
||||
customElement,
|
||||
PropertyValues,
|
||||
} from "lit-element";
|
||||
import { Editor } from "codemirror";
|
||||
import {
|
||||
customElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
UpdatingElement,
|
||||
} from "lit-element";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { loadCodeMirror } from "../resources/codemirror.ondemand";
|
||||
|
||||
declare global {
|
||||
interface HASSDomEvents {
|
||||
@ -17,10 +17,15 @@ declare global {
|
||||
@customElement("ha-code-editor")
|
||||
export class HaCodeEditor extends UpdatingElement {
|
||||
public codemirror?: Editor;
|
||||
|
||||
@property() public mode?: string;
|
||||
|
||||
@property() public autofocus = false;
|
||||
|
||||
@property() public rtl = false;
|
||||
|
||||
@property() public error = false;
|
||||
|
||||
@property() private _value = "";
|
||||
|
||||
public set value(value: string) {
|
||||
@ -32,7 +37,7 @@ export class HaCodeEditor extends UpdatingElement {
|
||||
}
|
||||
|
||||
public get hasComments(): boolean {
|
||||
return this.shadowRoot!.querySelector("span.cm-comment") ? true : false;
|
||||
return !!this.shadowRoot!.querySelector("span.cm-comment");
|
||||
}
|
||||
|
||||
public connectedCallback() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { EventsMixin } from "../mixins/events-mixin";
|
||||
|
||||
/**
|
||||
@ -332,8 +332,9 @@ class HaColorPicker extends EventsMixin(PolymerElement) {
|
||||
applyColorToCanvas(hs) {
|
||||
// we're not really converting hs to hsl here, but we keep it cheap
|
||||
// setting the color on the interactionLayer, the svg elements can inherit
|
||||
this.interactionLayer.style.color = `hsl(${hs.h}, 100%, ${100 -
|
||||
hs.s * 50}%)`;
|
||||
this.interactionLayer.style.color = `hsl(${hs.h}, 100%, ${
|
||||
100 - hs.s * 50
|
||||
}%)`;
|
||||
}
|
||||
|
||||
applyHsColor(hs) {
|
||||
|
||||
@ -2,9 +2,9 @@ import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-item/paper-item";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
import "@vaadin/vaadin-combo-box/theme/material/vaadin-combo-box-light";
|
||||
|
||||
import { EventsMixin } from "../mixins/events-mixin";
|
||||
|
||||
class HaComboBox extends EventsMixin(PolymerElement) {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import CoverEntity from "../util/cover-model";
|
||||
import { UNAVAILABLE_STATES } from "../data/entity";
|
||||
import CoverEntity from "../util/cover-model";
|
||||
|
||||
class HaCoverControls extends PolymerElement {
|
||||
static get template() {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import "@polymer/iron-flex-layout/iron-flex-layout-classes";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import CoverEntity from "../util/cover-model";
|
||||
import { UNAVAILABLE_STATES } from "../data/entity";
|
||||
import CoverEntity from "../util/cover-model";
|
||||
|
||||
class HaCoverTiltControls extends PolymerElement {
|
||||
static get template() {
|
||||
|
||||
@ -1,21 +1,22 @@
|
||||
import {
|
||||
html,
|
||||
css,
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
property,
|
||||
customElement,
|
||||
} from "lit-element";
|
||||
|
||||
import "@polymer/paper-input/paper-input";
|
||||
// tslint:disable-next-line:no-duplicate-imports
|
||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import {
|
||||
css,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
@customElement("ha-date-input")
|
||||
export class HaDateInput extends LitElement {
|
||||
@property() public year?: string;
|
||||
|
||||
@property() public month?: string;
|
||||
|
||||
@property() public day?: string;
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
|
||||
static get styles() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "./ha-label-badge";
|
||||
|
||||
class HaDemoBadge extends PolymerElement {
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { customElement, CSSResult, css, html } from "lit-element";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import "@material/mwc-dialog";
|
||||
import type { Dialog } from "@material/mwc-dialog";
|
||||
import { style } from "@material/mwc-dialog/mwc-dialog-css";
|
||||
// tslint:disable-next-line
|
||||
import { Dialog } from "@material/mwc-dialog";
|
||||
import { Constructor, HomeAssistant } from "../types";
|
||||
// tslint:disable-next-line
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import { css, CSSResult, customElement, html } from "lit-element";
|
||||
import type { Constructor, HomeAssistant } from "../types";
|
||||
|
||||
const MwcDialog = customElements.get("mwc-dialog") as Constructor<Dialog>;
|
||||
|
||||
export const createCloseHeading = (hass: HomeAssistant, title: string) => html`
|
||||
|
||||
@ -1,19 +1,17 @@
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
import { html, customElement } from "lit-element";
|
||||
import { ripple } from "@material/mwc-ripple/ripple-directive";
|
||||
|
||||
import "@material/mwc-fab";
|
||||
import { Constructor } from "../types";
|
||||
// tslint:disable-next-line
|
||||
import { Fab } from "@material/mwc-fab";
|
||||
// tslint:disable-next-line
|
||||
import type { Fab } from "@material/mwc-fab";
|
||||
import { ripple } from "@material/mwc-ripple/ripple-directive";
|
||||
import { customElement, html, TemplateResult } from "lit-element";
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
import type { Constructor } from "../types";
|
||||
|
||||
const MwcFab = customElements.get("mwc-fab") as Constructor<Fab>;
|
||||
|
||||
@customElement("ha-fab")
|
||||
export class HaFab extends MwcFab {
|
||||
// We override the render method because we don't have an icon font and mwc-fab doesn't support our svg-icon sets.
|
||||
// Based on version mwc-fab 0.8
|
||||
protected render() {
|
||||
protected render(): TemplateResult {
|
||||
const classes = {
|
||||
"mdc-fab--mini": this.mini,
|
||||
"mdc-fab--exited": this.exited,
|
||||
@ -28,11 +26,7 @@ export class HaFab extends MwcFab {
|
||||
aria-label="${this.label || this.icon}"
|
||||
>
|
||||
${showLabel && this.showIconAtEnd ? this.label : ""}
|
||||
${this.icon
|
||||
? html`
|
||||
<ha-icon .icon=${this.icon}></ha-icon>
|
||||
`
|
||||
: ""}
|
||||
${this.icon ? html` <ha-icon .icon=${this.icon}></ha-icon> ` : ""}
|
||||
${showLabel && !this.showIconAtEnd ? this.label : ""}
|
||||
</button>
|
||||
`;
|
||||
|
||||
@ -1,31 +1,32 @@
|
||||
import "@polymer/paper-checkbox/paper-checkbox";
|
||||
import type { PaperCheckboxElement } from "@polymer/paper-checkbox/paper-checkbox";
|
||||
import {
|
||||
customElement,
|
||||
LitElement,
|
||||
html,
|
||||
property,
|
||||
TemplateResult,
|
||||
CSSResult,
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import {
|
||||
HaFormElement,
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import type {
|
||||
HaFormBooleanData,
|
||||
HaFormBooleanSchema,
|
||||
HaFormElement,
|
||||
} from "./ha-form";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
|
||||
import "@polymer/paper-checkbox/paper-checkbox";
|
||||
// Not duplicate, is for typing
|
||||
// tslint:disable-next-line
|
||||
import { PaperCheckboxElement } from "@polymer/paper-checkbox/paper-checkbox";
|
||||
|
||||
@customElement("ha-form-boolean")
|
||||
export class HaFormBoolean extends LitElement implements HaFormElement {
|
||||
@property() public schema!: HaFormBooleanSchema;
|
||||
|
||||
@property() public data!: HaFormBooleanData;
|
||||
|
||||
@property() public label!: string;
|
||||
|
||||
@property() public suffix!: string;
|
||||
|
||||
@query("paper-checkbox") private _input?: HTMLElement;
|
||||
|
||||
public focus() {
|
||||
|
||||
@ -1,25 +1,26 @@
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import {
|
||||
customElement,
|
||||
LitElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { HaFormElement, HaFormFloatData, HaFormFloatSchema } from "./ha-form";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
|
||||
import "@polymer/paper-input/paper-input";
|
||||
// Not duplicate, is for typing
|
||||
// tslint:disable-next-line
|
||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import { HaFormElement, HaFormFloatData, HaFormFloatSchema } from "./ha-form";
|
||||
|
||||
@customElement("ha-form-float")
|
||||
export class HaFormFloat extends LitElement implements HaFormElement {
|
||||
@property() public schema!: HaFormFloatSchema;
|
||||
|
||||
@property() public data!: HaFormFloatData;
|
||||
|
||||
@property() public label!: string;
|
||||
|
||||
@property() public suffix!: string;
|
||||
|
||||
@query("paper-input") private _input?: HTMLElement;
|
||||
|
||||
public focus() {
|
||||
|
||||
@ -1,34 +1,36 @@
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-slider/paper-slider";
|
||||
import type { PaperSliderElement } from "@polymer/paper-slider/paper-slider";
|
||||
import {
|
||||
customElement,
|
||||
LitElement,
|
||||
html,
|
||||
property,
|
||||
TemplateResult,
|
||||
query,
|
||||
CSSResult,
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { HaCheckbox } from "../ha-checkbox";
|
||||
import "../ha-paper-slider";
|
||||
import {
|
||||
HaFormElement,
|
||||
HaFormIntegerData,
|
||||
HaFormIntegerSchema,
|
||||
} from "./ha-form";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
|
||||
import "../ha-paper-slider";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
// Not duplicate, is for typing
|
||||
// tslint:disable-next-line
|
||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import { PaperSliderElement } from "@polymer/paper-slider/paper-slider";
|
||||
import { HaCheckbox } from "../ha-checkbox";
|
||||
|
||||
@customElement("ha-form-integer")
|
||||
export class HaFormInteger extends LitElement implements HaFormElement {
|
||||
@property() public schema!: HaFormIntegerSchema;
|
||||
|
||||
@property() public data?: HaFormIntegerData;
|
||||
|
||||
@property() public label?: string;
|
||||
|
||||
@property() public suffix?: string;
|
||||
|
||||
@query("paper-input ha-paper-slider") private _input?: HTMLElement;
|
||||
|
||||
public focus() {
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
import "@polymer/paper-checkbox/paper-checkbox";
|
||||
import "@polymer/paper-menu-button/paper-menu-button";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-item/paper-icon-item";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import "@polymer/paper-menu-button/paper-menu-button";
|
||||
import "@polymer/paper-ripple/paper-ripple";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
query,
|
||||
TemplateResult,
|
||||
CSSResult,
|
||||
css,
|
||||
} from "lit-element";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import {
|
||||
@ -24,10 +24,15 @@ import {
|
||||
@customElement("ha-form-multi_select")
|
||||
export class HaFormMultiSelect extends LitElement implements HaFormElement {
|
||||
@property() public schema!: HaFormMultiSelectSchema;
|
||||
|
||||
@property() public data!: HaFormMultiSelectData;
|
||||
|
||||
@property() public label!: string;
|
||||
|
||||
@property() public suffix!: string;
|
||||
|
||||
@property() private _init = false;
|
||||
|
||||
@query("paper-menu-button") private _input?: HTMLElement;
|
||||
|
||||
public focus(): void {
|
||||
|
||||
@ -1,20 +1,24 @@
|
||||
import {
|
||||
customElement,
|
||||
LitElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { HaFormElement, HaFormTimeData, HaFormTimeSchema } from "./ha-form";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { HaFormElement, HaFormTimeData, HaFormTimeSchema } from "./ha-form";
|
||||
|
||||
@customElement("ha-form-positive_time_period_dict")
|
||||
export class HaFormTimePeriod extends LitElement implements HaFormElement {
|
||||
@property() public schema!: HaFormTimeSchema;
|
||||
|
||||
@property() public data!: HaFormTimeData;
|
||||
|
||||
@property() public label!: string;
|
||||
|
||||
@property() public suffix!: string;
|
||||
|
||||
@query("paper-time-input") private _input?: HTMLElement;
|
||||
|
||||
public focus() {
|
||||
@ -87,12 +91,12 @@ export class HaFormTimePeriod extends LitElement implements HaFormElement {
|
||||
let minutes = this._minutes;
|
||||
|
||||
if (unit === "seconds" && value > 59) {
|
||||
minutes = minutes + Math.floor(value / 60);
|
||||
minutes += Math.floor(value / 60);
|
||||
value %= 60;
|
||||
}
|
||||
|
||||
if (unit === "minutes" && value > 59) {
|
||||
hours = hours + Math.floor(value / 60);
|
||||
hours += Math.floor(value / 60);
|
||||
value %= 60;
|
||||
}
|
||||
|
||||
|
||||
@ -1,26 +1,29 @@
|
||||
import {
|
||||
customElement,
|
||||
LitElement,
|
||||
html,
|
||||
property,
|
||||
TemplateResult,
|
||||
query,
|
||||
CSSResult,
|
||||
css,
|
||||
} from "lit-element";
|
||||
import { HaFormElement, HaFormSelectData, HaFormSelectSchema } from "./ha-form";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
|
||||
import "@polymer/paper-dropdown-menu/paper-dropdown-menu";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import "@polymer/paper-item/paper-item";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { HaFormElement, HaFormSelectData, HaFormSelectSchema } from "./ha-form";
|
||||
|
||||
@customElement("ha-form-select")
|
||||
export class HaFormSelect extends LitElement implements HaFormElement {
|
||||
@property() public schema!: HaFormSelectSchema;
|
||||
|
||||
@property() public data!: HaFormSelectData;
|
||||
|
||||
@property() public label!: string;
|
||||
|
||||
@property() public suffix!: string;
|
||||
|
||||
@query("paper-dropdown-menu") private _input?: HTMLElement;
|
||||
|
||||
public focus() {
|
||||
|
||||
@ -1,31 +1,36 @@
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import {
|
||||
customElement,
|
||||
LitElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
|
||||
import { HaFormElement, HaFormStringData, HaFormStringSchema } from "./ha-form";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
// Not duplicate, is for typing
|
||||
// tslint:disable-next-line
|
||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import type {
|
||||
HaFormElement,
|
||||
HaFormStringData,
|
||||
HaFormStringSchema,
|
||||
} from "./ha-form";
|
||||
|
||||
@customElement("ha-form-string")
|
||||
export class HaFormString extends LitElement implements HaFormElement {
|
||||
@property() public schema!: HaFormStringSchema;
|
||||
|
||||
@property() public data!: HaFormStringData;
|
||||
|
||||
@property() public label!: string;
|
||||
|
||||
@property() public suffix!: string;
|
||||
|
||||
@property() private _unmaskedPassword = false;
|
||||
|
||||
@query("paper-input") private _input?: HTMLElement;
|
||||
|
||||
public focus() {
|
||||
public focus(): void {
|
||||
if (this._input) {
|
||||
this._input.focus();
|
||||
}
|
||||
@ -67,11 +72,11 @@ export class HaFormString extends LitElement implements HaFormElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _toggleUnmaskedPassword(ev: Event) {
|
||||
private _toggleUnmaskedPassword(ev: Event): void {
|
||||
this._unmaskedPassword = (ev.target as any).active;
|
||||
}
|
||||
|
||||
private _valueChanged(ev: Event) {
|
||||
private _valueChanged(ev: Event): void {
|
||||
const value = (ev.target as PaperInputElement).value;
|
||||
if (this.data === value) {
|
||||
return;
|
||||
@ -81,7 +86,7 @@ export class HaFormString extends LitElement implements HaFormElement {
|
||||
});
|
||||
}
|
||||
|
||||
private get _stringType() {
|
||||
private get _stringType(): string {
|
||||
if (this.schema.format) {
|
||||
if (["email", "url"].includes(this.schema.format)) {
|
||||
return this.schema.format;
|
||||
|
||||
@ -1,21 +1,20 @@
|
||||
import {
|
||||
customElement,
|
||||
LitElement,
|
||||
html,
|
||||
property,
|
||||
CSSResult,
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
} from "lit-element";
|
||||
|
||||
import "./ha-form-string";
|
||||
import "./ha-form-integer";
|
||||
import "./ha-form-float";
|
||||
import { dynamicElement } from "../../common/dom/dynamic-element-directive";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import "./ha-form-boolean";
|
||||
import "./ha-form-select";
|
||||
import "./ha-form-float";
|
||||
import "./ha-form-integer";
|
||||
import "./ha-form-multi_select";
|
||||
import "./ha-form-positive_time_period_dict";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { dynamicElement } from "../../common/dom/dynamic-element-directive";
|
||||
import "./ha-form-select";
|
||||
import "./ha-form-string";
|
||||
|
||||
export type HaFormSchema =
|
||||
| HaFormStringSchema
|
||||
@ -103,10 +102,15 @@ export interface HaFormElement extends LitElement {
|
||||
@customElement("ha-form")
|
||||
export class HaForm extends LitElement implements HaFormElement {
|
||||
@property() public data!: HaFormDataContainer | HaFormData;
|
||||
|
||||
@property() public schema!: HaFormSchema;
|
||||
|
||||
@property() public error;
|
||||
|
||||
@property() public computeError?: (schema: HaFormSchema, error) => string;
|
||||
|
||||
@property() public computeLabel?: (schema: HaFormSchema) => string;
|
||||
|
||||
@property() public computeSuffix?: (schema: HaFormSchema) => string;
|
||||
|
||||
public focus() {
|
||||
|
||||
@ -1,22 +1,25 @@
|
||||
import {
|
||||
html,
|
||||
css,
|
||||
LitElement,
|
||||
TemplateResult,
|
||||
property,
|
||||
customElement,
|
||||
} from "lit-element";
|
||||
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import "./ha-icon";
|
||||
import {
|
||||
css,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import "./ha-icon";
|
||||
|
||||
@customElement("ha-icon-input")
|
||||
export class HaIconInput extends LitElement {
|
||||
@property() public value?: string;
|
||||
|
||||
@property() public label?: string;
|
||||
|
||||
@property() public placeholder?: string;
|
||||
|
||||
@property({ attribute: "error-message" }) public errorMessage?: string;
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import "@polymer/iron-icon/iron-icon";
|
||||
// Not duplicate, this is for typing.
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
import { HaIcon } from "./ha-icon";
|
||||
|
||||
export class HaIconNext extends HaIcon {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import "@polymer/iron-icon/iron-icon";
|
||||
// Not duplicate, this is for typing.
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
import { HaIcon } from "./ha-icon";
|
||||
|
||||
export class HaIconPrev extends HaIcon {
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
import { Constructor } from "../types";
|
||||
|
||||
import "@polymer/iron-icon/iron-icon";
|
||||
// Not duplicate, this is for typing.
|
||||
// tslint:disable-next-line
|
||||
import { IronIconElement } from "@polymer/iron-icon/iron-icon";
|
||||
import type { IronIconElement } from "@polymer/iron-icon/iron-icon";
|
||||
import { Constructor } from "../types";
|
||||
|
||||
const ironIconClass = customElements.get("iron-icon") as Constructor<
|
||||
IronIconElement
|
||||
|
||||
@ -1,20 +1,24 @@
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
CSSResult,
|
||||
css,
|
||||
property,
|
||||
} from "lit-element";
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
import "./ha-icon";
|
||||
|
||||
class HaLabelBadge extends LitElement {
|
||||
@property() public value?: string;
|
||||
|
||||
@property() public icon?: string;
|
||||
|
||||
@property() public label?: string;
|
||||
|
||||
@property() public description?: string;
|
||||
|
||||
@property() public image?: string;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
@ -28,14 +32,10 @@ class HaLabelBadge extends LitElement {
|
||||
})}"
|
||||
>
|
||||
${this.icon && !this.value && !this.image
|
||||
? html`
|
||||
<ha-icon .icon="${this.icon}"></ha-icon>
|
||||
`
|
||||
? html` <ha-icon .icon="${this.icon}"></ha-icon> `
|
||||
: ""}
|
||||
${this.value && !this.image
|
||||
? html`
|
||||
<span>${this.value}</span>
|
||||
`
|
||||
? html` <span>${this.value}</span> `
|
||||
: ""}
|
||||
</div>
|
||||
${this.label
|
||||
@ -52,9 +52,7 @@ class HaLabelBadge extends LitElement {
|
||||
: ""}
|
||||
</div>
|
||||
${this.description
|
||||
? html`
|
||||
<div class="title">${this.description}</div>
|
||||
`
|
||||
? html` <div class="title">${this.description}</div> `
|
||||
: ""}
|
||||
</div>
|
||||
`;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "./ha-paper-slider";
|
||||
import "./ha-icon";
|
||||
import "./ha-paper-slider";
|
||||
|
||||
class HaLabeledSlider extends PolymerElement {
|
||||
static get template() {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { UpdatingElement, property, customElement } from "lit-element";
|
||||
// eslint-disable-next-line import/no-webpack-loader-syntax
|
||||
import { customElement, property, UpdatingElement } from "lit-element";
|
||||
// @ts-ignore
|
||||
// tslint:disable-next-line: no-implicit-dependencies
|
||||
// eslint-disable-next-line import/no-webpack-loader-syntax
|
||||
import markdownWorker from "workerize-loader!../resources/markdown_worker";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
|
||||
@ -10,6 +9,7 @@ let worker: any | undefined;
|
||||
@customElement("ha-markdown")
|
||||
class HaMarkdown extends UpdatingElement {
|
||||
@property() public content = "";
|
||||
|
||||
@property({ type: Boolean }) public allowSvg = false;
|
||||
|
||||
protected update(changedProps) {
|
||||
|
||||
@ -1,28 +1,33 @@
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
LitElement,
|
||||
html,
|
||||
customElement,
|
||||
CSSResult,
|
||||
css,
|
||||
} from "lit-element";
|
||||
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { HomeAssistant } from "../types";
|
||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import { subscribeNotifications } from "../data/persistent_notification";
|
||||
import { computeDomain } from "../common/entity/compute_domain";
|
||||
import { subscribeNotifications } from "../data/persistent_notification";
|
||||
import { HomeAssistant } from "../types";
|
||||
|
||||
@customElement("ha-menu-button")
|
||||
class HaMenuButton extends LitElement {
|
||||
@property({ type: Boolean }) public hassio = false;
|
||||
|
||||
@property() public narrow!: boolean;
|
||||
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() private _hasNotifications = false;
|
||||
|
||||
private _alwaysVisible = false;
|
||||
|
||||
private _attachNotifOnConnect = false;
|
||||
|
||||
private _unsubNotifications?: UnsubscribeFunc;
|
||||
|
||||
public connectedCallback() {
|
||||
@ -55,11 +60,7 @@ class HaMenuButton extends LitElement {
|
||||
.icon=${this.hassio ? "hassio:menu" : "hass:menu"}
|
||||
@click=${this._toggleMenu}
|
||||
></paper-icon-button>
|
||||
${hasNotifications
|
||||
? html`
|
||||
<div class="dot"></div>
|
||||
`
|
||||
: ""}
|
||||
${hasNotifications ? html` <div class="dot"></div> ` : ""}
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import { Constructor } from "../types";
|
||||
// Not duplicate, this is for typing.
|
||||
// tslint:disable-next-line
|
||||
import { PaperIconButtonElement } from "@polymer/paper-icon-button/paper-icon-button";
|
||||
import type { PaperIconButtonElement } from "@polymer/paper-icon-button/paper-icon-button";
|
||||
import type { Constructor } from "../types";
|
||||
|
||||
const paperIconButtonClass = customElements.get(
|
||||
"paper-icon-button"
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import { Constructor } from "../types";
|
||||
// Not duplicate, this is for typing.
|
||||
// tslint:disable-next-line
|
||||
import { PaperIconButtonElement } from "@polymer/paper-icon-button/paper-icon-button";
|
||||
import type { PaperIconButtonElement } from "@polymer/paper-icon-button/paper-icon-button";
|
||||
import type { Constructor } from "../types";
|
||||
|
||||
const paperIconButtonClass = customElements.get(
|
||||
"paper-icon-button"
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import { Constructor } from "../types";
|
||||
// Not duplicate, this is for typing.
|
||||
// tslint:disable-next-line
|
||||
import { PaperIconButtonElement } from "@polymer/paper-icon-button/paper-icon-button";
|
||||
import type { PaperIconButtonElement } from "@polymer/paper-icon-button/paper-icon-button";
|
||||
import type { Constructor } from "../types";
|
||||
|
||||
const paperIconButtonClass = customElements.get(
|
||||
"paper-icon-button"
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import { Constructor } from "../types";
|
||||
// Not duplicate, this is for typing.
|
||||
// tslint:disable-next-line
|
||||
import { PaperIconButtonElement } from "@polymer/paper-icon-button/paper-icon-button";
|
||||
import type { PaperIconButtonElement } from "@polymer/paper-icon-button/paper-icon-button";
|
||||
import type { Constructor } from "../types";
|
||||
|
||||
const paperIconButtonClass = customElements.get(
|
||||
"paper-icon-button"
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { getAppKey } from "../data/notify_html5";
|
||||
import { EventsMixin } from "../mixins/events-mixin";
|
||||
|
||||
import "./ha-switch";
|
||||
|
||||
export const pushSupported =
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import { HassEntity, UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
CSSResult,
|
||||
css,
|
||||
} from "lit-element";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import {
|
||||
@ -28,11 +28,17 @@ import "./ha-switch";
|
||||
@customElement("ha-related-items")
|
||||
export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public itemType!: ItemType;
|
||||
|
||||
@property() public itemId!: string;
|
||||
|
||||
@property() private _entries?: ConfigEntry[];
|
||||
|
||||
@property() private _devices?: DeviceRegistryEntry[];
|
||||
|
||||
@property() private _areas?: AreaRegistryEntry[];
|
||||
|
||||
@property() private _related?: RelatedResult;
|
||||
|
||||
public hassSubscribe(): UnsubscribeFunc[] {
|
||||
@ -80,7 +86,7 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
(configEntry) => configEntry.entry_id === relatedConfigEntryId
|
||||
);
|
||||
if (!entry) {
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
return html`
|
||||
<h3>
|
||||
@ -104,7 +110,7 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
(dev) => dev.id === relatedDeviceId
|
||||
);
|
||||
if (!device) {
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
return html`
|
||||
<h3>
|
||||
@ -125,7 +131,7 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
(ar) => ar.area_id === relatedAreaId
|
||||
);
|
||||
if (!area) {
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
return html`
|
||||
<h3>
|
||||
@ -146,7 +152,7 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
entityId
|
||||
];
|
||||
if (!entity) {
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
return html`
|
||||
<li>
|
||||
@ -170,7 +176,7 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
${this._related.group.map((groupId) => {
|
||||
const group: HassEntity | undefined = this.hass.states[groupId];
|
||||
if (!group) {
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
return html`
|
||||
<li>
|
||||
@ -196,7 +202,7 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
sceneId
|
||||
];
|
||||
if (!scene) {
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
return html`
|
||||
<li>
|
||||
@ -224,7 +230,7 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
automationId
|
||||
];
|
||||
if (!automation) {
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
return html`
|
||||
<li>
|
||||
@ -234,7 +240,7 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
.entityId="${automationId}"
|
||||
>
|
||||
${automation.attributes.friendly_name ||
|
||||
automation.entity_id}
|
||||
automation.entity_id}
|
||||
</button>
|
||||
</li>
|
||||
`;
|
||||
@ -253,7 +259,7 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
|
||||
scriptId
|
||||
];
|
||||
if (!script) {
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
return html`
|
||||
<li>
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { dom } from "@polymer/polymer/lib/legacy/polymer.dom";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import relativeTime from "../common/datetime/relative_time";
|
||||
|
||||
import LocalizeMixin from "../mixins/localize-mixin";
|
||||
|
||||
/*
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
class HaServiceDescription extends PolymerElement {
|
||||
static get template() {
|
||||
return html`
|
||||
[[_getDescription(hass, domain, service)]]
|
||||
`;
|
||||
return html` [[_getDescription(hass, domain, service)]] `;
|
||||
}
|
||||
|
||||
static get properties() {
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "./ha-combo-box";
|
||||
|
||||
import LocalizeMixin from "../mixins/localize-mixin";
|
||||
import "./ha-combo-box";
|
||||
|
||||
/*
|
||||
* @appliesMixin LocalizeMixin
|
||||
|
||||
@ -1,38 +1,36 @@
|
||||
import {
|
||||
LitElement,
|
||||
html,
|
||||
CSSResult,
|
||||
css,
|
||||
PropertyValues,
|
||||
property,
|
||||
eventOptions,
|
||||
} from "lit-element";
|
||||
import "@polymer/app-layout/app-toolbar/app-toolbar";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import "@polymer/paper-item/paper-icon-item";
|
||||
import type { PaperIconItemElement } from "@polymer/paper-item/paper-icon-item";
|
||||
import "@polymer/paper-item/paper-item";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import "./ha-icon";
|
||||
|
||||
import "../components/user/ha-user-badge";
|
||||
import "../components/ha-menu-button";
|
||||
import { HomeAssistant, PanelInfo } from "../types";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import {
|
||||
getExternalConfig,
|
||||
ExternalConfig,
|
||||
} from "../external_app/external_config";
|
||||
css,
|
||||
CSSResult,
|
||||
eventOptions,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
} from "lit-element";
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { computeDomain } from "../common/entity/compute_domain";
|
||||
import { compare } from "../common/string/compare";
|
||||
import { computeRTL } from "../common/util/compute_rtl";
|
||||
import { getDefaultPanel } from "../data/panel";
|
||||
import {
|
||||
PersistentNotification,
|
||||
subscribeNotifications,
|
||||
} from "../data/persistent_notification";
|
||||
import { computeDomain } from "../common/entity/compute_domain";
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
// tslint:disable-next-line: no-duplicate-imports
|
||||
import { PaperIconItemElement } from "@polymer/paper-item/paper-icon-item";
|
||||
import { computeRTL } from "../common/util/compute_rtl";
|
||||
import { compare } from "../common/string/compare";
|
||||
import { getDefaultPanel } from "../data/panel";
|
||||
import {
|
||||
ExternalConfig,
|
||||
getExternalConfig,
|
||||
} from "../external_app/external_config";
|
||||
import type { HomeAssistant, PanelInfo } from "../types";
|
||||
import "./ha-icon";
|
||||
import "./ha-menu-button";
|
||||
import "./user/ha-user-badge";
|
||||
|
||||
const SHOW_AFTER_SPACER = ["config", "developer-tools", "hassio"];
|
||||
|
||||
@ -108,19 +106,25 @@ const computePanels = (hass: HomeAssistant): [PanelInfo[], PanelInfo[]] => {
|
||||
*/
|
||||
class HaSidebar extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@property() public narrow!: boolean;
|
||||
|
||||
@property({ type: Boolean }) public alwaysExpand = false;
|
||||
|
||||
@property({ type: Boolean, reflect: true }) public expanded = false;
|
||||
|
||||
@property() private _externalConfig?: ExternalConfig;
|
||||
|
||||
@property() private _notifications?: PersistentNotification[];
|
||||
|
||||
// property used only in css
|
||||
// @ts-ignore
|
||||
@property({ type: Boolean, reflect: true }) private _rtl = false;
|
||||
|
||||
private _mouseLeaveTimeout?: number;
|
||||
|
||||
private _tooltipHideTimeout?: number;
|
||||
|
||||
private _recentKeydownActiveUntil = 0;
|
||||
|
||||
protected render() {
|
||||
|
||||
@ -1,19 +1,18 @@
|
||||
import { ripple } from "@material/mwc-ripple/ripple-directive";
|
||||
import "@material/mwc-switch";
|
||||
import type { Switch } from "@material/mwc-switch";
|
||||
import { style } from "@material/mwc-switch/mwc-switch-css";
|
||||
import {
|
||||
customElement,
|
||||
CSSResult,
|
||||
css,
|
||||
query,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
property,
|
||||
query,
|
||||
} from "lit-element";
|
||||
import "@material/mwc-switch";
|
||||
import { style } from "@material/mwc-switch/mwc-switch-css";
|
||||
// tslint:disable-next-line
|
||||
import { Switch } from "@material/mwc-switch";
|
||||
import { Constructor } from "../types";
|
||||
import { forwardHaptic } from "../data/haptics";
|
||||
import { ripple } from "@material/mwc-ripple/ripple-directive";
|
||||
// tslint:disable-next-line
|
||||
import { Constructor } from "../types";
|
||||
|
||||
const MwcSwitch = customElements.get("mwc-switch") as Constructor<Switch>;
|
||||
|
||||
@customElement("ha-switch")
|
||||
@ -22,6 +21,7 @@ export class HaSwitch extends MwcSwitch {
|
||||
// Only set to true if the new value of the switch is applied right away when toggling.
|
||||
// Do not add haptic when a user is required to press save.
|
||||
@property({ type: Boolean }) public haptic = false;
|
||||
|
||||
@query("slot") private _slot!: HTMLSlotElement;
|
||||
|
||||
protected firstUpdated() {
|
||||
|
||||
@ -11,6 +11,7 @@ WebKit issue: https://bugs.webkit.org/show_bug.cgi?id=174629
|
||||
|
||||
import "@polymer/paper-input/paper-textarea";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
class HaTextarea extends PolymerElement {
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
import "@polymer/paper-toast/paper-toast";
|
||||
import type { PaperToastElement } from "@polymer/paper-toast/paper-toast";
|
||||
import type { Constructor } from "../types";
|
||||
|
||||
// tslint:disable-next-line
|
||||
const PaperToast = customElements.get("paper-toast");
|
||||
const PaperToast = customElements.get("paper-toast") as Constructor<
|
||||
PaperToastElement
|
||||
>;
|
||||
|
||||
export class HaToast extends PaperToast {
|
||||
private _resizeListener?: (obj: { matches: boolean }) => unknown;
|
||||
|
||||
private _mediaq?: MediaQueryList;
|
||||
|
||||
public connectedCallback() {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import "@material/mwc-button";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import LocalizeMixin from "../mixins/localize-mixin";
|
||||
|
||||
const STATES_INTERCEPTABLE = {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import "@polymer/iron-flex-layout/iron-flex-layout-classes";
|
||||
import "@polymer/paper-icon-button/paper-icon-button";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import { EventsMixin } from "../mixins/events-mixin";
|
||||
|
||||
/*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import LocalizeMixin from "../mixins/localize-mixin";
|
||||
|
||||
/*
|
||||
|
||||
@ -1,10 +1,16 @@
|
||||
import { safeDump, safeLoad } from "js-yaml";
|
||||
import "./ha-code-editor";
|
||||
import { LitElement, property, customElement, html, query } from "lit-element";
|
||||
import {
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
query,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { afterNextRender } from "../common/util/render-status";
|
||||
// tslint:disable-next-line
|
||||
import { HaCodeEditor } from "./ha-code-editor";
|
||||
import "./ha-code-editor";
|
||||
import type { HaCodeEditor } from "./ha-code-editor";
|
||||
|
||||
declare global {
|
||||
// for fire event
|
||||
@ -13,12 +19,12 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
const isEmpty = (obj: object) => {
|
||||
const isEmpty = (obj: object): boolean => {
|
||||
if (typeof obj !== "object") {
|
||||
return false;
|
||||
}
|
||||
for (const key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -28,13 +34,18 @@ const isEmpty = (obj: object) => {
|
||||
@customElement("ha-yaml-editor")
|
||||
export class HaYamlEditor extends LitElement {
|
||||
@property() public value?: any;
|
||||
|
||||
@property() public defaultValue?: any;
|
||||
|
||||
@property() public isValid = true;
|
||||
|
||||
@property() public label?: string;
|
||||
@property() private _yaml: string = "";
|
||||
|
||||
@property() private _yaml = "";
|
||||
|
||||
@query("ha-code-editor") private _editor?: HaCodeEditor;
|
||||
|
||||
public setValue(value) {
|
||||
public setValue(value): void {
|
||||
try {
|
||||
this._yaml = value && !isEmpty(value) ? safeDump(value) : "";
|
||||
} catch (err) {
|
||||
@ -48,22 +59,18 @@ export class HaYamlEditor extends LitElement {
|
||||
});
|
||||
}
|
||||
|
||||
protected firstUpdated() {
|
||||
protected firstUpdated(): void {
|
||||
if (this.defaultValue) {
|
||||
this.setValue(this.defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
protected render() {
|
||||
protected render(): TemplateResult {
|
||||
if (this._yaml === undefined) {
|
||||
return;
|
||||
return html``;
|
||||
}
|
||||
return html`
|
||||
${this.label
|
||||
? html`
|
||||
<p>${this.label}</p>
|
||||
`
|
||||
: ""}
|
||||
${this.label ? html` <p>${this.label}</p> ` : ""}
|
||||
<ha-code-editor
|
||||
.value=${this._yaml}
|
||||
mode="yaml"
|
||||
@ -73,7 +80,7 @@ export class HaYamlEditor extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _onChange(ev: CustomEvent) {
|
||||
private _onChange(ev: CustomEvent): void {
|
||||
ev.stopPropagation();
|
||||
const value = ev.detail.value;
|
||||
let parsed;
|
||||
|
||||
@ -1,43 +1,51 @@
|
||||
import {
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
html,
|
||||
CSSResult,
|
||||
css,
|
||||
customElement,
|
||||
PropertyValues,
|
||||
} from "lit-element";
|
||||
import {
|
||||
Marker,
|
||||
Map,
|
||||
LeafletMouseEvent,
|
||||
DragEndEvent,
|
||||
LatLng,
|
||||
Circle,
|
||||
DivIcon,
|
||||
DragEndEvent,
|
||||
LatLng,
|
||||
LeafletMouseEvent,
|
||||
Map,
|
||||
Marker,
|
||||
} from "leaflet";
|
||||
import {
|
||||
setupLeafletMap,
|
||||
LeafletModuleType,
|
||||
} from "../../common/dom/setup-leaflet-map";
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import {
|
||||
LeafletModuleType,
|
||||
setupLeafletMap,
|
||||
} from "../../common/dom/setup-leaflet-map";
|
||||
import { nextRender } from "../../common/util/render-status";
|
||||
import { defaultRadiusColor } from "../../data/zone";
|
||||
|
||||
@customElement("ha-location-editor")
|
||||
class LocationEditor extends LitElement {
|
||||
@property() public location?: [number, number];
|
||||
|
||||
@property() public radius?: number;
|
||||
|
||||
@property() public radiusColor?: string;
|
||||
|
||||
@property() public icon?: string;
|
||||
|
||||
public fitZoom = 16;
|
||||
|
||||
private _iconEl?: DivIcon;
|
||||
|
||||
private _ignoreFitToMap?: [number, number];
|
||||
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
private Leaflet?: LeafletModuleType;
|
||||
|
||||
private _leafletMap?: Map;
|
||||
|
||||
private _locationMarker?: Marker | Circle;
|
||||
|
||||
public fitMap(): void {
|
||||
@ -53,9 +61,7 @@ class LocationEditor extends LitElement {
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<div id="map"></div>
|
||||
`;
|
||||
return html` <div id="map"></div> `;
|
||||
}
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues): void {
|
||||
|
||||
@ -1,27 +1,27 @@
|
||||
import {
|
||||
LitElement,
|
||||
property,
|
||||
TemplateResult,
|
||||
html,
|
||||
CSSResult,
|
||||
css,
|
||||
customElement,
|
||||
PropertyValues,
|
||||
} from "lit-element";
|
||||
import {
|
||||
Marker,
|
||||
Map,
|
||||
Circle,
|
||||
DivIcon,
|
||||
DragEndEvent,
|
||||
LatLng,
|
||||
Circle,
|
||||
Map,
|
||||
Marker,
|
||||
MarkerOptions,
|
||||
DivIcon,
|
||||
} from "leaflet";
|
||||
import {
|
||||
setupLeafletMap,
|
||||
LeafletModuleType,
|
||||
} from "../../common/dom/setup-leaflet-map";
|
||||
css,
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
LitElement,
|
||||
property,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import {
|
||||
LeafletModuleType,
|
||||
setupLeafletMap,
|
||||
} from "../../common/dom/setup-leaflet-map";
|
||||
import { defaultRadiusColor } from "../../data/zone";
|
||||
|
||||
declare global {
|
||||
@ -48,13 +48,17 @@ export interface MarkerLocation {
|
||||
@customElement("ha-locations-editor")
|
||||
export class HaLocationsEditor extends LitElement {
|
||||
@property() public locations?: MarkerLocation[];
|
||||
|
||||
public fitZoom = 16;
|
||||
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line
|
||||
private Leaflet?: LeafletModuleType;
|
||||
// tslint:disable-next-line
|
||||
|
||||
// eslint-disable-next-line
|
||||
private _leafletMap?: Map;
|
||||
|
||||
private _locationMarkers?: { [key: string]: Marker | Circle };
|
||||
|
||||
private _circles: { [key: string]: Circle } = {};
|
||||
|
||||
public fitMap(): void {
|
||||
@ -93,9 +97,7 @@ export class HaLocationsEditor extends LitElement {
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<div id="map"></div>
|
||||
`;
|
||||
return html` <div id="map"></div> `;
|
||||
}
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues): void {
|
||||
|
||||
@ -17,21 +17,27 @@ import {
|
||||
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||
import { debounce } from "../../common/util/debounce";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import "../../panels/map/ha-entity-marker";
|
||||
import { HomeAssistant } from "../../types";
|
||||
|
||||
@customElement("ha-map")
|
||||
class HaMap extends LitElement {
|
||||
@property() public hass?: HomeAssistant;
|
||||
|
||||
@property() public entities?: string[];
|
||||
|
||||
@property() public darkMode = false;
|
||||
|
||||
@property() public zoom?: number;
|
||||
// tslint:disable-next-line
|
||||
|
||||
// eslint-disable-next-line
|
||||
private Leaflet?: LeafletModuleType;
|
||||
|
||||
private _leafletMap?: Map;
|
||||
|
||||
// @ts-ignore
|
||||
private _resizeObserver?: ResizeObserver;
|
||||
|
||||
private _debouncedResizeListener = debounce(
|
||||
() => {
|
||||
if (!this._leafletMap) {
|
||||
@ -42,8 +48,11 @@ class HaMap extends LitElement {
|
||||
100,
|
||||
false
|
||||
);
|
||||
|
||||
private _mapItems: Array<Marker | Circle> = [];
|
||||
|
||||
private _mapZones: Array<Marker | Circle> = [];
|
||||
|
||||
private _connected = false;
|
||||
|
||||
public connectedCallback(): void {
|
||||
@ -76,9 +85,7 @@ class HaMap extends LitElement {
|
||||
if (!this.entities) {
|
||||
return html``;
|
||||
}
|
||||
return html`
|
||||
<div id="map"></div>
|
||||
`;
|
||||
return html` <div id="map"></div> `;
|
||||
}
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues): void {
|
||||
|
||||
@ -16,11 +16,12 @@ Custom property | Description | Default
|
||||
`--paper-time-input-cotnainer` | Mixin applied to the inputs | `{}`
|
||||
`--paper-time-dropdown-input-cotnainer` | Mixin applied to the dropdown input | `{}`
|
||||
*/
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import "@polymer/paper-item/paper-item";
|
||||
import "@polymer/paper-dropdown-menu/paper-dropdown-menu";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import "@polymer/paper-item/paper-item";
|
||||
import "@polymer/paper-listbox/paper-listbox";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
export class PaperTimeInput extends PolymerElement {
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import "@polymer/polymer/lib/utils/debounce";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import "./entity/ha-chart-base";
|
||||
|
||||
import LocalizeMixin from "../mixins/localize-mixin";
|
||||
import { formatDateTimeWithSeconds } from "../common/datetime/format_date_time";
|
||||
import LocalizeMixin from "../mixins/localize-mixin";
|
||||
import "./entity/ha-chart-base";
|
||||
|
||||
class StateHistoryChartLine extends LocalizeMixin(PolymerElement) {
|
||||
static get template() {
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
import "@polymer/polymer/lib/utils/debounce";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
/* eslint-plugin-disable lit */
|
||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||
|
||||
import LocalizeMixin from "../mixins/localize-mixin";
|
||||
|
||||
import "./entity/ha-chart-base";
|
||||
|
||||
import { formatDateTimeWithSeconds } from "../common/datetime/format_date_time";
|
||||
import { computeRTL } from "../common/util/compute_rtl";
|
||||
import LocalizeMixin from "../mixins/localize-mixin";
|
||||
import "./entity/ha-chart-base";
|
||||
|
||||
class StateHistoryChartTimeline extends LocalizeMixin(PolymerElement) {
|
||||
static get template() {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user