Compare commits
144 Commits
add-import
...
upgrade-we
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8ecd54ddf2 | ||
![]() |
304fad3f49 | ||
![]() |
a3736683eb | ||
![]() |
8ad2bf5401 | ||
![]() |
66409f0fa5 | ||
![]() |
68172e006f | ||
![]() |
cf5e808a96 | ||
![]() |
3faebaeb4b | ||
![]() |
6b8cfe661c | ||
![]() |
2fd64af737 | ||
![]() |
050cdf3783 | ||
![]() |
d73b3d77ea | ||
![]() |
acc024bcf9 | ||
![]() |
deb179ad38 | ||
![]() |
bfb11790a2 | ||
![]() |
af23110074 | ||
![]() |
b8e71609db | ||
![]() |
1876b3827f | ||
![]() |
38d3b8d087 | ||
![]() |
c5ef33cc78 | ||
![]() |
7427b209a7 | ||
![]() |
71397e5199 | ||
![]() |
1bc3b3befc | ||
![]() |
872e46a076 | ||
![]() |
ad386c0e22 | ||
![]() |
7e281f66c2 | ||
![]() |
7daafcbe1b | ||
![]() |
c5b223988a | ||
![]() |
06667455ae | ||
![]() |
3640960486 | ||
![]() |
4ad3dbf3e2 | ||
![]() |
10957deb1f | ||
![]() |
0a128db269 | ||
![]() |
6bb3b84377 | ||
![]() |
b8d2c551e0 | ||
![]() |
34e06351fb | ||
![]() |
e179404a9e | ||
![]() |
5f81a204f2 | ||
![]() |
df3b70a533 | ||
![]() |
e4607735ff | ||
![]() |
389b7def0b | ||
![]() |
e35bd30ed3 | ||
![]() |
5cc4e2bb16 | ||
![]() |
3a453f5843 | ||
![]() |
28e0384b55 | ||
![]() |
dcd6c6f06f | ||
![]() |
28d26065e4 | ||
![]() |
300c8d06c4 | ||
![]() |
d2a1d11d16 | ||
![]() |
6ae717bbfe | ||
![]() |
21296b4224 | ||
![]() |
0c94ad46b2 | ||
![]() |
d9bb40f934 | ||
![]() |
bbc16b6bc8 | ||
![]() |
16154e9d8b | ||
![]() |
61bd536d7b | ||
![]() |
02c798a8bc | ||
![]() |
c37a691b9b | ||
![]() |
23c68d17e8 | ||
![]() |
c9e8bd2e5d | ||
![]() |
a66d2ca1b9 | ||
![]() |
d38a0f0366 | ||
![]() |
29759de021 | ||
![]() |
264759ddf0 | ||
![]() |
91b0bd5b5e | ||
![]() |
a0e2cc7a3a | ||
![]() |
9e1eb41cbe | ||
![]() |
c37eb023b0 | ||
![]() |
840948ba4a | ||
![]() |
8fbdd88b24 | ||
![]() |
512d35d2e0 | ||
![]() |
0321e55a42 | ||
![]() |
a1ee9ad48b | ||
![]() |
1ad1fd28f1 | ||
![]() |
6fe8a87cca | ||
![]() |
5f46679d94 | ||
![]() |
18a3f212f3 | ||
![]() |
67a3f5d87b | ||
![]() |
c88439ba2f | ||
![]() |
67e17d4016 | ||
![]() |
b61cf60faf | ||
![]() |
5503853445 | ||
![]() |
bec42d941b | ||
![]() |
dcbbaf08f9 | ||
![]() |
349355584a | ||
![]() |
7ce0b34774 | ||
![]() |
dd894758a4 | ||
![]() |
2aa1eb97fd | ||
![]() |
4c43ae7b2f | ||
![]() |
34e516e0be | ||
![]() |
7bd3427e76 | ||
![]() |
252ce1e467 | ||
![]() |
221c12bd61 | ||
![]() |
12edd68874 | ||
![]() |
f469753fb1 | ||
![]() |
c894ecd0e6 | ||
![]() |
2153bc536c | ||
![]() |
86bbac430c | ||
![]() |
16ad8a3c01 | ||
![]() |
b2af91c83e | ||
![]() |
4c0810f530 | ||
![]() |
f70130e21f | ||
![]() |
6bb7b01d00 | ||
![]() |
54704e53b3 | ||
![]() |
cc46797576 | ||
![]() |
7f1fb6f75f | ||
![]() |
2c2a1d204b | ||
![]() |
581fafdcc9 | ||
![]() |
10358abbec | ||
![]() |
eb2b24d57c | ||
![]() |
825db8a56a | ||
![]() |
577a21fc5c | ||
![]() |
1b2841eef9 | ||
![]() |
845511e322 | ||
![]() |
96ab057853 | ||
![]() |
f85cf0a238 | ||
![]() |
84a2676a9c | ||
![]() |
466a1af902 | ||
![]() |
ebbe7e805f | ||
![]() |
c861ee025e | ||
![]() |
6d0823328d | ||
![]() |
60be14dc77 | ||
![]() |
2d627819d9 | ||
![]() |
cf575f83f5 | ||
![]() |
79935b2d4c | ||
![]() |
d1cceb2013 | ||
![]() |
f5da130d51 | ||
![]() |
8768304ec5 | ||
![]() |
f10a5dcdbe | ||
![]() |
a27428ebcd | ||
![]() |
1a0bf861ee | ||
![]() |
db906ad4d0 | ||
![]() |
75ed0f2f99 | ||
![]() |
29ed1144d5 | ||
![]() |
fa445d4066 | ||
![]() |
d10be4ef2d | ||
![]() |
7f66d5b8e9 | ||
![]() |
0c8cd680c2 | ||
![]() |
a7ba1977b4 | ||
![]() |
a960b39235 | ||
![]() |
3febf059ec | ||
![]() |
20203f7bdb | ||
![]() |
a399d76d06 | ||
![]() |
1ca097c5a0 |
@@ -69,7 +69,7 @@
|
|||||||
"import/extensions": [
|
"import/extensions": [
|
||||||
2,
|
2,
|
||||||
"ignorePackages",
|
"ignorePackages",
|
||||||
{ "ts": "ignorePackages", "js": "ignorePackages" }
|
{ "ts": "never", "js": "never" }
|
||||||
],
|
],
|
||||||
"no-restricted-syntax": ["error", "LabeledStatement", "WithStatement"],
|
"no-restricted-syntax": ["error", "LabeledStatement", "WithStatement"],
|
||||||
"object-curly-newline": 0,
|
"object-curly-newline": 0,
|
||||||
|
14
.github/workflows/release-drafter.yaml
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
name: Release Drafter
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update_release_draft:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: release-drafter/release-drafter@v5
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@@ -2,79 +2,139 @@
|
|||||||
|
|
||||||
## Our Pledge
|
## Our Pledge
|
||||||
|
|
||||||
In the interest of fostering an open and welcoming environment, we as
|
We as members, contributors, and leaders pledge to make participation in our
|
||||||
contributors and maintainers pledge to making participation in our project and
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
our community a harassment-free experience for everyone, regardless of age, body
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
nationality, personal appearance, race, religion, or sexual identity and
|
nationality, personal appearance, race, religion, or sexual identity
|
||||||
orientation.
|
and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
|
diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
## Our Standards
|
## Our Standards
|
||||||
|
|
||||||
Examples of behavior that contributes to creating a positive environment
|
Examples of behavior that contributes to a positive environment for our
|
||||||
include:
|
community include:
|
||||||
|
|
||||||
* Using welcoming and inclusive language
|
* Demonstrating empathy and kindness toward other people
|
||||||
* Being respectful of differing viewpoints and experiences
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
* Gracefully accepting constructive criticism
|
* Giving and gracefully accepting constructive feedback
|
||||||
* Focusing on what is best for the community
|
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
* Showing empathy towards other community members
|
and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the
|
||||||
|
overall community
|
||||||
|
|
||||||
Examples of unacceptable behavior by participants include:
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
* The use of sexualized language or imagery, and sexual attention or
|
||||||
advances
|
advances of any kind
|
||||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
* Public or private harassment
|
* Public or private harassment
|
||||||
* Publishing others' private information, such as a physical or electronic
|
* Publishing others' private information, such as a physical or email
|
||||||
address, without explicit permission
|
address, without their explicit permission
|
||||||
* Other conduct which could reasonably be considered inappropriate in a
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
professional setting
|
professional setting
|
||||||
|
|
||||||
## Our Responsibilities
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
Project maintainers are responsible for clarifying the standards of acceptable
|
Community leaders are responsible for clarifying and enforcing our standards of
|
||||||
behavior and are expected to take appropriate and fair corrective action in
|
acceptable behavior and will take appropriate and fair corrective action in
|
||||||
response to any instances of unacceptable behavior.
|
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||||
|
or harmful.
|
||||||
|
|
||||||
Project maintainers have the right and responsibility to remove, edit, or
|
Community leaders have the right and responsibility to remove, edit, or reject
|
||||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||||
permanently any contributor for other behaviors that they deem inappropriate,
|
decisions when appropriate.
|
||||||
threatening, offensive, or harmful.
|
|
||||||
|
|
||||||
## Scope
|
## Scope
|
||||||
|
|
||||||
This Code of Conduct applies both within project spaces and in public spaces
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
when an individual is representing the project or its community. Examples of
|
an individual is officially representing the community in public spaces.
|
||||||
representing a project or community include using an official project e-mail
|
Examples of representing our community include using an official e-mail address,
|
||||||
address, posting via an official social media account, or acting as an appointed
|
posting via an official social media account, or acting as an appointed
|
||||||
representative at an online or offline event. Representation of a project may be
|
representative at an online or offline event.
|
||||||
further defined and clarified by project maintainers.
|
|
||||||
|
|
||||||
## Enforcement
|
## Enforcement
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
reported by contacting the project team at [safety@home-assistant.io][email]. All
|
reported to the community leaders responsible for enforcement at
|
||||||
complaints will be reviewed and investigated and will result in a response that
|
[safety@home-assistant.io][email] or by using the report/flag feature of
|
||||||
is deemed necessary and appropriate to the circumstances. The project team is
|
the medium used. All complaints will be reviewed and investigated promptly and
|
||||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
fairly.
|
||||||
Further details of specific enforcement policies may be posted separately.
|
|
||||||
|
|
||||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
faith may face temporary or permanent repercussions as determined by other
|
reporter of any incident.
|
||||||
members of the project's leadership.
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining
|
||||||
|
the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||||
|
unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing
|
||||||
|
clarity around the nature of the violation and an explanation of why the
|
||||||
|
behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series
|
||||||
|
of actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
|
interaction with the people involved, including unsolicited interaction with
|
||||||
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
|
like social media. Violating these terms may lead to a temporary or
|
||||||
|
permanent ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including
|
||||||
|
sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public
|
||||||
|
communication with the community for a specified period of time. No public or
|
||||||
|
private interaction with the people involved, including unsolicited interaction
|
||||||
|
with those enforcing the Code of Conduct, is allowed during this period.
|
||||||
|
Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within
|
||||||
|
the community.
|
||||||
|
|
||||||
## Attribution
|
## Attribution
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
available [here][version].
|
version 2.0, available [here][version].
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||||
|
enforcement ladder][mozilla].
|
||||||
|
|
||||||
## Adoption
|
## Adoption
|
||||||
|
|
||||||
This Code of Conduct was first adopted January 21st, 2017 and announced in [this][coc-blog] blog post.
|
This Code of Conduct was first adopted January 21st, 2017 and announced in
|
||||||
|
[this][coc-blog] blog post and has been updated on May 25th, 2020 to version
|
||||||
|
2.0 of the [Contributor Covenant][homepage] as announced in [this][coc2-blog]
|
||||||
|
blog post.
|
||||||
|
|
||||||
[homepage]: http://contributor-covenant.org
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
[version]: http://contributor-covenant.org/version/1/4/
|
<https://www.contributor-covenant.org/faq>. Translations are available at
|
||||||
|
<https://www.contributor-covenant.org/translations>.
|
||||||
|
|
||||||
|
[coc-blog]: /blog/2017/01/21/home-assistant-governance/
|
||||||
|
[coc2-blog]: /blog/2020/05/25/code-of-conduct-updated/
|
||||||
[email]: mailto:safety@home-assistant.io
|
[email]: mailto:safety@home-assistant.io
|
||||||
[coc-blog]: https://home-assistant.io/blog/2017/01/21/home-assistant-governance/
|
[homepage]: http://contributor-covenant.org
|
||||||
|
[mozilla]: https://github.com/mozilla/diversity
|
||||||
|
[version]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
|
||||||
|
@@ -6,12 +6,12 @@ This is the repository for the official [Home Assistant](https://home-assistant.
|
|||||||
|
|
||||||
- [View demo of Home Assistant](https://demo.home-assistant.io/)
|
- [View demo of Home Assistant](https://demo.home-assistant.io/)
|
||||||
- [More information about Home Assistant](https://home-assistant.io)
|
- [More information about Home Assistant](https://home-assistant.io)
|
||||||
- [Frontend development instructions](https://developers.home-assistant.io/docs/en/frontend_index.html)
|
- [Frontend development instructions](https://developers.home-assistant.io/docs/frontend/development/)
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
- Initial setup: `script/setup`
|
- Initial setup: `script/setup`
|
||||||
- Development: [Instructions](https://developers.home-assistant.io/docs/en/frontend_development.html)
|
- Development: [Instructions](https://developers.home-assistant.io/docs/frontend/development/)
|
||||||
- Production build: `script/build_frontend`
|
- Production build: `script/build_frontend`
|
||||||
- Gallery: `cd gallery && script/develop_gallery`
|
- Gallery: `cd gallery && script/develop_gallery`
|
||||||
- Hass.io: [Instructions](https://developers.home-assistant.io/docs/en/hassio_hass.html)
|
- Hass.io: [Instructions](https://developers.home-assistant.io/docs/en/hassio_hass.html)
|
||||||
|
@@ -1,40 +0,0 @@
|
|||||||
const options = ({ latestBuild }) => ({
|
|
||||||
presets: [
|
|
||||||
!latestBuild && [require("@babel/preset-env").default, { modules: false }],
|
|
||||||
require("@babel/preset-typescript").default,
|
|
||||||
].filter(Boolean),
|
|
||||||
plugins: [
|
|
||||||
// Part of ES2018. Converts {...a, b: 2} to Object.assign({}, a, {b: 2})
|
|
||||||
[
|
|
||||||
"@babel/plugin-proposal-object-rest-spread",
|
|
||||||
{ loose: true, useBuiltIns: true },
|
|
||||||
],
|
|
||||||
// Only support the syntax, Webpack will handle it.
|
|
||||||
"@babel/syntax-dynamic-import",
|
|
||||||
"@babel/plugin-proposal-optional-chaining",
|
|
||||||
"@babel/plugin-proposal-nullish-coalescing-operator",
|
|
||||||
[
|
|
||||||
require("@babel/plugin-proposal-decorators").default,
|
|
||||||
{ decoratorsBeforeExport: true },
|
|
||||||
],
|
|
||||||
[
|
|
||||||
require("@babel/plugin-proposal-class-properties").default,
|
|
||||||
{ loose: true },
|
|
||||||
],
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports.options = options;
|
|
||||||
module.exports.babelLoaderConfig = ({ latestBuild }) => {
|
|
||||||
if (latestBuild === undefined) {
|
|
||||||
throw Error("latestBuild not defined for babel loader config");
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
test: /\.m?js$|\.tsx?$/,
|
|
||||||
exclude: [require.resolve("@mdi/js/mdi.js"), require.resolve("hls.js")],
|
|
||||||
use: {
|
|
||||||
loader: "babel-loader",
|
|
||||||
options: options({ latestBuild }),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
196
build-scripts/bundle.js
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
const path = require("path");
|
||||||
|
const env = require("./env.js");
|
||||||
|
const paths = require("./paths.js");
|
||||||
|
|
||||||
|
// Files from NPM Packages that should not be imported
|
||||||
|
module.exports.ignorePackages = ({ latestBuild }) => [
|
||||||
|
// Bloats bundle and it's not used.
|
||||||
|
path.resolve(require.resolve("moment"), "../locale"),
|
||||||
|
// Part of yaml.js and only used for !!js functions that we don't use
|
||||||
|
require.resolve("esprima"),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Files from NPM packages that we should replace with empty file
|
||||||
|
module.exports.emptyPackages = ({ latestBuild }) =>
|
||||||
|
[
|
||||||
|
// Contains all color definitions for all material color sets.
|
||||||
|
// We don't use it
|
||||||
|
require.resolve("@polymer/paper-styles/color.js"),
|
||||||
|
require.resolve("@polymer/paper-styles/default-theme.js"),
|
||||||
|
// Loads stuff from a CDN
|
||||||
|
require.resolve("@polymer/font-roboto/roboto.js"),
|
||||||
|
require.resolve("@vaadin/vaadin-material-styles/font-roboto.js"),
|
||||||
|
// Compatibility not needed for latest builds
|
||||||
|
latestBuild &&
|
||||||
|
path.resolve(paths.polymer_dir, "src/entrypoints/compatibility.ts"),
|
||||||
|
// This polyfill is loaded in workers to support ES5, filter it out.
|
||||||
|
latestBuild && require.resolve("proxy-polyfill/src/index.js"),
|
||||||
|
].filter(Boolean);
|
||||||
|
|
||||||
|
module.exports.definedVars = ({ isProdBuild, latestBuild, defineOverlay }) => ({
|
||||||
|
__DEV__: !isProdBuild,
|
||||||
|
__BUILD__: JSON.stringify(latestBuild ? "latest" : "es5"),
|
||||||
|
__VERSION__: JSON.stringify(env.version()),
|
||||||
|
__DEMO__: false,
|
||||||
|
__BACKWARDS_COMPAT__: false,
|
||||||
|
__STATIC_PATH__: "/static/",
|
||||||
|
"process.env.NODE_ENV": JSON.stringify(
|
||||||
|
isProdBuild ? "production" : "development"
|
||||||
|
),
|
||||||
|
...defineOverlay,
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports.terserOptions = (latestBuild) => ({
|
||||||
|
safari10: true,
|
||||||
|
ecma: latestBuild ? undefined : 5,
|
||||||
|
output: { comments: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports.babelOptions = ({ latestBuild }) => ({
|
||||||
|
babelrc: false,
|
||||||
|
presets: [
|
||||||
|
!latestBuild && [require("@babel/preset-env").default, { modules: false }],
|
||||||
|
require("@babel/preset-typescript").default,
|
||||||
|
].filter(Boolean),
|
||||||
|
plugins: [
|
||||||
|
// Part of ES2018. Converts {...a, b: 2} to Object.assign({}, a, {b: 2})
|
||||||
|
[
|
||||||
|
"@babel/plugin-proposal-object-rest-spread",
|
||||||
|
{ loose: true, useBuiltIns: true },
|
||||||
|
],
|
||||||
|
// Only support the syntax, Webpack will handle it.
|
||||||
|
"@babel/syntax-dynamic-import",
|
||||||
|
"@babel/plugin-proposal-optional-chaining",
|
||||||
|
"@babel/plugin-proposal-nullish-coalescing-operator",
|
||||||
|
[
|
||||||
|
require("@babel/plugin-proposal-decorators").default,
|
||||||
|
{ decoratorsBeforeExport: true },
|
||||||
|
],
|
||||||
|
[
|
||||||
|
require("@babel/plugin-proposal-class-properties").default,
|
||||||
|
{ loose: true },
|
||||||
|
],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Are already ES5, cause warnings when babelified.
|
||||||
|
module.exports.babelExclude = () => [
|
||||||
|
require.resolve("@mdi/js/mdi.js"),
|
||||||
|
require.resolve("hls.js"),
|
||||||
|
];
|
||||||
|
|
||||||
|
const outputPath = (outputRoot, latestBuild) =>
|
||||||
|
path.resolve(outputRoot, latestBuild ? "frontend_latest" : "frontend_es5");
|
||||||
|
|
||||||
|
const publicPath = (latestBuild) =>
|
||||||
|
latestBuild ? "/frontend_latest/" : "/frontend_es5/";
|
||||||
|
|
||||||
|
/*
|
||||||
|
BundleConfig {
|
||||||
|
// Object with entrypoints that need to be bundled
|
||||||
|
entry: { [name: string]: pathToFile },
|
||||||
|
// Folder where bundled files need to be written
|
||||||
|
outputPath: string,
|
||||||
|
// absolute url-path where bundled files can be found
|
||||||
|
publicPath: string,
|
||||||
|
// extra definitions that we need to replace in source
|
||||||
|
defineOverlay: {[name: string]: value },
|
||||||
|
// if this is a production build
|
||||||
|
isProdBuild: boolean,
|
||||||
|
// If we're targeting latest browsers
|
||||||
|
latestBuild: boolean,
|
||||||
|
// If we're doing a stats build (create nice chunk names)
|
||||||
|
isStatsBuild: boolean,
|
||||||
|
// Names of entrypoints that should not be hashed
|
||||||
|
dontHash: Set<string>
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports.config = {
|
||||||
|
app({ isProdBuild, latestBuild, isStatsBuild }) {
|
||||||
|
return {
|
||||||
|
entry: {
|
||||||
|
service_worker: "./src/entrypoints/service_worker.ts",
|
||||||
|
app: "./src/entrypoints/app.ts",
|
||||||
|
authorize: "./src/entrypoints/authorize.ts",
|
||||||
|
onboarding: "./src/entrypoints/onboarding.ts",
|
||||||
|
core: "./src/entrypoints/core.ts",
|
||||||
|
"custom-panel": "./src/entrypoints/custom-panel.ts",
|
||||||
|
},
|
||||||
|
outputPath: outputPath(paths.app_output_root, latestBuild),
|
||||||
|
publicPath: publicPath(latestBuild),
|
||||||
|
isProdBuild,
|
||||||
|
latestBuild,
|
||||||
|
isStatsBuild,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
demo({ isProdBuild, latestBuild, isStatsBuild }) {
|
||||||
|
return {
|
||||||
|
entry: {
|
||||||
|
main: path.resolve(paths.demo_dir, "src/entrypoint.ts"),
|
||||||
|
},
|
||||||
|
outputPath: outputPath(paths.demo_output_root, latestBuild),
|
||||||
|
publicPath: publicPath(latestBuild),
|
||||||
|
defineOverlay: {
|
||||||
|
__VERSION__: JSON.stringify(`DEMO-${env.version()}`),
|
||||||
|
__DEMO__: true,
|
||||||
|
},
|
||||||
|
isProdBuild,
|
||||||
|
latestBuild,
|
||||||
|
isStatsBuild,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
cast({ isProdBuild, latestBuild }) {
|
||||||
|
const entry = {
|
||||||
|
launcher: path.resolve(paths.cast_dir, "src/launcher/entrypoint.ts"),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (latestBuild) {
|
||||||
|
entry.receiver = path.resolve(
|
||||||
|
paths.cast_dir,
|
||||||
|
"src/receiver/entrypoint.ts"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
entry,
|
||||||
|
outputPath: outputPath(paths.cast_output_root, latestBuild),
|
||||||
|
publicPath: publicPath(latestBuild),
|
||||||
|
isProdBuild,
|
||||||
|
latestBuild,
|
||||||
|
defineOverlay: {
|
||||||
|
__BACKWARDS_COMPAT__: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
hassio({ isProdBuild, latestBuild }) {
|
||||||
|
if (latestBuild) {
|
||||||
|
throw new Error("Hass.io does not support latest build!");
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
entry: {
|
||||||
|
entrypoint: path.resolve(paths.hassio_dir, "src/entrypoint.ts"),
|
||||||
|
},
|
||||||
|
outputPath: paths.hassio_output_root,
|
||||||
|
publicPath: paths.hassio_publicPath,
|
||||||
|
isProdBuild,
|
||||||
|
latestBuild,
|
||||||
|
dontHash: new Set(["entrypoint"]),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
gallery({ isProdBuild, latestBuild }) {
|
||||||
|
return {
|
||||||
|
entry: {
|
||||||
|
entrypoint: path.resolve(paths.gallery_dir, "src/entrypoint.js"),
|
||||||
|
},
|
||||||
|
outputPath: outputPath(paths.gallery_output_root, latestBuild),
|
||||||
|
publicPath: publicPath(latestBuild),
|
||||||
|
isProdBuild,
|
||||||
|
latestBuild,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
@@ -3,8 +3,13 @@ const path = require("path");
|
|||||||
const paths = require("./paths.js");
|
const paths = require("./paths.js");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
useRollup() {
|
||||||
|
return process.env.ROLLUP === "1";
|
||||||
|
},
|
||||||
isProdBuild() {
|
isProdBuild() {
|
||||||
return process.env.NODE_ENV === "production";
|
return (
|
||||||
|
process.env.NODE_ENV === "production" || module.exports.isStatsBuild()
|
||||||
|
);
|
||||||
},
|
},
|
||||||
isStatsBuild() {
|
isStatsBuild() {
|
||||||
return process.env.STATS === "1";
|
return process.env.STATS === "1";
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// Run HA develop mode
|
// Run HA develop mode
|
||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
|
|
||||||
const envVars = require("../env");
|
const env = require("../env");
|
||||||
|
|
||||||
require("./clean.js");
|
require("./clean.js");
|
||||||
require("./translations.js");
|
require("./translations.js");
|
||||||
@@ -11,6 +11,7 @@ require("./compress.js");
|
|||||||
require("./webpack.js");
|
require("./webpack.js");
|
||||||
require("./service-worker.js");
|
require("./service-worker.js");
|
||||||
require("./entry-html.js");
|
require("./entry-html.js");
|
||||||
|
require("./rollup.js");
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"develop-app",
|
"develop-app",
|
||||||
@@ -20,14 +21,14 @@ gulp.task(
|
|||||||
},
|
},
|
||||||
"clean",
|
"clean",
|
||||||
gulp.parallel(
|
gulp.parallel(
|
||||||
"gen-service-worker-dev",
|
"gen-service-worker-app-dev",
|
||||||
"gen-icons-json",
|
"gen-icons-json",
|
||||||
"gen-pages-dev",
|
"gen-pages-dev",
|
||||||
"gen-index-app-dev",
|
"gen-index-app-dev",
|
||||||
"build-translations"
|
"build-translations"
|
||||||
),
|
),
|
||||||
"copy-static",
|
"copy-static-app",
|
||||||
"webpack-watch-app"
|
env.useRollup() ? "rollup-watch-app" : "webpack-watch-app"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -39,14 +40,14 @@ gulp.task(
|
|||||||
},
|
},
|
||||||
"clean",
|
"clean",
|
||||||
gulp.parallel("gen-icons-json", "build-translations"),
|
gulp.parallel("gen-icons-json", "build-translations"),
|
||||||
"copy-static",
|
"copy-static-app",
|
||||||
"webpack-prod-app",
|
env.useRollup() ? "rollup-prod-app" : "webpack-prod-app",
|
||||||
...// Don't compress running tests
|
...// Don't compress running tests
|
||||||
(envVars.isTest() ? [] : ["compress-app"]),
|
(env.isTest() ? [] : ["compress-app"]),
|
||||||
gulp.parallel(
|
gulp.parallel(
|
||||||
"gen-pages-prod",
|
"gen-pages-prod",
|
||||||
"gen-index-app-prod",
|
"gen-index-app-prod",
|
||||||
"gen-service-worker-prod"
|
"gen-service-worker-app-prod"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@@ -1,11 +1,14 @@
|
|||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
|
|
||||||
|
const env = require("../env");
|
||||||
|
|
||||||
require("./clean.js");
|
require("./clean.js");
|
||||||
require("./translations.js");
|
require("./translations.js");
|
||||||
require("./gather-static.js");
|
require("./gather-static.js");
|
||||||
require("./webpack.js");
|
require("./webpack.js");
|
||||||
require("./service-worker.js");
|
require("./service-worker.js");
|
||||||
require("./entry-html.js");
|
require("./entry-html.js");
|
||||||
|
require("./rollup.js");
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"develop-cast",
|
"develop-cast",
|
||||||
@@ -17,7 +20,7 @@ gulp.task(
|
|||||||
"translations-enable-merge-backend",
|
"translations-enable-merge-backend",
|
||||||
gulp.parallel("gen-icons-json", "build-translations"),
|
gulp.parallel("gen-icons-json", "build-translations"),
|
||||||
"copy-static-cast",
|
"copy-static-cast",
|
||||||
"webpack-dev-server-cast"
|
env.useRollup() ? "rollup-dev-server-cast" : "webpack-dev-server-cast"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -31,7 +34,7 @@ gulp.task(
|
|||||||
"translations-enable-merge-backend",
|
"translations-enable-merge-backend",
|
||||||
gulp.parallel("gen-icons-json", "build-translations"),
|
gulp.parallel("gen-icons-json", "build-translations"),
|
||||||
"copy-static-cast",
|
"copy-static-cast",
|
||||||
"webpack-prod-cast",
|
env.useRollup() ? "rollup-prod-cast" : "webpack-prod-cast",
|
||||||
"gen-index-cast-prod"
|
"gen-index-cast-prod"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@@ -6,34 +6,34 @@ require("./translations");
|
|||||||
gulp.task(
|
gulp.task(
|
||||||
"clean",
|
"clean",
|
||||||
gulp.parallel("clean-translations", function cleanOutputAndBuildDir() {
|
gulp.parallel("clean-translations", function cleanOutputAndBuildDir() {
|
||||||
return del([config.root, config.build_dir]);
|
return del([config.app_output_root, config.build_dir]);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"clean-demo",
|
"clean-demo",
|
||||||
gulp.parallel("clean-translations", function cleanOutputAndBuildDir() {
|
gulp.parallel("clean-translations", function cleanOutputAndBuildDir() {
|
||||||
return del([config.demo_root, config.build_dir]);
|
return del([config.demo_output_root, config.build_dir]);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"clean-cast",
|
"clean-cast",
|
||||||
gulp.parallel("clean-translations", function cleanOutputAndBuildDir() {
|
gulp.parallel("clean-translations", function cleanOutputAndBuildDir() {
|
||||||
return del([config.cast_root, config.build_dir]);
|
return del([config.cast_output_root, config.build_dir]);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"clean-hassio",
|
"clean-hassio",
|
||||||
gulp.parallel("clean-translations", function cleanOutputAndBuildDir() {
|
gulp.parallel("clean-translations", function cleanOutputAndBuildDir() {
|
||||||
return del([config.hassio_root, config.build_dir]);
|
return del([config.hassio_output_root, config.build_dir]);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"clean-gallery",
|
"clean-gallery",
|
||||||
gulp.parallel("clean-translations", function cleanOutputAndBuildDir() {
|
gulp.parallel("clean-translations", function cleanOutputAndBuildDir() {
|
||||||
return del([config.gallery_root, config.build_dir]);
|
return del([config.gallery_output_root, config.build_dir]);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@@ -8,31 +8,36 @@ const paths = require("../paths");
|
|||||||
|
|
||||||
gulp.task("compress-app", function compressApp() {
|
gulp.task("compress-app", function compressApp() {
|
||||||
const jsLatest = gulp
|
const jsLatest = gulp
|
||||||
.src(path.resolve(paths.output, "**/*.js"))
|
.src(path.resolve(paths.app_output_latest, "**/*.js"))
|
||||||
.pipe(zopfli())
|
.pipe(zopfli({ threshold: 150 }))
|
||||||
.pipe(gulp.dest(paths.output));
|
.pipe(gulp.dest(paths.app_output_latest));
|
||||||
|
|
||||||
const jsEs5 = gulp
|
const jsEs5 = gulp
|
||||||
.src(path.resolve(paths.output_es5, "**/*.js"))
|
.src(path.resolve(paths.app_output_es5, "**/*.js"))
|
||||||
.pipe(zopfli())
|
.pipe(zopfli({ threshold: 150 }))
|
||||||
.pipe(gulp.dest(paths.output_es5));
|
.pipe(gulp.dest(paths.app_output_es5));
|
||||||
|
|
||||||
const polyfills = gulp
|
const polyfills = gulp
|
||||||
.src(path.resolve(paths.static, "polyfills/*.js"))
|
.src(path.resolve(paths.app_output_static, "polyfills/*.js"))
|
||||||
.pipe(zopfli())
|
.pipe(zopfli({ threshold: 150 }))
|
||||||
.pipe(gulp.dest(path.resolve(paths.static, "polyfills")));
|
.pipe(gulp.dest(path.resolve(paths.app_output_static, "polyfills")));
|
||||||
|
|
||||||
const translations = gulp
|
const translations = gulp
|
||||||
.src(path.resolve(paths.static, "translations/*.json"))
|
.src(path.resolve(paths.app_output_static, "translations/**/*.json"))
|
||||||
.pipe(zopfli())
|
.pipe(zopfli({ threshold: 150 }))
|
||||||
.pipe(gulp.dest(path.resolve(paths.static, "translations")));
|
.pipe(gulp.dest(path.resolve(paths.app_output_static, "translations")));
|
||||||
|
|
||||||
return merge(jsLatest, jsEs5, polyfills, translations);
|
const icons = gulp
|
||||||
|
.src(path.resolve(paths.app_output_static, "mdi/*.json"))
|
||||||
|
.pipe(zopfli({ threshold: 150 }))
|
||||||
|
.pipe(gulp.dest(path.resolve(paths.app_output_static, "mdi")));
|
||||||
|
|
||||||
|
return merge(jsLatest, jsEs5, polyfills, translations, icons);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("compress-hassio", function compressApp() {
|
gulp.task("compress-hassio", function compressApp() {
|
||||||
return gulp
|
return gulp
|
||||||
.src(path.resolve(paths.hassio_root, "**/*.js"))
|
.src(path.resolve(paths.hassio_output_root, "**/*.js"))
|
||||||
.pipe(zopfli())
|
.pipe(zopfli())
|
||||||
.pipe(gulp.dest(paths.hassio_root));
|
.pipe(gulp.dest(paths.hassio_output_root));
|
||||||
});
|
});
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
// Run demo develop mode
|
// Run demo develop mode
|
||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
|
|
||||||
|
const env = require("../env");
|
||||||
|
|
||||||
require("./clean.js");
|
require("./clean.js");
|
||||||
require("./translations.js");
|
require("./translations.js");
|
||||||
require("./gen-icons-json.js");
|
require("./gen-icons-json.js");
|
||||||
@@ -8,6 +10,7 @@ require("./gather-static.js");
|
|||||||
require("./webpack.js");
|
require("./webpack.js");
|
||||||
require("./service-worker.js");
|
require("./service-worker.js");
|
||||||
require("./entry-html.js");
|
require("./entry-html.js");
|
||||||
|
require("./rollup.js");
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"develop-demo",
|
"develop-demo",
|
||||||
@@ -19,7 +22,7 @@ gulp.task(
|
|||||||
"translations-enable-merge-backend",
|
"translations-enable-merge-backend",
|
||||||
gulp.parallel("gen-icons-json", "gen-index-demo-dev", "build-translations"),
|
gulp.parallel("gen-icons-json", "gen-index-demo-dev", "build-translations"),
|
||||||
"copy-static-demo",
|
"copy-static-demo",
|
||||||
"webpack-dev-server-demo"
|
env.useRollup() ? "rollup-dev-server-demo" : "webpack-dev-server-demo"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -34,7 +37,7 @@ gulp.task(
|
|||||||
"translations-enable-merge-backend",
|
"translations-enable-merge-backend",
|
||||||
gulp.parallel("gen-icons-json", "build-translations"),
|
gulp.parallel("gen-icons-json", "build-translations"),
|
||||||
"copy-static-demo",
|
"copy-static-demo",
|
||||||
"webpack-prod-demo",
|
env.useRollup() ? "rollup-prod-demo" : "webpack-prod-demo",
|
||||||
"gen-index-demo-prod"
|
"gen-index-demo-prod"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@@ -1,9 +1,14 @@
|
|||||||
const del = require("del");
|
const del = require("del");
|
||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
|
const fs = require("fs");
|
||||||
const mapStream = require("map-stream");
|
const mapStream = require("map-stream");
|
||||||
|
|
||||||
const inDir = "translations/frontend";
|
const inDirFrontend = "translations/frontend";
|
||||||
const downloadDir = inDir + "/downloads";
|
const inDirBackend = "translations/backend";
|
||||||
|
const downloadDir = "translations/downloads";
|
||||||
|
const srcMeta = "src/translations/translationMetadata.json";
|
||||||
|
|
||||||
|
const encoding = "utf8";
|
||||||
|
|
||||||
const tasks = [];
|
const tasks = [];
|
||||||
|
|
||||||
@@ -53,9 +58,25 @@ gulp.task(taskName, function () {
|
|||||||
});
|
});
|
||||||
tasks.push(taskName);
|
tasks.push(taskName);
|
||||||
|
|
||||||
|
taskName = "check-all-files-exist";
|
||||||
|
gulp.task(taskName, function () {
|
||||||
|
const file = fs.readFileSync(srcMeta, { encoding });
|
||||||
|
const meta = JSON.parse(file);
|
||||||
|
Object.keys(meta).forEach((lang) => {
|
||||||
|
if (!fs.existsSync(`${inDirFrontend}/${lang}.json`)) {
|
||||||
|
fs.writeFileSync(`${inDirFrontend}/${lang}.json`, JSON.stringify({}));
|
||||||
|
}
|
||||||
|
if (!fs.existsSync(`${inDirBackend}/${lang}.json`)) {
|
||||||
|
fs.writeFileSync(`${inDirBackend}/${lang}.json`, JSON.stringify({}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return Promise.resolve();
|
||||||
|
});
|
||||||
|
tasks.push(taskName);
|
||||||
|
|
||||||
taskName = "move-downloaded-translations";
|
taskName = "move-downloaded-translations";
|
||||||
gulp.task(taskName, function () {
|
gulp.task(taskName, function () {
|
||||||
return gulp.src(`${downloadDir}/*.json`).pipe(gulp.dest(inDir));
|
return gulp.src(`${downloadDir}/*.json`).pipe(gulp.dest(inDirFrontend));
|
||||||
});
|
});
|
||||||
tasks.push(taskName);
|
tasks.push(taskName);
|
||||||
|
|
||||||
@@ -65,6 +86,7 @@ gulp.task(
|
|||||||
gulp.series(
|
gulp.series(
|
||||||
"check-translations-html",
|
"check-translations-html",
|
||||||
"move-downloaded-translations",
|
"move-downloaded-translations",
|
||||||
|
"check-all-files-exist",
|
||||||
"clean-downloaded-translations"
|
"clean-downloaded-translations"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@@ -6,31 +6,36 @@ const fs = require("fs-extra");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const template = require("lodash.template");
|
const template = require("lodash.template");
|
||||||
const minify = require("html-minifier").minify;
|
const minify = require("html-minifier").minify;
|
||||||
const config = require("../paths.js");
|
const paths = require("../paths.js");
|
||||||
|
const env = require("../env.js");
|
||||||
|
|
||||||
const templatePath = (tpl) =>
|
const templatePath = (tpl) =>
|
||||||
path.resolve(config.polymer_dir, "src/html/", `${tpl}.html.template`);
|
path.resolve(paths.polymer_dir, "src/html/", `${tpl}.html.template`);
|
||||||
|
|
||||||
const readFile = (pth) => fs.readFileSync(pth).toString();
|
const readFile = (pth) => fs.readFileSync(pth).toString();
|
||||||
|
|
||||||
const renderTemplate = (pth, data = {}, pathFunc = templatePath) => {
|
const renderTemplate = (pth, data = {}, pathFunc = templatePath) => {
|
||||||
const compiled = template(readFile(pathFunc(pth)));
|
const compiled = template(readFile(pathFunc(pth)));
|
||||||
return compiled({ ...data, renderTemplate });
|
return compiled({
|
||||||
|
...data,
|
||||||
|
useRollup: env.useRollup(),
|
||||||
|
renderTemplate,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderDemoTemplate = (pth, data = {}) =>
|
const renderDemoTemplate = (pth, data = {}) =>
|
||||||
renderTemplate(pth, data, (tpl) =>
|
renderTemplate(pth, data, (tpl) =>
|
||||||
path.resolve(config.demo_dir, "src/html/", `${tpl}.html.template`)
|
path.resolve(paths.demo_dir, "src/html/", `${tpl}.html.template`)
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderCastTemplate = (pth, data = {}) =>
|
const renderCastTemplate = (pth, data = {}) =>
|
||||||
renderTemplate(pth, data, (tpl) =>
|
renderTemplate(pth, data, (tpl) =>
|
||||||
path.resolve(config.cast_dir, "src/html/", `${tpl}.html.template`)
|
path.resolve(paths.cast_dir, "src/html/", `${tpl}.html.template`)
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderGalleryTemplate = (pth, data = {}) =>
|
const renderGalleryTemplate = (pth, data = {}) =>
|
||||||
renderTemplate(pth, data, (tpl) =>
|
renderTemplate(pth, data, (tpl) =>
|
||||||
path.resolve(config.gallery_dir, "src/html/", `${tpl}.html.template`)
|
path.resolve(paths.gallery_dir, "src/html/", `${tpl}.html.template`)
|
||||||
);
|
);
|
||||||
|
|
||||||
const minifyHtml = (content) =>
|
const minifyHtml = (content) =>
|
||||||
@@ -48,29 +53,36 @@ gulp.task("gen-pages-dev", (done) => {
|
|||||||
const content = renderTemplate(page, {
|
const content = renderTemplate(page, {
|
||||||
latestPageJS: `/frontend_latest/${page}.js`,
|
latestPageJS: `/frontend_latest/${page}.js`,
|
||||||
|
|
||||||
es5Compatibility: "/frontend_es5/compatibility.js",
|
|
||||||
es5PageJS: `/frontend_es5/${page}.js`,
|
es5PageJS: `/frontend_es5/${page}.js`,
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.outputFileSync(path.resolve(config.root, `${page}.html`), content);
|
fs.outputFileSync(
|
||||||
|
path.resolve(paths.app_output_root, `${page}.html`),
|
||||||
|
content
|
||||||
|
);
|
||||||
}
|
}
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("gen-pages-prod", (done) => {
|
gulp.task("gen-pages-prod", (done) => {
|
||||||
const latestManifest = require(path.resolve(config.output, "manifest.json"));
|
const latestManifest = require(path.resolve(
|
||||||
const es5Manifest = require(path.resolve(config.output_es5, "manifest.json"));
|
paths.app_output_latest,
|
||||||
|
"manifest.json"
|
||||||
|
));
|
||||||
|
const es5Manifest = require(path.resolve(
|
||||||
|
paths.app_output_es5,
|
||||||
|
"manifest.json"
|
||||||
|
));
|
||||||
|
|
||||||
for (const page of PAGES) {
|
for (const page of PAGES) {
|
||||||
const content = renderTemplate(page, {
|
const content = renderTemplate(page, {
|
||||||
latestPageJS: latestManifest[`${page}.js`],
|
latestPageJS: latestManifest[`${page}.js`],
|
||||||
|
|
||||||
es5Compatibility: es5Manifest["compatibility.js"],
|
|
||||||
es5PageJS: es5Manifest[`${page}.js`],
|
es5PageJS: es5Manifest[`${page}.js`],
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.outputFileSync(
|
fs.outputFileSync(
|
||||||
path.resolve(config.root, `${page}.html`),
|
path.resolve(paths.app_output_root, `${page}.html`),
|
||||||
minifyHtml(content)
|
minifyHtml(content)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -85,32 +97,39 @@ gulp.task("gen-index-app-dev", (done) => {
|
|||||||
latestCoreJS: "/frontend_latest/core.js",
|
latestCoreJS: "/frontend_latest/core.js",
|
||||||
latestCustomPanelJS: "/frontend_latest/custom-panel.js",
|
latestCustomPanelJS: "/frontend_latest/custom-panel.js",
|
||||||
|
|
||||||
es5Compatibility: "/frontend_es5/compatibility.js",
|
|
||||||
es5AppJS: "/frontend_es5/app.js",
|
es5AppJS: "/frontend_es5/app.js",
|
||||||
es5CoreJS: "/frontend_es5/core.js",
|
es5CoreJS: "/frontend_es5/core.js",
|
||||||
es5CustomPanelJS: "/frontend_es5/custom-panel.js",
|
es5CustomPanelJS: "/frontend_es5/custom-panel.js",
|
||||||
}).replace(/#THEMEC/g, "{{ theme_color }}");
|
}).replace(/#THEMEC/g, "{{ theme_color }}");
|
||||||
|
|
||||||
fs.outputFileSync(path.resolve(config.root, "index.html"), content);
|
fs.outputFileSync(path.resolve(paths.app_output_root, "index.html"), content);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("gen-index-app-prod", (done) => {
|
gulp.task("gen-index-app-prod", (done) => {
|
||||||
const latestManifest = require(path.resolve(config.output, "manifest.json"));
|
const latestManifest = require(path.resolve(
|
||||||
const es5Manifest = require(path.resolve(config.output_es5, "manifest.json"));
|
paths.app_output_latest,
|
||||||
|
"manifest.json"
|
||||||
|
));
|
||||||
|
const es5Manifest = require(path.resolve(
|
||||||
|
paths.app_output_es5,
|
||||||
|
"manifest.json"
|
||||||
|
));
|
||||||
const content = renderTemplate("index", {
|
const content = renderTemplate("index", {
|
||||||
latestAppJS: latestManifest["app.js"],
|
latestAppJS: latestManifest["app.js"],
|
||||||
latestCoreJS: latestManifest["core.js"],
|
latestCoreJS: latestManifest["core.js"],
|
||||||
latestCustomPanelJS: latestManifest["custom-panel.js"],
|
latestCustomPanelJS: latestManifest["custom-panel.js"],
|
||||||
|
|
||||||
es5Compatibility: es5Manifest["compatibility.js"],
|
|
||||||
es5AppJS: es5Manifest["app.js"],
|
es5AppJS: es5Manifest["app.js"],
|
||||||
es5CoreJS: es5Manifest["core.js"],
|
es5CoreJS: es5Manifest["core.js"],
|
||||||
es5CustomPanelJS: es5Manifest["custom-panel.js"],
|
es5CustomPanelJS: es5Manifest["custom-panel.js"],
|
||||||
});
|
});
|
||||||
const minified = minifyHtml(content).replace(/#THEMEC/g, "{{ theme_color }}");
|
const minified = minifyHtml(content).replace(/#THEMEC/g, "{{ theme_color }}");
|
||||||
|
|
||||||
fs.outputFileSync(path.resolve(config.root, "index.html"), minified);
|
fs.outputFileSync(
|
||||||
|
path.resolve(paths.app_output_root, "index.html"),
|
||||||
|
minified
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -119,7 +138,7 @@ gulp.task("gen-index-cast-dev", (done) => {
|
|||||||
latestReceiverJS: "/frontend_latest/receiver.js",
|
latestReceiverJS: "/frontend_latest/receiver.js",
|
||||||
});
|
});
|
||||||
fs.outputFileSync(
|
fs.outputFileSync(
|
||||||
path.resolve(config.cast_root, "receiver.html"),
|
path.resolve(paths.cast_output_root, "receiver.html"),
|
||||||
contentReceiver
|
contentReceiver
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -127,14 +146,17 @@ gulp.task("gen-index-cast-dev", (done) => {
|
|||||||
latestLauncherJS: "/frontend_latest/launcher.js",
|
latestLauncherJS: "/frontend_latest/launcher.js",
|
||||||
es5LauncherJS: "/frontend_es5/launcher.js",
|
es5LauncherJS: "/frontend_es5/launcher.js",
|
||||||
});
|
});
|
||||||
fs.outputFileSync(path.resolve(config.cast_root, "faq.html"), contentFAQ);
|
fs.outputFileSync(
|
||||||
|
path.resolve(paths.cast_output_root, "faq.html"),
|
||||||
|
contentFAQ
|
||||||
|
);
|
||||||
|
|
||||||
const contentLauncher = renderCastTemplate("launcher", {
|
const contentLauncher = renderCastTemplate("launcher", {
|
||||||
latestLauncherJS: "/frontend_latest/launcher.js",
|
latestLauncherJS: "/frontend_latest/launcher.js",
|
||||||
es5LauncherJS: "/frontend_es5/launcher.js",
|
es5LauncherJS: "/frontend_es5/launcher.js",
|
||||||
});
|
});
|
||||||
fs.outputFileSync(
|
fs.outputFileSync(
|
||||||
path.resolve(config.cast_root, "index.html"),
|
path.resolve(paths.cast_output_root, "index.html"),
|
||||||
contentLauncher
|
contentLauncher
|
||||||
);
|
);
|
||||||
done();
|
done();
|
||||||
@@ -142,11 +164,11 @@ gulp.task("gen-index-cast-dev", (done) => {
|
|||||||
|
|
||||||
gulp.task("gen-index-cast-prod", (done) => {
|
gulp.task("gen-index-cast-prod", (done) => {
|
||||||
const latestManifest = require(path.resolve(
|
const latestManifest = require(path.resolve(
|
||||||
config.cast_output,
|
paths.cast_output_latest,
|
||||||
"manifest.json"
|
"manifest.json"
|
||||||
));
|
));
|
||||||
const es5Manifest = require(path.resolve(
|
const es5Manifest = require(path.resolve(
|
||||||
config.cast_output_es5,
|
paths.cast_output_es5,
|
||||||
"manifest.json"
|
"manifest.json"
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -154,7 +176,7 @@ gulp.task("gen-index-cast-prod", (done) => {
|
|||||||
latestReceiverJS: latestManifest["receiver.js"],
|
latestReceiverJS: latestManifest["receiver.js"],
|
||||||
});
|
});
|
||||||
fs.outputFileSync(
|
fs.outputFileSync(
|
||||||
path.resolve(config.cast_root, "receiver.html"),
|
path.resolve(paths.cast_output_root, "receiver.html"),
|
||||||
contentReceiver
|
contentReceiver
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -162,14 +184,17 @@ gulp.task("gen-index-cast-prod", (done) => {
|
|||||||
latestLauncherJS: latestManifest["launcher.js"],
|
latestLauncherJS: latestManifest["launcher.js"],
|
||||||
es5LauncherJS: es5Manifest["launcher.js"],
|
es5LauncherJS: es5Manifest["launcher.js"],
|
||||||
});
|
});
|
||||||
fs.outputFileSync(path.resolve(config.cast_root, "faq.html"), contentFAQ);
|
fs.outputFileSync(
|
||||||
|
path.resolve(paths.cast_output_root, "faq.html"),
|
||||||
|
contentFAQ
|
||||||
|
);
|
||||||
|
|
||||||
const contentLauncher = renderCastTemplate("launcher", {
|
const contentLauncher = renderCastTemplate("launcher", {
|
||||||
latestLauncherJS: latestManifest["launcher.js"],
|
latestLauncherJS: latestManifest["launcher.js"],
|
||||||
es5LauncherJS: es5Manifest["launcher.js"],
|
es5LauncherJS: es5Manifest["launcher.js"],
|
||||||
});
|
});
|
||||||
fs.outputFileSync(
|
fs.outputFileSync(
|
||||||
path.resolve(config.cast_root, "index.html"),
|
path.resolve(paths.cast_output_root, "index.html"),
|
||||||
contentLauncher
|
contentLauncher
|
||||||
);
|
);
|
||||||
done();
|
done();
|
||||||
@@ -181,32 +206,36 @@ gulp.task("gen-index-demo-dev", (done) => {
|
|||||||
const content = renderDemoTemplate("index", {
|
const content = renderDemoTemplate("index", {
|
||||||
latestDemoJS: "/frontend_latest/main.js",
|
latestDemoJS: "/frontend_latest/main.js",
|
||||||
|
|
||||||
es5Compatibility: "/frontend_es5/compatibility.js",
|
|
||||||
es5DemoJS: "/frontend_es5/main.js",
|
es5DemoJS: "/frontend_es5/main.js",
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.outputFileSync(path.resolve(config.demo_root, "index.html"), content);
|
fs.outputFileSync(
|
||||||
|
path.resolve(paths.demo_output_root, "index.html"),
|
||||||
|
content
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("gen-index-demo-prod", (done) => {
|
gulp.task("gen-index-demo-prod", (done) => {
|
||||||
const latestManifest = require(path.resolve(
|
const latestManifest = require(path.resolve(
|
||||||
config.demo_output,
|
paths.demo_output_latest,
|
||||||
"manifest.json"
|
"manifest.json"
|
||||||
));
|
));
|
||||||
const es5Manifest = require(path.resolve(
|
const es5Manifest = require(path.resolve(
|
||||||
config.demo_output_es5,
|
paths.demo_output_es5,
|
||||||
"manifest.json"
|
"manifest.json"
|
||||||
));
|
));
|
||||||
const content = renderDemoTemplate("index", {
|
const content = renderDemoTemplate("index", {
|
||||||
latestDemoJS: latestManifest["main.js"],
|
latestDemoJS: latestManifest["main.js"],
|
||||||
|
|
||||||
es5Compatibility: es5Manifest["compatibility.js"],
|
|
||||||
es5DemoJS: es5Manifest["main.js"],
|
es5DemoJS: es5Manifest["main.js"],
|
||||||
});
|
});
|
||||||
const minified = minifyHtml(content);
|
const minified = minifyHtml(content);
|
||||||
|
|
||||||
fs.outputFileSync(path.resolve(config.demo_root, "index.html"), minified);
|
fs.outputFileSync(
|
||||||
|
path.resolve(paths.demo_output_root, "index.html"),
|
||||||
|
minified
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -217,13 +246,16 @@ gulp.task("gen-index-gallery-dev", (done) => {
|
|||||||
latestGalleryJS: "./frontend_latest/entrypoint.js",
|
latestGalleryJS: "./frontend_latest/entrypoint.js",
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.outputFileSync(path.resolve(config.gallery_root, "index.html"), content);
|
fs.outputFileSync(
|
||||||
|
path.resolve(paths.gallery_output_root, "index.html"),
|
||||||
|
content
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("gen-index-gallery-prod", (done) => {
|
gulp.task("gen-index-gallery-prod", (done) => {
|
||||||
const latestManifest = require(path.resolve(
|
const latestManifest = require(path.resolve(
|
||||||
config.gallery_output,
|
paths.gallery_output_latest,
|
||||||
"manifest.json"
|
"manifest.json"
|
||||||
));
|
));
|
||||||
const content = renderGalleryTemplate("index", {
|
const content = renderGalleryTemplate("index", {
|
||||||
@@ -231,6 +263,9 @@ gulp.task("gen-index-gallery-prod", (done) => {
|
|||||||
});
|
});
|
||||||
const minified = minifyHtml(content);
|
const minified = minifyHtml(content);
|
||||||
|
|
||||||
fs.outputFileSync(path.resolve(config.gallery_root, "index.html"), minified);
|
fs.outputFileSync(
|
||||||
|
path.resolve(paths.gallery_output_root, "index.html"),
|
||||||
|
minified
|
||||||
|
);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
// Run demo develop mode
|
// Run demo develop mode
|
||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
|
|
||||||
|
const env = require("../env");
|
||||||
|
|
||||||
require("./clean.js");
|
require("./clean.js");
|
||||||
require("./translations.js");
|
require("./translations.js");
|
||||||
require("./gen-icons-json.js");
|
require("./gen-icons-json.js");
|
||||||
@@ -8,6 +10,7 @@ require("./gather-static.js");
|
|||||||
require("./webpack.js");
|
require("./webpack.js");
|
||||||
require("./service-worker.js");
|
require("./service-worker.js");
|
||||||
require("./entry-html.js");
|
require("./entry-html.js");
|
||||||
|
require("./rollup.js");
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"develop-gallery",
|
"develop-gallery",
|
||||||
@@ -20,7 +23,7 @@ gulp.task(
|
|||||||
gulp.parallel("gen-icons-json", "build-translations"),
|
gulp.parallel("gen-icons-json", "build-translations"),
|
||||||
"copy-static-gallery",
|
"copy-static-gallery",
|
||||||
"gen-index-gallery-dev",
|
"gen-index-gallery-dev",
|
||||||
"webpack-dev-server-gallery"
|
env.useRollup() ? "rollup-dev-server-gallery" : "webpack-dev-server-gallery"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -34,7 +37,7 @@ gulp.task(
|
|||||||
"translations-enable-merge-backend",
|
"translations-enable-merge-backend",
|
||||||
gulp.parallel("gen-icons-json", "build-translations"),
|
gulp.parallel("gen-icons-json", "build-translations"),
|
||||||
"copy-static-gallery",
|
"copy-static-gallery",
|
||||||
"webpack-prod-gallery",
|
env.useRollup() ? "rollup-prod-gallery" : "webpack-prod-gallery",
|
||||||
"gen-index-gallery-prod"
|
"gen-index-gallery-prod"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@@ -51,6 +51,12 @@ function copyPolyfills(staticDir) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copyLoaderJS(staticDir) {
|
||||||
|
const staticPath = genStaticPath(staticDir);
|
||||||
|
copyFileDir(npmPath("systemjs/dist/s.min.js"), staticPath("js"));
|
||||||
|
copyFileDir(npmPath("systemjs/dist/s.min.js.map"), staticPath("js"));
|
||||||
|
}
|
||||||
|
|
||||||
function copyFonts(staticDir) {
|
function copyFonts(staticDir) {
|
||||||
const staticPath = genStaticPath(staticDir);
|
const staticPath = genStaticPath(staticDir);
|
||||||
// Local fonts
|
// Local fonts
|
||||||
@@ -72,17 +78,17 @@ function copyMapPanel(staticDir) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
gulp.task("copy-translations", (done) => {
|
gulp.task("copy-translations-app", async () => {
|
||||||
const staticDir = paths.static;
|
const staticDir = paths.app_output_static;
|
||||||
copyTranslations(staticDir);
|
copyTranslations(staticDir);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("copy-static", (done) => {
|
gulp.task("copy-static-app", async () => {
|
||||||
const staticDir = paths.static;
|
const staticDir = paths.app_output_static;
|
||||||
// Basic static files
|
// Basic static files
|
||||||
fs.copySync(polyPath("public"), paths.root);
|
fs.copySync(polyPath("public"), paths.app_output_root);
|
||||||
|
|
||||||
|
copyLoaderJS(staticDir);
|
||||||
copyPolyfills(staticDir);
|
copyPolyfills(staticDir);
|
||||||
copyFonts(staticDir);
|
copyFonts(staticDir);
|
||||||
copyTranslations(staticDir);
|
copyTranslations(staticDir);
|
||||||
@@ -90,48 +96,50 @@ gulp.task("copy-static", (done) => {
|
|||||||
|
|
||||||
// Panel assets
|
// Panel assets
|
||||||
copyMapPanel(staticDir);
|
copyMapPanel(staticDir);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("copy-static-demo", (done) => {
|
gulp.task("copy-static-demo", async () => {
|
||||||
// Copy app static files
|
// Copy app static files
|
||||||
fs.copySync(
|
fs.copySync(
|
||||||
polyPath("public/static"),
|
polyPath("public/static"),
|
||||||
path.resolve(paths.demo_root, "static")
|
path.resolve(paths.demo_output_root, "static")
|
||||||
);
|
);
|
||||||
// Copy demo static files
|
// Copy demo static files
|
||||||
fs.copySync(path.resolve(paths.demo_dir, "public"), paths.demo_root);
|
fs.copySync(path.resolve(paths.demo_dir, "public"), paths.demo_output_root);
|
||||||
|
|
||||||
copyPolyfills(paths.demo_static);
|
copyLoaderJS(paths.demo_output_static);
|
||||||
copyMapPanel(paths.demo_static);
|
copyPolyfills(paths.demo_output_static);
|
||||||
copyFonts(paths.demo_static);
|
copyMapPanel(paths.demo_output_static);
|
||||||
copyTranslations(paths.demo_static);
|
copyFonts(paths.demo_output_static);
|
||||||
copyMdiIcons(paths.demo_static);
|
copyTranslations(paths.demo_output_static);
|
||||||
done();
|
copyMdiIcons(paths.demo_output_static);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("copy-static-cast", (done) => {
|
gulp.task("copy-static-cast", async () => {
|
||||||
// Copy app static files
|
// Copy app static files
|
||||||
fs.copySync(polyPath("public/static"), paths.cast_static);
|
fs.copySync(polyPath("public/static"), paths.cast_output_static);
|
||||||
// Copy cast static files
|
// Copy cast static files
|
||||||
fs.copySync(path.resolve(paths.cast_dir, "public"), paths.cast_root);
|
fs.copySync(path.resolve(paths.cast_dir, "public"), paths.cast_output_root);
|
||||||
|
|
||||||
copyMapPanel(paths.cast_static);
|
copyLoaderJS(paths.cast_output_static);
|
||||||
copyFonts(paths.cast_static);
|
copyPolyfills(paths.cast_output_static);
|
||||||
copyTranslations(paths.cast_static);
|
copyMapPanel(paths.cast_output_static);
|
||||||
copyMdiIcons(paths.cast_static);
|
copyFonts(paths.cast_output_static);
|
||||||
done();
|
copyTranslations(paths.cast_output_static);
|
||||||
|
copyMdiIcons(paths.cast_output_static);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("copy-static-gallery", (done) => {
|
gulp.task("copy-static-gallery", async () => {
|
||||||
// Copy app static files
|
// Copy app static files
|
||||||
fs.copySync(polyPath("public/static"), paths.gallery_static);
|
fs.copySync(polyPath("public/static"), paths.gallery_output_static);
|
||||||
// Copy gallery static files
|
// Copy gallery static files
|
||||||
fs.copySync(path.resolve(paths.gallery_dir, "public"), paths.gallery_root);
|
fs.copySync(
|
||||||
|
path.resolve(paths.gallery_dir, "public"),
|
||||||
|
paths.gallery_output_root
|
||||||
|
);
|
||||||
|
|
||||||
copyMapPanel(paths.gallery_static);
|
copyMapPanel(paths.gallery_output_static);
|
||||||
copyFonts(paths.gallery_static);
|
copyFonts(paths.gallery_output_static);
|
||||||
copyTranslations(paths.gallery_static);
|
copyTranslations(paths.gallery_output_static);
|
||||||
copyMdiIcons(paths.gallery_static);
|
copyMdiIcons(paths.gallery_output_static);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
|
|
||||||
const envVars = require("../env");
|
const env = require("../env");
|
||||||
|
|
||||||
require("./clean.js");
|
require("./clean.js");
|
||||||
require("./gen-icons-json.js");
|
require("./gen-icons-json.js");
|
||||||
require("./webpack.js");
|
require("./webpack.js");
|
||||||
require("./compress.js");
|
require("./compress.js");
|
||||||
|
require("./rollup.js");
|
||||||
|
|
||||||
gulp.task(
|
gulp.task(
|
||||||
"develop-hassio",
|
"develop-hassio",
|
||||||
@@ -15,7 +16,7 @@ gulp.task(
|
|||||||
},
|
},
|
||||||
"clean-hassio",
|
"clean-hassio",
|
||||||
"gen-icons-json",
|
"gen-icons-json",
|
||||||
"webpack-watch-hassio"
|
env.useRollup() ? "rollup-watch-hassio" : "webpack-watch-hassio"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -27,8 +28,8 @@ gulp.task(
|
|||||||
},
|
},
|
||||||
"clean-hassio",
|
"clean-hassio",
|
||||||
"gen-icons-json",
|
"gen-icons-json",
|
||||||
"webpack-prod-hassio",
|
env.useRollup() ? "rollup-prod-hassio" : "webpack-prod-hassio",
|
||||||
...// Don't compress running tests
|
...// Don't compress running tests
|
||||||
(envVars.isTest() ? [] : ["compress-hassio"])
|
(env.isTest() ? [] : ["compress-hassio"])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
151
build-scripts/gulp/rollup.js
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
// Tasks to run Rollup
|
||||||
|
const path = require("path");
|
||||||
|
const gulp = require("gulp");
|
||||||
|
const rollup = require("rollup");
|
||||||
|
const handler = require("serve-handler");
|
||||||
|
const http = require("http");
|
||||||
|
const log = require("fancy-log");
|
||||||
|
const rollupConfig = require("../rollup");
|
||||||
|
const paths = require("../paths");
|
||||||
|
const open = require("open");
|
||||||
|
|
||||||
|
const bothBuilds = (createConfigFunc, params) =>
|
||||||
|
gulp.series(
|
||||||
|
async function buildLatest() {
|
||||||
|
await buildRollup(
|
||||||
|
createConfigFunc({
|
||||||
|
...params,
|
||||||
|
latestBuild: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
async function buildES5() {
|
||||||
|
await buildRollup(
|
||||||
|
createConfigFunc({
|
||||||
|
...params,
|
||||||
|
latestBuild: false,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
function createServer(serveOptions) {
|
||||||
|
const server = http.createServer((request, response) => {
|
||||||
|
return handler(request, response, {
|
||||||
|
public: serveOptions.root,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
server.listen(
|
||||||
|
serveOptions.port,
|
||||||
|
serveOptions.networkAccess ? "0.0.0.0" : undefined,
|
||||||
|
() => {
|
||||||
|
log.info(`Available at http://localhost:${serveOptions.port}`);
|
||||||
|
open(`http://localhost:${serveOptions.port}`);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function watchRollup(createConfig, extraWatchSrc = [], serveOptions) {
|
||||||
|
const { inputOptions, outputOptions } = createConfig({
|
||||||
|
isProdBuild: false,
|
||||||
|
latestBuild: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const watcher = rollup.watch({
|
||||||
|
...inputOptions,
|
||||||
|
output: [outputOptions],
|
||||||
|
watch: {
|
||||||
|
include: ["src/**"] + extraWatchSrc,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
let startedHttp = false;
|
||||||
|
|
||||||
|
watcher.on("event", (event) => {
|
||||||
|
if (event.code === "BUNDLE_END") {
|
||||||
|
log(`Build done @ ${new Date().toLocaleTimeString()}`);
|
||||||
|
} else if (event.code === "ERROR") {
|
||||||
|
log.error(event.error);
|
||||||
|
} else if (event.code === "END") {
|
||||||
|
if (startedHttp || !serveOptions) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
startedHttp = true;
|
||||||
|
createServer(serveOptions);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.watch(
|
||||||
|
path.join(paths.translations_src, "en.json"),
|
||||||
|
gulp.series("build-translations", "copy-translations-app")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function buildRollup(config) {
|
||||||
|
const bundle = await rollup.rollup(config.inputOptions);
|
||||||
|
await bundle.write(config.outputOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
gulp.task("rollup-watch-app", () => {
|
||||||
|
watchRollup(rollupConfig.createAppConfig);
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task("rollup-watch-hassio", () => {
|
||||||
|
watchRollup(rollupConfig.createHassioConfig, ["hassio/src/**"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task("rollup-dev-server-demo", () => {
|
||||||
|
watchRollup(rollupConfig.createDemoConfig, ["demo/src/**"], {
|
||||||
|
root: paths.demo_output_root,
|
||||||
|
port: 8090,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task("rollup-dev-server-cast", () => {
|
||||||
|
watchRollup(rollupConfig.createCastConfig, ["cast/src/**"], {
|
||||||
|
root: paths.cast_output_root,
|
||||||
|
port: 8080,
|
||||||
|
networkAccess: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task("rollup-dev-server-gallery", () => {
|
||||||
|
watchRollup(rollupConfig.createGalleryConfig, ["gallery/src/**"], {
|
||||||
|
root: paths.gallery_output_root,
|
||||||
|
port: 8100,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task(
|
||||||
|
"rollup-prod-app",
|
||||||
|
bothBuilds(rollupConfig.createAppConfig, { isProdBuild: true })
|
||||||
|
);
|
||||||
|
|
||||||
|
gulp.task(
|
||||||
|
"rollup-prod-demo",
|
||||||
|
bothBuilds(rollupConfig.createDemoConfig, { isProdBuild: true })
|
||||||
|
);
|
||||||
|
|
||||||
|
gulp.task(
|
||||||
|
"rollup-prod-cast",
|
||||||
|
bothBuilds(rollupConfig.createCastConfig, { isProdBuild: true })
|
||||||
|
);
|
||||||
|
|
||||||
|
gulp.task("rollup-prod-hassio", () =>
|
||||||
|
buildRollup(
|
||||||
|
rollupConfig.createHassioConfig({
|
||||||
|
isProdBuild: true,
|
||||||
|
latestBuild: false,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
gulp.task("rollup-prod-gallery", () =>
|
||||||
|
buildRollup(
|
||||||
|
rollupConfig.createGalleryConfig({
|
||||||
|
isProdBuild: true,
|
||||||
|
latestBuild: true,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
@@ -5,18 +5,22 @@
|
|||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
const config = require("../paths.js");
|
const workboxBuild = require("workbox-build");
|
||||||
|
const sourceMapUrl = require("source-map-url");
|
||||||
|
const paths = require("../paths.js");
|
||||||
|
|
||||||
const swPath = path.resolve(config.root, "service_worker.js");
|
const swDest = path.resolve(paths.app_output_root, "service_worker.js");
|
||||||
|
|
||||||
const writeSW = (content) => fs.outputFileSync(swPath, content.trim() + "\n");
|
const writeSW = (content) => fs.outputFileSync(swDest, content.trim() + "\n");
|
||||||
|
|
||||||
gulp.task("gen-service-worker-dev", (done) => {
|
gulp.task("gen-service-worker-app-dev", (done) => {
|
||||||
writeSW(
|
writeSW(
|
||||||
`
|
`
|
||||||
console.debug('Service worker disabled in development');
|
console.debug('Service worker disabled in development');
|
||||||
|
|
||||||
self.addEventListener('install', (event) => {
|
self.addEventListener('install', (event) => {
|
||||||
|
// This will activate the dev service worker,
|
||||||
|
// removing any prod service worker the dev might have running
|
||||||
self.skipWaiting();
|
self.skipWaiting();
|
||||||
});
|
});
|
||||||
`
|
`
|
||||||
@@ -24,10 +28,69 @@ self.addEventListener('install', (event) => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("gen-service-worker-prod", (done) => {
|
gulp.task("gen-service-worker-app-prod", async () => {
|
||||||
fs.copySync(
|
// Read bundled source file
|
||||||
path.resolve(config.output, "service_worker.js"),
|
const bundleManifestLatest = require(path.resolve(
|
||||||
path.resolve(config.root, "service_worker.js")
|
paths.app_output_latest,
|
||||||
|
"manifest.json"
|
||||||
|
));
|
||||||
|
let serviceWorkerContent = fs.readFileSync(
|
||||||
|
paths.app_output_root + bundleManifestLatest["service_worker.js"],
|
||||||
|
"utf-8"
|
||||||
);
|
);
|
||||||
done();
|
|
||||||
|
// Delete old file from frontend_latest so manifest won't pick it up
|
||||||
|
fs.removeSync(
|
||||||
|
paths.app_output_root + bundleManifestLatest["service_worker.js"]
|
||||||
|
);
|
||||||
|
fs.removeSync(
|
||||||
|
paths.app_output_root + bundleManifestLatest["service_worker.js.map"]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Remove ES5
|
||||||
|
const bundleManifestES5 = require(path.resolve(
|
||||||
|
paths.app_output_es5,
|
||||||
|
"manifest.json"
|
||||||
|
));
|
||||||
|
fs.removeSync(paths.app_output_root + bundleManifestES5["service_worker.js"]);
|
||||||
|
fs.removeSync(
|
||||||
|
paths.app_output_root + bundleManifestES5["service_worker.js.map"]
|
||||||
|
);
|
||||||
|
|
||||||
|
const workboxManifest = await workboxBuild.getManifest({
|
||||||
|
// Files that mach this pattern will be considered unique and skip revision check
|
||||||
|
// ignore JS files + translation files
|
||||||
|
dontCacheBustURLsMatching: /(frontend_latest\/.+|static\/translations\/.+)/,
|
||||||
|
|
||||||
|
globDirectory: paths.app_output_root,
|
||||||
|
globPatterns: [
|
||||||
|
"frontend_latest/*.js",
|
||||||
|
// Cache all English translations because we catch them as fallback
|
||||||
|
// Using pattern to match hash instead of * to avoid caching en-GB
|
||||||
|
// 'v' added as valid hash letter because in dev we hash with 'dev'
|
||||||
|
"static/translations/**/en-+([a-fv0-9]).json",
|
||||||
|
// Icon shown on splash screen
|
||||||
|
"static/icons/favicon-192x192.png",
|
||||||
|
"static/icons/favicon.ico",
|
||||||
|
// Common fonts
|
||||||
|
"static/fonts/roboto/Roboto-Light.woff2",
|
||||||
|
"static/fonts/roboto/Roboto-Medium.woff2",
|
||||||
|
"static/fonts/roboto/Roboto-Regular.woff2",
|
||||||
|
"static/fonts/roboto/Roboto-Bold.woff2",
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const warning of workboxManifest.warnings) {
|
||||||
|
console.warn(warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove source map and add WB manifest
|
||||||
|
serviceWorkerContent = sourceMapUrl.removeFrom(serviceWorkerContent);
|
||||||
|
serviceWorkerContent = serviceWorkerContent.replace(
|
||||||
|
"WB_MANIFEST",
|
||||||
|
JSON.stringify(workboxManifest.manifestEntries)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Write new file to root
|
||||||
|
fs.writeFileSync(swDest, serviceWorkerContent);
|
||||||
});
|
});
|
||||||
|
@@ -38,9 +38,9 @@ const runDevServer = ({
|
|||||||
|
|
||||||
const handler = (done) => (err, stats) => {
|
const handler = (done) => (err, stats) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err.stack || err);
|
log.error(err.stack || err);
|
||||||
if (err.details) {
|
if (err.details) {
|
||||||
console.log(err.details);
|
log.error(err.details);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ const handler = (done) => (err, stats) => {
|
|||||||
log(`Build done @ ${new Date().toLocaleTimeString()}`);
|
log(`Build done @ ${new Date().toLocaleTimeString()}`);
|
||||||
|
|
||||||
if (stats.hasErrors() || stats.hasWarnings()) {
|
if (stats.hasErrors() || stats.hasWarnings()) {
|
||||||
console.log(stats.toString("minimal"));
|
log.warn(stats.toString("minimal"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (done) {
|
if (done) {
|
||||||
@@ -64,7 +64,7 @@ gulp.task("webpack-watch-app", () => {
|
|||||||
);
|
);
|
||||||
gulp.watch(
|
gulp.watch(
|
||||||
path.join(paths.translations_src, "en.json"),
|
path.join(paths.translations_src, "en.json"),
|
||||||
gulp.series("build-translations", "copy-translations")
|
gulp.series("build-translations", "copy-translations-app")
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ gulp.task(
|
|||||||
gulp.task("webpack-dev-server-demo", () => {
|
gulp.task("webpack-dev-server-demo", () => {
|
||||||
runDevServer({
|
runDevServer({
|
||||||
compiler: webpack(bothBuilds(createDemoConfig, { isProdBuild: false })),
|
compiler: webpack(bothBuilds(createDemoConfig, { isProdBuild: false })),
|
||||||
contentBase: paths.demo_root,
|
contentBase: paths.demo_output_root,
|
||||||
port: 8090,
|
port: 8090,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -103,7 +103,7 @@ gulp.task(
|
|||||||
gulp.task("webpack-dev-server-cast", () => {
|
gulp.task("webpack-dev-server-cast", () => {
|
||||||
runDevServer({
|
runDevServer({
|
||||||
compiler: webpack(bothBuilds(createCastConfig, { isProdBuild: false })),
|
compiler: webpack(bothBuilds(createCastConfig, { isProdBuild: false })),
|
||||||
contentBase: paths.cast_root,
|
contentBase: paths.cast_output_root,
|
||||||
port: 8080,
|
port: 8080,
|
||||||
// Accessible from the network, because that's how Cast hits it.
|
// Accessible from the network, because that's how Cast hits it.
|
||||||
listenHost: "0.0.0.0",
|
listenHost: "0.0.0.0",
|
||||||
@@ -152,7 +152,7 @@ gulp.task("webpack-dev-server-gallery", () => {
|
|||||||
runDevServer({
|
runDevServer({
|
||||||
// We don't use the es5 build, but the dev server will fuck up the publicPath if we don't
|
// We don't use the es5 build, but the dev server will fuck up the publicPath if we don't
|
||||||
compiler: webpack(bothBuilds(createGalleryConfig, { isProdBuild: false })),
|
compiler: webpack(bothBuilds(createGalleryConfig, { isProdBuild: false })),
|
||||||
contentBase: paths.gallery_root,
|
contentBase: paths.gallery_output_root,
|
||||||
port: 8100,
|
port: 8100,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -4,30 +4,36 @@ module.exports = {
|
|||||||
polymer_dir: path.resolve(__dirname, ".."),
|
polymer_dir: path.resolve(__dirname, ".."),
|
||||||
|
|
||||||
build_dir: path.resolve(__dirname, "../build"),
|
build_dir: path.resolve(__dirname, "../build"),
|
||||||
root: path.resolve(__dirname, "../hass_frontend"),
|
app_output_root: path.resolve(__dirname, "../hass_frontend"),
|
||||||
static: path.resolve(__dirname, "../hass_frontend/static"),
|
app_output_static: path.resolve(__dirname, "../hass_frontend/static"),
|
||||||
output: path.resolve(__dirname, "../hass_frontend/frontend_latest"),
|
app_output_latest: path.resolve(
|
||||||
output_es5: path.resolve(__dirname, "../hass_frontend/frontend_es5"),
|
__dirname,
|
||||||
|
"../hass_frontend/frontend_latest"
|
||||||
|
),
|
||||||
|
app_output_es5: path.resolve(__dirname, "../hass_frontend/frontend_es5"),
|
||||||
|
|
||||||
demo_dir: path.resolve(__dirname, "../demo"),
|
demo_dir: path.resolve(__dirname, "../demo"),
|
||||||
demo_root: path.resolve(__dirname, "../demo/dist"),
|
demo_output_root: path.resolve(__dirname, "../demo/dist"),
|
||||||
demo_static: path.resolve(__dirname, "../demo/dist/static"),
|
demo_output_static: path.resolve(__dirname, "../demo/dist/static"),
|
||||||
demo_output: path.resolve(__dirname, "../demo/dist/frontend_latest"),
|
demo_output_latest: path.resolve(__dirname, "../demo/dist/frontend_latest"),
|
||||||
demo_output_es5: path.resolve(__dirname, "../demo/dist/frontend_es5"),
|
demo_output_es5: path.resolve(__dirname, "../demo/dist/frontend_es5"),
|
||||||
|
|
||||||
cast_dir: path.resolve(__dirname, "../cast"),
|
cast_dir: path.resolve(__dirname, "../cast"),
|
||||||
cast_root: path.resolve(__dirname, "../cast/dist"),
|
cast_output_root: path.resolve(__dirname, "../cast/dist"),
|
||||||
cast_static: path.resolve(__dirname, "../cast/dist/static"),
|
cast_output_static: path.resolve(__dirname, "../cast/dist/static"),
|
||||||
cast_output: path.resolve(__dirname, "../cast/dist/frontend_latest"),
|
cast_output_latest: path.resolve(__dirname, "../cast/dist/frontend_latest"),
|
||||||
cast_output_es5: path.resolve(__dirname, "../cast/dist/frontend_es5"),
|
cast_output_es5: path.resolve(__dirname, "../cast/dist/frontend_es5"),
|
||||||
|
|
||||||
gallery_dir: path.resolve(__dirname, "../gallery"),
|
gallery_dir: path.resolve(__dirname, "../gallery"),
|
||||||
gallery_root: path.resolve(__dirname, "../gallery/dist"),
|
gallery_output_root: path.resolve(__dirname, "../gallery/dist"),
|
||||||
gallery_output: path.resolve(__dirname, "../gallery/dist/frontend_latest"),
|
gallery_output_latest: path.resolve(
|
||||||
gallery_static: path.resolve(__dirname, "../gallery/dist/static"),
|
__dirname,
|
||||||
|
"../gallery/dist/frontend_latest"
|
||||||
|
),
|
||||||
|
gallery_output_static: path.resolve(__dirname, "../gallery/dist/static"),
|
||||||
|
|
||||||
hassio_dir: path.resolve(__dirname, "../hassio"),
|
hassio_dir: path.resolve(__dirname, "../hassio"),
|
||||||
hassio_root: path.resolve(__dirname, "../hassio/build"),
|
hassio_output_root: path.resolve(__dirname, "../hassio/build"),
|
||||||
hassio_publicPath: "/api/hassio/app/",
|
hassio_publicPath: "/api/hassio/app/",
|
||||||
|
|
||||||
translations_src: path.resolve(__dirname, "../src/translations"),
|
translations_src: path.resolve(__dirname, "../src/translations"),
|
||||||
|
14
build-scripts/rollup-plugins/dont-hash-plugin.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
module.exports = function (opts = {}) {
|
||||||
|
const dontHash = opts.dontHash || new Set();
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: "dont-hash",
|
||||||
|
renderChunk(_code, chunk, _options) {
|
||||||
|
if (!chunk.isEntry || !dontHash.has(chunk.name)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
chunk.fileName = `${chunk.name}.js`;
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
26
build-scripts/rollup-plugins/ignore-plugin.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
module.exports = function (userOptions = {}) {
|
||||||
|
// Files need to be absolute paths.
|
||||||
|
// This only works if the file has no exports
|
||||||
|
// and only is imported for its side effects
|
||||||
|
const files = userOptions.files || [];
|
||||||
|
|
||||||
|
if (files.length === 0) {
|
||||||
|
return {
|
||||||
|
name: "ignore",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: "ignore",
|
||||||
|
|
||||||
|
load(id) {
|
||||||
|
return files.some((toIgnorePath) => id.startsWith(toIgnorePath))
|
||||||
|
? {
|
||||||
|
code: "",
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
34
build-scripts/rollup-plugins/manifest-plugin.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
const url = require("url");
|
||||||
|
|
||||||
|
const defaultOptions = {
|
||||||
|
publicPath: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = function (userOptions = {}) {
|
||||||
|
const options = { ...defaultOptions, ...userOptions };
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: "manifest",
|
||||||
|
generateBundle(outputOptions, bundle) {
|
||||||
|
const manifest = {};
|
||||||
|
|
||||||
|
for (const chunk of Object.values(bundle)) {
|
||||||
|
if (!chunk.isEntry) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Add js extension to mimic Webpack manifest.
|
||||||
|
manifest[`${chunk.name}.js`] = url.resolve(
|
||||||
|
options.publicPath,
|
||||||
|
chunk.fileName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.emitFile({
|
||||||
|
type: "asset",
|
||||||
|
source: JSON.stringify(manifest, undefined, 2),
|
||||||
|
name: "manifest.json",
|
||||||
|
fileName: "manifest.json",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
149
build-scripts/rollup-plugins/worker-plugin.js
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
// Worker plugin
|
||||||
|
// Each worker will include all of its dependencies
|
||||||
|
// instead of relying on an importer.
|
||||||
|
|
||||||
|
// Forked from v.1.4.1
|
||||||
|
// https://github.com/surma/rollup-plugin-off-main-thread
|
||||||
|
/**
|
||||||
|
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const rollup = require("rollup");
|
||||||
|
const path = require("path");
|
||||||
|
const MagicString = require("magic-string");
|
||||||
|
|
||||||
|
const defaultOpts = {
|
||||||
|
// A RegExp to find `new Workers()` calls. The second capture group _must_
|
||||||
|
// capture the provided file name without the quotes.
|
||||||
|
workerRegexp: /new Worker\((["'])(.+?)\1(,[^)]+)?\)/g,
|
||||||
|
plugins: ["node-resolve", "commonjs", "babel", "terser", "ignore"],
|
||||||
|
};
|
||||||
|
|
||||||
|
async function getBundledWorker(workerPath, rollupOptions) {
|
||||||
|
const bundle = await rollup.rollup({
|
||||||
|
...rollupOptions,
|
||||||
|
input: {
|
||||||
|
worker: workerPath,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const { output } = await bundle.generate({
|
||||||
|
// Generates cleanest output, we shouldn't have any imports/exports
|
||||||
|
// that would be incompatible with ES5.
|
||||||
|
format: "es",
|
||||||
|
// We should not export anything. This will fail build if we are.
|
||||||
|
exports: "none",
|
||||||
|
});
|
||||||
|
|
||||||
|
let code;
|
||||||
|
|
||||||
|
for (const chunkOrAsset of output) {
|
||||||
|
if (chunkOrAsset.name === "worker") {
|
||||||
|
code = chunkOrAsset.code;
|
||||||
|
} else if (chunkOrAsset.type !== "asset") {
|
||||||
|
throw new Error("Unexpected extra output");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = function (opts = {}) {
|
||||||
|
opts = { ...defaultOpts, ...opts };
|
||||||
|
|
||||||
|
let rollupOptions;
|
||||||
|
let refIds;
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: "hass-worker",
|
||||||
|
|
||||||
|
async buildStart(options) {
|
||||||
|
refIds = {};
|
||||||
|
rollupOptions = {
|
||||||
|
plugins: options.plugins.filter((plugin) =>
|
||||||
|
opts.plugins.includes(plugin.name)
|
||||||
|
),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
async transform(code, id) {
|
||||||
|
// Copy the regexp as they are stateful and this hook is async.
|
||||||
|
const workerRegexp = new RegExp(
|
||||||
|
opts.workerRegexp.source,
|
||||||
|
opts.workerRegexp.flags
|
||||||
|
);
|
||||||
|
if (!workerRegexp.test(code)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ms = new MagicString(code);
|
||||||
|
// Reset the regexp
|
||||||
|
workerRegexp.lastIndex = 0;
|
||||||
|
while (true) {
|
||||||
|
const match = workerRegexp.exec(code);
|
||||||
|
if (!match) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const workerFile = match[2];
|
||||||
|
let optionsObject = {};
|
||||||
|
// Parse the optional options object
|
||||||
|
if (match[3] && match[3].length > 0) {
|
||||||
|
// FIXME: ooooof!
|
||||||
|
optionsObject = new Function(`return ${match[3].slice(1)};`)();
|
||||||
|
}
|
||||||
|
delete optionsObject.type;
|
||||||
|
|
||||||
|
if (!new RegExp("^.*/").test(workerFile)) {
|
||||||
|
this.warn(
|
||||||
|
`Paths passed to the Worker constructor must be relative or absolute, i.e. start with /, ./ or ../ (just like dynamic import!). Ignoring "${workerFile}".`
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find worker file and store it as a chunk with ID prefixed for our loader
|
||||||
|
const resolvedWorkerFile = (await this.resolve(workerFile, id)).id;
|
||||||
|
let chunkRefId;
|
||||||
|
if (resolvedWorkerFile in refIds) {
|
||||||
|
chunkRefId = refIds[resolvedWorkerFile];
|
||||||
|
} else {
|
||||||
|
this.addWatchFile(resolvedWorkerFile);
|
||||||
|
const source = await getBundledWorker(
|
||||||
|
resolvedWorkerFile,
|
||||||
|
rollupOptions
|
||||||
|
);
|
||||||
|
chunkRefId = refIds[resolvedWorkerFile] = this.emitFile({
|
||||||
|
name: path.basename(resolvedWorkerFile),
|
||||||
|
source,
|
||||||
|
type: "asset",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const workerParametersStartIndex = match.index + "new Worker(".length;
|
||||||
|
const workerParametersEndIndex =
|
||||||
|
match.index + match[0].length - ")".length;
|
||||||
|
|
||||||
|
ms.overwrite(
|
||||||
|
workerParametersStartIndex,
|
||||||
|
workerParametersEndIndex,
|
||||||
|
`import.meta.ROLLUP_FILE_URL_${chunkRefId}, ${JSON.stringify(
|
||||||
|
optionsObject
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
code: ms.toString(),
|
||||||
|
map: ms.generateMap({ hires: true }),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
151
build-scripts/rollup.js
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const commonjs = require("@rollup/plugin-commonjs");
|
||||||
|
const resolve = require("@rollup/plugin-node-resolve");
|
||||||
|
const json = require("@rollup/plugin-json");
|
||||||
|
const babel = require("rollup-plugin-babel");
|
||||||
|
const replace = require("@rollup/plugin-replace");
|
||||||
|
const visualizer = require("rollup-plugin-visualizer");
|
||||||
|
const { string } = require("rollup-plugin-string");
|
||||||
|
const { terser } = require("rollup-plugin-terser");
|
||||||
|
const manifest = require("./rollup-plugins/manifest-plugin");
|
||||||
|
const worker = require("./rollup-plugins/worker-plugin");
|
||||||
|
const dontHashPlugin = require("./rollup-plugins/dont-hash-plugin");
|
||||||
|
const ignore = require("./rollup-plugins/ignore-plugin");
|
||||||
|
|
||||||
|
const bundle = require("./bundle");
|
||||||
|
const paths = require("./paths");
|
||||||
|
|
||||||
|
const extensions = [".js", ".ts"];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} arg
|
||||||
|
* @param { import("rollup").InputOption } arg.input
|
||||||
|
*/
|
||||||
|
const createRollupConfig = ({
|
||||||
|
entry,
|
||||||
|
outputPath,
|
||||||
|
defineOverlay,
|
||||||
|
isProdBuild,
|
||||||
|
latestBuild,
|
||||||
|
isStatsBuild,
|
||||||
|
publicPath,
|
||||||
|
dontHash,
|
||||||
|
}) => {
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
* @type { import("rollup").InputOptions }
|
||||||
|
*/
|
||||||
|
inputOptions: {
|
||||||
|
input: entry,
|
||||||
|
// Some entry points contain no JavaScript. This setting silences a warning about that.
|
||||||
|
// https://rollupjs.org/guide/en/#preserveentrysignatures
|
||||||
|
preserveEntrySignatures: false,
|
||||||
|
plugins: [
|
||||||
|
ignore({
|
||||||
|
files: bundle.emptyPackages({ latestBuild }),
|
||||||
|
}),
|
||||||
|
resolve({
|
||||||
|
extensions,
|
||||||
|
preferBuiltins: false,
|
||||||
|
browser: true,
|
||||||
|
rootDir: paths.polymer_dir,
|
||||||
|
}),
|
||||||
|
commonjs({
|
||||||
|
namedExports: {
|
||||||
|
"js-yaml": ["safeDump", "safeLoad"],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
json(),
|
||||||
|
babel({
|
||||||
|
...bundle.babelOptions({ latestBuild }),
|
||||||
|
extensions,
|
||||||
|
exclude: bundle.babelExclude(),
|
||||||
|
}),
|
||||||
|
string({
|
||||||
|
// Import certain extensions as strings
|
||||||
|
include: [path.join(paths.polymer_dir, "node_modules/**/*.css")],
|
||||||
|
}),
|
||||||
|
replace(
|
||||||
|
bundle.definedVars({ isProdBuild, latestBuild, defineOverlay })
|
||||||
|
),
|
||||||
|
manifest({
|
||||||
|
publicPath,
|
||||||
|
}),
|
||||||
|
worker(),
|
||||||
|
dontHashPlugin({ dontHash }),
|
||||||
|
isProdBuild && terser(bundle.terserOptions(latestBuild)),
|
||||||
|
isStatsBuild &&
|
||||||
|
visualizer({
|
||||||
|
// https://github.com/btd/rollup-plugin-visualizer#options
|
||||||
|
open: true,
|
||||||
|
sourcemap: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @type { import("rollup").OutputOptions }
|
||||||
|
*/
|
||||||
|
outputOptions: {
|
||||||
|
// https://rollupjs.org/guide/en/#outputdir
|
||||||
|
dir: outputPath,
|
||||||
|
// https://rollupjs.org/guide/en/#outputformat
|
||||||
|
format: latestBuild ? "es" : "systemjs",
|
||||||
|
// https://rollupjs.org/guide/en/#outputexternallivebindings
|
||||||
|
externalLiveBindings: false,
|
||||||
|
// https://rollupjs.org/guide/en/#outputentryfilenames
|
||||||
|
// https://rollupjs.org/guide/en/#outputchunkfilenames
|
||||||
|
// https://rollupjs.org/guide/en/#outputassetfilenames
|
||||||
|
entryFileNames:
|
||||||
|
isProdBuild && !isStatsBuild ? "[name]-[hash].js" : "[name].js",
|
||||||
|
chunkFileNames:
|
||||||
|
isProdBuild && !isStatsBuild ? "c.[hash].js" : "[name].js",
|
||||||
|
assetFileNames:
|
||||||
|
isProdBuild && !isStatsBuild ? "a.[hash].js" : "[name].js",
|
||||||
|
// https://rollupjs.org/guide/en/#outputsourcemap
|
||||||
|
sourcemap: isProdBuild ? true : "inline",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const createAppConfig = ({ isProdBuild, latestBuild, isStatsBuild }) => {
|
||||||
|
return createRollupConfig(
|
||||||
|
bundle.config.app({
|
||||||
|
isProdBuild,
|
||||||
|
latestBuild,
|
||||||
|
isStatsBuild,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const createDemoConfig = ({ isProdBuild, latestBuild, isStatsBuild }) => {
|
||||||
|
return createRollupConfig(
|
||||||
|
bundle.config.demo({
|
||||||
|
isProdBuild,
|
||||||
|
latestBuild,
|
||||||
|
isStatsBuild,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const createCastConfig = ({ isProdBuild, latestBuild }) => {
|
||||||
|
return createRollupConfig(bundle.config.cast({ isProdBuild, latestBuild }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const createHassioConfig = ({ isProdBuild, latestBuild }) => {
|
||||||
|
return createRollupConfig(bundle.config.hassio({ isProdBuild, latestBuild }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const createGalleryConfig = ({ isProdBuild, latestBuild }) => {
|
||||||
|
return createRollupConfig(
|
||||||
|
bundle.config.gallery({ isProdBuild, latestBuild })
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
createAppConfig,
|
||||||
|
createDemoConfig,
|
||||||
|
createCastConfig,
|
||||||
|
createHassioConfig,
|
||||||
|
createGalleryConfig,
|
||||||
|
};
|
@@ -1,15 +1,15 @@
|
|||||||
const webpack = require("webpack");
|
const webpack = require("webpack");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const TerserPlugin = require("terser-webpack-plugin");
|
const TerserPlugin = require("terser-webpack-plugin");
|
||||||
const WorkboxPlugin = require("workbox-webpack-plugin");
|
|
||||||
const ManifestPlugin = require("webpack-manifest-plugin");
|
const ManifestPlugin = require("webpack-manifest-plugin");
|
||||||
|
const WorkerPlugin = require("worker-plugin");
|
||||||
const paths = require("./paths.js");
|
const paths = require("./paths.js");
|
||||||
const env = require("./env.js");
|
const bundle = require("./bundle");
|
||||||
const { babelLoaderConfig } = require("./babel.js");
|
|
||||||
|
|
||||||
const createWebpackConfig = ({
|
const createWebpackConfig = ({
|
||||||
entry,
|
entry,
|
||||||
outputRoot,
|
outputPath,
|
||||||
|
publicPath,
|
||||||
defineOverlay,
|
defineOverlay,
|
||||||
isProdBuild,
|
isProdBuild,
|
||||||
latestBuild,
|
latestBuild,
|
||||||
@@ -19,22 +19,30 @@ const createWebpackConfig = ({
|
|||||||
if (!dontHash) {
|
if (!dontHash) {
|
||||||
dontHash = new Set();
|
dontHash = new Set();
|
||||||
}
|
}
|
||||||
|
const ignorePackages = bundle.ignorePackages({ latestBuild });
|
||||||
return {
|
return {
|
||||||
mode: isProdBuild ? "production" : "development",
|
mode: isProdBuild ? "production" : "development",
|
||||||
devtool: isProdBuild ? "source-map" : "inline-cheap-module-source-map",
|
devtool: isProdBuild
|
||||||
|
? "cheap-module-source-map"
|
||||||
|
: "eval-cheap-module-source-map",
|
||||||
entry,
|
entry,
|
||||||
|
node: false,
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
babelLoaderConfig({ latestBuild }),
|
{
|
||||||
|
test: /\.js$|\.ts$/,
|
||||||
|
exclude: bundle.babelExclude(),
|
||||||
|
use: {
|
||||||
|
loader: "babel-loader",
|
||||||
|
options: bundle.babelOptions({ latestBuild }),
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
use: "raw-loader",
|
use: "raw-loader",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
externals: {
|
|
||||||
esprima: "esprima",
|
|
||||||
},
|
|
||||||
optimization: {
|
optimization: {
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new TerserPlugin({
|
new TerserPlugin({
|
||||||
@@ -42,45 +50,50 @@ const createWebpackConfig = ({
|
|||||||
parallel: true,
|
parallel: true,
|
||||||
extractComments: true,
|
extractComments: true,
|
||||||
sourceMap: true,
|
sourceMap: true,
|
||||||
terserOptions: {
|
terserOptions: bundle.terserOptions(latestBuild),
|
||||||
safari10: true,
|
|
||||||
ecma: latestBuild ? undefined : 5,
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new ManifestPlugin(),
|
new WorkerPlugin(),
|
||||||
new webpack.DefinePlugin({
|
new ManifestPlugin({
|
||||||
__DEV__: !isProdBuild,
|
// Only include the JS of entrypoints
|
||||||
__BUILD__: JSON.stringify(latestBuild ? "latest" : "es5"),
|
filter: (file) => file.isInitial && !file.name.endsWith(".map"),
|
||||||
__VERSION__: JSON.stringify(env.version()),
|
}),
|
||||||
__DEMO__: false,
|
new webpack.DefinePlugin(
|
||||||
__BACKWARDS_COMPAT__: false,
|
bundle.definedVars({ isProdBuild, latestBuild, defineOverlay })
|
||||||
__STATIC_PATH__: "/static/",
|
),
|
||||||
"process.env.NODE_ENV": JSON.stringify(
|
new webpack.IgnorePlugin({
|
||||||
isProdBuild ? "production" : "development"
|
checkResource(resource, context) {
|
||||||
),
|
// Only use ignore to intercept imports that we don't control
|
||||||
...defineOverlay,
|
// inside node_module dependencies.
|
||||||
|
if (
|
||||||
|
!context.includes("/node_modules/") ||
|
||||||
|
// calling define.amd will call require("!!webpack amd options")
|
||||||
|
resource.startsWith("!!webpack")
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let fullPath;
|
||||||
|
try {
|
||||||
|
fullPath = resource.startsWith(".")
|
||||||
|
? path.resolve(context, resource)
|
||||||
|
: require.resolve(resource);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error in ignore plugin", resource, context);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ignorePackages.some((toIgnorePath) =>
|
||||||
|
fullPath.startsWith(toIgnorePath)
|
||||||
|
);
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
// Ignore moment.js locales
|
|
||||||
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
|
||||||
// Color.js is bloated, it contains all color definitions for all material color sets.
|
|
||||||
new webpack.NormalModuleReplacementPlugin(
|
new webpack.NormalModuleReplacementPlugin(
|
||||||
/@polymer\/paper-styles\/color\.js$/,
|
new RegExp(bundle.emptyPackages({ latestBuild }).join("|")),
|
||||||
path.resolve(paths.polymer_dir, "src/util/empty.js")
|
path.resolve(paths.polymer_dir, "src/util/empty.js")
|
||||||
),
|
),
|
||||||
// Ignore roboto pointing at CDN. We use local font-roboto-local.
|
],
|
||||||
new webpack.NormalModuleReplacementPlugin(
|
|
||||||
/@polymer\/font-roboto\/roboto\.js$/,
|
|
||||||
path.resolve(paths.polymer_dir, "src/util/empty.js")
|
|
||||||
),
|
|
||||||
// Ignore mwc icons pointing at CDN.
|
|
||||||
new webpack.NormalModuleReplacementPlugin(
|
|
||||||
/@material\/mwc-icon\/mwc-icon-font\.js$/,
|
|
||||||
path.resolve(paths.polymer_dir, "src/util/empty.js")
|
|
||||||
),
|
|
||||||
].filter(Boolean),
|
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: [".ts", ".js", ".json"],
|
extensions: [".ts", ".js", ".json"],
|
||||||
},
|
},
|
||||||
@@ -95,147 +108,40 @@ const createWebpackConfig = ({
|
|||||||
isProdBuild && !isStatsBuild
|
isProdBuild && !isStatsBuild
|
||||||
? "chunk.[chunkhash].js"
|
? "chunk.[chunkhash].js"
|
||||||
: "[name].chunk.js",
|
: "[name].chunk.js",
|
||||||
path: path.resolve(
|
path: outputPath,
|
||||||
outputRoot,
|
publicPath,
|
||||||
latestBuild ? "frontend_latest" : "frontend_es5"
|
// To silence warning in worker plugin
|
||||||
),
|
|
||||||
publicPath: latestBuild ? "/frontend_latest/" : "/frontend_es5/",
|
|
||||||
// For workerize loader
|
|
||||||
globalObject: "self",
|
globalObject: "self",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const createAppConfig = ({ isProdBuild, latestBuild, isStatsBuild }) => {
|
const createAppConfig = ({ isProdBuild, latestBuild, isStatsBuild }) => {
|
||||||
const config = createWebpackConfig({
|
return createWebpackConfig(
|
||||||
entry: {
|
bundle.config.app({ isProdBuild, latestBuild, isStatsBuild })
|
||||||
app: "./src/entrypoints/app.ts",
|
);
|
||||||
authorize: "./src/entrypoints/authorize.ts",
|
|
||||||
onboarding: "./src/entrypoints/onboarding.ts",
|
|
||||||
core: "./src/entrypoints/core.ts",
|
|
||||||
compatibility: "./src/entrypoints/compatibility.ts",
|
|
||||||
"custom-panel": "./src/entrypoints/custom-panel.ts",
|
|
||||||
},
|
|
||||||
outputRoot: paths.root,
|
|
||||||
isProdBuild,
|
|
||||||
latestBuild,
|
|
||||||
isStatsBuild,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (latestBuild) {
|
|
||||||
// Create an object mapping browser urls to their paths during build
|
|
||||||
const translationMetadata = require("../build-translations/translationMetadata.json");
|
|
||||||
const workBoxTranslationsTemplatedURLs = {};
|
|
||||||
const englishFilename = `en-${translationMetadata.translations.en.hash}.json`;
|
|
||||||
|
|
||||||
// core
|
|
||||||
workBoxTranslationsTemplatedURLs[
|
|
||||||
`/static/translations/${englishFilename}`
|
|
||||||
] = `build-translations/output/${englishFilename}`;
|
|
||||||
|
|
||||||
translationMetadata.fragments.forEach((fragment) => {
|
|
||||||
workBoxTranslationsTemplatedURLs[
|
|
||||||
`/static/translations/${fragment}/${englishFilename}`
|
|
||||||
] = `build-translations/output/${fragment}/${englishFilename}`;
|
|
||||||
});
|
|
||||||
|
|
||||||
config.plugins.push(
|
|
||||||
new WorkboxPlugin.InjectManifest({
|
|
||||||
swSrc: "./src/entrypoints/service-worker-hass.js",
|
|
||||||
swDest: "service_worker.js",
|
|
||||||
importWorkboxFrom: "local",
|
|
||||||
include: [/\.js$/],
|
|
||||||
templatedURLs: {
|
|
||||||
...workBoxTranslationsTemplatedURLs,
|
|
||||||
"/static/icons/favicon-192x192.png":
|
|
||||||
"public/icons/favicon-192x192.png",
|
|
||||||
"/static/fonts/roboto/Roboto-Light.woff2":
|
|
||||||
"node_modules/roboto-fontface/fonts/roboto/Roboto-Light.woff2",
|
|
||||||
"/static/fonts/roboto/Roboto-Medium.woff2":
|
|
||||||
"node_modules/roboto-fontface/fonts/roboto/Roboto-Medium.woff2",
|
|
||||||
"/static/fonts/roboto/Roboto-Regular.woff2":
|
|
||||||
"node_modules/roboto-fontface/fonts/roboto/Roboto-Regular.woff2",
|
|
||||||
"/static/fonts/roboto/Roboto-Bold.woff2":
|
|
||||||
"node_modules/roboto-fontface/fonts/roboto/Roboto-Bold.woff2",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return config;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const createDemoConfig = ({ isProdBuild, latestBuild, isStatsBuild }) => {
|
const createDemoConfig = ({ isProdBuild, latestBuild, isStatsBuild }) => {
|
||||||
return createWebpackConfig({
|
return createWebpackConfig(
|
||||||
entry: {
|
bundle.config.demo({ isProdBuild, latestBuild, isStatsBuild })
|
||||||
main: path.resolve(paths.demo_dir, "src/entrypoint.ts"),
|
);
|
||||||
compatibility: path.resolve(
|
|
||||||
paths.polymer_dir,
|
|
||||||
"src/entrypoints/compatibility.ts"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
outputRoot: paths.demo_root,
|
|
||||||
defineOverlay: {
|
|
||||||
__VERSION__: JSON.stringify(`DEMO-${env.version()}`),
|
|
||||||
__DEMO__: true,
|
|
||||||
},
|
|
||||||
isProdBuild,
|
|
||||||
latestBuild,
|
|
||||||
isStatsBuild,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const createCastConfig = ({ isProdBuild, latestBuild }) => {
|
const createCastConfig = ({ isProdBuild, latestBuild }) => {
|
||||||
const entry = {
|
return createWebpackConfig(bundle.config.cast({ isProdBuild, latestBuild }));
|
||||||
launcher: path.resolve(paths.cast_dir, "src/launcher/entrypoint.ts"),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (latestBuild) {
|
|
||||||
entry.receiver = path.resolve(paths.cast_dir, "src/receiver/entrypoint.ts");
|
|
||||||
}
|
|
||||||
|
|
||||||
return createWebpackConfig({
|
|
||||||
entry,
|
|
||||||
outputRoot: paths.cast_root,
|
|
||||||
isProdBuild,
|
|
||||||
latestBuild,
|
|
||||||
defineOverlay: {
|
|
||||||
__BACKWARDS_COMPAT__: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const createHassioConfig = ({ isProdBuild, latestBuild }) => {
|
const createHassioConfig = ({ isProdBuild, latestBuild }) => {
|
||||||
if (latestBuild) {
|
return createWebpackConfig(
|
||||||
throw new Error("Hass.io does not support latest build!");
|
bundle.config.hassio({ isProdBuild, latestBuild })
|
||||||
}
|
);
|
||||||
const config = createWebpackConfig({
|
|
||||||
entry: {
|
|
||||||
entrypoint: path.resolve(paths.hassio_dir, "src/entrypoint.ts"),
|
|
||||||
},
|
|
||||||
outputRoot: "",
|
|
||||||
isProdBuild,
|
|
||||||
latestBuild,
|
|
||||||
dontHash: new Set(["entrypoint"]),
|
|
||||||
});
|
|
||||||
|
|
||||||
config.output.path = paths.hassio_root;
|
|
||||||
config.output.publicPath = paths.hassio_publicPath;
|
|
||||||
|
|
||||||
return config;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const createGalleryConfig = ({ isProdBuild, latestBuild }) => {
|
const createGalleryConfig = ({ isProdBuild, latestBuild }) => {
|
||||||
const config = createWebpackConfig({
|
return createWebpackConfig(
|
||||||
entry: {
|
bundle.config.gallery({ isProdBuild, latestBuild })
|
||||||
entrypoint: path.resolve(paths.gallery_dir, "src/entrypoint.js"),
|
);
|
||||||
},
|
|
||||||
outputRoot: paths.gallery_root,
|
|
||||||
isProdBuild,
|
|
||||||
latestBuild,
|
|
||||||
});
|
|
||||||
|
|
||||||
return config;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
10
cast/rollup.config.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
const rollup = require("../build-scripts/rollup.js");
|
||||||
|
const env = require("../build-scripts/env.js");
|
||||||
|
|
||||||
|
const config = rollup.createCastConfig({
|
||||||
|
isProdBuild: env.isProdBuild(),
|
||||||
|
latestBuild: true,
|
||||||
|
isStatsBuild: env.isStatsBuild(),
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = { ...config.inputOptions, output: config.outputOptions };
|
@@ -46,7 +46,13 @@
|
|||||||
// // Safari 10.1 supports type=module but ignores nomodule, so we add this check.
|
// // Safari 10.1 supports type=module but ignores nomodule, so we add this check.
|
||||||
if (!isS101) {
|
if (!isS101) {
|
||||||
_ls("/static/polyfills/custom-elements-es5-adapter.js");
|
_ls("/static/polyfills/custom-elements-es5-adapter.js");
|
||||||
_ls("<%= es5LauncherJS %>");
|
<% if (useRollup) { %>
|
||||||
|
_ls("/static/js/s.min.js").onload = function() {
|
||||||
|
System.import("<%= es5LauncherJS %>");
|
||||||
|
};
|
||||||
|
<% } else { %>
|
||||||
|
_ls("<%= es5LauncherJS %>");
|
||||||
|
<% } %>
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
@@ -37,7 +37,13 @@
|
|||||||
// // Safari 10.1 supports type=module but ignores nomodule, so we add this check.
|
// // Safari 10.1 supports type=module but ignores nomodule, so we add this check.
|
||||||
if (!isS101) {
|
if (!isS101) {
|
||||||
_ls("/static/polyfills/custom-elements-es5-adapter.js");
|
_ls("/static/polyfills/custom-elements-es5-adapter.js");
|
||||||
_ls("<%= es5LauncherJS %>");
|
<% if (useRollup) { %>
|
||||||
|
_ls("/static/js/s.min.js").onload = function() {
|
||||||
|
System.import("<%= es5LauncherJS %>");
|
||||||
|
};
|
||||||
|
<% } else { %>
|
||||||
|
_ls("<%= es5LauncherJS %>");
|
||||||
|
<% } %>
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
@@ -184,7 +184,7 @@ export class HcConnect extends LitElement {
|
|||||||
this.castManager = null;
|
this.castManager = null;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
registerServiceWorker(false);
|
registerServiceWorker(this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _handleDemo() {
|
private async _handleDemo() {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
import "web-animations-js/web-animations-next-lite.min";
|
import "web-animations-js/web-animations-next-lite.min";
|
||||||
import "../../../src/resources/roboto";
|
import "../../../src/resources/roboto";
|
||||||
|
import "../../../src/resources/ha-style";
|
||||||
import "./layout/hc-lovelace";
|
import "./layout/hc-lovelace";
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"background_color": "#FFFFFF",
|
"background_color": "#FFFFFF",
|
||||||
"description": "Open-source home automation platform running on Python 3.",
|
"description": "Home automation platform that puts local control and privacy first.",
|
||||||
"dir": "ltr",
|
"dir": "ltr",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"icons": [
|
"icons": [
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
],
|
],
|
||||||
"lang": "en-US",
|
"lang": "en-US",
|
||||||
"name": "Home Assistant Demo",
|
"name": "Home Assistant Demo",
|
||||||
"short_name": "Demo",
|
"short_name": "HA Demo",
|
||||||
"start_url": "/?homescreen=1",
|
"start_url": "/?homescreen=1",
|
||||||
"theme_color": "#03A9F4"
|
"theme_color": "#03A9F4"
|
||||||
}
|
}
|
||||||
|
10
demo/rollup.config.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
const rollup = require("../build-scripts/rollup.js");
|
||||||
|
const env = require("../build-scripts/env.js");
|
||||||
|
|
||||||
|
const config = rollup.createDemoConfig({
|
||||||
|
isProdBuild: env.isProdBuild(),
|
||||||
|
latestBuild: true,
|
||||||
|
isStatsBuild: env.isStatsBuild(),
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = { ...config.inputOptions, output: config.outputOptions };
|
@@ -7,5 +7,5 @@ set -e
|
|||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
STATS=1 NODE_ENV=production ../node_modules/.bin/webpack --profile --json > compilation-stats.json
|
STATS=1 NODE_ENV=production ../node_modules/.bin/webpack --profile --json > compilation-stats.json
|
||||||
npx webpack-bundle-analyzer compilation-stats.json dist
|
npx webpack-bundle-analyzer compilation-stats.json dist/frontend_latest
|
||||||
rm compilation-stats.json
|
rm compilation-stats.json
|
||||||
|
@@ -63,7 +63,7 @@ export const demoLovelaceTeachingbirds: DemoConfig["lovelace"] = () => ({
|
|||||||
elements: [
|
elements: [
|
||||||
{
|
{
|
||||||
style: {
|
style: {
|
||||||
"--mdc-icon-size": "100px",
|
"--mdc-icon-size": "100%",
|
||||||
top: "50%",
|
top: "50%",
|
||||||
left: "50%",
|
left: "50%",
|
||||||
},
|
},
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import "@polymer/paper-styles/typography";
|
|
||||||
import "@polymer/polymer/lib/elements/dom-if";
|
import "@polymer/polymer/lib/elements/dom-if";
|
||||||
import "@polymer/polymer/lib/elements/dom-repeat";
|
import "@polymer/polymer/lib/elements/dom-repeat";
|
||||||
import "../../src/resources/ha-style";
|
import "../../src/resources/ha-style";
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import "../../src/resources/compatibility";
|
||||||
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
|
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
|
||||||
import { navigate } from "../../src/common/navigate";
|
import { navigate } from "../../src/common/navigate";
|
||||||
import {
|
import {
|
||||||
|
@@ -104,8 +104,13 @@
|
|||||||
// // Safari 10.1 supports type=module but ignores nomodule, so we add this check.
|
// // Safari 10.1 supports type=module but ignores nomodule, so we add this check.
|
||||||
if (!isS101) {
|
if (!isS101) {
|
||||||
_ls("/static/polyfills/custom-elements-es5-adapter.js");
|
_ls("/static/polyfills/custom-elements-es5-adapter.js");
|
||||||
_ls("<%= es5Compatibility %>");
|
<% if (useRollup) { %>
|
||||||
_ls("<%= es5DemoJS %>");
|
_ls("/static/js/s.min.js").onload = function() {
|
||||||
|
System.import("<%= es5DemoJS %>");
|
||||||
|
};
|
||||||
|
<% } else { %>
|
||||||
|
_ls("<%= es5DemoJS %>");
|
||||||
|
<% } %>
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
10
gallery/rollup.config.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
const rollup = require("../build-scripts/rollup.js");
|
||||||
|
const env = require("../build-scripts/env.js");
|
||||||
|
|
||||||
|
const config = rollup.createGalleryConfig({
|
||||||
|
isProdBuild: env.isProdBuild(),
|
||||||
|
latestBuild: true,
|
||||||
|
isStatsBuild: env.isStatsBuild(),
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = { ...config.inputOptions, output: config.outputOptions };
|
@@ -1,4 +1,3 @@
|
|||||||
import "@polymer/paper-styles/typography";
|
|
||||||
import "@polymer/polymer/lib/elements/dom-if";
|
import "@polymer/polymer/lib/elements/dom-if";
|
||||||
import "@polymer/polymer/lib/elements/dom-repeat";
|
import "@polymer/polymer/lib/elements/dom-repeat";
|
||||||
import "../../src/resources/ha-style";
|
import "../../src/resources/ha-style";
|
||||||
|
@@ -10,6 +10,7 @@ import { html } from "@polymer/polymer/lib/utils/html-tag";
|
|||||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||||
import "../../src/components/ha-card";
|
import "../../src/components/ha-card";
|
||||||
import "../../src/managers/notification-manager";
|
import "../../src/managers/notification-manager";
|
||||||
|
import "../../src/styles/polymer-ha-style";
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
const DEMOS = require.context("./demos", true, /^(.*\.(ts$))[^.]*$/im);
|
const DEMOS = require.context("./demos", true, /^(.*\.(ts$))[^.]*$/im);
|
||||||
|
10
hassio/rollup.config.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
const rollup = require("../build-scripts/rollup.js");
|
||||||
|
const env = require("../build-scripts/env.js");
|
||||||
|
|
||||||
|
const config = rollup.createHassioConfig({
|
||||||
|
isProdBuild: env.isProdBuild(),
|
||||||
|
latestBuild: false,
|
||||||
|
isStatsBuild: env.isStatsBuild(),
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = { ...config.inputOptions, output: config.outputOptions };
|
@@ -1,4 +1,4 @@
|
|||||||
import "@polymer/paper-card/paper-card";
|
import { mdiArrowUpBoldCircle, mdiPuzzle } from "@mdi/js";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResultArray,
|
CSSResultArray,
|
||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { atLeastVersion } from "../../../src/common/config/version";
|
import { atLeastVersion } from "../../../src/common/config/version";
|
||||||
import { navigate } from "../../../src/common/navigate";
|
import { navigate } from "../../../src/common/navigate";
|
||||||
|
import "../../../src/components/ha-card";
|
||||||
import {
|
import {
|
||||||
HassioAddonInfo,
|
HassioAddonInfo,
|
||||||
HassioAddonRepository,
|
HassioAddonRepository,
|
||||||
@@ -66,7 +67,7 @@ class HassioAddonRepositoryEl extends LitElement {
|
|||||||
<div class="card-group">
|
<div class="card-group">
|
||||||
${addons.map(
|
${addons.map(
|
||||||
(addon) => html`
|
(addon) => html`
|
||||||
<paper-card
|
<ha-card
|
||||||
.addon=${addon}
|
.addon=${addon}
|
||||||
class=${addon.available ? "" : "not_available"}
|
class=${addon.available ? "" : "not_available"}
|
||||||
@click=${this._addonTapped}
|
@click=${this._addonTapped}
|
||||||
@@ -78,8 +79,8 @@ class HassioAddonRepositoryEl extends LitElement {
|
|||||||
.description=${addon.description}
|
.description=${addon.description}
|
||||||
.available=${addon.available}
|
.available=${addon.available}
|
||||||
.icon=${addon.installed && addon.installed !== addon.version
|
.icon=${addon.installed && addon.installed !== addon.version
|
||||||
? "hassio:arrow-up-bold-circle"
|
? mdiArrowUpBoldCircle
|
||||||
: "hassio:puzzle"}
|
: mdiPuzzle}
|
||||||
.iconTitle=${addon.installed
|
.iconTitle=${addon.installed
|
||||||
? addon.installed !== addon.version
|
? addon.installed !== addon.version
|
||||||
? "New version available"
|
? "New version available"
|
||||||
@@ -111,7 +112,7 @@ class HassioAddonRepositoryEl extends LitElement {
|
|||||||
: ""}
|
: ""}
|
||||||
></hassio-card-content>
|
></hassio-card-content>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -127,7 +128,7 @@ class HassioAddonRepositoryEl extends LitElement {
|
|||||||
return [
|
return [
|
||||||
hassioStyle,
|
hassioStyle,
|
||||||
css`
|
css`
|
||||||
paper-card {
|
ha-card {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.not_available {
|
.not_available {
|
||||||
|
@@ -1,3 +1,6 @@
|
|||||||
|
import "@material/mwc-icon-button/mwc-icon-button";
|
||||||
|
import "@material/mwc-list/mwc-list-item";
|
||||||
|
import { mdiDotsVertical } from "@mdi/js";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -6,22 +9,21 @@ import {
|
|||||||
PropertyValues,
|
PropertyValues,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { html, TemplateResult } from "lit-html";
|
import { html, TemplateResult } from "lit-html";
|
||||||
|
import "../../../src/common/search/search-input";
|
||||||
|
import "../../../src/components/ha-button-menu";
|
||||||
|
import "../../../src/components/ha-svg-icon";
|
||||||
import {
|
import {
|
||||||
fetchHassioAddonsInfo,
|
fetchHassioAddonsInfo,
|
||||||
HassioAddonInfo,
|
HassioAddonInfo,
|
||||||
HassioAddonRepository,
|
HassioAddonRepository,
|
||||||
reloadHassioAddons,
|
reloadHassioAddons,
|
||||||
} from "../../../src/data/hassio/addon";
|
} from "../../../src/data/hassio/addon";
|
||||||
import "../../../src/components/ha-icon-button";
|
|
||||||
import "../../../src/layouts/loading-screen";
|
|
||||||
import "../../../src/layouts/hass-tabs-subpage";
|
import "../../../src/layouts/hass-tabs-subpage";
|
||||||
|
import "../../../src/layouts/loading-screen";
|
||||||
import { HomeAssistant, Route } from "../../../src/types";
|
import { HomeAssistant, Route } from "../../../src/types";
|
||||||
import "../../../src/common/search/search-input";
|
|
||||||
import "./hassio-addon-repository";
|
|
||||||
|
|
||||||
import { supervisorTabs } from "../hassio-panel";
|
|
||||||
|
|
||||||
import { showRepositoriesDialog } from "../dialogs/repositories/show-dialog-repositories";
|
import { showRepositoriesDialog } from "../dialogs/repositories/show-dialog-repositories";
|
||||||
|
import { supervisorTabs } from "../hassio-panel";
|
||||||
|
import "./hassio-addon-repository";
|
||||||
|
|
||||||
const sortRepos = (a: HassioAddonRepository, b: HassioAddonRepository) => {
|
const sortRepos = (a: HassioAddonRepository, b: HassioAddonRepository) => {
|
||||||
if (a.slug === "local") {
|
if (a.slug === "local") {
|
||||||
@@ -94,27 +96,17 @@ class HassioAddonStore extends LitElement {
|
|||||||
.tabs=${supervisorTabs}
|
.tabs=${supervisorTabs}
|
||||||
>
|
>
|
||||||
<span slot="header">Add-on store</span>
|
<span slot="header">Add-on store</span>
|
||||||
<paper-menu-button
|
<ha-button-menu corner="BOTTOM_START" slot="toolbar-icon">
|
||||||
close-on-activate
|
<mwc-icon-button slot="trigger" alt="menu">
|
||||||
no-animations
|
<ha-svg-icon path=${mdiDotsVertical}></ha-svg-icon>
|
||||||
horizontal-align="right"
|
</mwc-icon-button>
|
||||||
horizontal-offset="-5"
|
<mwc-list-item @tap=${this._manageRepositories}>
|
||||||
slot="toolbar-icon"
|
Repositories
|
||||||
>
|
</mwc-list-item>
|
||||||
<ha-icon-button
|
<mwc-list-item @tap=${this.refreshData}>
|
||||||
icon="hassio:dots-vertical"
|
Reload
|
||||||
slot="dropdown-trigger"
|
</mwc-list-item>
|
||||||
alt="menu"
|
</ha-button-menu>
|
||||||
></ha-icon-button>
|
|
||||||
<paper-listbox slot="dropdown-content" role="listbox">
|
|
||||||
<paper-item @tap=${this._manageRepositories}>
|
|
||||||
Repositories
|
|
||||||
</paper-item>
|
|
||||||
<paper-item @tap=${this.refreshData}>
|
|
||||||
Reload
|
|
||||||
</paper-item>
|
|
||||||
</paper-listbox>
|
|
||||||
</paper-menu-button>
|
|
||||||
${repos.length === 0
|
${repos.length === 0
|
||||||
? html`<loading-screen></loading-screen>`
|
? html`<loading-screen></loading-screen>`
|
||||||
: html`
|
: html`
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import "@polymer/paper-card/paper-card";
|
|
||||||
import "@polymer/paper-dropdown-menu/paper-dropdown-menu";
|
import "@polymer/paper-dropdown-menu/paper-dropdown-menu";
|
||||||
import "@polymer/paper-item/paper-item";
|
import "@polymer/paper-item/paper-item";
|
||||||
import "@polymer/paper-listbox/paper-listbox";
|
import "@polymer/paper-listbox/paper-listbox";
|
||||||
@@ -14,6 +13,7 @@ import {
|
|||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import "web-animations-js/web-animations-next-lite.min";
|
import "web-animations-js/web-animations-next-lite.min";
|
||||||
|
import "../../../../src/components/ha-card";
|
||||||
import {
|
import {
|
||||||
HassioAddonDetails,
|
HassioAddonDetails,
|
||||||
HassioAddonSetOptionParams,
|
HassioAddonSetOptionParams,
|
||||||
@@ -23,9 +23,9 @@ import {
|
|||||||
fetchHassioHardwareAudio,
|
fetchHassioHardwareAudio,
|
||||||
HassioHardwareAudioDevice,
|
HassioHardwareAudioDevice,
|
||||||
} from "../../../../src/data/hassio/hardware";
|
} from "../../../../src/data/hassio/hardware";
|
||||||
import { suggestAddonRestart } from "../../dialogs/suggestAddonRestart";
|
|
||||||
import { haStyle } from "../../../../src/resources/styles";
|
import { haStyle } from "../../../../src/resources/styles";
|
||||||
import { HomeAssistant } from "../../../../src/types";
|
import { HomeAssistant } from "../../../../src/types";
|
||||||
|
import { suggestAddonRestart } from "../../dialogs/suggestAddonRestart";
|
||||||
import { hassioStyle } from "../../resources/hassio-style";
|
import { hassioStyle } from "../../resources/hassio-style";
|
||||||
|
|
||||||
@customElement("hassio-addon-audio")
|
@customElement("hassio-addon-audio")
|
||||||
@@ -46,7 +46,7 @@ class HassioAddonAudio extends LitElement {
|
|||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<paper-card heading="Audio">
|
<ha-card header="Audio">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ class HassioAddonAudio extends LitElement {
|
|||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<mwc-button @click=${this._saveSettings}>Save</mwc-button>
|
<mwc-button @click=${this._saveSettings}>Save</mwc-button>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ class HassioAddonAudio extends LitElement {
|
|||||||
hassioStyle,
|
hassioStyle,
|
||||||
css`
|
css`
|
||||||
:host,
|
:host,
|
||||||
paper-card,
|
ha-card,
|
||||||
paper-dropdown-menu {
|
paper-dropdown-menu {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
@@ -8,12 +8,10 @@ import {
|
|||||||
property,
|
property,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
|
||||||
import { HomeAssistant } from "../../../../src/types";
|
|
||||||
import { HassioAddonDetails } from "../../../../src/data/hassio/addon";
|
import { HassioAddonDetails } from "../../../../src/data/hassio/addon";
|
||||||
import { hassioStyle } from "../../resources/hassio-style";
|
|
||||||
import { haStyle } from "../../../../src/resources/styles";
|
import { haStyle } from "../../../../src/resources/styles";
|
||||||
|
import { HomeAssistant } from "../../../../src/types";
|
||||||
|
import { hassioStyle } from "../../resources/hassio-style";
|
||||||
import "./hassio-addon-audio";
|
import "./hassio-addon-audio";
|
||||||
import "./hassio-addon-config";
|
import "./hassio-addon-config";
|
||||||
import "./hassio-addon-network";
|
import "./hassio-addon-network";
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import "@polymer/iron-autogrow-textarea/iron-autogrow-textarea";
|
import "@polymer/iron-autogrow-textarea/iron-autogrow-textarea";
|
||||||
import "@polymer/paper-card/paper-card";
|
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -13,6 +12,7 @@ import {
|
|||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||||
|
import "../../../../src/components/ha-card";
|
||||||
import "../../../../src/components/ha-yaml-editor";
|
import "../../../../src/components/ha-yaml-editor";
|
||||||
import type { HaYamlEditor } from "../../../../src/components/ha-yaml-editor";
|
import type { HaYamlEditor } from "../../../../src/components/ha-yaml-editor";
|
||||||
import {
|
import {
|
||||||
@@ -23,9 +23,8 @@ import {
|
|||||||
import { showConfirmationDialog } from "../../../../src/dialogs/generic/show-dialog-box";
|
import { showConfirmationDialog } from "../../../../src/dialogs/generic/show-dialog-box";
|
||||||
import { haStyle } from "../../../../src/resources/styles";
|
import { haStyle } from "../../../../src/resources/styles";
|
||||||
import type { HomeAssistant } from "../../../../src/types";
|
import type { HomeAssistant } from "../../../../src/types";
|
||||||
import { hassioStyle } from "../../resources/hassio-style";
|
|
||||||
|
|
||||||
import { suggestAddonRestart } from "../../dialogs/suggestAddonRestart";
|
import { suggestAddonRestart } from "../../dialogs/suggestAddonRestart";
|
||||||
|
import { hassioStyle } from "../../resources/hassio-style";
|
||||||
|
|
||||||
@customElement("hassio-addon-config")
|
@customElement("hassio-addon-config")
|
||||||
class HassioAddonConfig extends LitElement {
|
class HassioAddonConfig extends LitElement {
|
||||||
@@ -46,7 +45,7 @@ class HassioAddonConfig extends LitElement {
|
|||||||
|
|
||||||
return html`
|
return html`
|
||||||
<h1>${this.addon.name}</h1>
|
<h1>${this.addon.name}</h1>
|
||||||
<paper-card heading="Configuration">
|
<ha-card header="Configuration">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<ha-yaml-editor
|
<ha-yaml-editor
|
||||||
@value-changed=${this._configChanged}
|
@value-changed=${this._configChanged}
|
||||||
@@ -65,7 +64,7 @@ class HassioAddonConfig extends LitElement {
|
|||||||
Save
|
Save
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +76,7 @@ class HassioAddonConfig extends LitElement {
|
|||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
paper-card {
|
ha-card {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.card-actions {
|
.card-actions {
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import "@polymer/paper-card/paper-card";
|
|
||||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
@@ -11,15 +10,15 @@ import {
|
|||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||||
|
import "../../../../src/components/ha-card";
|
||||||
import {
|
import {
|
||||||
HassioAddonDetails,
|
HassioAddonDetails,
|
||||||
HassioAddonSetOptionParams,
|
HassioAddonSetOptionParams,
|
||||||
setHassioAddonOption,
|
setHassioAddonOption,
|
||||||
} from "../../../../src/data/hassio/addon";
|
} from "../../../../src/data/hassio/addon";
|
||||||
import { suggestAddonRestart } from "../../dialogs/suggestAddonRestart";
|
|
||||||
|
|
||||||
import { haStyle } from "../../../../src/resources/styles";
|
import { haStyle } from "../../../../src/resources/styles";
|
||||||
import { HomeAssistant } from "../../../../src/types";
|
import { HomeAssistant } from "../../../../src/types";
|
||||||
|
import { suggestAddonRestart } from "../../dialogs/suggestAddonRestart";
|
||||||
import { hassioStyle } from "../../resources/hassio-style";
|
import { hassioStyle } from "../../resources/hassio-style";
|
||||||
|
|
||||||
interface NetworkItem {
|
interface NetworkItem {
|
||||||
@@ -53,7 +52,7 @@ class HassioAddonNetwork extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<paper-card heading="Network">
|
<ha-card header="Network">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
||||||
|
|
||||||
@@ -90,7 +89,7 @@ class HassioAddonNetwork extends LitElement {
|
|||||||
</mwc-button>
|
</mwc-button>
|
||||||
<mwc-button @click=${this._saveTapped}>Save</mwc-button>
|
<mwc-button @click=${this._saveTapped}>Save</mwc-button>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +101,7 @@ class HassioAddonNetwork extends LitElement {
|
|||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
paper-card {
|
ha-card {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.errors {
|
.errors {
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import "@polymer/paper-spinner/paper-spinner-lite";
|
import "@polymer/paper-spinner/paper-spinner-lite";
|
||||||
import "@polymer/paper-card/paper-card";
|
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -9,16 +8,15 @@ import {
|
|||||||
property,
|
property,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
|
||||||
import { HomeAssistant } from "../../../../src/types";
|
|
||||||
import {
|
|
||||||
HassioAddonDetails,
|
|
||||||
fetchHassioAddonDocumentation,
|
|
||||||
} from "../../../../src/data/hassio/addon";
|
|
||||||
import "../../../../src/components/ha-markdown";
|
import "../../../../src/components/ha-markdown";
|
||||||
|
import {
|
||||||
|
fetchHassioAddonDocumentation,
|
||||||
|
HassioAddonDetails,
|
||||||
|
} from "../../../../src/data/hassio/addon";
|
||||||
import "../../../../src/layouts/loading-screen";
|
import "../../../../src/layouts/loading-screen";
|
||||||
import { hassioStyle } from "../../resources/hassio-style";
|
|
||||||
import { haStyle } from "../../../../src/resources/styles";
|
import { haStyle } from "../../../../src/resources/styles";
|
||||||
|
import { HomeAssistant } from "../../../../src/types";
|
||||||
|
import { hassioStyle } from "../../resources/hassio-style";
|
||||||
|
|
||||||
@customElement("hassio-addon-documentation-tab")
|
@customElement("hassio-addon-documentation-tab")
|
||||||
class HassioAddonDocumentationDashboard extends LitElement {
|
class HassioAddonDocumentationDashboard extends LitElement {
|
||||||
@@ -41,14 +39,14 @@ class HassioAddonDocumentationDashboard extends LitElement {
|
|||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<paper-card>
|
<ha-card>
|
||||||
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${this._content
|
${this._content
|
||||||
? html`<ha-markdown .content=${this._content}></ha-markdown>`
|
? html`<ha-markdown .content=${this._content}></ha-markdown>`
|
||||||
: html`<loading-screen></loading-screen>`}
|
: html`<loading-screen></loading-screen>`}
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -58,7 +56,7 @@ class HassioAddonDocumentationDashboard extends LitElement {
|
|||||||
haStyle,
|
haStyle,
|
||||||
hassioStyle,
|
hassioStyle,
|
||||||
css`
|
css`
|
||||||
paper-card {
|
ha-card {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.content {
|
.content {
|
||||||
@@ -66,6 +64,9 @@ class HassioAddonDocumentationDashboard extends LitElement {
|
|||||||
padding: 8px;
|
padding: 8px;
|
||||||
max-width: 1024px;
|
max-width: 1024px;
|
||||||
}
|
}
|
||||||
|
ha-markdown {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,9 @@
|
|||||||
import "../../../src/components/ha-icon-button";
|
import {
|
||||||
|
mdiCogs,
|
||||||
|
mdiFileDocument,
|
||||||
|
mdiInformationVariant,
|
||||||
|
mdiMathLog,
|
||||||
|
} from "@mdi/js";
|
||||||
import "@polymer/paper-spinner/paper-spinner-lite";
|
import "@polymer/paper-spinner/paper-spinner-lite";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
@@ -14,18 +19,17 @@ import {
|
|||||||
fetchHassioAddonInfo,
|
fetchHassioAddonInfo,
|
||||||
HassioAddonDetails,
|
HassioAddonDetails,
|
||||||
} from "../../../src/data/hassio/addon";
|
} from "../../../src/data/hassio/addon";
|
||||||
|
import "../../../src/layouts/hass-tabs-subpage";
|
||||||
|
import type { PageNavigation } from "../../../src/layouts/hass-tabs-subpage";
|
||||||
import { haStyle } from "../../../src/resources/styles";
|
import { haStyle } from "../../../src/resources/styles";
|
||||||
import { HomeAssistant, Route } from "../../../src/types";
|
import { HomeAssistant, Route } from "../../../src/types";
|
||||||
import { hassioStyle } from "../resources/hassio-style";
|
import { hassioStyle } from "../resources/hassio-style";
|
||||||
import "./config/hassio-addon-audio";
|
import "./config/hassio-addon-audio";
|
||||||
import "./config/hassio-addon-config";
|
import "./config/hassio-addon-config";
|
||||||
|
import "./config/hassio-addon-network";
|
||||||
|
import "./hassio-addon-router";
|
||||||
import "./info/hassio-addon-info";
|
import "./info/hassio-addon-info";
|
||||||
import "./log/hassio-addon-logs";
|
import "./log/hassio-addon-logs";
|
||||||
import "./config/hassio-addon-network";
|
|
||||||
import type { PageNavigation } from "../../../src/layouts/hass-tabs-subpage";
|
|
||||||
import "../../../src/layouts/hass-tabs-subpage";
|
|
||||||
|
|
||||||
import "./hassio-addon-router";
|
|
||||||
|
|
||||||
@customElement("hassio-addon-dashboard")
|
@customElement("hassio-addon-dashboard")
|
||||||
class HassioAddonDashboard extends LitElement {
|
class HassioAddonDashboard extends LitElement {
|
||||||
@@ -59,7 +63,7 @@ class HassioAddonDashboard extends LitElement {
|
|||||||
{
|
{
|
||||||
name: "Info",
|
name: "Info",
|
||||||
path: `/hassio/addon/${this.addon.slug}/info`,
|
path: `/hassio/addon/${this.addon.slug}/info`,
|
||||||
icon: "hassio:information-variant",
|
iconPath: mdiInformationVariant,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -67,7 +71,7 @@ class HassioAddonDashboard extends LitElement {
|
|||||||
addonTabs.push({
|
addonTabs.push({
|
||||||
name: "Documentation",
|
name: "Documentation",
|
||||||
path: `/hassio/addon/${this.addon.slug}/documentation`,
|
path: `/hassio/addon/${this.addon.slug}/documentation`,
|
||||||
icon: "hassio:file-document",
|
iconPath: mdiFileDocument,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,12 +80,12 @@ class HassioAddonDashboard extends LitElement {
|
|||||||
{
|
{
|
||||||
name: "Configuration",
|
name: "Configuration",
|
||||||
path: `/hassio/addon/${this.addon.slug}/config`,
|
path: `/hassio/addon/${this.addon.slug}/config`,
|
||||||
icon: "hassio:cogs",
|
iconPath: mdiCogs,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Log",
|
name: "Log",
|
||||||
path: `/hassio/addon/${this.addon.slug}/logs`,
|
path: `/hassio/addon/${this.addon.slug}/logs`,
|
||||||
icon: "hassio:math-log",
|
iconPath: mdiMathLog,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -115,7 +119,6 @@ class HassioAddonDashboard extends LitElement {
|
|||||||
css`
|
css`
|
||||||
:host {
|
:host {
|
||||||
color: var(--primary-text-color);
|
color: var(--primary-text-color);
|
||||||
--paper-card-header-color: var(--primary-text-color);
|
|
||||||
}
|
}
|
||||||
.content {
|
.content {
|
||||||
padding: 24px 0 32px;
|
padding: 24px 0 32px;
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
|
import { customElement, property } from "lit-element";
|
||||||
|
import { HassioAddonDetails } from "../../../src/data/hassio/addon";
|
||||||
import {
|
import {
|
||||||
HassRouterPage,
|
HassRouterPage,
|
||||||
RouterOptions,
|
RouterOptions,
|
||||||
} from "../../../src/layouts/hass-router-page";
|
} from "../../../src/layouts/hass-router-page";
|
||||||
import { customElement, property } from "lit-element";
|
|
||||||
import { HomeAssistant } from "../../../src/types";
|
import { HomeAssistant } from "../../../src/types";
|
||||||
|
import "./config/hassio-addon-config-tab";
|
||||||
|
import "./documentation/hassio-addon-documentation-tab";
|
||||||
// Don't codesplit the others, because it breaks the UI when pushed to a Pi
|
// Don't codesplit the others, because it breaks the UI when pushed to a Pi
|
||||||
import "./info/hassio-addon-info-tab";
|
import "./info/hassio-addon-info-tab";
|
||||||
import "./config/hassio-addon-config-tab";
|
|
||||||
import "./log/hassio-addon-log-tab";
|
import "./log/hassio-addon-log-tab";
|
||||||
import "./documentation/hassio-addon-documentation-tab";
|
|
||||||
import { HassioAddonDetails } from "../../../src/data/hassio/addon";
|
|
||||||
|
|
||||||
@customElement("hassio-addon-router")
|
@customElement("hassio-addon-router")
|
||||||
class HassioAddonRouter extends HassRouterPage {
|
class HassioAddonRouter extends HassRouterPage {
|
||||||
|
@@ -8,12 +8,10 @@ import {
|
|||||||
property,
|
property,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
|
||||||
import { HomeAssistant } from "../../../../src/types";
|
|
||||||
import { HassioAddonDetails } from "../../../../src/data/hassio/addon";
|
import { HassioAddonDetails } from "../../../../src/data/hassio/addon";
|
||||||
import { hassioStyle } from "../../resources/hassio-style";
|
|
||||||
import { haStyle } from "../../../../src/resources/styles";
|
import { haStyle } from "../../../../src/resources/styles";
|
||||||
|
import { HomeAssistant } from "../../../../src/types";
|
||||||
|
import { hassioStyle } from "../../resources/hassio-style";
|
||||||
import "./hassio-addon-info";
|
import "./hassio-addon-info";
|
||||||
|
|
||||||
@customElement("hassio-addon-info-tab")
|
@customElement("hassio-addon-info-tab")
|
||||||
|
@@ -1,5 +1,20 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import "@polymer/paper-card/paper-card";
|
import {
|
||||||
|
mdiArrowUpBoldCircle,
|
||||||
|
mdiCheckCircle,
|
||||||
|
mdiChip,
|
||||||
|
mdiCircle,
|
||||||
|
mdiCursorDefaultClickOutline,
|
||||||
|
mdiDocker,
|
||||||
|
mdiExclamationThick,
|
||||||
|
mdiFlask,
|
||||||
|
mdiHomeAssistant,
|
||||||
|
mdiInformation,
|
||||||
|
mdiKey,
|
||||||
|
mdiNetwork,
|
||||||
|
mdiPound,
|
||||||
|
mdiShield,
|
||||||
|
} from "@mdi/js";
|
||||||
import "@polymer/paper-tooltip/paper-tooltip";
|
import "@polymer/paper-tooltip/paper-tooltip";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
@@ -16,10 +31,11 @@ import { fireEvent } from "../../../../src/common/dom/fire_event";
|
|||||||
import { navigate } from "../../../../src/common/navigate";
|
import { navigate } from "../../../../src/common/navigate";
|
||||||
import "../../../../src/components/buttons/ha-call-api-button";
|
import "../../../../src/components/buttons/ha-call-api-button";
|
||||||
import "../../../../src/components/buttons/ha-progress-button";
|
import "../../../../src/components/buttons/ha-progress-button";
|
||||||
|
import "../../../../src/components/ha-card";
|
||||||
import "../../../../src/components/ha-label-badge";
|
import "../../../../src/components/ha-label-badge";
|
||||||
import "../../../../src/components/ha-markdown";
|
import "../../../../src/components/ha-markdown";
|
||||||
|
import "../../../../src/components/ha-svg-icon";
|
||||||
import "../../../../src/components/ha-switch";
|
import "../../../../src/components/ha-switch";
|
||||||
import "../../../../src/components/ha-icon";
|
|
||||||
import {
|
import {
|
||||||
fetchHassioAddonChangelog,
|
fetchHassioAddonChangelog,
|
||||||
HassioAddonDetails,
|
HassioAddonDetails,
|
||||||
@@ -30,23 +46,23 @@ import {
|
|||||||
setHassioAddonSecurity,
|
setHassioAddonSecurity,
|
||||||
uninstallHassioAddon,
|
uninstallHassioAddon,
|
||||||
} from "../../../../src/data/hassio/addon";
|
} from "../../../../src/data/hassio/addon";
|
||||||
|
import { showConfirmationDialog } from "../../../../src/dialogs/generic/show-dialog-box";
|
||||||
import { haStyle } from "../../../../src/resources/styles";
|
import { haStyle } from "../../../../src/resources/styles";
|
||||||
import { HomeAssistant } from "../../../../src/types";
|
import { HomeAssistant } from "../../../../src/types";
|
||||||
import "../../components/hassio-card-content";
|
import "../../components/hassio-card-content";
|
||||||
import { showHassioMarkdownDialog } from "../../dialogs/markdown/show-dialog-hassio-markdown";
|
import { showHassioMarkdownDialog } from "../../dialogs/markdown/show-dialog-hassio-markdown";
|
||||||
import { hassioStyle } from "../../resources/hassio-style";
|
import { hassioStyle } from "../../resources/hassio-style";
|
||||||
import { showConfirmationDialog } from "../../../../src/dialogs/generic/show-dialog-box";
|
|
||||||
|
|
||||||
const STAGE_ICON = {
|
const STAGE_ICON = {
|
||||||
stable: "mdi:check-circle",
|
stable: mdiCheckCircle,
|
||||||
experimental: "mdi:flask",
|
experimental: mdiFlask,
|
||||||
deprecated: "mdi:exclamation-thick",
|
deprecated: mdiExclamationThick,
|
||||||
};
|
};
|
||||||
|
|
||||||
const PERMIS_DESC = {
|
const PERMIS_DESC = {
|
||||||
stage: {
|
stage: {
|
||||||
title: "Add-on Stage",
|
title: "Add-on Stage",
|
||||||
description: `Add-ons can have one of three stages:\n\n<ha-icon icon='${STAGE_ICON.stable}'></ha-icon>**Stable**: These are add-ons ready to be used in production.\n<ha-icon icon='${STAGE_ICON.experimental}'></ha-icon>**Experimental**: These may contain bugs, and may be unfinished.\n<ha-icon icon='${STAGE_ICON.deprecated}'></ha-icon>**Deprecated**: These add-ons will no longer receive any updates.`,
|
description: `Add-ons can have one of three stages:\n\n<ha-svg-icon path='${STAGE_ICON.stable}'></ha-svg-icon> **Stable**: These are add-ons ready to be used in production.\n\n<ha-svg-icon path='${STAGE_ICON.experimental}'></ha-svg-icon> **Experimental**: These may contain bugs, and may be unfinished.\n\n<ha-svg-icon path='${STAGE_ICON.deprecated}'></ha-svg-icon> **Deprecated**: These add-ons will no longer receive any updates.`,
|
||||||
},
|
},
|
||||||
rating: {
|
rating: {
|
||||||
title: "Add-on Security Rating",
|
title: "Add-on Security Rating",
|
||||||
@@ -116,7 +132,7 @@ class HassioAddonInfo extends LitElement {
|
|||||||
return html`
|
return html`
|
||||||
${this._computeUpdateAvailable
|
${this._computeUpdateAvailable
|
||||||
? html`
|
? html`
|
||||||
<paper-card heading="Update available! 🎉">
|
<ha-card header="Update available! 🎉">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<hassio-card-content
|
<hassio-card-content
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -124,7 +140,7 @@ class HassioAddonInfo extends LitElement {
|
|||||||
.version_latest} is available"
|
.version_latest} is available"
|
||||||
.description="You are currently running version ${this.addon
|
.description="You are currently running version ${this.addon
|
||||||
.version}"
|
.version}"
|
||||||
icon="hassio:arrow-up-bold-circle"
|
icon=${mdiArrowUpBoldCircle}
|
||||||
iconClass="update"
|
iconClass="update"
|
||||||
></hassio-card-content>
|
></hassio-card-content>
|
||||||
${!this.addon.available
|
${!this.addon.available
|
||||||
@@ -151,12 +167,13 @@ class HassioAddonInfo extends LitElement {
|
|||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
${!this.addon.protected
|
${!this.addon.protected
|
||||||
? html`
|
? html`
|
||||||
<paper-card heading="Warning: Protection mode is disabled!" class="warning">
|
<ha-card class="warning">
|
||||||
|
<div class="card-header">Warning: Protection mode is disabled!</div>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
Protection mode on this add-on is disabled! This gives the add-on full access to the entire system, which adds security risks, and could damage your system when used incorrectly. Only disable the protection mode if you know, need AND trust the source of this add-on.
|
Protection mode on this add-on is disabled! This gives the add-on full access to the entire system, which adds security risks, and could damage your system when used incorrectly. Only disable the protection mode if you know, need AND trust the source of this add-on.
|
||||||
</div>
|
</div>
|
||||||
@@ -164,11 +181,11 @@ class HassioAddonInfo extends LitElement {
|
|||||||
<mwc-button @click=${this._protectionToggled}>Enable Protection mode</mwc-button>
|
<mwc-button @click=${this._protectionToggled}>Enable Protection mode</mwc-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
|
|
||||||
<paper-card>
|
<ha-card>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div class="addon-header">
|
<div class="addon-header">
|
||||||
${!this.narrow ? this.addon.name : ""}
|
${!this.narrow ? this.addon.name : ""}
|
||||||
@@ -177,18 +194,18 @@ class HassioAddonInfo extends LitElement {
|
|||||||
? html`
|
? html`
|
||||||
${this._computeIsRunning
|
${this._computeIsRunning
|
||||||
? html`
|
? html`
|
||||||
<ha-icon
|
<ha-svg-icon
|
||||||
title="Add-on is running"
|
title="Add-on is running"
|
||||||
class="running"
|
class="running"
|
||||||
icon="hassio:circle"
|
path=${mdiCircle}
|
||||||
></ha-icon>
|
></ha-svg-icon>
|
||||||
`
|
`
|
||||||
: html`
|
: html`
|
||||||
<ha-icon
|
<ha-svg-icon
|
||||||
title="Add-on is stopped"
|
title="Add-on is stopped"
|
||||||
class="stopped"
|
class="stopped"
|
||||||
icon="hassio:circle"
|
path=${mdiCircle}
|
||||||
></ha-icon>
|
></ha-svg-icon>
|
||||||
`}
|
`}
|
||||||
`
|
`
|
||||||
: html` ${this.addon.version_latest} `}
|
: html` ${this.addon.version_latest} `}
|
||||||
@@ -232,10 +249,11 @@ class HassioAddonInfo extends LitElement {
|
|||||||
})}
|
})}
|
||||||
@click=${this._showMoreInfo}
|
@click=${this._showMoreInfo}
|
||||||
id="stage"
|
id="stage"
|
||||||
.icon=${STAGE_ICON[this.addon.stage]}
|
|
||||||
label="stage"
|
label="stage"
|
||||||
description=""
|
description=""
|
||||||
></ha-label-badge>
|
>
|
||||||
|
<ha-svg-icon .path=${STAGE_ICON[this.addon.stage]}></ha-svg-icon>
|
||||||
|
</ha-label-badge>
|
||||||
<ha-label-badge
|
<ha-label-badge
|
||||||
class=${classMap({
|
class=${classMap({
|
||||||
green: [5, 6].includes(Number(this.addon.rating)),
|
green: [5, 6].includes(Number(this.addon.rating)),
|
||||||
@@ -253,10 +271,11 @@ class HassioAddonInfo extends LitElement {
|
|||||||
<ha-label-badge
|
<ha-label-badge
|
||||||
@click=${this._showMoreInfo}
|
@click=${this._showMoreInfo}
|
||||||
id="host_network"
|
id="host_network"
|
||||||
icon="hassio:network"
|
|
||||||
label="host"
|
label="host"
|
||||||
description=""
|
description=""
|
||||||
></ha-label-badge>
|
>
|
||||||
|
<ha-svg-icon path=${mdiNetwork}></ha-svg-icon>
|
||||||
|
</ha-label-badge>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
${this.addon.full_access
|
${this.addon.full_access
|
||||||
@@ -264,10 +283,11 @@ class HassioAddonInfo extends LitElement {
|
|||||||
<ha-label-badge
|
<ha-label-badge
|
||||||
@click=${this._showMoreInfo}
|
@click=${this._showMoreInfo}
|
||||||
id="full_access"
|
id="full_access"
|
||||||
icon="hassio:chip"
|
|
||||||
label="hardware"
|
label="hardware"
|
||||||
description=""
|
description=""
|
||||||
></ha-label-badge>
|
>
|
||||||
|
<ha-svg-icon path=${mdiChip}></ha-svg-icon>
|
||||||
|
</ha-label-badge>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
${this.addon.homeassistant_api
|
${this.addon.homeassistant_api
|
||||||
@@ -275,10 +295,11 @@ class HassioAddonInfo extends LitElement {
|
|||||||
<ha-label-badge
|
<ha-label-badge
|
||||||
@click=${this._showMoreInfo}
|
@click=${this._showMoreInfo}
|
||||||
id="homeassistant_api"
|
id="homeassistant_api"
|
||||||
icon="hassio:home-assistant"
|
|
||||||
label="hass"
|
label="hass"
|
||||||
description=""
|
description=""
|
||||||
></ha-label-badge>
|
>
|
||||||
|
<ha-svg-icon path=${mdiHomeAssistant}></ha-svg-icon>
|
||||||
|
</ha-label-badge>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
${this._computeHassioApi
|
${this._computeHassioApi
|
||||||
@@ -286,10 +307,11 @@ class HassioAddonInfo extends LitElement {
|
|||||||
<ha-label-badge
|
<ha-label-badge
|
||||||
@click=${this._showMoreInfo}
|
@click=${this._showMoreInfo}
|
||||||
id="hassio_api"
|
id="hassio_api"
|
||||||
icon="hassio:home-assistant"
|
|
||||||
label="hassio"
|
label="hassio"
|
||||||
.description=${this.addon.hassio_role}
|
.description=${this.addon.hassio_role}
|
||||||
></ha-label-badge>
|
>
|
||||||
|
<ha-svg-icon path=${mdiHomeAssistant}></ha-svg-icon>
|
||||||
|
</ha-label-badge>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
${this.addon.docker_api
|
${this.addon.docker_api
|
||||||
@@ -297,10 +319,11 @@ class HassioAddonInfo extends LitElement {
|
|||||||
<ha-label-badge
|
<ha-label-badge
|
||||||
@click=${this._showMoreInfo}
|
@click=${this._showMoreInfo}
|
||||||
id="docker_api"
|
id="docker_api"
|
||||||
icon="hassio:docker"
|
|
||||||
label="docker"
|
label="docker"
|
||||||
description=""
|
description=""
|
||||||
></ha-label-badge>
|
>
|
||||||
|
<ha-svg-icon path=${mdiDocker}></ha-svg-icon>
|
||||||
|
</ha-label-badge>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
${this.addon.host_pid
|
${this.addon.host_pid
|
||||||
@@ -308,10 +331,11 @@ class HassioAddonInfo extends LitElement {
|
|||||||
<ha-label-badge
|
<ha-label-badge
|
||||||
@click=${this._showMoreInfo}
|
@click=${this._showMoreInfo}
|
||||||
id="host_pid"
|
id="host_pid"
|
||||||
icon="hassio:pound"
|
|
||||||
label="host pid"
|
label="host pid"
|
||||||
description=""
|
description=""
|
||||||
></ha-label-badge>
|
>
|
||||||
|
<ha-svg-icon path=${mdiPound}></ha-svg-icon>
|
||||||
|
</ha-label-badge>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
${this.addon.apparmor
|
${this.addon.apparmor
|
||||||
@@ -320,10 +344,11 @@ class HassioAddonInfo extends LitElement {
|
|||||||
@click=${this._showMoreInfo}
|
@click=${this._showMoreInfo}
|
||||||
class=${this._computeApparmorClassName}
|
class=${this._computeApparmorClassName}
|
||||||
id="apparmor"
|
id="apparmor"
|
||||||
icon="hassio:shield"
|
|
||||||
label="apparmor"
|
label="apparmor"
|
||||||
description=""
|
description=""
|
||||||
></ha-label-badge>
|
>
|
||||||
|
<ha-svg-icon path=${mdiShield}></ha-svg-icon>
|
||||||
|
</ha-label-badge>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
${this.addon.auth_api
|
${this.addon.auth_api
|
||||||
@@ -331,10 +356,11 @@ class HassioAddonInfo extends LitElement {
|
|||||||
<ha-label-badge
|
<ha-label-badge
|
||||||
@click=${this._showMoreInfo}
|
@click=${this._showMoreInfo}
|
||||||
id="auth_api"
|
id="auth_api"
|
||||||
icon="hassio:key"
|
|
||||||
label="auth"
|
label="auth"
|
||||||
description=""
|
description=""
|
||||||
></ha-label-badge>
|
>
|
||||||
|
<ha-svg-icon path=${mdiKey}></ha-svg-icon>
|
||||||
|
</ha-label-badge>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
${this.addon.ingress
|
${this.addon.ingress
|
||||||
@@ -342,10 +368,13 @@ class HassioAddonInfo extends LitElement {
|
|||||||
<ha-label-badge
|
<ha-label-badge
|
||||||
@click=${this._showMoreInfo}
|
@click=${this._showMoreInfo}
|
||||||
id="ingress"
|
id="ingress"
|
||||||
icon="hassio:cursor-default-click-outline"
|
|
||||||
label="ingress"
|
label="ingress"
|
||||||
description=""
|
description=""
|
||||||
></ha-label-badge>
|
>
|
||||||
|
<ha-svg-icon
|
||||||
|
path=${mdiCursorDefaultClickOutline}
|
||||||
|
></ha-svg-icon>
|
||||||
|
</ha-label-badge>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
@@ -399,7 +428,7 @@ class HassioAddonInfo extends LitElement {
|
|||||||
<div>
|
<div>
|
||||||
Protection mode
|
Protection mode
|
||||||
<span>
|
<span>
|
||||||
<ha-icon icon="hassio:information"></ha-icon>
|
<ha-svg-icon path=${mdiInformation}></ha-svg-icon>
|
||||||
<paper-tooltip>
|
<paper-tooltip>
|
||||||
Grant the add-on elevated system access.
|
Grant the add-on elevated system access.
|
||||||
</paper-tooltip>
|
</paper-tooltip>
|
||||||
@@ -502,17 +531,17 @@ class HassioAddonInfo extends LitElement {
|
|||||||
</ha-progress-button>
|
</ha-progress-button>
|
||||||
`}
|
`}
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
|
|
||||||
${this.addon.long_description
|
${this.addon.long_description
|
||||||
? html`
|
? html`
|
||||||
<paper-card>
|
<ha-card>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<ha-markdown
|
<ha-markdown
|
||||||
.content=${this.addon.long_description}
|
.content=${this.addon.long_description}
|
||||||
></ha-markdown>
|
></ha-markdown>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
`;
|
`;
|
||||||
@@ -526,16 +555,21 @@ class HassioAddonInfo extends LitElement {
|
|||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
paper-card {
|
ha-card {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
paper-card.warning {
|
ha-card.warning {
|
||||||
background-color: var(--google-red-500);
|
background-color: var(--google-red-500);
|
||||||
color: white;
|
color: white;
|
||||||
--paper-card-header-color: white;
|
|
||||||
}
|
}
|
||||||
paper-card.warning mwc-button {
|
ha-card.warning .card-header {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
ha-card.warning .card-content {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
ha-card.warning mwc-button {
|
||||||
--mdc-theme-primary: white !important;
|
--mdc-theme-primary: white !important;
|
||||||
}
|
}
|
||||||
.warning {
|
.warning {
|
||||||
@@ -548,7 +582,7 @@ class HassioAddonInfo extends LitElement {
|
|||||||
.addon-header {
|
.addon-header {
|
||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
color: var(--paper-card-header-color, --primary-text-color);
|
color: var(--ha-card-header-color, --primary-text-color);
|
||||||
}
|
}
|
||||||
.addon-version {
|
.addon-version {
|
||||||
float: right;
|
float: right;
|
||||||
@@ -575,7 +609,7 @@ class HassioAddonInfo extends LitElement {
|
|||||||
width: 180px;
|
width: 180px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
.state ha-icon {
|
.state ha-svg-icon {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
color: var(--secondary-text-color);
|
color: var(--secondary-text-color);
|
||||||
@@ -583,10 +617,10 @@ class HassioAddonInfo extends LitElement {
|
|||||||
ha-switch {
|
ha-switch {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
ha-icon.running {
|
ha-svg-icon.running {
|
||||||
color: var(--paper-green-400);
|
color: var(--paper-green-400);
|
||||||
}
|
}
|
||||||
ha-icon.stopped {
|
ha-svg-icon.stopped {
|
||||||
color: var(--google-red-300);
|
color: var(--google-red-300);
|
||||||
}
|
}
|
||||||
ha-call-api-button {
|
ha-call-api-button {
|
||||||
@@ -596,14 +630,10 @@ class HassioAddonInfo extends LitElement {
|
|||||||
.right {
|
.right {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
ha-markdown img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
protection-enable mwc-button {
|
protection-enable mwc-button {
|
||||||
--mdc-theme-primary: white;
|
--mdc-theme-primary: white;
|
||||||
}
|
}
|
||||||
.description a,
|
.description a {
|
||||||
ha-markdown a {
|
|
||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
}
|
}
|
||||||
.red {
|
.red {
|
||||||
@@ -641,6 +671,9 @@ class HassioAddonInfo extends LitElement {
|
|||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
ha-markdown {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -664,7 +697,7 @@ class HassioAddonInfo extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _showMoreInfo(ev): void {
|
private _showMoreInfo(ev): void {
|
||||||
const id = ev.target.getAttribute("id");
|
const id = ev.currentTarget.id;
|
||||||
showHassioMarkdownDialog(this, {
|
showHassioMarkdownDialog(this, {
|
||||||
title: PERMIS_DESC[id].title,
|
title: PERMIS_DESC[id].title,
|
||||||
content: PERMIS_DESC[id].description,
|
content: PERMIS_DESC[id].description,
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import "@polymer/paper-spinner/paper-spinner-lite";
|
import "@polymer/paper-spinner/paper-spinner-lite";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -9,12 +8,10 @@ import {
|
|||||||
property,
|
property,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
|
||||||
import { HomeAssistant } from "../../../../src/types";
|
|
||||||
import { HassioAddonDetails } from "../../../../src/data/hassio/addon";
|
import { HassioAddonDetails } from "../../../../src/data/hassio/addon";
|
||||||
import { hassioStyle } from "../../resources/hassio-style";
|
|
||||||
import { haStyle } from "../../../../src/resources/styles";
|
import { haStyle } from "../../../../src/resources/styles";
|
||||||
|
import { HomeAssistant } from "../../../../src/types";
|
||||||
|
import { hassioStyle } from "../../resources/hassio-style";
|
||||||
import "./hassio-addon-logs";
|
import "./hassio-addon-logs";
|
||||||
|
|
||||||
@customElement("hassio-addon-log-tab")
|
@customElement("hassio-addon-log-tab")
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import "@polymer/paper-card/paper-card";
|
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -9,6 +8,7 @@ import {
|
|||||||
property,
|
property,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
import "../../../../src/components/ha-card";
|
||||||
import {
|
import {
|
||||||
fetchHassioAddonLogs,
|
fetchHassioAddonLogs,
|
||||||
HassioAddonDetails,
|
HassioAddonDetails,
|
||||||
@@ -36,7 +36,7 @@ class HassioAddonLogs extends LitElement {
|
|||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<h1>${this.addon.name}</h1>
|
<h1>${this.addon.name}</h1>
|
||||||
<paper-card>
|
<ha-card>
|
||||||
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${this._content
|
${this._content
|
||||||
@@ -48,7 +48,7 @@ class HassioAddonLogs extends LitElement {
|
|||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<mwc-button @click=${this._refresh}>Refresh</mwc-button>
|
<mwc-button @click=${this._refresh}>Refresh</mwc-button>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ class HassioAddonLogs extends LitElement {
|
|||||||
hassioStyle,
|
hassioStyle,
|
||||||
css`
|
css`
|
||||||
:host,
|
:host,
|
||||||
paper-card {
|
ha-card {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.errors {
|
.errors {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import { mdiHelpCircle } from "@mdi/js";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -8,7 +9,7 @@ import {
|
|||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import "../../../src/components/ha-relative-time";
|
import "../../../src/components/ha-relative-time";
|
||||||
import "../../../src/components/ha-icon";
|
import "../../../src/components/ha-svg-icon";
|
||||||
import { HomeAssistant } from "../../../src/types";
|
import { HomeAssistant } from "../../../src/types";
|
||||||
|
|
||||||
@customElement("hassio-card-content")
|
@customElement("hassio-card-content")
|
||||||
@@ -31,7 +32,7 @@ class HassioCardContent extends LitElement {
|
|||||||
|
|
||||||
@property() public iconClass?: string;
|
@property() public iconClass?: string;
|
||||||
|
|
||||||
@property() public icon = "hass:help-circle";
|
@property() public icon = mdiHelpCircle;
|
||||||
|
|
||||||
@property() public iconImage?: string;
|
@property() public iconImage?: string;
|
||||||
|
|
||||||
@@ -48,11 +49,11 @@ class HassioCardContent extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: html`
|
: html`
|
||||||
<ha-icon
|
<ha-svg-icon
|
||||||
class=${this.iconClass}
|
class=${this.iconClass}
|
||||||
.icon=${this.icon}
|
.path=${this.icon}
|
||||||
.title=${this.iconTitle}
|
.title=${this.iconTitle}
|
||||||
></ha-icon>
|
></ha-svg-icon>
|
||||||
`}
|
`}
|
||||||
<div>
|
<div>
|
||||||
<div class="title">
|
<div class="title">
|
||||||
@@ -78,25 +79,25 @@ class HassioCardContent extends LitElement {
|
|||||||
|
|
||||||
static get styles(): CSSResult {
|
static get styles(): CSSResult {
|
||||||
return css`
|
return css`
|
||||||
ha-icon {
|
ha-svg-icon {
|
||||||
margin-right: 24px;
|
margin-right: 24px;
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
float: left;
|
float: left;
|
||||||
color: var(--secondary-text-color);
|
color: var(--secondary-text-color);
|
||||||
}
|
}
|
||||||
ha-icon.update {
|
ha-svg-icon.update {
|
||||||
color: var(--paper-orange-400);
|
color: var(--paper-orange-400);
|
||||||
}
|
}
|
||||||
ha-icon.running,
|
ha-svg-icon.running,
|
||||||
ha-icon.installed {
|
ha-svg-icon.installed {
|
||||||
color: var(--paper-green-400);
|
color: var(--paper-green-400);
|
||||||
}
|
}
|
||||||
ha-icon.hassupdate,
|
ha-svg-icon.hassupdate,
|
||||||
ha-icon.snapshot {
|
ha-svg-icon.snapshot {
|
||||||
color: var(--paper-item-icon-color);
|
color: var(--paper-item-icon-color);
|
||||||
}
|
}
|
||||||
ha-icon.not_available {
|
ha-svg-icon.not_available {
|
||||||
color: var(--google-red-500);
|
color: var(--google-red-500);
|
||||||
}
|
}
|
||||||
.title {
|
.title {
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
import * as Fuse from "fuse.js";
|
import Fuse from "fuse.js";
|
||||||
import { HassioAddonInfo } from "../../../src/data/hassio/addon";
|
import { HassioAddonInfo } from "../../../src/data/hassio/addon";
|
||||||
|
|
||||||
export function filterAndSort(addons: HassioAddonInfo[], filter: string) {
|
export function filterAndSort(addons: HassioAddonInfo[], filter: string) {
|
||||||
const options: Fuse.FuseOptions<HassioAddonInfo> = {
|
const options: Fuse.IFuseOptions<HassioAddonInfo> = {
|
||||||
keys: ["name", "description", "slug"],
|
keys: ["name", "description", "slug"],
|
||||||
caseSensitive: false,
|
isCaseSensitive: false,
|
||||||
minMatchCharLength: 2,
|
minMatchCharLength: 2,
|
||||||
threshold: 0.2,
|
threshold: 0.2,
|
||||||
};
|
};
|
||||||
const fuse = new Fuse(addons, options);
|
const fuse = new Fuse(addons, options);
|
||||||
return fuse.search(filter);
|
return fuse.search(filter).map((result) => result.item);
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import "@polymer/paper-card/paper-card";
|
import { mdiArrowUpBoldCircle, mdiPuzzle } from "@mdi/js";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { atLeastVersion } from "../../../src/common/config/version";
|
import { atLeastVersion } from "../../../src/common/config/version";
|
||||||
import { navigate } from "../../../src/common/navigate";
|
import { navigate } from "../../../src/common/navigate";
|
||||||
|
import "../../../src/components/ha-card";
|
||||||
import { HassioAddonInfo } from "../../../src/data/hassio/addon";
|
import { HassioAddonInfo } from "../../../src/data/hassio/addon";
|
||||||
import { haStyle } from "../../../src/resources/styles";
|
import { haStyle } from "../../../src/resources/styles";
|
||||||
import { HomeAssistant } from "../../../src/types";
|
import { HomeAssistant } from "../../../src/types";
|
||||||
@@ -29,19 +30,19 @@ class HassioAddons extends LitElement {
|
|||||||
<div class="card-group">
|
<div class="card-group">
|
||||||
${!this.addons
|
${!this.addons
|
||||||
? html`
|
? html`
|
||||||
<paper-card>
|
<ha-card>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
You don't have any add-ons installed yet. Head over to
|
You don't have any add-ons installed yet. Head over to
|
||||||
<a href="#" @click=${this._openStore}>the add-on store</a>
|
<a href="#" @click=${this._openStore}>the add-on store</a>
|
||||||
to get started!
|
to get started!
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`
|
`
|
||||||
: this.addons
|
: this.addons
|
||||||
.sort((a, b) => (a.name > b.name ? 1 : -1))
|
.sort((a, b) => (a.name > b.name ? 1 : -1))
|
||||||
.map(
|
.map(
|
||||||
(addon) => html`
|
(addon) => html`
|
||||||
<paper-card .addon=${addon} @click=${this._addonTapped}>
|
<ha-card .addon=${addon} @click=${this._addonTapped}>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<hassio-card-content
|
<hassio-card-content
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -51,8 +52,8 @@ class HassioAddons extends LitElement {
|
|||||||
.showTopbar=${addon.installed !== addon.version}
|
.showTopbar=${addon.installed !== addon.version}
|
||||||
topbarClass="update"
|
topbarClass="update"
|
||||||
.icon=${addon.installed !== addon.version
|
.icon=${addon.installed !== addon.version
|
||||||
? "hassio:arrow-up-bold-circle"
|
? mdiArrowUpBoldCircle
|
||||||
: "hassio:puzzle"}
|
: mdiPuzzle}
|
||||||
.iconTitle=${addon.state !== "started"
|
.iconTitle=${addon.state !== "started"
|
||||||
? "Add-on is stopped"
|
? "Add-on is stopped"
|
||||||
: addon.installed !== addon.version
|
: addon.installed !== addon.version
|
||||||
@@ -75,7 +76,7 @@ class HassioAddons extends LitElement {
|
|||||||
: undefined}
|
: undefined}
|
||||||
></hassio-card-content>
|
></hassio-card-content>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -88,7 +89,7 @@ class HassioAddons extends LitElement {
|
|||||||
haStyle,
|
haStyle,
|
||||||
hassioStyle,
|
hassioStyle,
|
||||||
css`
|
css`
|
||||||
paper-card {
|
ha-card {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
|
@@ -12,14 +12,13 @@ import {
|
|||||||
HassioHomeAssistantInfo,
|
HassioHomeAssistantInfo,
|
||||||
HassioSupervisorInfo,
|
HassioSupervisorInfo,
|
||||||
} from "../../../src/data/hassio/supervisor";
|
} from "../../../src/data/hassio/supervisor";
|
||||||
|
import "../../../src/layouts/hass-tabs-subpage";
|
||||||
import { haStyle } from "../../../src/resources/styles";
|
import { haStyle } from "../../../src/resources/styles";
|
||||||
import { HomeAssistant, Route } from "../../../src/types";
|
import { HomeAssistant, Route } from "../../../src/types";
|
||||||
import "../../../src/layouts/hass-tabs-subpage";
|
import { supervisorTabs } from "../hassio-panel";
|
||||||
import "./hassio-addons";
|
import "./hassio-addons";
|
||||||
import "./hassio-update";
|
import "./hassio-update";
|
||||||
|
|
||||||
import { supervisorTabs } from "../hassio-panel";
|
|
||||||
|
|
||||||
@customElement("hassio-dashboard")
|
@customElement("hassio-dashboard")
|
||||||
class HassioDashboard extends LitElement {
|
class HassioDashboard extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import "@polymer/paper-card/paper-card";
|
import { mdiHomeAssistant } from "@mdi/js";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -10,15 +10,15 @@ import {
|
|||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import "../../../src/components/buttons/ha-call-api-button";
|
import "../../../src/components/buttons/ha-call-api-button";
|
||||||
|
import "../../../src/components/ha-card";
|
||||||
|
import "../../../src/components/ha-svg-icon";
|
||||||
import { HassioHassOSInfo } from "../../../src/data/hassio/host";
|
import { HassioHassOSInfo } from "../../../src/data/hassio/host";
|
||||||
import {
|
import {
|
||||||
HassioHomeAssistantInfo,
|
HassioHomeAssistantInfo,
|
||||||
HassioSupervisorInfo,
|
HassioSupervisorInfo,
|
||||||
} from "../../../src/data/hassio/supervisor";
|
} from "../../../src/data/hassio/supervisor";
|
||||||
import { haStyle } from "../../../src/resources/styles";
|
import { haStyle } from "../../../src/resources/styles";
|
||||||
import "../../../src/components/ha-icon";
|
|
||||||
import { HomeAssistant } from "../../../src/types";
|
import { HomeAssistant } from "../../../src/types";
|
||||||
import "../components/hassio-card-content";
|
|
||||||
import { hassioStyle } from "../resources/hassio-style";
|
import { hassioStyle } from "../resources/hassio-style";
|
||||||
|
|
||||||
@customElement("hassio-update")
|
@customElement("hassio-update")
|
||||||
@@ -72,7 +72,7 @@ export class HassioUpdate extends LitElement {
|
|||||||
`https://${
|
`https://${
|
||||||
this.hassInfo.version_latest.includes("b") ? "rc" : "www"
|
this.hassInfo.version_latest.includes("b") ? "rc" : "www"
|
||||||
}.home-assistant.io/latest-release-notes/`,
|
}.home-assistant.io/latest-release-notes/`,
|
||||||
"hassio:home-assistant"
|
mdiHomeAssistant
|
||||||
)}
|
)}
|
||||||
${this._renderUpdateCard(
|
${this._renderUpdateCard(
|
||||||
"Supervisor",
|
"Supervisor",
|
||||||
@@ -107,12 +107,12 @@ export class HassioUpdate extends LitElement {
|
|||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<paper-card>
|
<ha-card>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${icon
|
${icon
|
||||||
? html`
|
? html`
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<ha-icon .icon=${icon}></ha-icon>
|
<ha-svg-icon .path=${icon}></ha-svg-icon>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
@@ -133,7 +133,7 @@ export class HassioUpdate extends LitElement {
|
|||||||
Update
|
Update
|
||||||
</ha-call-api-button>
|
</ha-call-api-button>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,7 +1,3 @@
|
|||||||
import "@polymer/app-layout/app-toolbar/app-toolbar";
|
|
||||||
import { PaperDialogElement } from "@polymer/paper-dialog";
|
|
||||||
import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable";
|
|
||||||
import "../../../../src/components/ha-icon-button";
|
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -9,46 +5,50 @@ import {
|
|||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
property,
|
property,
|
||||||
query,
|
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import "../../../../src/components/dialog/ha-paper-dialog";
|
import { createCloseHeading } from "../../../../src/components/ha-dialog";
|
||||||
import "../../../../src/components/ha-markdown";
|
import "../../../../src/components/ha-markdown";
|
||||||
import { haStyleDialog } from "../../../../src/resources/styles";
|
import { haStyleDialog } from "../../../../src/resources/styles";
|
||||||
|
import { HomeAssistant } from "../../../../src/types";
|
||||||
import { hassioStyle } from "../../resources/hassio-style";
|
import { hassioStyle } from "../../resources/hassio-style";
|
||||||
import { HassioMarkdownDialogParams } from "./show-dialog-hassio-markdown";
|
import { HassioMarkdownDialogParams } from "./show-dialog-hassio-markdown";
|
||||||
|
|
||||||
@customElement("dialog-hassio-markdown")
|
@customElement("dialog-hassio-markdown")
|
||||||
class HassioMarkdownDialog extends LitElement {
|
class HassioMarkdownDialog extends LitElement {
|
||||||
|
@property() public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property() public title!: string;
|
@property() public title!: string;
|
||||||
|
|
||||||
@property() public content!: string;
|
@property() public content!: string;
|
||||||
|
|
||||||
@query("#dialog") private _dialog!: PaperDialogElement;
|
@property() private _opened = false;
|
||||||
|
|
||||||
public showDialog(params: HassioMarkdownDialogParams) {
|
public showDialog(params: HassioMarkdownDialogParams) {
|
||||||
this.title = params.title;
|
this.title = params.title;
|
||||||
this.content = params.content;
|
this.content = params.content;
|
||||||
this._dialog.open();
|
this._opened = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
|
if (!this._opened) {
|
||||||
|
return html``;
|
||||||
|
}
|
||||||
return html`
|
return html`
|
||||||
<ha-paper-dialog id="dialog" with-backdrop="">
|
<ha-dialog
|
||||||
<app-toolbar>
|
open
|
||||||
<ha-icon-button
|
@closing=${this._closeDialog}
|
||||||
icon="hassio:close"
|
.heading=${createCloseHeading(this.hass, this.title)}
|
||||||
dialog-dismiss=""
|
>
|
||||||
></ha-icon-button>
|
<ha-markdown .content=${this.content || ""}></ha-markdown>
|
||||||
<div main-title="">${this.title}</div>
|
</ha-dialog>
|
||||||
</app-toolbar>
|
|
||||||
<paper-dialog-scrollable>
|
|
||||||
<ha-markdown .content=${this.content || ""}></ha-markdown>
|
|
||||||
</paper-dialog-scrollable>
|
|
||||||
</ha-paper-dialog>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _closeDialog(): void {
|
||||||
|
this._opened = false;
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResult[] {
|
static get styles(): CSSResult[] {
|
||||||
return [
|
return [
|
||||||
haStyleDialog,
|
haStyleDialog,
|
||||||
@@ -90,6 +90,9 @@ class HassioMarkdownDialog extends LitElement {
|
|||||||
color: var(--text-primary-color);
|
color: var(--text-primary-color);
|
||||||
background-color: var(--primary-color);
|
background-color: var(--primary-color);
|
||||||
}
|
}
|
||||||
|
ha-markdown {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
import "@material/mwc-button/mwc-button";
|
import "@material/mwc-button/mwc-button";
|
||||||
|
import "@material/mwc-icon-button/mwc-icon-button";
|
||||||
|
import { mdiDelete } from "@mdi/js";
|
||||||
import "@polymer/paper-input/paper-input";
|
import "@polymer/paper-input/paper-input";
|
||||||
import "@polymer/paper-spinner/paper-spinner";
|
|
||||||
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
|
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||||
import "@polymer/paper-item/paper-item";
|
import "@polymer/paper-item/paper-item";
|
||||||
import "@polymer/paper-item/paper-item-body";
|
import "@polymer/paper-item/paper-item-body";
|
||||||
|
import "@polymer/paper-spinner/paper-spinner";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -16,16 +18,14 @@ import {
|
|||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import "../../../../src/components/ha-dialog";
|
import "../../../../src/components/ha-dialog";
|
||||||
import "../../../../src/components/ha-icon-button";
|
import "../../../../src/components/ha-svg-icon";
|
||||||
|
import {
|
||||||
|
fetchHassioAddonsInfo,
|
||||||
|
HassioAddonRepository,
|
||||||
|
} from "../../../../src/data/hassio/addon";
|
||||||
|
import { setSupervisorOption } from "../../../../src/data/hassio/supervisor";
|
||||||
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
||||||
import type { HomeAssistant } from "../../../../src/types";
|
import type { HomeAssistant } from "../../../../src/types";
|
||||||
import {
|
|
||||||
HassioAddonRepository,
|
|
||||||
fetchHassioAddonsInfo,
|
|
||||||
} from "../../../../src/data/hassio/addon";
|
|
||||||
|
|
||||||
import { setSupervisorOption } from "../../../../src/data/hassio/supervisor";
|
|
||||||
import { HassioRepositoryDialogParams } from "./show-dialog-repositories";
|
import { HassioRepositoryDialogParams } from "./show-dialog-repositories";
|
||||||
|
|
||||||
@customElement("dialog-hassio-repositories")
|
@customElement("dialog-hassio-repositories")
|
||||||
@@ -84,12 +84,13 @@ class HassioRepositoriesDialog extends LitElement {
|
|||||||
<div secondary>${repo.maintainer}</div>
|
<div secondary>${repo.maintainer}</div>
|
||||||
<div secondary>${repo.url}</div>
|
<div secondary>${repo.url}</div>
|
||||||
</paper-item-body>
|
</paper-item-body>
|
||||||
<ha-icon-button
|
<mwc-icon-button
|
||||||
.slug=${repo.slug}
|
.slug=${repo.slug}
|
||||||
title="Remove"
|
title="Remove"
|
||||||
@click=${this._removeRepository}
|
@click=${this._removeRepository}
|
||||||
icon="hassio:delete"
|
>
|
||||||
></ha-icon-button>
|
<ha-svg-icon path=${mdiDelete}></ha-svg-icon>
|
||||||
|
</mwc-icon-button>
|
||||||
</paper-item>
|
</paper-item>
|
||||||
`;
|
`;
|
||||||
})
|
})
|
||||||
@@ -194,7 +195,7 @@ class HassioRepositoriesDialog extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _removeRepository(ev: Event) {
|
private async _removeRepository(ev: Event) {
|
||||||
const slug = (ev.target as any).slug;
|
const slug = (ev.currentTarget as any).slug;
|
||||||
const repositories = this._filteredRepositories(this._repos);
|
const repositories = this._filteredRepositories(this._repos);
|
||||||
const repository = repositories.find((repo) => {
|
const repository = repositories.find((repo) => {
|
||||||
return repo.slug === slug;
|
return repo.slug === slug;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||||
import "./dialog-hassio-repositories";
|
|
||||||
import { HassioAddonRepository } from "../../../../src/data/hassio/addon";
|
import { HassioAddonRepository } from "../../../../src/data/hassio/addon";
|
||||||
|
import "./dialog-hassio-repositories";
|
||||||
|
|
||||||
export interface HassioRepositoryDialogParams {
|
export interface HassioRepositoryDialogParams {
|
||||||
repos: HassioAddonRepository[];
|
repos: HassioAddonRepository[];
|
||||||
|
@@ -1,10 +1,6 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import "@polymer/app-layout/app-toolbar/app-toolbar";
|
import { mdiDelete, mdiDownload, mdiHistory } from "@mdi/js";
|
||||||
import { PaperCheckboxElement } from "@polymer/paper-checkbox/paper-checkbox";
|
import { PaperCheckboxElement } from "@polymer/paper-checkbox/paper-checkbox";
|
||||||
import { PaperDialogElement } from "@polymer/paper-dialog";
|
|
||||||
import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable";
|
|
||||||
import "../../../../src/components/ha-icon-button";
|
|
||||||
import "../../../../src/components/ha-icon";
|
|
||||||
import "@polymer/paper-input/paper-input";
|
import "@polymer/paper-input/paper-input";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
@@ -13,10 +9,10 @@ import {
|
|||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
property,
|
property,
|
||||||
query,
|
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import "../../../../src/components/dialog/ha-paper-dialog";
|
import { createCloseHeading } from "../../../../src/components/ha-dialog";
|
||||||
|
import "../../../../src/components/ha-svg-icon";
|
||||||
import { getSignedPath } from "../../../../src/data/auth";
|
import { getSignedPath } from "../../../../src/data/auth";
|
||||||
import {
|
import {
|
||||||
fetchHassioSnapshotInfo,
|
fetchHassioSnapshotInfo,
|
||||||
@@ -76,7 +72,7 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
|
|
||||||
@property() private _error?: string;
|
@property() private _error?: string;
|
||||||
|
|
||||||
@property() private snapshot?: HassioSnapshotDetail;
|
@property() private _snapshot?: HassioSnapshotDetail;
|
||||||
|
|
||||||
@property() private _folders!: FolderItem[];
|
@property() private _folders!: FolderItem[];
|
||||||
|
|
||||||
@@ -88,49 +84,35 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
|
|
||||||
@property() private _restoreHass: boolean | null | undefined = true;
|
@property() private _restoreHass: boolean | null | undefined = true;
|
||||||
|
|
||||||
@query("#dialog") private _dialog!: PaperDialogElement;
|
|
||||||
|
|
||||||
public async showDialog(params: HassioSnapshotDialogParams) {
|
public async showDialog(params: HassioSnapshotDialogParams) {
|
||||||
this.snapshot = await fetchHassioSnapshotInfo(this.hass, params.slug);
|
this._snapshot = await fetchHassioSnapshotInfo(this.hass, params.slug);
|
||||||
this._folders = _computeFolders(
|
this._folders = _computeFolders(
|
||||||
this.snapshot.folders
|
this._snapshot.folders
|
||||||
).sort((a: FolderItem, b: FolderItem) => (a.name > b.name ? 1 : -1));
|
).sort((a: FolderItem, b: FolderItem) => (a.name > b.name ? 1 : -1));
|
||||||
this._addons = _computeAddons(
|
this._addons = _computeAddons(
|
||||||
this.snapshot.addons
|
this._snapshot.addons
|
||||||
).sort((a: AddonItem, b: AddonItem) => (a.name > b.name ? 1 : -1));
|
).sort((a: AddonItem, b: AddonItem) => (a.name > b.name ? 1 : -1));
|
||||||
|
|
||||||
this._dialogParams = params;
|
this._dialogParams = params;
|
||||||
|
|
||||||
try {
|
|
||||||
this._dialog.open();
|
|
||||||
} catch {
|
|
||||||
await this.showDialog(params);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
if (!this.snapshot) {
|
if (!this._dialogParams || !this._snapshot) {
|
||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<ha-paper-dialog
|
<ha-dialog
|
||||||
id="dialog"
|
open
|
||||||
with-backdrop=""
|
stacked
|
||||||
.on-iron-overlay-closed=${this._dialogClosed}
|
@closing=${this._closeDialog}
|
||||||
|
.heading=${createCloseHeading(this.hass, this._computeName)}
|
||||||
>
|
>
|
||||||
<app-toolbar>
|
|
||||||
<ha-icon-button
|
|
||||||
icon="hassio:close"
|
|
||||||
dialog-dismiss=""
|
|
||||||
></ha-icon-button>
|
|
||||||
<div main-title="">${this._computeName}</div>
|
|
||||||
</app-toolbar>
|
|
||||||
<div class="details">
|
<div class="details">
|
||||||
${this.snapshot.type === "full"
|
${this._snapshot.type === "full"
|
||||||
? "Full snapshot"
|
? "Full snapshot"
|
||||||
: "Partial snapshot"}
|
: "Partial snapshot"}
|
||||||
(${this._computeSize})<br />
|
(${this._computeSize})<br />
|
||||||
${this._formatDatetime(this.snapshot.date)}
|
${this._formatDatetime(this._snapshot.date)}
|
||||||
</div>
|
</div>
|
||||||
<div>Home Assistant:</div>
|
<div>Home Assistant:</div>
|
||||||
<paper-checkbox
|
<paper-checkbox
|
||||||
@@ -139,7 +121,7 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
this._restoreHass = (ev.target as PaperCheckboxElement).checked;
|
this._restoreHass = (ev.target as PaperCheckboxElement).checked;
|
||||||
}}"
|
}}"
|
||||||
>
|
>
|
||||||
Home Assistant ${this.snapshot.homeassistant}
|
Home Assistant ${this._snapshot.homeassistant}
|
||||||
</paper-checkbox>
|
</paper-checkbox>
|
||||||
${this._folders.length
|
${this._folders.length
|
||||||
? html`
|
? html`
|
||||||
@@ -183,7 +165,7 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
</paper-dialog-scrollable>
|
</paper-dialog-scrollable>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
${this.snapshot.protected
|
${this._snapshot.protected
|
||||||
? html`
|
? html`
|
||||||
<paper-input
|
<paper-input
|
||||||
autofocus=""
|
autofocus=""
|
||||||
@@ -197,37 +179,35 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
${this._error ? html` <p class="error">Error: ${this._error}</p> ` : ""}
|
${this._error ? html` <p class="error">Error: ${this._error}</p> ` : ""}
|
||||||
|
|
||||||
<div>Actions:</div>
|
<div>Actions:</div>
|
||||||
<ul class="buttons">
|
|
||||||
<li>
|
<mwc-button @click=${this._downloadClicked} slot="primaryAction">
|
||||||
<mwc-button @click=${this._downloadClicked}>
|
<ha-svg-icon path=${mdiDownload} class="icon"></ha-svg-icon>
|
||||||
<ha-icon icon="hassio:download" class="icon"></ha-icon>
|
Download Snapshot
|
||||||
Download Snapshot
|
</mwc-button>
|
||||||
</mwc-button>
|
|
||||||
</li>
|
<mwc-button
|
||||||
<li>
|
@click=${this._partialRestoreClicked}
|
||||||
<mwc-button @click=${this._partialRestoreClicked}>
|
slot="secondaryAction"
|
||||||
<ha-icon icon="hassio:history" class="icon"> </ha-icon>
|
>
|
||||||
Restore Selected
|
<ha-svg-icon path=${mdiHistory} class="icon"></ha-svg-icon>
|
||||||
</mwc-button>
|
Restore Selected
|
||||||
</li>
|
</mwc-button>
|
||||||
${this.snapshot.type === "full"
|
${this._snapshot.type === "full"
|
||||||
? html`
|
? html`
|
||||||
<li>
|
<mwc-button
|
||||||
<mwc-button @click=${this._fullRestoreClicked}>
|
@click=${this._fullRestoreClicked}
|
||||||
<ha-icon icon="hassio:history" class="icon"> </ha-icon>
|
slot="secondaryAction"
|
||||||
Wipe & restore
|
>
|
||||||
</mwc-button>
|
<ha-svg-icon path=${mdiHistory} class="icon"></ha-svg-icon>
|
||||||
</li>
|
Wipe & restore
|
||||||
`
|
</mwc-button>
|
||||||
: ""}
|
`
|
||||||
<li>
|
: ""}
|
||||||
<mwc-button @click=${this._deleteClicked}>
|
<mwc-button @click=${this._deleteClicked} slot="secondaryAction">
|
||||||
<ha-icon icon="hassio:delete" class="icon warning"> </ha-icon>
|
<ha-svg-icon path=${mdiDelete} class="icon warning"></ha-svg-icon>
|
||||||
<span class="warning">Delete Snapshot</span>
|
<span class="warning">Delete Snapshot</span>
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
</li>
|
</ha-dialog>
|
||||||
</ul>
|
|
||||||
</ha-paper-dialog>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,37 +215,10 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
return [
|
return [
|
||||||
haStyleDialog,
|
haStyleDialog,
|
||||||
css`
|
css`
|
||||||
ha-paper-dialog {
|
|
||||||
min-width: 350px;
|
|
||||||
font-size: 14px;
|
|
||||||
border-radius: 2px;
|
|
||||||
}
|
|
||||||
app-toolbar {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0 16px;
|
|
||||||
color: var(--primary-text-color);
|
|
||||||
background-color: var(--secondary-background-color);
|
|
||||||
}
|
|
||||||
app-toolbar [main-title] {
|
|
||||||
margin-left: 16px;
|
|
||||||
}
|
|
||||||
ha-paper-dialog-scrollable {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
paper-checkbox {
|
paper-checkbox {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 4px;
|
margin: 4px;
|
||||||
}
|
}
|
||||||
@media all and (max-width: 450px), all and (max-height: 500px) {
|
|
||||||
ha-paper-dialog {
|
|
||||||
max-height: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
app-toolbar {
|
|
||||||
color: var(--text-primary-color);
|
|
||||||
background-color: var(--primary-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.details {
|
.details {
|
||||||
color: var(--secondary-text-color);
|
color: var(--secondary-text-color);
|
||||||
}
|
}
|
||||||
@@ -336,7 +289,7 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
folders,
|
folders,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.snapshot!.protected) {
|
if (this._snapshot!.protected) {
|
||||||
data.password = this._snapshotPassword;
|
data.password = this._snapshotPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,13 +297,13 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
.callApi(
|
.callApi(
|
||||||
"POST",
|
"POST",
|
||||||
|
|
||||||
`hassio/snapshots/${this.snapshot!.slug}/restore/partial`,
|
`hassio/snapshots/${this._snapshot!.slug}/restore/partial`,
|
||||||
data
|
data
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
() => {
|
() => {
|
||||||
alert("Snapshot restored!");
|
alert("Snapshot restored!");
|
||||||
this._dialog.close();
|
this._closeDialog();
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
this._error = error.body.message;
|
this._error = error.body.message;
|
||||||
@@ -363,20 +316,20 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = this.snapshot!.protected
|
const data = this._snapshot!.protected
|
||||||
? { password: this._snapshotPassword }
|
? { password: this._snapshotPassword }
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
this.hass
|
this.hass
|
||||||
.callApi(
|
.callApi(
|
||||||
"POST",
|
"POST",
|
||||||
`hassio/snapshots/${this.snapshot!.slug}/restore/full`,
|
`hassio/snapshots/${this._snapshot!.slug}/restore/full`,
|
||||||
data
|
data
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
() => {
|
() => {
|
||||||
alert("Snapshot restored!");
|
alert("Snapshot restored!");
|
||||||
this._dialog.close();
|
this._closeDialog();
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
this._error = error.body.message;
|
this._error = error.body.message;
|
||||||
@@ -391,11 +344,11 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
|
|
||||||
this.hass
|
this.hass
|
||||||
|
|
||||||
.callApi("POST", `hassio/snapshots/${this.snapshot!.slug}/remove`)
|
.callApi("POST", `hassio/snapshots/${this._snapshot!.slug}/remove`)
|
||||||
.then(
|
.then(
|
||||||
() => {
|
() => {
|
||||||
this._dialog.close();
|
|
||||||
this._dialogParams!.onDelete();
|
this._dialogParams!.onDelete();
|
||||||
|
this._closeDialog();
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
this._error = error.body.message;
|
this._error = error.body.message;
|
||||||
@@ -408,7 +361,7 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
try {
|
try {
|
||||||
signedPath = await getSignedPath(
|
signedPath = await getSignedPath(
|
||||||
this.hass,
|
this.hass,
|
||||||
`/api/hassio/snapshots/${this.snapshot!.slug}/download`
|
`/api/hassio/snapshots/${this._snapshot!.slug}/download`
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert(`Error: ${err.message}`);
|
alert(`Error: ${err.message}`);
|
||||||
@@ -419,19 +372,19 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
a.href = signedPath.path;
|
a.href = signedPath.path;
|
||||||
a.download = `Hass_io_${name}.tar`;
|
a.download = `Hass_io_${name}.tar`;
|
||||||
this._dialog.appendChild(a);
|
this.shadowRoot!.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
this._dialog.removeChild(a);
|
this.shadowRoot!.removeChild(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
private get _computeName() {
|
private get _computeName() {
|
||||||
return this.snapshot
|
return this._snapshot
|
||||||
? this.snapshot.name || this.snapshot.slug
|
? this._snapshot.name || this._snapshot.slug
|
||||||
: "Unnamed snapshot";
|
: "Unnamed snapshot";
|
||||||
}
|
}
|
||||||
|
|
||||||
private get _computeSize() {
|
private get _computeSize() {
|
||||||
return Math.ceil(this.snapshot!.size * 10) / 10 + " MB";
|
return Math.ceil(this._snapshot!.size * 10) / 10 + " MB";
|
||||||
}
|
}
|
||||||
|
|
||||||
private _formatDatetime(datetime) {
|
private _formatDatetime(datetime) {
|
||||||
@@ -445,9 +398,9 @@ class HassioSnapshotDialog extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _dialogClosed() {
|
private _closeDialog() {
|
||||||
this._dialogParams = undefined;
|
this._dialogParams = undefined;
|
||||||
this.snapshot = undefined;
|
this._snapshot = undefined;
|
||||||
this._snapshotPassword = "";
|
this._snapshotPassword = "";
|
||||||
this._folders = [];
|
this._folders = [];
|
||||||
this._addons = [];
|
this._addons = [];
|
||||||
|
@@ -3,11 +3,11 @@ import {
|
|||||||
HassioAddonDetails,
|
HassioAddonDetails,
|
||||||
restartHassioAddon,
|
restartHassioAddon,
|
||||||
} from "../../../src/data/hassio/addon";
|
} from "../../../src/data/hassio/addon";
|
||||||
import { HomeAssistant } from "../../../src/types";
|
|
||||||
import {
|
import {
|
||||||
showConfirmationDialog,
|
|
||||||
showAlertDialog,
|
showAlertDialog,
|
||||||
|
showConfirmationDialog,
|
||||||
} from "../../../src/dialogs/generic/show-dialog-box";
|
} from "../../../src/dialogs/generic/show-dialog-box";
|
||||||
|
import { HomeAssistant } from "../../../src/types";
|
||||||
|
|
||||||
export const suggestAddonRestart = async (
|
export const suggestAddonRestart = async (
|
||||||
element: LitElement,
|
element: LitElement,
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import "../../src/components/ha-icon-button";
|
|
||||||
import { PolymerElement } from "@polymer/polymer";
|
import { PolymerElement } from "@polymer/polymer";
|
||||||
import { customElement, property, PropertyValues } from "lit-element";
|
import { customElement, property, PropertyValues } from "lit-element";
|
||||||
import { applyThemesOnElement } from "../../src/common/dom/apply_themes_on_element";
|
import { applyThemesOnElement } from "../../src/common/dom/apply_themes_on_element";
|
||||||
@@ -34,12 +33,6 @@ import { HomeAssistant } from "../../src/types";
|
|||||||
// Don't codesplit it, that way the dashboard always loads fast.
|
// Don't codesplit it, that way the dashboard always loads fast.
|
||||||
import "./hassio-panel";
|
import "./hassio-panel";
|
||||||
|
|
||||||
// The register callback of the IronA11yKeysBehavior inside ha-icon-button
|
|
||||||
// is not called, causing _keyBindings to be uninitiliazed for ha-icon-button,
|
|
||||||
// causing an exception when added to DOM. When transpiled to ES5, this will
|
|
||||||
// break the build.
|
|
||||||
customElements.get("ha-icon-button").prototype._keyBindings = {};
|
|
||||||
|
|
||||||
@customElement("hassio-main")
|
@customElement("hassio-main")
|
||||||
class HassioMain extends ProvideHassLitMixin(HassRouterPage) {
|
class HassioMain extends ProvideHassLitMixin(HassRouterPage) {
|
||||||
@property() public hass!: HomeAssistant;
|
@property() public hass!: HomeAssistant;
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import { mdiBackupRestore, mdiCogs, mdiStore, mdiViewDashboard } from "@mdi/js";
|
||||||
import {
|
import {
|
||||||
customElement,
|
customElement,
|
||||||
html,
|
html,
|
||||||
@@ -5,37 +6,35 @@ import {
|
|||||||
property,
|
property,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
|
||||||
import { HassioHassOSInfo, HassioHostInfo } from "../../src/data/hassio/host";
|
import { HassioHassOSInfo, HassioHostInfo } from "../../src/data/hassio/host";
|
||||||
import {
|
import {
|
||||||
HassioHomeAssistantInfo,
|
HassioHomeAssistantInfo,
|
||||||
HassioSupervisorInfo,
|
HassioSupervisorInfo,
|
||||||
} from "../../src/data/hassio/supervisor";
|
} from "../../src/data/hassio/supervisor";
|
||||||
import "../../src/resources/ha-style";
|
import type { PageNavigation } from "../../src/layouts/hass-tabs-subpage";
|
||||||
import { HomeAssistant, Route } from "../../src/types";
|
import { HomeAssistant, Route } from "../../src/types";
|
||||||
import "./hassio-panel-router";
|
import "./hassio-panel-router";
|
||||||
import type { PageNavigation } from "../../src/layouts/hass-tabs-subpage";
|
|
||||||
|
|
||||||
export const supervisorTabs: PageNavigation[] = [
|
export const supervisorTabs: PageNavigation[] = [
|
||||||
{
|
{
|
||||||
name: "Dashboard",
|
name: "Dashboard",
|
||||||
path: `/hassio/dashboard`,
|
path: `/hassio/dashboard`,
|
||||||
icon: "hassio:view-dashboard",
|
iconPath: mdiViewDashboard,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Add-on store",
|
name: "Add-on store",
|
||||||
path: `/hassio/store`,
|
path: `/hassio/store`,
|
||||||
icon: "hassio:store",
|
iconPath: mdiStore,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Snapshots",
|
name: "Snapshots",
|
||||||
path: `/hassio/snapshots`,
|
path: `/hassio/snapshots`,
|
||||||
icon: "hassio:backup-restore",
|
iconPath: mdiBackupRestore,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "System",
|
name: "System",
|
||||||
path: `/hassio/system`,
|
path: `/hassio/system`,
|
||||||
icon: "hassio:cogs",
|
iconPath: mdiCogs,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -86,9 +86,6 @@ class HassioIngressView extends LitElement {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
ha-icon-button {
|
|
||||||
color: var(--text-primary-color);
|
|
||||||
}
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import "@polymer/paper-card/paper-card";
|
import "@material/mwc-icon-button";
|
||||||
|
import { mdiPackageVariant, mdiPackageVariantClosed, mdiReload } from "@mdi/js";
|
||||||
import "@polymer/paper-checkbox/paper-checkbox";
|
import "@polymer/paper-checkbox/paper-checkbox";
|
||||||
import type { PaperCheckboxElement } from "@polymer/paper-checkbox/paper-checkbox";
|
import type { PaperCheckboxElement } from "@polymer/paper-checkbox/paper-checkbox";
|
||||||
import "@polymer/paper-input/paper-input";
|
import "@polymer/paper-input/paper-input";
|
||||||
@@ -18,6 +19,8 @@ import {
|
|||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||||
|
import "../../../src/components/ha-card";
|
||||||
|
import "../../../src/components/ha-svg-icon";
|
||||||
import {
|
import {
|
||||||
createHassioFullSnapshot,
|
createHassioFullSnapshot,
|
||||||
createHassioPartialSnapshot,
|
createHassioPartialSnapshot,
|
||||||
@@ -28,15 +31,14 @@ import {
|
|||||||
reloadHassioSnapshots,
|
reloadHassioSnapshots,
|
||||||
} from "../../../src/data/hassio/snapshot";
|
} from "../../../src/data/hassio/snapshot";
|
||||||
import { HassioSupervisorInfo } from "../../../src/data/hassio/supervisor";
|
import { HassioSupervisorInfo } from "../../../src/data/hassio/supervisor";
|
||||||
|
import "../../../src/layouts/hass-tabs-subpage";
|
||||||
import { PolymerChangedEvent } from "../../../src/polymer-types";
|
import { PolymerChangedEvent } from "../../../src/polymer-types";
|
||||||
import { haStyle } from "../../../src/resources/styles";
|
import { haStyle } from "../../../src/resources/styles";
|
||||||
import { HomeAssistant, Route } from "../../../src/types";
|
import { HomeAssistant, Route } from "../../../src/types";
|
||||||
import "../../../src/layouts/hass-tabs-subpage";
|
|
||||||
import "../components/hassio-card-content";
|
import "../components/hassio-card-content";
|
||||||
import { showHassioSnapshotDialog } from "../dialogs/snapshot/show-dialog-hassio-snapshot";
|
import { showHassioSnapshotDialog } from "../dialogs/snapshot/show-dialog-hassio-snapshot";
|
||||||
import { hassioStyle } from "../resources/hassio-style";
|
|
||||||
|
|
||||||
import { supervisorTabs } from "../hassio-panel";
|
import { supervisorTabs } from "../hassio-panel";
|
||||||
|
import { hassioStyle } from "../resources/hassio-style";
|
||||||
|
|
||||||
interface CheckboxItem {
|
interface CheckboxItem {
|
||||||
slug: string;
|
slug: string;
|
||||||
@@ -98,12 +100,13 @@ class HassioSnapshots extends LitElement {
|
|||||||
>
|
>
|
||||||
<span slot="header">Snapshots</span>
|
<span slot="header">Snapshots</span>
|
||||||
|
|
||||||
<ha-icon-button
|
<mwc-icon-button
|
||||||
icon="hassio:reload"
|
|
||||||
slot="toolbar-icon"
|
slot="toolbar-icon"
|
||||||
aria-label="Reload snapshots"
|
aria-label="Reload snapshots"
|
||||||
@click=${this.refreshData}
|
@click=${this.refreshData}
|
||||||
></ha-icon-button>
|
>
|
||||||
|
<ha-svg-icon path=${mdiReload}></ha-svg-icon>
|
||||||
|
</mwc-icon-button>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h1>
|
<h1>
|
||||||
@@ -114,7 +117,7 @@ class HassioSnapshots extends LitElement {
|
|||||||
Home Assistant instance.
|
Home Assistant instance.
|
||||||
</p>
|
</p>
|
||||||
<div class="card-group">
|
<div class="card-group">
|
||||||
<paper-card>
|
<ha-card>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<paper-input
|
<paper-input
|
||||||
autofocus
|
autofocus
|
||||||
@@ -195,7 +198,7 @@ class HassioSnapshots extends LitElement {
|
|||||||
Create
|
Create
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h1>Available snapshots</h1>
|
<h1>Available snapshots</h1>
|
||||||
@@ -204,15 +207,15 @@ class HassioSnapshots extends LitElement {
|
|||||||
? undefined
|
? undefined
|
||||||
: this._snapshots.length === 0
|
: this._snapshots.length === 0
|
||||||
? html`
|
? html`
|
||||||
<paper-card>
|
<ha-card>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
You don't have any snapshots yet.
|
You don't have any snapshots yet.
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`
|
`
|
||||||
: this._snapshots.map(
|
: this._snapshots.map(
|
||||||
(snapshot) => html`
|
(snapshot) => html`
|
||||||
<paper-card
|
<ha-card
|
||||||
class="pointer"
|
class="pointer"
|
||||||
.snapshot=${snapshot}
|
.snapshot=${snapshot}
|
||||||
@click=${this._snapshotClicked}
|
@click=${this._snapshotClicked}
|
||||||
@@ -224,12 +227,12 @@ class HassioSnapshots extends LitElement {
|
|||||||
.description=${this._computeDetails(snapshot)}
|
.description=${this._computeDetails(snapshot)}
|
||||||
.datetime=${snapshot.date}
|
.datetime=${snapshot.date}
|
||||||
.icon=${snapshot.type === "full"
|
.icon=${snapshot.type === "full"
|
||||||
? "hassio:package-variant-closed"
|
? mdiPackageVariantClosed
|
||||||
: "hassio:package-variant"}
|
: mdiPackageVariant}
|
||||||
.icon-class="snapshot"
|
.icon-class="snapshot"
|
||||||
></hassio-card-content>
|
></hassio-card-content>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import "@polymer/paper-card/paper-card";
|
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -12,23 +11,23 @@ import {
|
|||||||
import "../../../src/components/buttons/ha-call-api-button";
|
import "../../../src/components/buttons/ha-call-api-button";
|
||||||
import { fetchHassioHardwareInfo } from "../../../src/data/hassio/hardware";
|
import { fetchHassioHardwareInfo } from "../../../src/data/hassio/hardware";
|
||||||
import {
|
import {
|
||||||
|
changeHostOptions,
|
||||||
fetchHassioHostInfo,
|
fetchHassioHostInfo,
|
||||||
HassioHassOSInfo,
|
HassioHassOSInfo,
|
||||||
HassioHostInfo as HassioHostInfoType,
|
HassioHostInfo as HassioHostInfoType,
|
||||||
rebootHost,
|
rebootHost,
|
||||||
shutdownHost,
|
shutdownHost,
|
||||||
updateOS,
|
updateOS,
|
||||||
changeHostOptions,
|
|
||||||
} from "../../../src/data/hassio/host";
|
} from "../../../src/data/hassio/host";
|
||||||
|
import {
|
||||||
|
showAlertDialog,
|
||||||
|
showConfirmationDialog,
|
||||||
|
showPromptDialog,
|
||||||
|
} from "../../../src/dialogs/generic/show-dialog-box";
|
||||||
import { haStyle } from "../../../src/resources/styles";
|
import { haStyle } from "../../../src/resources/styles";
|
||||||
import { HomeAssistant } from "../../../src/types";
|
import { HomeAssistant } from "../../../src/types";
|
||||||
import { showHassioMarkdownDialog } from "../dialogs/markdown/show-dialog-hassio-markdown";
|
import { showHassioMarkdownDialog } from "../dialogs/markdown/show-dialog-hassio-markdown";
|
||||||
import { hassioStyle } from "../resources/hassio-style";
|
import { hassioStyle } from "../resources/hassio-style";
|
||||||
import {
|
|
||||||
showConfirmationDialog,
|
|
||||||
showAlertDialog,
|
|
||||||
showPromptDialog,
|
|
||||||
} from "../../../src/dialogs/generic/show-dialog-box";
|
|
||||||
|
|
||||||
@customElement("hassio-host-info")
|
@customElement("hassio-host-info")
|
||||||
class HassioHostInfo extends LitElement {
|
class HassioHostInfo extends LitElement {
|
||||||
@@ -42,7 +41,7 @@ class HassioHostInfo extends LitElement {
|
|||||||
|
|
||||||
public render(): TemplateResult | void {
|
public render(): TemplateResult | void {
|
||||||
return html`
|
return html`
|
||||||
<paper-card>
|
<ha-card>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<h2>Host system</h2>
|
<h2>Host system</h2>
|
||||||
<table class="info">
|
<table class="info">
|
||||||
@@ -113,7 +112,7 @@ class HassioHostInfo extends LitElement {
|
|||||||
? html` <mwc-button @click=${this._updateOS}>Update</mwc-button> `
|
? html` <mwc-button @click=${this._updateOS}>Update</mwc-button> `
|
||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +121,7 @@ class HassioHostInfo extends LitElement {
|
|||||||
haStyle,
|
haStyle,
|
||||||
hassioStyle,
|
hassioStyle,
|
||||||
css`
|
css`
|
||||||
paper-card {
|
ha-card {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import "@polymer/paper-card/paper-card";
|
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -11,15 +10,16 @@ import {
|
|||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||||
import "../../../src/components/buttons/ha-call-api-button";
|
import "../../../src/components/buttons/ha-call-api-button";
|
||||||
|
import "../../../src/components/ha-card";
|
||||||
import {
|
import {
|
||||||
HassioSupervisorInfo as HassioSupervisorInfoType,
|
HassioSupervisorInfo as HassioSupervisorInfoType,
|
||||||
setSupervisorOption,
|
setSupervisorOption,
|
||||||
SupervisorOptions,
|
SupervisorOptions,
|
||||||
} from "../../../src/data/hassio/supervisor";
|
} from "../../../src/data/hassio/supervisor";
|
||||||
|
import { showConfirmationDialog } from "../../../src/dialogs/generic/show-dialog-box";
|
||||||
import { haStyle } from "../../../src/resources/styles";
|
import { haStyle } from "../../../src/resources/styles";
|
||||||
import { HomeAssistant } from "../../../src/types";
|
import { HomeAssistant } from "../../../src/types";
|
||||||
import { hassioStyle } from "../resources/hassio-style";
|
import { hassioStyle } from "../resources/hassio-style";
|
||||||
import { showConfirmationDialog } from "../../../src/dialogs/generic/show-dialog-box";
|
|
||||||
|
|
||||||
@customElement("hassio-supervisor-info")
|
@customElement("hassio-supervisor-info")
|
||||||
class HassioSupervisorInfo extends LitElement {
|
class HassioSupervisorInfo extends LitElement {
|
||||||
@@ -31,7 +31,7 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
|
|
||||||
public render(): TemplateResult | void {
|
public render(): TemplateResult | void {
|
||||||
return html`
|
return html`
|
||||||
<paper-card>
|
<ha-card>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<h2>Supervisor</h2>
|
<h2>Supervisor</h2>
|
||||||
<table class="info">
|
<table class="info">
|
||||||
@@ -92,7 +92,7 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
haStyle,
|
haStyle,
|
||||||
hassioStyle,
|
hassioStyle,
|
||||||
css`
|
css`
|
||||||
paper-card {
|
ha-card {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,6 @@ import "@material/mwc-button";
|
|||||||
import "@polymer/paper-dropdown-menu/paper-dropdown-menu";
|
import "@polymer/paper-dropdown-menu/paper-dropdown-menu";
|
||||||
import "@polymer/paper-item/paper-item";
|
import "@polymer/paper-item/paper-item";
|
||||||
import "@polymer/paper-listbox/paper-listbox";
|
import "@polymer/paper-listbox/paper-listbox";
|
||||||
import "@polymer/paper-card/paper-card";
|
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -12,14 +11,13 @@ import {
|
|||||||
property,
|
property,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
|
import "../../../src/components/ha-card";
|
||||||
|
import { fetchHassioLogs } from "../../../src/data/hassio/supervisor";
|
||||||
|
import "../../../src/layouts/loading-screen";
|
||||||
import { haStyle } from "../../../src/resources/styles";
|
import { haStyle } from "../../../src/resources/styles";
|
||||||
import { HomeAssistant } from "../../../src/types";
|
import { HomeAssistant } from "../../../src/types";
|
||||||
|
|
||||||
import { fetchHassioLogs } from "../../../src/data/hassio/supervisor";
|
|
||||||
|
|
||||||
import "../components/hassio-ansi-to-html";
|
import "../components/hassio-ansi-to-html";
|
||||||
import { hassioStyle } from "../resources/hassio-style";
|
import { hassioStyle } from "../resources/hassio-style";
|
||||||
import "../../../src/layouts/loading-screen";
|
|
||||||
|
|
||||||
interface LogProvider {
|
interface LogProvider {
|
||||||
key: string;
|
key: string;
|
||||||
@@ -70,7 +68,7 @@ class HassioSupervisorLog extends LitElement {
|
|||||||
|
|
||||||
public render(): TemplateResult | void {
|
public render(): TemplateResult | void {
|
||||||
return html`
|
return html`
|
||||||
<paper-card>
|
<ha-card>
|
||||||
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
${this._error ? html` <div class="errors">${this._error}</div> ` : ""}
|
||||||
${this.hass.userData?.showAdvanced
|
${this.hass.userData?.showAdvanced
|
||||||
? html`
|
? html`
|
||||||
@@ -105,7 +103,7 @@ class HassioSupervisorLog extends LitElement {
|
|||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<mwc-button @click=${this._refresh}>Refresh</mwc-button>
|
<mwc-button @click=${this._refresh}>Refresh</mwc-button>
|
||||||
</div>
|
</div>
|
||||||
</paper-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +112,7 @@ class HassioSupervisorLog extends LitElement {
|
|||||||
haStyle,
|
haStyle,
|
||||||
hassioStyle,
|
hassioStyle,
|
||||||
css`
|
css`
|
||||||
paper-card {
|
ha-card {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
pre {
|
pre {
|
||||||
|
@@ -13,16 +13,15 @@ import {
|
|||||||
HassioHostInfo,
|
HassioHostInfo,
|
||||||
} from "../../../src/data/hassio/host";
|
} from "../../../src/data/hassio/host";
|
||||||
import { HassioSupervisorInfo } from "../../../src/data/hassio/supervisor";
|
import { HassioSupervisorInfo } from "../../../src/data/hassio/supervisor";
|
||||||
import { haStyle } from "../../../src/resources/styles";
|
|
||||||
import "../../../src/layouts/hass-tabs-subpage";
|
import "../../../src/layouts/hass-tabs-subpage";
|
||||||
|
import { haStyle } from "../../../src/resources/styles";
|
||||||
import { HomeAssistant, Route } from "../../../src/types";
|
import { HomeAssistant, Route } from "../../../src/types";
|
||||||
|
import { supervisorTabs } from "../hassio-panel";
|
||||||
import { hassioStyle } from "../resources/hassio-style";
|
import { hassioStyle } from "../resources/hassio-style";
|
||||||
import "./hassio-host-info";
|
import "./hassio-host-info";
|
||||||
import "./hassio-supervisor-info";
|
import "./hassio-supervisor-info";
|
||||||
import "./hassio-supervisor-log";
|
import "./hassio-supervisor-log";
|
||||||
|
|
||||||
import { supervisorTabs } from "../hassio-panel";
|
|
||||||
|
|
||||||
@customElement("hassio-system")
|
@customElement("hassio-system")
|
||||||
class HassioSystem extends LitElement {
|
class HassioSystem extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
112
package.json
@@ -24,25 +24,25 @@
|
|||||||
"author": "Paulus Schoutsen <Paulus@PaulusSchoutsen.nl> (http://paulusschoutsen.nl)",
|
"author": "Paulus Schoutsen <Paulus@PaulusSchoutsen.nl> (http://paulusschoutsen.nl)",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fullcalendar/core": "5.0.0-beta.2",
|
"@formatjs/intl-pluralrules": "^1.5.8",
|
||||||
"@fullcalendar/daygrid": "5.0.0-beta.2",
|
"@fullcalendar/core": "^5.0.0-beta.2",
|
||||||
"@material/chips": "^6.0.0-canary.35a32aaea.0",
|
"@fullcalendar/daygrid": "^5.0.0-beta.2",
|
||||||
"@material/mwc-button": "0.14.1",
|
"@material/chips": "7.0.0-canary.d92d8c93e.0",
|
||||||
"@material/mwc-checkbox": "0.14.1",
|
"@material/mwc-button": "^0.15.0",
|
||||||
"@material/mwc-dialog": "0.14.1",
|
"@material/mwc-checkbox": "^0.15.0",
|
||||||
"@material/mwc-fab": "0.14.1",
|
"@material/mwc-dialog": "^0.15.0",
|
||||||
"@material/mwc-formfield": "0.14.1",
|
"@material/mwc-fab": "^0.15.0",
|
||||||
"@material/mwc-icon-button": "0.14.1",
|
"@material/mwc-formfield": "^0.15.0",
|
||||||
"@material/mwc-list": "0.14.1",
|
"@material/mwc-icon-button": "^0.15.0",
|
||||||
"@material/mwc-menu": "0.14.1",
|
"@material/mwc-list": "^0.15.0",
|
||||||
"@material/mwc-ripple": "0.14.1",
|
"@material/mwc-menu": "^0.15.0",
|
||||||
"@material/mwc-switch": "0.14.1",
|
"@material/mwc-ripple": "^0.15.0",
|
||||||
|
"@material/mwc-switch": "^0.15.0",
|
||||||
"@mdi/js": "4.9.95",
|
"@mdi/js": "4.9.95",
|
||||||
"@mdi/svg": "4.9.95",
|
"@mdi/svg": "4.9.95",
|
||||||
"@polymer/app-layout": "^3.0.2",
|
"@polymer/app-layout": "^3.0.2",
|
||||||
"@polymer/app-route": "^3.0.2",
|
"@polymer/app-route": "^3.0.2",
|
||||||
"@polymer/app-storage": "^3.0.2",
|
"@polymer/app-storage": "^3.0.2",
|
||||||
"@polymer/font-roboto": "^3.0.2",
|
|
||||||
"@polymer/iron-autogrow-textarea": "^3.0.1",
|
"@polymer/iron-autogrow-textarea": "^3.0.1",
|
||||||
"@polymer/iron-flex-layout": "^3.0.1",
|
"@polymer/iron-flex-layout": "^3.0.1",
|
||||||
"@polymer/iron-icon": "^3.0.1",
|
"@polymer/iron-icon": "^3.0.1",
|
||||||
@@ -51,15 +51,12 @@
|
|||||||
"@polymer/iron-label": "^3.0.1",
|
"@polymer/iron-label": "^3.0.1",
|
||||||
"@polymer/iron-media-query": "^3.0.1",
|
"@polymer/iron-media-query": "^3.0.1",
|
||||||
"@polymer/iron-overlay-behavior": "^3.0.2",
|
"@polymer/iron-overlay-behavior": "^3.0.2",
|
||||||
"@polymer/iron-pages": "^3.0.1",
|
|
||||||
"@polymer/iron-resizable-behavior": "^3.0.1",
|
"@polymer/iron-resizable-behavior": "^3.0.1",
|
||||||
"@polymer/neon-animation": "^3.0.1",
|
|
||||||
"@polymer/paper-card": "^3.0.1",
|
"@polymer/paper-card": "^3.0.1",
|
||||||
"@polymer/paper-checkbox": "^3.1.0",
|
"@polymer/paper-checkbox": "^3.1.0",
|
||||||
"@polymer/paper-dialog": "^3.0.1",
|
"@polymer/paper-dialog": "^3.0.1",
|
||||||
"@polymer/paper-dialog-behavior": "^3.0.1",
|
"@polymer/paper-dialog-behavior": "^3.0.1",
|
||||||
"@polymer/paper-dialog-scrollable": "^3.0.1",
|
"@polymer/paper-dialog-scrollable": "^3.0.1",
|
||||||
"@polymer/paper-drawer-panel": "^3.0.1",
|
|
||||||
"@polymer/paper-dropdown-menu": "^3.0.1",
|
"@polymer/paper-dropdown-menu": "^3.0.1",
|
||||||
"@polymer/paper-input": "^3.0.1",
|
"@polymer/paper-input": "^3.0.1",
|
||||||
"@polymer/paper-item": "^3.0.1",
|
"@polymer/paper-item": "^3.0.1",
|
||||||
@@ -69,7 +66,6 @@
|
|||||||
"@polymer/paper-radio-button": "^3.0.1",
|
"@polymer/paper-radio-button": "^3.0.1",
|
||||||
"@polymer/paper-radio-group": "^3.0.1",
|
"@polymer/paper-radio-group": "^3.0.1",
|
||||||
"@polymer/paper-ripple": "^3.0.1",
|
"@polymer/paper-ripple": "^3.0.1",
|
||||||
"@polymer/paper-scroll-header-panel": "^3.0.1",
|
|
||||||
"@polymer/paper-slider": "^3.0.1",
|
"@polymer/paper-slider": "^3.0.1",
|
||||||
"@polymer/paper-spinner": "^3.0.2",
|
"@polymer/paper-spinner": "^3.0.2",
|
||||||
"@polymer/paper-styles": "^3.0.1",
|
"@polymer/paper-styles": "^3.0.1",
|
||||||
@@ -77,43 +73,46 @@
|
|||||||
"@polymer/paper-toast": "^3.0.1",
|
"@polymer/paper-toast": "^3.0.1",
|
||||||
"@polymer/paper-tooltip": "^3.0.1",
|
"@polymer/paper-tooltip": "^3.0.1",
|
||||||
"@polymer/polymer": "3.1.0",
|
"@polymer/polymer": "3.1.0",
|
||||||
"@thomasloven/round-slider": "0.3.7",
|
"@thomasloven/round-slider": "0.5.0",
|
||||||
"@vaadin/vaadin-combo-box": "^5.0.10",
|
"@vaadin/vaadin-combo-box": "^5.0.10",
|
||||||
"@vaadin/vaadin-date-picker": "^4.0.7",
|
"@vaadin/vaadin-date-picker": "^4.0.7",
|
||||||
"@webcomponents/shadycss": "^1.9.0",
|
"@webcomponents/webcomponentsjs": "^2.3.4",
|
||||||
"@webcomponents/webcomponentsjs": "^2.2.7",
|
|
||||||
"chart.js": "~2.8.0",
|
"chart.js": "~2.8.0",
|
||||||
"chartjs-chart-timeline": "^0.3.0",
|
"chartjs-chart-timeline": "^0.3.0",
|
||||||
"codemirror": "^5.49.0",
|
"codemirror": "^5.49.0",
|
||||||
|
"comlink": "^4.3.0",
|
||||||
"cpx": "^1.5.0",
|
"cpx": "^1.5.0",
|
||||||
"deep-clone-simple": "^1.1.1",
|
"deep-clone-simple": "^1.1.1",
|
||||||
"deep-freeze": "^0.0.1",
|
"deep-freeze": "^0.0.1",
|
||||||
"es6-object-assign": "^1.1.0",
|
"es6-object-assign": "^1.1.0",
|
||||||
"fecha": "^4.2.0",
|
"fecha": "^4.2.0",
|
||||||
"fuse.js": "^3.4.4",
|
"fuse.js": "^6.0.0",
|
||||||
"google-timezones-json": "^1.0.2",
|
"google-timezones-json": "^1.0.2",
|
||||||
"hls.js": "^0.12.4",
|
"hls.js": "^0.12.4",
|
||||||
"home-assistant-js-websocket": "5.0.0",
|
"home-assistant-js-websocket": "^5.1.2",
|
||||||
"idb-keyval": "^3.2.0",
|
"idb-keyval": "^3.2.0",
|
||||||
"intl-messageformat": "^8.3.9",
|
"intl-messageformat": "^8.3.9",
|
||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
"leaflet": "^1.4.0",
|
"leaflet": "^1.4.0",
|
||||||
"leaflet-draw": "^1.0.4",
|
"leaflet-draw": "^1.0.4",
|
||||||
"lit-element": "^2.2.1",
|
"lit-element": "^2.3.1",
|
||||||
"lit-html": "^1.1.0",
|
"lit-html": "^1.2.1",
|
||||||
"lit-virtualizer": "^0.4.2",
|
"lit-virtualizer": "^0.4.2",
|
||||||
"marked": "^0.6.1",
|
"marked": "^0.6.1",
|
||||||
"mdn-polyfills": "^5.16.0",
|
"mdn-polyfills": "^5.16.0",
|
||||||
"memoize-one": "^5.0.2",
|
"memoize-one": "^5.0.2",
|
||||||
"moment": "^2.24.0",
|
|
||||||
"node-vibrant": "^3.1.5",
|
"node-vibrant": "^3.1.5",
|
||||||
|
"proxy-polyfill": "^0.3.1",
|
||||||
"regenerator-runtime": "^0.13.2",
|
"regenerator-runtime": "^0.13.2",
|
||||||
"resize-observer": "^1.0.0",
|
"resize-observer-polyfill": "^1.5.1",
|
||||||
"roboto-fontface": "^0.10.0",
|
"roboto-fontface": "^0.10.0",
|
||||||
"superstruct": "^0.6.1",
|
"superstruct": "^0.6.1",
|
||||||
"tslib": "^1.10.0",
|
|
||||||
"unfetch": "^4.1.0",
|
"unfetch": "^4.1.0",
|
||||||
"web-animations-js": "^2.3.2",
|
"web-animations-js": "^2.3.2",
|
||||||
|
"workbox-core": "^5.1.3",
|
||||||
|
"workbox-precaching": "^5.1.3",
|
||||||
|
"workbox-routing": "^5.1.3",
|
||||||
|
"workbox-strategies": "^5.1.3",
|
||||||
"xss": "^1.0.6"
|
"xss": "^1.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -127,6 +126,10 @@
|
|||||||
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
||||||
"@babel/preset-env": "^7.9.5",
|
"@babel/preset-env": "^7.9.5",
|
||||||
"@babel/preset-typescript": "^7.9.0",
|
"@babel/preset-typescript": "^7.9.0",
|
||||||
|
"@rollup/plugin-commonjs": "^11.1.0",
|
||||||
|
"@rollup/plugin-json": "^4.0.3",
|
||||||
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
||||||
|
"@rollup/plugin-replace": "^2.3.2",
|
||||||
"@types/chai": "^4.1.7",
|
"@types/chai": "^4.1.7",
|
||||||
"@types/chromecast-caf-receiver": "^3.0.12",
|
"@types/chromecast-caf-receiver": "^3.0.12",
|
||||||
"@types/codemirror": "^0.0.78",
|
"@types/codemirror": "^0.0.78",
|
||||||
@@ -142,7 +145,6 @@
|
|||||||
"@typescript-eslint/parser": "^2.28.0",
|
"@typescript-eslint/parser": "^2.28.0",
|
||||||
"babel-loader": "^8.1.0",
|
"babel-loader": "^8.1.0",
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
"copy-webpack-plugin": "^5.0.2",
|
|
||||||
"del": "^4.0.0",
|
"del": "^4.0.0",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-config-airbnb-typescript": "^7.2.1",
|
"eslint-config-airbnb-typescript": "^7.2.1",
|
||||||
@@ -153,63 +155,71 @@
|
|||||||
"eslint-plugin-lit": "^1.2.0",
|
"eslint-plugin-lit": "^1.2.0",
|
||||||
"eslint-plugin-prettier": "^3.1.3",
|
"eslint-plugin-prettier": "^3.1.3",
|
||||||
"eslint-plugin-wc": "^1.2.0",
|
"eslint-plugin-wc": "^1.2.0",
|
||||||
|
"fancy-log": "^1.3.3",
|
||||||
"fs-extra": "^7.0.1",
|
"fs-extra": "^7.0.1",
|
||||||
"gulp": "^4.0.0",
|
"gulp": "^4.0.0",
|
||||||
"gulp-foreach": "^0.1.0",
|
"gulp-foreach": "^0.1.0",
|
||||||
"gulp-insert": "^0.5.0",
|
|
||||||
"gulp-json-transform": "^0.4.6",
|
"gulp-json-transform": "^0.4.6",
|
||||||
"gulp-jsonminify": "^1.1.0",
|
"gulp-jsonminify": "^1.1.0",
|
||||||
"gulp-merge-json": "^1.3.1",
|
"gulp-merge-json": "^1.3.1",
|
||||||
"gulp-rename": "^2.0.0",
|
"gulp-rename": "^2.0.0",
|
||||||
"gulp-zopfli-green": "^3.0.1",
|
"gulp-zopfli-green": "^3.0.1",
|
||||||
"html-webpack-plugin": "^3.2.0",
|
"html-minifier": "^4.0.0",
|
||||||
"husky": "^1.3.1",
|
"husky": "^1.3.1",
|
||||||
"lint-staged": "^8.1.5",
|
"lint-staged": "^8.1.5",
|
||||||
"lit-analyzer": "^1.1.10",
|
"lit-analyzer": "^1.1.10",
|
||||||
"lodash.template": "^4.5.0",
|
"lodash.template": "^4.5.0",
|
||||||
|
"magic-string": "^0.25.7",
|
||||||
"map-stream": "^0.0.7",
|
"map-stream": "^0.0.7",
|
||||||
"merge-stream": "^1.0.1",
|
"merge-stream": "^1.0.1",
|
||||||
"mocha": "^6.0.2",
|
"mocha": "^6.0.2",
|
||||||
"object-hash": "^2.0.3",
|
"object-hash": "^2.0.3",
|
||||||
"parse5": "^5.1.0",
|
"open": "^7.0.4",
|
||||||
"prettier": "^2.0.4",
|
"prettier": "^2.0.4",
|
||||||
"raw-loader": "^2.0.0",
|
"raw-loader": "^2.0.0",
|
||||||
"reify": "^0.18.1",
|
|
||||||
"require-dir": "^1.2.0",
|
"require-dir": "^1.2.0",
|
||||||
|
"rollup": "^2.8.2",
|
||||||
|
"rollup-plugin-babel": "^4.4.0",
|
||||||
|
"rollup-plugin-string": "^3.0.0",
|
||||||
|
"rollup-plugin-terser": "^5.3.0",
|
||||||
|
"rollup-plugin-visualizer": "^4.0.4",
|
||||||
|
"serve": "^11.3.0",
|
||||||
"sinon": "^7.3.1",
|
"sinon": "^7.3.1",
|
||||||
|
"source-map-url": "^0.4.0",
|
||||||
|
"systemjs": "^6.3.2",
|
||||||
"terser-webpack-plugin": "^1.2.3",
|
"terser-webpack-plugin": "^1.2.3",
|
||||||
"ts-lit-plugin": "^1.1.10",
|
"ts-lit-plugin": "^1.1.10",
|
||||||
"ts-mocha": "^6.0.0",
|
"ts-mocha": "^6.0.0",
|
||||||
"typescript": "^3.8.3",
|
"typescript": "^3.8.3",
|
||||||
"vinyl-buffer": "^1.0.1",
|
"vinyl-buffer": "^1.0.1",
|
||||||
"vinyl-source-stream": "^2.0.0",
|
"vinyl-source-stream": "^2.0.0",
|
||||||
"web-component-tester": "^6.9.2",
|
|
||||||
"webpack": "^4.40.2",
|
"webpack": "^4.40.2",
|
||||||
"webpack-cli": "^3.3.9",
|
"webpack-cli": "^3.3.9",
|
||||||
"webpack-dev-server": "^3.10.3",
|
"webpack-dev-server": "^3.10.3",
|
||||||
"webpack-manifest-plugin": "^2.0.4",
|
"webpack-manifest-plugin": "^2.0.4",
|
||||||
"workbox-webpack-plugin": "^4.1.1",
|
"workbox-build": "^5.1.3",
|
||||||
"workerize-loader": "^1.1.0"
|
"worker-plugin": "^4.0.3"
|
||||||
},
|
},
|
||||||
"_comment": "Polymer fixed to 3.1 because 3.2 throws on logbook page",
|
"_comment": "Polymer fixed to 3.1 because 3.2 throws on logbook page",
|
||||||
"_comment_2": "Fix in https://github.com/Polymer/polymer/pull/5569",
|
"_comment_2": "Fix in https://github.com/Polymer/polymer/pull/5569",
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"@webcomponents/webcomponentsjs": "^2.2.10",
|
"@webcomponents/webcomponentsjs": "^2.3.4",
|
||||||
"@polymer/polymer": "3.1.0",
|
"@polymer/polymer": "3.1.0",
|
||||||
"lit-html": "^1.1.2",
|
"lit-html": "1.2.1",
|
||||||
"@material/animation": "6.0.0",
|
"lit-element": "2.3.1",
|
||||||
"@material/base": "6.0.0",
|
"@material/animation": "7.0.0-canary.d92d8c93e.0",
|
||||||
"@material/checkbox": "6.0.0",
|
"@material/base": "7.0.0-canary.d92d8c93e.0",
|
||||||
"@material/density": "6.0.0",
|
"@material/checkbox": "7.0.0-canary.d92d8c93e.0",
|
||||||
"@material/dom": "6.0.0",
|
"@material/density": "7.0.0-canary.d92d8c93e.0",
|
||||||
"@material/elevation": "6.0.0",
|
"@material/dom": "7.0.0-canary.d92d8c93e.0",
|
||||||
"@material/feature-targeting": "6.0.0",
|
"@material/elevation": "7.0.0-canary.d92d8c93e.0",
|
||||||
"@material/ripple": "6.0.0",
|
"@material/feature-targeting": "7.0.0-canary.d92d8c93e.0",
|
||||||
"@material/rtl": "6.0.0",
|
"@material/ripple": "7.0.0-canary.d92d8c93e.0",
|
||||||
"@material/shape": "6.0.0",
|
"@material/rtl": "7.0.0-canary.d92d8c93e.0",
|
||||||
"@material/theme": "6.0.0",
|
"@material/shape": "7.0.0-canary.d92d8c93e.0",
|
||||||
"@material/touch-target": "6.0.0",
|
"@material/theme": "7.0.0-canary.d92d8c93e.0",
|
||||||
"@material/typography": "6.0.0"
|
"@material/touch-target": "7.0.0-canary.d92d8c93e.0",
|
||||||
|
"@material/typography": "7.0.0-canary.d92d8c93e.0"
|
||||||
},
|
},
|
||||||
"main": "src/home-assistant.js",
|
"main": "src/home-assistant.js",
|
||||||
"husky": {
|
"husky": {
|
||||||
|
Before Width: | Height: | Size: 655 B |
Before Width: | Height: | Size: 888 B |
Before Width: | Height: | Size: 807 B |
Before Width: | Height: | Size: 639 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 840 B |
Before Width: | Height: | Size: 798 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 487 B |
Before Width: | Height: | Size: 774 B |
10
rollup.config.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
const rollup = require("./build-scripts/rollup.js");
|
||||||
|
const env = require("./build-scripts/env.js");
|
||||||
|
|
||||||
|
const config = rollup.createAppConfig({
|
||||||
|
isProdBuild: env.isProdBuild(),
|
||||||
|
latestBuild: true,
|
||||||
|
isStatsBuild: env.isStatsBuild(),
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = { ...config.inputOptions, output: config.outputOptions };
|
2
setup.py
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="home-assistant-frontend",
|
name="home-assistant-frontend",
|
||||||
version="20200505.0",
|
version="20200519.0",
|
||||||
description="The Home Assistant frontend",
|
description="The Home Assistant frontend",
|
||||||
url="https://github.com/home-assistant/home-assistant-polymer",
|
url="https://github.com/home-assistant/home-assistant-polymer",
|
||||||
author="The Home Assistant Authors",
|
author="The Home Assistant Authors",
|
||||||
|
@@ -83,12 +83,24 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
|||||||
${this._renderStep(this._step)}
|
${this._renderStep(this._step)}
|
||||||
<div class="action">
|
<div class="action">
|
||||||
<mwc-button raised @click=${this._handleSubmit}
|
<mwc-button raised @click=${this._handleSubmit}
|
||||||
>${this._step.type === "form" ? "Next" : "Start over"}</mwc-button
|
>${this._step.type === "form"
|
||||||
|
? this.localize("ui.panel.page-authorize.form.next")
|
||||||
|
: this.localize(
|
||||||
|
"ui.panel.page-authorize.form.start_over"
|
||||||
|
)}</mwc-button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
case "error":
|
case "error":
|
||||||
return html` <div class="error">Error: ${this._errorMessage}</div> `;
|
return html`
|
||||||
|
<div class="error">
|
||||||
|
${this.localize(
|
||||||
|
"ui.panel.page-authorize.form.error",
|
||||||
|
"error",
|
||||||
|
this._errorMessage
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
case "loading":
|
case "loading":
|
||||||
return html` ${this.localize("ui.panel.page-authorize.form.working")} `;
|
return html` ${this.localize("ui.panel.page-authorize.form.working")} `;
|
||||||
default:
|
default:
|
||||||
|
@@ -121,7 +121,7 @@ class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
|
|||||||
const tempA = document.createElement("a");
|
const tempA = document.createElement("a");
|
||||||
tempA.href = this.redirectUri!;
|
tempA.href = this.redirectUri!;
|
||||||
if (tempA.host === location.host) {
|
if (tempA.host === location.host) {
|
||||||
registerServiceWorker(false);
|
registerServiceWorker(this, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import "@polymer/paper-item/paper-item.js";
|
import "@polymer/paper-item/paper-item";
|
||||||
import "@polymer/paper-item/paper-item-body.js";
|
import "@polymer/paper-item/paper-item-body";
|
||||||
import { html, LitElement, property } from "lit-element";
|
import { html, LitElement, property } from "lit-element";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import "../components/ha-icon-next";
|
import "../components/ha-icon-next";
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import "@polymer/paper-card";
|
import "@polymer/paper-card/paper-card";
|
||||||
import { html } from "@polymer/polymer/lib/utils/html-tag.js";
|
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||||
/* eslint-plugin-disable lit */
|
/* eslint-plugin-disable lit */
|
||||||
import { PolymerElement } from "@polymer/polymer/polymer-element.js";
|
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||||
import { computeStateName } from "../common/entity/compute_state_name";
|
import { computeStateName } from "../common/entity/compute_state_name";
|
||||||
import "../components/state-history-charts";
|
import "../components/state-history-charts";
|
||||||
import "../data/ha-state-history-data";
|
import "../data/ha-state-history-data";
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import "../../components/ha-icon-button";
|
import "@polymer/paper-input/paper-input";
|
||||||
import "@polymer/paper-input/paper-input.js";
|
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@@ -8,9 +7,11 @@ import {
|
|||||||
property,
|
property,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { html, TemplateResult } from "lit-html";
|
import { html, TemplateResult } from "lit-html";
|
||||||
import { classMap } from "lit-html/directives/class-map.js";
|
import { classMap } from "lit-html/directives/class-map";
|
||||||
import "../../components/ha-icon";
|
import "../../components/ha-svg-icon";
|
||||||
import { fireEvent } from "../dom/fire_event";
|
import { fireEvent } from "../dom/fire_event";
|
||||||
|
import { mdiMagnify, mdiClose } from "@mdi/js";
|
||||||
|
import "@material/mwc-icon-button/mwc-icon-button";
|
||||||
|
|
||||||
@customElement("search-input")
|
@customElement("search-input")
|
||||||
class SearchInput extends LitElement {
|
class SearchInput extends LitElement {
|
||||||
@@ -47,17 +48,22 @@ class SearchInput extends LitElement {
|
|||||||
@value-changed=${this._filterInputChanged}
|
@value-changed=${this._filterInputChanged}
|
||||||
.noLabelFloat=${this.noLabelFloat}
|
.noLabelFloat=${this.noLabelFloat}
|
||||||
>
|
>
|
||||||
<ha-icon icon="hass:magnify" slot="prefix" class="prefix"></ha-icon>
|
<ha-svg-icon
|
||||||
|
path=${mdiMagnify}
|
||||||
|
slot="prefix"
|
||||||
|
class="prefix"
|
||||||
|
></ha-svg-icon>
|
||||||
${this.filter &&
|
${this.filter &&
|
||||||
html`
|
html`
|
||||||
<ha-icon-button
|
<mwc-icon-button
|
||||||
slot="suffix"
|
slot="suffix"
|
||||||
class="suffix"
|
class="suffix"
|
||||||
@click=${this._clearSearch}
|
@click=${this._clearSearch}
|
||||||
icon="hass:close"
|
|
||||||
alt="Clear"
|
alt="Clear"
|
||||||
title="Clear"
|
title="Clear"
|
||||||
></ha-icon-button>
|
>
|
||||||
|
<ha-svg-icon path=${mdiClose}></ha-svg-icon>
|
||||||
|
</mwc-icon-button>
|
||||||
`}
|
`}
|
||||||
</paper-input>
|
</paper-input>
|
||||||
`;
|
`;
|
||||||
@@ -77,11 +83,14 @@ class SearchInput extends LitElement {
|
|||||||
|
|
||||||
static get styles(): CSSResult {
|
static get styles(): CSSResult {
|
||||||
return css`
|
return css`
|
||||||
ha-icon,
|
ha-svg-icon,
|
||||||
ha-icon-button {
|
mwc-icon-button {
|
||||||
color: var(--primary-text-color);
|
color: var(--primary-text-color);
|
||||||
}
|
}
|
||||||
ha-icon {
|
mwc-icon-button {
|
||||||
|
--mdc-icon-button-size: 24px;
|
||||||
|
}
|
||||||
|
ha-svg-icon.prefix {
|
||||||
margin: 8px;
|
margin: 8px;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
@@ -12,6 +12,10 @@ export interface FormatsType {
|
|||||||
time: FormatType;
|
time: FormatType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Intl.PluralRules) {
|
||||||
|
import("@formatjs/intl-pluralrules/polyfill-locales");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapted from Polymer app-localize-behavior.
|
* Adapted from Polymer app-localize-behavior.
|
||||||
*
|
*
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { html } from "@polymer/polymer/lib/utils/html-tag.js";
|
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||||
/* eslint-plugin-disable lit */
|
/* eslint-plugin-disable lit */
|
||||||
import { PolymerElement } from "@polymer/polymer/polymer-element.js";
|
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||||
import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box";
|
import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box";
|
||||||
import { EventsMixin } from "../../mixins/events-mixin";
|
import { EventsMixin } from "../../mixins/events-mixin";
|
||||||
import "./ha-progress-button";
|
import "./ha-progress-button";
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import "@polymer/paper-spinner/paper-spinner.js";
|
import "@polymer/paper-spinner/paper-spinner";
|
||||||
import { html } from "@polymer/polymer/lib/utils/html-tag.js";
|
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||||
/* eslint-plugin-disable lit */
|
/* eslint-plugin-disable lit */
|
||||||
import { PolymerElement } from "@polymer/polymer/polymer-element.js";
|
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||||
|
|
||||||
class HaProgressButton extends PolymerElement {
|
class HaProgressButton extends PolymerElement {
|
||||||
static get template() {
|
static get template() {
|
||||||
|
@@ -10,13 +10,10 @@ import {
|
|||||||
query,
|
query,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { classMap } from "lit-html/directives/class-map.js";
|
import { classMap } from "lit-html/directives/class-map";
|
||||||
import { ifDefined } from "lit-html/directives/if-defined.js";
|
import { ifDefined } from "lit-html/directives/if-defined";
|
||||||
import { styleMap } from "lit-html/directives/style-map.js";
|
import { styleMap } from "lit-html/directives/style-map";
|
||||||
import { scroll } from "lit-virtualizer";
|
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 { fireEvent } from "../../common/dom/fire_event";
|
||||||
import "../../common/search/search-input";
|
import "../../common/search/search-input";
|
||||||
import { debounce } from "../../common/util/debounce";
|
import { debounce } from "../../common/util/debounce";
|
||||||
@@ -24,6 +21,8 @@ import { nextRender } from "../../common/util/render-status";
|
|||||||
import "../ha-checkbox";
|
import "../ha-checkbox";
|
||||||
import type { HaCheckbox } from "../ha-checkbox";
|
import type { HaCheckbox } from "../ha-checkbox";
|
||||||
import "../ha-icon";
|
import "../ha-icon";
|
||||||
|
import { filterData, sortData } from "./sort-filter";
|
||||||
|
import memoizeOne from "memoize-one";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
// for fire event
|
// for fire event
|
||||||
@@ -74,6 +73,10 @@ export interface DataTableRowData {
|
|||||||
selectable?: boolean;
|
selectable?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SortableColumnContainer {
|
||||||
|
[key: string]: DataTableSortColumnData;
|
||||||
|
}
|
||||||
|
|
||||||
@customElement("ha-data-table")
|
@customElement("ha-data-table")
|
||||||
export class HaDataTable extends LitElement {
|
export class HaDataTable extends LitElement {
|
||||||
@property({ type: Object }) public columns: DataTableColumnContainer = {};
|
@property({ type: Object }) public columns: DataTableColumnContainer = {};
|
||||||
@@ -111,14 +114,10 @@ export class HaDataTable extends LitElement {
|
|||||||
|
|
||||||
private _checkedRows: string[] = [];
|
private _checkedRows: string[] = [];
|
||||||
|
|
||||||
private _sortColumns: {
|
private _sortColumns: SortableColumnContainer = {};
|
||||||
[key: string]: DataTableSortColumnData;
|
|
||||||
} = {};
|
|
||||||
|
|
||||||
private curRequest = 0;
|
private curRequest = 0;
|
||||||
|
|
||||||
private _worker: any | undefined;
|
|
||||||
|
|
||||||
private _debounceSearch = debounce(
|
private _debounceSearch = debounce(
|
||||||
(value: string) => {
|
(value: string) => {
|
||||||
this._filter = value;
|
this._filter = value;
|
||||||
@@ -140,11 +139,6 @@ export class HaDataTable extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected firstUpdated(properties: PropertyValues) {
|
|
||||||
super.firstUpdated(properties);
|
|
||||||
this._worker = sortFilterWorker();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected updated(properties: PropertyValues) {
|
protected updated(properties: PropertyValues) {
|
||||||
super.updated(properties);
|
super.updated(properties);
|
||||||
|
|
||||||
@@ -188,7 +182,7 @@ export class HaDataTable extends LitElement {
|
|||||||
properties.has("_sortColumn") ||
|
properties.has("_sortColumn") ||
|
||||||
properties.has("_sortDirection")
|
properties.has("_sortDirection")
|
||||||
) {
|
) {
|
||||||
this._filterData();
|
this._sortFilterData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,20 +372,30 @@ export class HaDataTable extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _filterData() {
|
private async _sortFilterData() {
|
||||||
const startTime = new Date().getTime();
|
const startTime = new Date().getTime();
|
||||||
this.curRequest++;
|
this.curRequest++;
|
||||||
const curRequest = this.curRequest;
|
const curRequest = this.curRequest;
|
||||||
|
|
||||||
const filterProm = this._worker.filterSortData(
|
let filteredData = this.data;
|
||||||
this.data,
|
if (this._filter) {
|
||||||
this._sortColumns,
|
filteredData = await this._memFilterData(
|
||||||
this._filter,
|
this.data,
|
||||||
this._sortDirection,
|
this._sortColumns,
|
||||||
this._sortColumn
|
this._filter
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const [data] = await Promise.all([filterProm, nextRender]);
|
const prom = this._sortColumn
|
||||||
|
? sortData(
|
||||||
|
filteredData,
|
||||||
|
this._sortColumns,
|
||||||
|
this._sortDirection,
|
||||||
|
this._sortColumn
|
||||||
|
)
|
||||||
|
: filteredData;
|
||||||
|
|
||||||
|
const [data] = await Promise.all([prom, nextRender]);
|
||||||
|
|
||||||
const curTime = new Date().getTime();
|
const curTime = new Date().getTime();
|
||||||
const elapsed = curTime - startTime;
|
const elapsed = curTime - startTime;
|
||||||
@@ -405,6 +409,16 @@ export class HaDataTable extends LitElement {
|
|||||||
this._filteredData = data;
|
this._filteredData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _memFilterData = memoizeOne(
|
||||||
|
async (
|
||||||
|
data: DataTableRowData[],
|
||||||
|
columns: SortableColumnContainer,
|
||||||
|
filter: string
|
||||||
|
): Promise<DataTableRowData[]> => {
|
||||||
|
return filterData(data, columns, filter);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
private _handleHeaderClick(ev: Event) {
|
private _handleHeaderClick(ev: Event) {
|
||||||
const columnId = ((ev.target as HTMLElement).closest(
|
const columnId = ((ev.target as HTMLElement).closest(
|
||||||
".mdc-data-table__header-cell"
|
".mdc-data-table__header-cell"
|
||||||
@@ -646,6 +660,11 @@ export class HaDataTable extends LitElement {
|
|||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mdc-data-table__cell--icon-button {
|
||||||
|
color: var(--secondary-text-color);
|
||||||
|
text-overflow: clip;
|
||||||
|
}
|
||||||
|
|
||||||
.mdc-data-table__header-cell--icon-button:first-child,
|
.mdc-data-table__header-cell--icon-button:first-child,
|
||||||
.mdc-data-table__cell--icon-button:first-child {
|
.mdc-data-table__cell--icon-button:first-child {
|
||||||
width: 64px;
|
width: 64px;
|
||||||
@@ -659,7 +678,7 @@ export class HaDataTable extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mdc-data-table__cell--icon-button a {
|
.mdc-data-table__cell--icon-button a {
|
||||||
color: var(--primary-text-color);
|
color: var(--secondary-text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.mdc-data-table__header-cell {
|
.mdc-data-table__header-cell {
|
||||||
|
36
src/components/data-table/sort-filter.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { wrap } from "comlink";
|
||||||
|
|
||||||
|
import type { api } from "./sort_filter_worker";
|
||||||
|
|
||||||
|
type FilterDataType = api["filterData"];
|
||||||
|
type FilterDataParamTypes = Parameters<FilterDataType>;
|
||||||
|
|
||||||
|
type SortDataType = api["sortData"];
|
||||||
|
type SortDataParamTypes = Parameters<SortDataType>;
|
||||||
|
|
||||||
|
let worker: any | undefined;
|
||||||
|
|
||||||
|
export const filterData = async (
|
||||||
|
data: FilterDataParamTypes[0],
|
||||||
|
columns: FilterDataParamTypes[1],
|
||||||
|
filter: FilterDataParamTypes[2]
|
||||||
|
): Promise<ReturnType<FilterDataType>> => {
|
||||||
|
if (!worker) {
|
||||||
|
worker = wrap(new Worker("./sort_filter_worker", { type: "module" }));
|
||||||
|
}
|
||||||
|
|
||||||
|
return await worker.filterData(data, columns, filter);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const sortData = async (
|
||||||
|
data: SortDataParamTypes[0],
|
||||||
|
columns: SortDataParamTypes[1],
|
||||||
|
direction: SortDataParamTypes[2],
|
||||||
|
sortColumn: SortDataParamTypes[3]
|
||||||
|
): Promise<ReturnType<SortDataType>> => {
|
||||||
|
if (!worker) {
|
||||||
|
worker = wrap(new Worker("./sort_filter_worker", { type: "module" }));
|
||||||
|
}
|
||||||
|
|
||||||
|
return await worker.sortData(data, columns, direction, sortColumn);
|
||||||
|
};
|
@@ -1,60 +1,20 @@
|
|||||||
import memoizeOne from "memoize-one";
|
// To use comlink under ES5
|
||||||
// eslint-disable-next-line import/no-cycle
|
import "proxy-polyfill";
|
||||||
import {
|
import { expose } from "comlink";
|
||||||
DataTableColumnContainer,
|
import type {
|
||||||
DataTableColumnData,
|
DataTableSortColumnData,
|
||||||
DataTableRowData,
|
DataTableRowData,
|
||||||
SortingDirection,
|
SortingDirection,
|
||||||
|
SortableColumnContainer,
|
||||||
} from "./ha-data-table";
|
} from "./ha-data-table";
|
||||||
|
|
||||||
export const filterSortData = memoizeOne(
|
const filterData = (
|
||||||
async (
|
|
||||||
data: DataTableRowData[],
|
|
||||||
columns: DataTableColumnContainer,
|
|
||||||
filter: string,
|
|
||||||
direction: SortingDirection,
|
|
||||||
sortColumn?: string
|
|
||||||
) =>
|
|
||||||
sortColumn
|
|
||||||
? _memSortData(
|
|
||||||
await _memFilterData(data, columns, filter),
|
|
||||||
columns,
|
|
||||||
direction,
|
|
||||||
sortColumn
|
|
||||||
)
|
|
||||||
: _memFilterData(data, columns, filter)
|
|
||||||
);
|
|
||||||
|
|
||||||
const _memFilterData = memoizeOne(
|
|
||||||
async (
|
|
||||||
data: DataTableRowData[],
|
|
||||||
columns: DataTableColumnContainer,
|
|
||||||
filter: string
|
|
||||||
) => {
|
|
||||||
if (!filter) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
return filterData(data, columns, filter.toUpperCase());
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const _memSortData = memoizeOne(
|
|
||||||
(
|
|
||||||
data: DataTableRowData[],
|
|
||||||
columns: DataTableColumnContainer,
|
|
||||||
direction: SortingDirection,
|
|
||||||
sortColumn: string
|
|
||||||
) => {
|
|
||||||
return sortData(data, columns[sortColumn], direction, sortColumn);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
export const filterData = (
|
|
||||||
data: DataTableRowData[],
|
data: DataTableRowData[],
|
||||||
columns: DataTableColumnContainer,
|
columns: SortableColumnContainer,
|
||||||
filter: string
|
filter: string
|
||||||
) =>
|
) => {
|
||||||
data.filter((row) => {
|
filter = filter.toUpperCase();
|
||||||
|
return data.filter((row) => {
|
||||||
return Object.entries(columns).some((columnEntry) => {
|
return Object.entries(columns).some((columnEntry) => {
|
||||||
const [key, column] = columnEntry;
|
const [key, column] = columnEntry;
|
||||||
if (column.filterable) {
|
if (column.filterable) {
|
||||||
@@ -69,10 +29,11 @@ export const filterData = (
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const sortData = (
|
const sortData = (
|
||||||
data: DataTableRowData[],
|
data: DataTableRowData[],
|
||||||
column: DataTableColumnData,
|
column: DataTableSortColumnData,
|
||||||
direction: SortingDirection,
|
direction: SortingDirection,
|
||||||
sortColumn: string
|
sortColumn: string
|
||||||
) =>
|
) =>
|
||||||
@@ -105,3 +66,12 @@ export const sortData = (
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const api = {
|
||||||
|
filterData,
|
||||||
|
sortData,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type api = typeof api;
|
||||||
|
|
||||||
|
expose(api);
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button/mwc-button";
|
||||||
import "../ha-icon-button";
|
import "../ha-icon-button";
|
||||||
import "@polymer/paper-input/paper-input.js";
|
import "@polymer/paper-input/paper-input";
|
||||||
import "@polymer/paper-item/paper-item.js";
|
import "@polymer/paper-item/paper-item";
|
||||||
import "@polymer/paper-item/paper-item-body.js";
|
import "@polymer/paper-item/paper-item-body";
|
||||||
import "@polymer/paper-listbox";
|
import "@polymer/paper-listbox/paper-listbox";
|
||||||
import "@vaadin/vaadin-combo-box/theme/material/vaadin-combo-box-light.js";
|
import "@vaadin/vaadin-combo-box/theme/material/vaadin-combo-box-light";
|
||||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import "@polymer/paper-input/paper-input.js";
|
import "@polymer/paper-input/paper-input";
|
||||||
import "@polymer/paper-item/paper-item.js";
|
import "@polymer/paper-item/paper-item";
|
||||||
import "@polymer/paper-item/paper-item-body.js";
|
import "@polymer/paper-item/paper-item-body";
|
||||||
import "@polymer/paper-listbox";
|
import "@polymer/paper-listbox/paper-listbox";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
|