mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-03 06:37:21 +00:00
Compare commits
219 Commits
auto-updat
...
cherry-pic
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce77ddf365 | ||
|
|
cf05fbaa9d | ||
|
|
552c474feb | ||
|
|
a4f8e886bc | ||
|
|
cc0c96b8b4 | ||
|
|
445f0e23fe | ||
|
|
6f240297d1 | ||
|
|
6da4981b70 | ||
|
|
cfadf4d700 | ||
|
|
7e60de0531 | ||
|
|
aaef6d7b91 | ||
|
|
58c5ce2638 | ||
|
|
a9d01c7b55 | ||
|
|
c5de8a4361 | ||
|
|
b53645ce92 | ||
|
|
de34a5a597 | ||
|
|
bd8e15bdd1 | ||
|
|
45c7e0eeeb | ||
|
|
a35a380ec7 | ||
|
|
02e67d1146 | ||
|
|
a5411f7ac4 | ||
|
|
e8da203fe1 | ||
|
|
10aa0a8829 | ||
|
|
85a37e2d2f | ||
|
|
ba8621fa2c | ||
|
|
43e80f1a2e | ||
|
|
3a305a44b6 | ||
|
|
e99143139e | ||
|
|
f0c7232704 | ||
|
|
b2186592df | ||
|
|
e51e3e79d5 | ||
|
|
3b6b4d7664 | ||
|
|
239e71b414 | ||
|
|
080cad0ccd | ||
|
|
dd49fd2788 | ||
|
|
a571fb5528 | ||
|
|
1369c1ae8c | ||
|
|
f5864181af | ||
|
|
a4a0d7cf19 | ||
|
|
092dfd1e87 | ||
|
|
a29ac33810 | ||
|
|
1421df2a5a | ||
|
|
591b8cc503 | ||
|
|
011467ece0 | ||
|
|
f52e8c3392 | ||
|
|
c8b87b65bd | ||
|
|
98cc82db44 | ||
|
|
f510e2a8e0 | ||
|
|
3438912ba5 | ||
|
|
671c8e387f | ||
|
|
0108ec65cf | ||
|
|
39f7034578 | ||
|
|
bf8affaf2b | ||
|
|
e16a61eb53 | ||
|
|
cadbe45bab | ||
|
|
51f971337d | ||
|
|
1f3c23de29 | ||
|
|
bdfb17d957 | ||
|
|
8c97aee1fe | ||
|
|
38b4090daa | ||
|
|
b8c55f2f65 | ||
|
|
7ca379e0a1 | ||
|
|
1617a9dfed | ||
|
|
2c9411c6c3 | ||
|
|
67626d4a06 | ||
|
|
8135611688 | ||
|
|
3ccbf6983e | ||
|
|
e4f91195d8 | ||
|
|
2751f8f33b | ||
|
|
57f2df3b3e | ||
|
|
6822f0d067 | ||
|
|
cfba957313 | ||
|
|
3149ffbf19 | ||
|
|
4cd8b76d7e | ||
|
|
4b644d8bc5 | ||
|
|
307cd5ad8c | ||
|
|
ebc807a6a4 | ||
|
|
66adecdfc9 | ||
|
|
2cc6432a0f | ||
|
|
a2c0c0474a | ||
|
|
27884b9a54 | ||
|
|
293df61872 | ||
|
|
f82dada3e5 | ||
|
|
e5824c4794 | ||
|
|
186550229c | ||
|
|
7877dd8e6b | ||
|
|
b03abc249b | ||
|
|
fda03918b9 | ||
|
|
6747375a1b | ||
|
|
53b6e31881 | ||
|
|
fa004de2d1 | ||
|
|
3605f7b70f | ||
|
|
5348c54c91 | ||
|
|
684e4421bc | ||
|
|
28f5611df5 | ||
|
|
8da73d49d7 | ||
|
|
049ddd5f84 | ||
|
|
8ae2d4e93a | ||
|
|
824bb9ba35 | ||
|
|
d550b1a18e | ||
|
|
dea6c0e761 | ||
|
|
9caee357c0 | ||
|
|
35d892c418 | ||
|
|
9572a2a46b | ||
|
|
8996361b26 | ||
|
|
02ee731602 | ||
|
|
bb1e6bf35b | ||
|
|
c1b65285c1 | ||
|
|
8b8d6e5fa3 | ||
|
|
c34fe184e8 | ||
|
|
7363838f86 | ||
|
|
3081425ccd | ||
|
|
95d494a54c | ||
|
|
145e5d7bc6 | ||
|
|
876fd9e85a | ||
|
|
e8c30cabca | ||
|
|
490f84a7b1 | ||
|
|
ca28178b86 | ||
|
|
2fceb0aeee | ||
|
|
86f39d1d43 | ||
|
|
1faf60444d | ||
|
|
e927091d21 | ||
|
|
cff2f856b3 | ||
|
|
a743e3bbba | ||
|
|
f8a52d250e | ||
|
|
b70a523bdf | ||
|
|
8f2ed747e6 | ||
|
|
5deccefb15 | ||
|
|
3f04abfa9d | ||
|
|
8e55c83996 | ||
|
|
dee59486ba | ||
|
|
77ef509aea | ||
|
|
bfa7bccfa6 | ||
|
|
a8c365edc8 | ||
|
|
94953ddf6c | ||
|
|
6b67546daf | ||
|
|
3e188d1f87 | ||
|
|
f69eb15a90 | ||
|
|
dfe348187f | ||
|
|
9706c56c5c | ||
|
|
3677c5be2c | ||
|
|
bd339fa963 | ||
|
|
28f1b6bdf4 | ||
|
|
c5aac3b81d | ||
|
|
70836597e9 | ||
|
|
958a1de2fd | ||
|
|
36d30266e3 | ||
|
|
558ab9761d | ||
|
|
269ef370e4 | ||
|
|
ba2958ecd2 | ||
|
|
3b8b6eb315 | ||
|
|
4f13db3178 | ||
|
|
ee7aa54ab4 | ||
|
|
c305dd4cd5 | ||
|
|
6865791596 | ||
|
|
2099259393 | ||
|
|
27ca45dc70 | ||
|
|
d290c11219 | ||
|
|
cabe10ffdb | ||
|
|
aa562c21a8 | ||
|
|
22175a7271 | ||
|
|
1e0647c0d1 | ||
|
|
58d94da8b3 | ||
|
|
d97763a3e8 | ||
|
|
aa129aa123 | ||
|
|
f648317206 | ||
|
|
0685fdf7c6 | ||
|
|
6fd4cda534 | ||
|
|
511368da13 | ||
|
|
76e1721c58 | ||
|
|
bad5a389b5 | ||
|
|
85d1f49763 | ||
|
|
7723d47ac1 | ||
|
|
30b130ca74 | ||
|
|
a124ec0717 | ||
|
|
323d98ecf7 | ||
|
|
125a601ae3 | ||
|
|
3c549c6b31 | ||
|
|
9c1494c74d | ||
|
|
e751abd775 | ||
|
|
714f2447b7 | ||
|
|
d900e40d04 | ||
|
|
8b82383790 | ||
|
|
5a2cc2646c | ||
|
|
16a0902989 | ||
|
|
8f67aa38af | ||
|
|
34184cf2ab | ||
|
|
611cd2818e | ||
|
|
0a4e8fd5d0 | ||
|
|
11f0361f48 | ||
|
|
cfa048ea4e | ||
|
|
bbca7b762b | ||
|
|
1dba849567 | ||
|
|
aff1ec10bf | ||
|
|
351ec08a71 | ||
|
|
a1a6a2cd30 | ||
|
|
4e82c23b29 | ||
|
|
59595aabde | ||
|
|
358f91c2a9 | ||
|
|
e0e01e68b4 | ||
|
|
61dc4eaaea | ||
|
|
65c4d02452 | ||
|
|
f78ce2c844 | ||
|
|
4d1ab83b30 | ||
|
|
fb4b40b828 | ||
|
|
db0c4ef941 | ||
|
|
c5b60b826b | ||
|
|
718f0330a7 | ||
|
|
89e31486c5 | ||
|
|
717eec1860 | ||
|
|
b6e51352e3 | ||
|
|
2ade728bc3 | ||
|
|
62f227da83 | ||
|
|
9557b604da | ||
|
|
b45c355c9f | ||
|
|
0b47d2c687 | ||
|
|
8baa0b2a9b | ||
|
|
c68a1d21ff | ||
|
|
419d659311 |
@@ -3,10 +3,10 @@ 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 { WebpackManifestPlugin } = require("webpack-manifest-plugin");
|
const { WebpackManifestPlugin } = require("webpack-manifest-plugin");
|
||||||
const paths = require("./paths.js");
|
|
||||||
const bundle = require("./bundle.js");
|
|
||||||
const log = require("fancy-log");
|
const log = require("fancy-log");
|
||||||
const WebpackBar = require("webpackbar");
|
const WebpackBar = require("webpackbar");
|
||||||
|
const paths = require("./paths.js");
|
||||||
|
const bundle = require("./bundle.js");
|
||||||
|
|
||||||
class LogStartCompilePlugin {
|
class LogStartCompilePlugin {
|
||||||
ignoredFirst = false;
|
ignoredFirst = false;
|
||||||
@@ -138,6 +138,8 @@ const createWebpackConfig = ({
|
|||||||
"lit/directives/cache$": "lit/directives/cache.js",
|
"lit/directives/cache$": "lit/directives/cache.js",
|
||||||
"lit/directives/repeat$": "lit/directives/repeat.js",
|
"lit/directives/repeat$": "lit/directives/repeat.js",
|
||||||
"lit/polyfill-support$": "lit/polyfill-support.js",
|
"lit/polyfill-support$": "lit/polyfill-support.js",
|
||||||
|
"@lit-labs/virtualizer/layouts/grid":
|
||||||
|
"@lit-labs/virtualizer/layouts/grid.js",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
@@ -62,6 +62,45 @@ const ACTIONS = [
|
|||||||
entity_id: "input_boolean.toggle_4",
|
entity_id: "input_boolean.toggle_4",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
parallel: [
|
||||||
|
{ scene: "scene.kitchen_morning" },
|
||||||
|
{
|
||||||
|
service: "media_player.play_media",
|
||||||
|
target: { entity_id: "media_player.living_room" },
|
||||||
|
data: { media_content_id: "", media_content_type: "" },
|
||||||
|
metadata: { title: "Happy Song" },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
stop: "No one is home!",
|
||||||
|
},
|
||||||
|
{ repeat: { count: 3, sequence: [{ delay: "00:00:01" }] } },
|
||||||
|
{
|
||||||
|
repeat: {
|
||||||
|
for_each: ["bread", "butter", "cheese"],
|
||||||
|
sequence: [{ delay: "00:00:01" }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
if: [{ condition: "state" }],
|
||||||
|
then: [{ delay: "00:00:01" }],
|
||||||
|
else: [{ delay: "00:00:05" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
choose: [
|
||||||
|
{
|
||||||
|
conditions: [{ condition: "state" }],
|
||||||
|
sequence: [{ delay: "00:00:01" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
conditions: [{ condition: "sun" }],
|
||||||
|
sequence: [{ delay: "00:00:05" }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: [{ delay: "00:00:03" }],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@customElement("demo-automation-describe-action")
|
@customElement("demo-automation-describe-action")
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ import { HaWaitForTriggerAction } from "../../../../src/panels/config/automation
|
|||||||
import { HaWaitAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-wait_template";
|
import { HaWaitAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-wait_template";
|
||||||
import { Action } from "../../../../src/data/script";
|
import { Action } from "../../../../src/data/script";
|
||||||
import { HaConditionAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-condition";
|
import { HaConditionAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-condition";
|
||||||
|
import { HaParallelAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-parallel";
|
||||||
|
import { HaIfAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-if";
|
||||||
|
import { HaStopAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-stop";
|
||||||
|
import { HaPlayMediaAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-play_media";
|
||||||
|
|
||||||
const SCHEMAS: { name: string; actions: Action[] }[] = [
|
const SCHEMAS: { name: string; actions: Action[] }[] = [
|
||||||
{ name: "Event", actions: [HaEventAction.defaultConfig] },
|
{ name: "Event", actions: [HaEventAction.defaultConfig] },
|
||||||
@@ -28,11 +32,15 @@ const SCHEMAS: { name: string; actions: Action[] }[] = [
|
|||||||
{ name: "Condition", actions: [HaConditionAction.defaultConfig] },
|
{ name: "Condition", actions: [HaConditionAction.defaultConfig] },
|
||||||
{ name: "Delay", actions: [HaDelayAction.defaultConfig] },
|
{ name: "Delay", actions: [HaDelayAction.defaultConfig] },
|
||||||
{ name: "Scene", actions: [HaSceneAction.defaultConfig] },
|
{ name: "Scene", actions: [HaSceneAction.defaultConfig] },
|
||||||
|
{ name: "Play media", actions: [HaPlayMediaAction.defaultConfig] },
|
||||||
{ name: "Wait", actions: [HaWaitAction.defaultConfig] },
|
{ name: "Wait", actions: [HaWaitAction.defaultConfig] },
|
||||||
{ name: "WaitForTrigger", actions: [HaWaitForTriggerAction.defaultConfig] },
|
{ name: "WaitForTrigger", actions: [HaWaitForTriggerAction.defaultConfig] },
|
||||||
{ name: "Repeat", actions: [HaRepeatAction.defaultConfig] },
|
{ name: "Repeat", actions: [HaRepeatAction.defaultConfig] },
|
||||||
|
{ name: "If-Then", actions: [HaIfAction.defaultConfig] },
|
||||||
{ name: "Choose", actions: [HaChooseAction.defaultConfig] },
|
{ name: "Choose", actions: [HaChooseAction.defaultConfig] },
|
||||||
{ name: "Variables", actions: [{ variables: { hello: "1" } }] },
|
{ name: "Variables", actions: [{ variables: { hello: "1" } }] },
|
||||||
|
{ name: "Parallel", actions: [HaParallelAction.defaultConfig] },
|
||||||
|
{ name: "Stop", actions: [HaStopAction.defaultConfig] },
|
||||||
];
|
];
|
||||||
|
|
||||||
@customElement("demo-automation-editor-action")
|
@customElement("demo-automation-editor-action")
|
||||||
@@ -86,6 +94,6 @@ class DemoHaAutomationEditorAction extends LitElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"demo-ha-automation-editor-action": DemoHaAutomationEditorAction;
|
"demo-automation-editor-action": DemoHaAutomationEditorAction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { mockEntityRegistry } from "../../../../demo/src/stubs/entity_registry";
|
|||||||
import { mockDeviceRegistry } from "../../../../demo/src/stubs/device_registry";
|
import { mockDeviceRegistry } from "../../../../demo/src/stubs/device_registry";
|
||||||
import { mockAreaRegistry } from "../../../../demo/src/stubs/area_registry";
|
import { mockAreaRegistry } from "../../../../demo/src/stubs/area_registry";
|
||||||
import { mockHassioSupervisor } from "../../../../demo/src/stubs/hassio_supervisor";
|
import { mockHassioSupervisor } from "../../../../demo/src/stubs/hassio_supervisor";
|
||||||
import type { Condition } from "../../../../src/data/automation";
|
import type { ConditionWithShorthand } from "../../../../src/data/automation";
|
||||||
import "../../../../src/panels/config/automation/condition/ha-automation-condition";
|
import "../../../../src/panels/config/automation/condition/ha-automation-condition";
|
||||||
import { HaDeviceCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-device";
|
import { HaDeviceCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-device";
|
||||||
import { HaLogicalCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-logical";
|
import { HaLogicalCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-logical";
|
||||||
@@ -20,7 +20,7 @@ import { HaTimeCondition } from "../../../../src/panels/config/automation/condit
|
|||||||
import { HaTriggerCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-trigger";
|
import { HaTriggerCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-trigger";
|
||||||
import { HaZoneCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-zone";
|
import { HaZoneCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-zone";
|
||||||
|
|
||||||
const SCHEMAS: { name: string; conditions: Condition[] }[] = [
|
const SCHEMAS: { name: string; conditions: ConditionWithShorthand[] }[] = [
|
||||||
{
|
{
|
||||||
name: "State",
|
name: "State",
|
||||||
conditions: [{ condition: "state", ...HaStateCondition.defaultConfig }],
|
conditions: [{ condition: "state", ...HaStateCondition.defaultConfig }],
|
||||||
@@ -69,6 +69,14 @@ const SCHEMAS: { name: string; conditions: Condition[] }[] = [
|
|||||||
name: "Trigger",
|
name: "Trigger",
|
||||||
conditions: [{ condition: "trigger", ...HaTriggerCondition.defaultConfig }],
|
conditions: [{ condition: "trigger", ...HaTriggerCondition.defaultConfig }],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Shorthand",
|
||||||
|
conditions: [
|
||||||
|
{ and: HaLogicalCondition.defaultConfig.conditions },
|
||||||
|
{ or: HaLogicalCondition.defaultConfig.conditions },
|
||||||
|
{ not: HaLogicalCondition.defaultConfig.conditions },
|
||||||
|
],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@customElement("demo-automation-editor-condition")
|
@customElement("demo-automation-editor-condition")
|
||||||
|
|||||||
@@ -159,13 +159,19 @@ export class DemoHaAlert extends LitElement {
|
|||||||
|
|
||||||
firstUpdated(changedProps) {
|
firstUpdated(changedProps) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
applyThemesOnElement(this.shadowRoot!.querySelector(".dark"), {
|
applyThemesOnElement(
|
||||||
default_theme: "default",
|
this.shadowRoot!.querySelector(".dark"),
|
||||||
default_dark_theme: "default",
|
{
|
||||||
themes: {},
|
default_theme: "default",
|
||||||
darkMode: true,
|
default_dark_theme: "default",
|
||||||
theme: "default",
|
themes: {},
|
||||||
});
|
darkMode: true,
|
||||||
|
theme: "default",
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles() {
|
static get styles() {
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ const SCHEMAS: {
|
|||||||
select: { options: ["Option 1", "Option 2"], mode: "list" },
|
select: { options: ["Option 1", "Option 2"], mode: "list" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
template: { name: "Template", selector: { template: {} } },
|
||||||
select: {
|
select: {
|
||||||
name: "Select",
|
name: "Select",
|
||||||
selector: {
|
selector: {
|
||||||
@@ -261,6 +262,8 @@ class DemoHaSelector extends LitElement implements ProvideHassElement {
|
|||||||
|
|
||||||
@state() private _required = false;
|
@state() private _required = false;
|
||||||
|
|
||||||
|
@state() private _helper = false;
|
||||||
|
|
||||||
@state() private _label = true;
|
@state() private _label = true;
|
||||||
|
|
||||||
private data = SCHEMAS.map(() => ({}));
|
private data = SCHEMAS.map(() => ({}));
|
||||||
@@ -418,6 +421,13 @@ class DemoHaSelector extends LitElement implements ProvideHassElement {
|
|||||||
@change=${this._handleOptionChange}
|
@change=${this._handleOptionChange}
|
||||||
></ha-switch>
|
></ha-switch>
|
||||||
</ha-formfield>
|
</ha-formfield>
|
||||||
|
<ha-formfield label="Helper text">
|
||||||
|
<ha-switch
|
||||||
|
.name=${"helper"}
|
||||||
|
.checked=${this._helper}
|
||||||
|
@change=${this._handleOptionChange}
|
||||||
|
></ha-switch>
|
||||||
|
</ha-formfield>
|
||||||
</div>
|
</div>
|
||||||
${SCHEMAS.map((info, idx) => {
|
${SCHEMAS.map((info, idx) => {
|
||||||
const data = this.data[idx];
|
const data = this.data[idx];
|
||||||
@@ -446,6 +456,7 @@ class DemoHaSelector extends LitElement implements ProvideHassElement {
|
|||||||
.disabled=${this._disabled}
|
.disabled=${this._disabled}
|
||||||
.required=${this._required}
|
.required=${this._required}
|
||||||
@value-changed=${valueChanged}
|
@value-changed=${valueChanged}
|
||||||
|
.helper=${this._helper ? "Helper text" : undefined}
|
||||||
></ha-selector>
|
></ha-selector>
|
||||||
</ha-settings-row>
|
</ha-settings-row>
|
||||||
`
|
`
|
||||||
@@ -466,7 +477,8 @@ class DemoHaSelector extends LitElement implements ProvideHassElement {
|
|||||||
width: 60;
|
width: 60;
|
||||||
}
|
}
|
||||||
.options {
|
.options {
|
||||||
padding: 16px 48px;
|
max-width: 800px;
|
||||||
|
margin: 16px auto;
|
||||||
}
|
}
|
||||||
.options ha-formfield {
|
.options ha-formfield {
|
||||||
margin-right: 16px;
|
margin-right: 16px;
|
||||||
|
|||||||
3
gallery/src/pages/components/ha-tip.markdown
Normal file
3
gallery/src/pages/components/ha-tip.markdown
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
title: Tips
|
||||||
|
---
|
||||||
73
gallery/src/pages/components/ha-tip.ts
Normal file
73
gallery/src/pages/components/ha-tip.ts
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import { html, css, LitElement, TemplateResult } from "lit";
|
||||||
|
import { customElement } from "lit/decorators";
|
||||||
|
import "../../../../src/components/ha-tip";
|
||||||
|
import "../../../../src/components/ha-card";
|
||||||
|
import { applyThemesOnElement } from "../../../../src/common/dom/apply_themes_on_element";
|
||||||
|
|
||||||
|
const tips: (string | TemplateResult)[] = [
|
||||||
|
"Test tip",
|
||||||
|
"Bigger test tip, with some random text just to fill up as much space as possible without it looking like I'm really trying to to that",
|
||||||
|
html`<i>Tip</i> <b>with</b> <sub>HTML</sub>`,
|
||||||
|
];
|
||||||
|
|
||||||
|
@customElement("demo-components-ha-tip")
|
||||||
|
export class DemoHaTip extends LitElement {
|
||||||
|
protected render(): TemplateResult {
|
||||||
|
return html` ${["light", "dark"].map(
|
||||||
|
(mode) => html`
|
||||||
|
<div class=${mode}>
|
||||||
|
<ha-card header="ha-tip ${mode} demo">
|
||||||
|
<div class="card-content">
|
||||||
|
${tips.map((tip) => html`<ha-tip>${tip}</ha-tip>`)}
|
||||||
|
</div>
|
||||||
|
</ha-card>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
firstUpdated(changedProps) {
|
||||||
|
super.firstUpdated(changedProps);
|
||||||
|
applyThemesOnElement(
|
||||||
|
this.shadowRoot!.querySelector(".dark"),
|
||||||
|
{
|
||||||
|
default_theme: "default",
|
||||||
|
default_dark_theme: "default",
|
||||||
|
themes: {},
|
||||||
|
darkMode: true,
|
||||||
|
theme: "default",
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static get styles() {
|
||||||
|
return css`
|
||||||
|
:host {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.dark,
|
||||||
|
.light {
|
||||||
|
display: block;
|
||||||
|
background-color: var(--primary-background-color);
|
||||||
|
padding: 0 50px;
|
||||||
|
}
|
||||||
|
ha-tip {
|
||||||
|
margin-bottom: 14px;
|
||||||
|
}
|
||||||
|
ha-card {
|
||||||
|
margin: 24px auto;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"demo-components-ha-tip": DemoHaTip;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ import { LONG_TEXT } from "../../data/text";
|
|||||||
|
|
||||||
const base_attributes = {
|
const base_attributes = {
|
||||||
title: "Awesome",
|
title: "Awesome",
|
||||||
current_version: "1.2.2",
|
installed_version: "1.2.2",
|
||||||
latest_version: "1.2.3",
|
latest_version: "1.2.3",
|
||||||
release_url: "https://home-assistant.io",
|
release_url: "https://home-assistant.io",
|
||||||
supported_features: UPDATE_SUPPORT_INSTALL,
|
supported_features: UPDATE_SUPPORT_INSTALL,
|
||||||
@@ -50,7 +50,7 @@ const ENTITIES = [
|
|||||||
}),
|
}),
|
||||||
getEntity("update", "update5", "off", {
|
getEntity("update", "update5", "off", {
|
||||||
...base_attributes,
|
...base_attributes,
|
||||||
current_version: "1.2.3",
|
installed_version: "1.2.3",
|
||||||
friendly_name: "No update",
|
friendly_name: "No update",
|
||||||
}),
|
}),
|
||||||
getEntity("update", "update6", "off", {
|
getEntity("update", "update6", "off", {
|
||||||
@@ -102,8 +102,8 @@ const ENTITIES = [
|
|||||||
}),
|
}),
|
||||||
getEntity("update", "update14", "off", {
|
getEntity("update", "update14", "off", {
|
||||||
...base_attributes,
|
...base_attributes,
|
||||||
current_version: null,
|
installed_version: null,
|
||||||
friendly_name: "Update without current_version",
|
friendly_name: "Update without installed_version",
|
||||||
}),
|
}),
|
||||||
getEntity("update", "update15", "off", {
|
getEntity("update", "update15", "off", {
|
||||||
...base_attributes,
|
...base_attributes,
|
||||||
@@ -128,6 +128,17 @@ const ENTITIES = [
|
|||||||
supported_features:
|
supported_features:
|
||||||
base_attributes.supported_features + UPDATE_SUPPORT_RELEASE_NOTES,
|
base_attributes.supported_features + UPDATE_SUPPORT_RELEASE_NOTES,
|
||||||
}),
|
}),
|
||||||
|
getEntity("update", "update19", "on", {
|
||||||
|
...base_attributes,
|
||||||
|
friendly_name: "Update with auto update",
|
||||||
|
auto_update: true,
|
||||||
|
}),
|
||||||
|
getEntity("update", "update20", "on", {
|
||||||
|
...base_attributes,
|
||||||
|
in_progress: true,
|
||||||
|
title: undefined,
|
||||||
|
friendly_name: "Installing without title",
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
@customElement("demo-more-info-update")
|
@customElement("demo-more-info-update")
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class HassioAddonRepositoryEl extends LitElement {
|
|||||||
${addons.map(
|
${addons.map(
|
||||||
(addon) => html`
|
(addon) => html`
|
||||||
<ha-card
|
<ha-card
|
||||||
|
outlined
|
||||||
.addon=${addon}
|
.addon=${addon}
|
||||||
class=${addon.available ? "" : "not_available"}
|
class=${addon.available ? "" : "not_available"}
|
||||||
@click=${this._addonTapped}
|
@click=${this._addonTapped}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class HassioAddonAudio extends LitElement {
|
|||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<ha-card
|
<ha-card
|
||||||
|
outlined
|
||||||
.header=${this.supervisor.localize("addon.configuration.audio.header")}
|
.header=${this.supervisor.localize("addon.configuration.audio.header")}
|
||||||
>
|
>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
|||||||
@@ -39,7 +39,14 @@ import type { HomeAssistant } from "../../../../src/types";
|
|||||||
import { suggestAddonRestart } from "../../dialogs/suggestAddonRestart";
|
import { suggestAddonRestart } from "../../dialogs/suggestAddonRestart";
|
||||||
import { hassioStyle } from "../../resources/hassio-style";
|
import { hassioStyle } from "../../resources/hassio-style";
|
||||||
|
|
||||||
const SUPPORTED_UI_TYPES = ["string", "select", "boolean", "integer", "float"];
|
const SUPPORTED_UI_TYPES = [
|
||||||
|
"string",
|
||||||
|
"select",
|
||||||
|
"boolean",
|
||||||
|
"integer",
|
||||||
|
"float",
|
||||||
|
"schema",
|
||||||
|
];
|
||||||
|
|
||||||
const ADDON_YAML_SCHEMA = DEFAULT_SCHEMA.extend([
|
const ADDON_YAML_SCHEMA = DEFAULT_SCHEMA.extend([
|
||||||
new Type("!secret", {
|
new Type("!secret", {
|
||||||
@@ -48,6 +55,8 @@ const ADDON_YAML_SCHEMA = DEFAULT_SCHEMA.extend([
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const MASKED_FIELDS = ["password", "secret", "token"];
|
||||||
|
|
||||||
@customElement("hassio-addon-config")
|
@customElement("hassio-addon-config")
|
||||||
class HassioAddonConfig extends LitElement {
|
class HassioAddonConfig extends LitElement {
|
||||||
@property({ attribute: false }) public addon!: HassioAddonDetails;
|
@property({ attribute: false }) public addon!: HassioAddonDetails;
|
||||||
@@ -75,19 +84,66 @@ class HassioAddonConfig extends LitElement {
|
|||||||
public computeLabel = (entry: HaFormSchema): string =>
|
public computeLabel = (entry: HaFormSchema): string =>
|
||||||
this.addon.translations[this.hass.language]?.configuration?.[entry.name]
|
this.addon.translations[this.hass.language]?.configuration?.[entry.name]
|
||||||
?.name ||
|
?.name ||
|
||||||
this.addon.translations.en?.configuration?.[entry.name].name ||
|
this.addon.translations.en?.configuration?.[entry.name]?.name ||
|
||||||
entry.name;
|
entry.name;
|
||||||
|
|
||||||
private _schema = memoizeOne((schema: HaFormSchema[]): HaFormSchema[] =>
|
public computeHelper = (entry: HaFormSchema): string =>
|
||||||
// @ts-expect-error supervisor does not implement [string, string] for select.options[]
|
this.addon.translations[this.hass.language]?.configuration?.[entry.name]
|
||||||
schema.map((entry) =>
|
?.description ||
|
||||||
entry.type === "select"
|
this.addon.translations.en?.configuration?.[entry.name]?.description ||
|
||||||
? {
|
"";
|
||||||
...entry,
|
|
||||||
options: entry.options.map((option) => [option, option]),
|
private _convertSchema = memoizeOne(
|
||||||
}
|
// Convert supervisor schema to selectors
|
||||||
: entry
|
(schema: Record<string, any>): HaFormSchema[] =>
|
||||||
)
|
schema.map((entry) =>
|
||||||
|
entry.type === "select"
|
||||||
|
? {
|
||||||
|
name: entry.name,
|
||||||
|
required: entry.required,
|
||||||
|
selector: { select: { options: entry.options } },
|
||||||
|
}
|
||||||
|
: entry.type === "string"
|
||||||
|
? entry.multiple
|
||||||
|
? {
|
||||||
|
name: entry.name,
|
||||||
|
required: entry.required,
|
||||||
|
selector: {
|
||||||
|
select: { options: [], multiple: true, custom_value: true },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
name: entry.name,
|
||||||
|
required: entry.required,
|
||||||
|
selector: {
|
||||||
|
text: {
|
||||||
|
type:
|
||||||
|
entry.format || MASKED_FIELDS.includes(entry.name)
|
||||||
|
? "password"
|
||||||
|
: "text",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: entry.type === "boolean"
|
||||||
|
? {
|
||||||
|
name: entry.name,
|
||||||
|
required: entry.required,
|
||||||
|
selector: { boolean: {} },
|
||||||
|
}
|
||||||
|
: entry.type === "schema"
|
||||||
|
? {
|
||||||
|
name: entry.name,
|
||||||
|
required: entry.required,
|
||||||
|
selector: { object: {} },
|
||||||
|
}
|
||||||
|
: entry.type === "float" || entry.type === "integer"
|
||||||
|
? {
|
||||||
|
name: entry.name,
|
||||||
|
required: entry.required,
|
||||||
|
selector: { number: { mode: "box" } },
|
||||||
|
}
|
||||||
|
: entry
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
private _filteredShchema = memoizeOne(
|
private _filteredShchema = memoizeOne(
|
||||||
@@ -106,7 +162,7 @@ class HassioAddonConfig extends LitElement {
|
|||||||
);
|
);
|
||||||
return html`
|
return html`
|
||||||
<h1>${this.addon.name}</h1>
|
<h1>${this.addon.name}</h1>
|
||||||
<ha-card>
|
<ha-card outlined>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h2>
|
<h2>
|
||||||
${this.supervisor.localize("addon.configuration.options.header")}
|
${this.supervisor.localize("addon.configuration.options.header")}
|
||||||
@@ -140,7 +196,8 @@ class HassioAddonConfig extends LitElement {
|
|||||||
.data=${this._options!}
|
.data=${this._options!}
|
||||||
@value-changed=${this._configChanged}
|
@value-changed=${this._configChanged}
|
||||||
.computeLabel=${this.computeLabel}
|
.computeLabel=${this.computeLabel}
|
||||||
.schema=${this._schema(
|
.computeHelper=${this.computeHelper}
|
||||||
|
.schema=${this._convertSchema(
|
||||||
this._showOptional
|
this._showOptional
|
||||||
? this.addon.schema!
|
? this.addon.schema!
|
||||||
: this._filteredShchema(
|
: this._filteredShchema(
|
||||||
@@ -197,8 +254,9 @@ class HassioAddonConfig extends LitElement {
|
|||||||
protected firstUpdated(changedProps) {
|
protected firstUpdated(changedProps) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
this._canShowSchema = !this.addon.schema!.find(
|
this._canShowSchema = !this.addon.schema!.find(
|
||||||
// @ts-ignore
|
(entry) =>
|
||||||
(entry) => !SUPPORTED_UI_TYPES.includes(entry.type) || entry.multiple
|
// @ts-ignore
|
||||||
|
!SUPPORTED_UI_TYPES.includes(entry.type)
|
||||||
);
|
);
|
||||||
this._yamlMode = !this._canShowSchema;
|
this._yamlMode = !this._canShowSchema;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
@@ -8,10 +7,13 @@ import {
|
|||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
|
import memoizeOne from "memoize-one";
|
||||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||||
import "../../../../src/components/buttons/ha-progress-button";
|
import "../../../../src/components/buttons/ha-progress-button";
|
||||||
import "../../../../src/components/ha-alert";
|
import "../../../../src/components/ha-alert";
|
||||||
import "../../../../src/components/ha-card";
|
import "../../../../src/components/ha-card";
|
||||||
|
import "../../../../src/components/ha-form/ha-form";
|
||||||
|
import type { HaFormSchema } from "../../../../src/components/ha-form/types";
|
||||||
import {
|
import {
|
||||||
HassioAddonDetails,
|
HassioAddonDetails,
|
||||||
HassioAddonSetOptionParams,
|
HassioAddonSetOptionParams,
|
||||||
@@ -24,16 +26,6 @@ import { HomeAssistant } from "../../../../src/types";
|
|||||||
import { suggestAddonRestart } from "../../dialogs/suggestAddonRestart";
|
import { suggestAddonRestart } from "../../dialogs/suggestAddonRestart";
|
||||||
import { hassioStyle } from "../../resources/hassio-style";
|
import { hassioStyle } from "../../resources/hassio-style";
|
||||||
|
|
||||||
interface NetworkItem {
|
|
||||||
description: string;
|
|
||||||
container: string;
|
|
||||||
host: number | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface NetworkItemInput extends PaperInputElement {
|
|
||||||
container: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@customElement("hassio-addon-network")
|
@customElement("hassio-addon-network")
|
||||||
class HassioAddonNetwork extends LitElement {
|
class HassioAddonNetwork extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
@@ -42,9 +34,13 @@ class HassioAddonNetwork extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public addon!: HassioAddonDetails;
|
@property({ attribute: false }) public addon!: HassioAddonDetails;
|
||||||
|
|
||||||
|
@state() private _showOptional = false;
|
||||||
|
|
||||||
|
@state() private _configHasChanged = false;
|
||||||
|
|
||||||
@state() private _error?: string;
|
@state() private _error?: string;
|
||||||
|
|
||||||
@state() private _config?: NetworkItem[];
|
@state() private _config?: Record<string, any>;
|
||||||
|
|
||||||
public connectedCallback(): void {
|
public connectedCallback(): void {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
@@ -56,59 +52,61 @@ class HassioAddonNetwork extends LitElement {
|
|||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasHiddenOptions = Object.keys(this._config).find(
|
||||||
|
(entry) => this._config![entry] === null
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-card
|
<ha-card
|
||||||
|
outlined
|
||||||
.header=${this.supervisor.localize(
|
.header=${this.supervisor.localize(
|
||||||
"addon.configuration.network.header"
|
"addon.configuration.network.header"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
<p>
|
||||||
|
${this.supervisor.localize(
|
||||||
|
"addon.configuration.network.introduction"
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
${this._error
|
${this._error
|
||||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||||
: ""}
|
: ""}
|
||||||
|
|
||||||
<table>
|
<ha-form
|
||||||
<tbody>
|
.data=${this._config}
|
||||||
<tr>
|
@value-changed=${this._configChanged}
|
||||||
<th>
|
.computeLabel=${this._computeLabel}
|
||||||
${this.supervisor.localize(
|
.computeHelper=${this._computeHelper}
|
||||||
"addon.configuration.network.container"
|
.schema=${this._createSchema(
|
||||||
)}
|
this._config,
|
||||||
</th>
|
this._showOptional,
|
||||||
<th>
|
this.hass.userData?.showAdvanced || false
|
||||||
${this.supervisor.localize(
|
)}
|
||||||
"addon.configuration.network.host"
|
></ha-form>
|
||||||
)}
|
|
||||||
</th>
|
|
||||||
<th>${this.supervisor.localize("common.description")}</th>
|
|
||||||
</tr>
|
|
||||||
${this._config!.map(
|
|
||||||
(item) => html`
|
|
||||||
<tr>
|
|
||||||
<td>${item.container}</td>
|
|
||||||
<td>
|
|
||||||
<paper-input
|
|
||||||
@value-changed=${this._configChanged}
|
|
||||||
placeholder=${this.supervisor.localize(
|
|
||||||
"addon.configuration.network.disabled"
|
|
||||||
)}
|
|
||||||
.value=${item.host ? String(item.host) : ""}
|
|
||||||
.container=${item.container}
|
|
||||||
no-label-float
|
|
||||||
></paper-input>
|
|
||||||
</td>
|
|
||||||
<td>${this._computeDescription(item)}</td>
|
|
||||||
</tr>
|
|
||||||
`
|
|
||||||
)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
|
${hasHiddenOptions
|
||||||
|
? html`<ha-formfield
|
||||||
|
class="show-optional"
|
||||||
|
.label=${this.supervisor.localize(
|
||||||
|
"addon.configuration.network.show_disabled"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<ha-switch
|
||||||
|
@change=${this._toggleOptional}
|
||||||
|
.checked=${this._showOptional}
|
||||||
|
>
|
||||||
|
</ha-switch>
|
||||||
|
</ha-formfield>`
|
||||||
|
: ""}
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<ha-progress-button class="warning" @click=${this._resetTapped}>
|
<ha-progress-button class="warning" @click=${this._resetTapped}>
|
||||||
${this.supervisor.localize("common.reset_defaults")}
|
${this.supervisor.localize("common.reset_defaults")}
|
||||||
</ha-progress-button>
|
</ha-progress-button>
|
||||||
<ha-progress-button @click=${this._saveTapped}>
|
<ha-progress-button
|
||||||
|
@click=${this._saveTapped}
|
||||||
|
.disabled=${!this._configHasChanged}
|
||||||
|
>
|
||||||
${this.supervisor.localize("common.save")}
|
${this.supervisor.localize("common.save")}
|
||||||
</ha-progress-button>
|
</ha-progress-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -123,50 +121,60 @@ class HassioAddonNetwork extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _computeDescription = (item: NetworkItem): string =>
|
private _createSchema = memoizeOne(
|
||||||
this.addon.translations[this.hass.language]?.network?.[item.container]
|
(
|
||||||
?.description ||
|
config: Record<string, number>,
|
||||||
this.addon.translations.en?.network?.[item.container]?.description ||
|
showOptional: boolean,
|
||||||
item.description;
|
advanced: boolean
|
||||||
|
): HaFormSchema[] =>
|
||||||
|
(showOptional
|
||||||
|
? Object.keys(config)
|
||||||
|
: Object.keys(config).filter((entry) => config[entry] !== null)
|
||||||
|
).map((entry) => ({
|
||||||
|
name: entry,
|
||||||
|
selector: {
|
||||||
|
number: {
|
||||||
|
mode: "box",
|
||||||
|
min: 0,
|
||||||
|
max: 65535,
|
||||||
|
unit_of_measurement: advanced ? entry : undefined,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
|
||||||
|
private _computeLabel = (_: HaFormSchema): string => "";
|
||||||
|
|
||||||
|
private _computeHelper = (item: HaFormSchema): string =>
|
||||||
|
this.addon.translations[this.hass.language]?.network?.[item.name] ||
|
||||||
|
this.addon.translations.en?.network?.[item.name] ||
|
||||||
|
this.addon.network_description?.[item.name] ||
|
||||||
|
item.name;
|
||||||
|
|
||||||
private _setNetworkConfig(): void {
|
private _setNetworkConfig(): void {
|
||||||
const network = this.addon.network || {};
|
this._config = this.addon.network || {};
|
||||||
const description = this.addon.network_description || {};
|
|
||||||
const items: NetworkItem[] = Object.keys(network).map((key) => ({
|
|
||||||
container: key,
|
|
||||||
host: network[key],
|
|
||||||
description: description[key],
|
|
||||||
}));
|
|
||||||
this._config = items.sort((a, b) => (a.container > b.container ? 1 : -1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _configChanged(ev: Event): Promise<void> {
|
private async _configChanged(ev: CustomEvent): Promise<void> {
|
||||||
const target = ev.target as NetworkItemInput;
|
this._configHasChanged = true;
|
||||||
this._config!.forEach((item) => {
|
this._config! = ev.detail.value;
|
||||||
if (
|
|
||||||
item.container === target.container &&
|
|
||||||
item.host !== parseInt(String(target.value), 10)
|
|
||||||
) {
|
|
||||||
item.host = target.value ? parseInt(String(target.value), 10) : null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _resetTapped(ev: CustomEvent): Promise<void> {
|
private async _resetTapped(ev: CustomEvent): Promise<void> {
|
||||||
const button = ev.currentTarget as any;
|
const button = ev.currentTarget as any;
|
||||||
button.progress = true;
|
|
||||||
|
|
||||||
const data: HassioAddonSetOptionParams = {
|
const data: HassioAddonSetOptionParams = {
|
||||||
network: null,
|
network: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await setHassioAddonOption(this.hass, this.addon.slug, data);
|
await setHassioAddonOption(this.hass, this.addon.slug, data);
|
||||||
|
this._configHasChanged = false;
|
||||||
const eventdata = {
|
const eventdata = {
|
||||||
success: true,
|
success: true,
|
||||||
response: undefined,
|
response: undefined,
|
||||||
path: "option",
|
path: "option",
|
||||||
};
|
};
|
||||||
|
button.actionSuccess();
|
||||||
fireEvent(this, "hass-api-called", eventdata);
|
fireEvent(this, "hass-api-called", eventdata);
|
||||||
if (this.addon?.state === "started") {
|
if (this.addon?.state === "started") {
|
||||||
await suggestAddonRestart(this, this.hass, this.supervisor, this.addon);
|
await suggestAddonRestart(this, this.hass, this.supervisor, this.addon);
|
||||||
@@ -177,19 +185,21 @@ class HassioAddonNetwork extends LitElement {
|
|||||||
"error",
|
"error",
|
||||||
extractApiErrorMessage(err)
|
extractApiErrorMessage(err)
|
||||||
);
|
);
|
||||||
|
button.actionError();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
button.progress = false;
|
private _toggleOptional() {
|
||||||
|
this._showOptional = !this._showOptional;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _saveTapped(ev: CustomEvent): Promise<void> {
|
private async _saveTapped(ev: CustomEvent): Promise<void> {
|
||||||
const button = ev.currentTarget as any;
|
const button = ev.currentTarget as any;
|
||||||
button.progress = true;
|
|
||||||
|
|
||||||
this._error = undefined;
|
this._error = undefined;
|
||||||
const networkconfiguration = {};
|
const networkconfiguration = {};
|
||||||
this._config!.forEach((item) => {
|
Object.entries(this._config!).forEach(([key, value]) => {
|
||||||
networkconfiguration[item.container] = parseInt(String(item.host), 10);
|
networkconfiguration[key] = value ?? null;
|
||||||
});
|
});
|
||||||
|
|
||||||
const data: HassioAddonSetOptionParams = {
|
const data: HassioAddonSetOptionParams = {
|
||||||
@@ -198,11 +208,13 @@ class HassioAddonNetwork extends LitElement {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await setHassioAddonOption(this.hass, this.addon.slug, data);
|
await setHassioAddonOption(this.hass, this.addon.slug, data);
|
||||||
|
this._configHasChanged = false;
|
||||||
const eventdata = {
|
const eventdata = {
|
||||||
success: true,
|
success: true,
|
||||||
response: undefined,
|
response: undefined,
|
||||||
path: "option",
|
path: "option",
|
||||||
};
|
};
|
||||||
|
button.actionSuccess();
|
||||||
fireEvent(this, "hass-api-called", eventdata);
|
fireEvent(this, "hass-api-called", eventdata);
|
||||||
if (this.addon?.state === "started") {
|
if (this.addon?.state === "started") {
|
||||||
await suggestAddonRestart(this, this.hass, this.supervisor, this.addon);
|
await suggestAddonRestart(this, this.hass, this.supervisor, this.addon);
|
||||||
@@ -213,8 +225,8 @@ class HassioAddonNetwork extends LitElement {
|
|||||||
"error",
|
"error",
|
||||||
extractApiErrorMessage(err)
|
extractApiErrorMessage(err)
|
||||||
);
|
);
|
||||||
|
button.actionError();
|
||||||
}
|
}
|
||||||
button.progress = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
@@ -232,6 +244,9 @@ class HassioAddonNetwork extends LitElement {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
.show-optional {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class HassioAddonDocumentationDashboard extends LitElement {
|
|||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<ha-card>
|
<ha-card outlined>
|
||||||
${this._error
|
${this._error
|
||||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||||
: ""}
|
: ""}
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ import {
|
|||||||
HassioAddonDetails,
|
HassioAddonDetails,
|
||||||
} from "../../../src/data/hassio/addon";
|
} from "../../../src/data/hassio/addon";
|
||||||
import { extractApiErrorMessage } from "../../../src/data/hassio/common";
|
import { extractApiErrorMessage } from "../../../src/data/hassio/common";
|
||||||
|
import { setSupervisorOption } from "../../../src/data/hassio/supervisor";
|
||||||
import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
||||||
|
import { showConfirmationDialog } from "../../../src/dialogs/generic/show-dialog-box";
|
||||||
import "../../../src/layouts/hass-error-screen";
|
import "../../../src/layouts/hass-error-screen";
|
||||||
import "../../../src/layouts/hass-loading-screen";
|
import "../../../src/layouts/hass-loading-screen";
|
||||||
import "../../../src/layouts/hass-tabs-subpage";
|
import "../../../src/layouts/hass-tabs-subpage";
|
||||||
@@ -166,6 +168,42 @@ class HassioAddonDashboard extends LitElement {
|
|||||||
protected async firstUpdated(): Promise<void> {
|
protected async firstUpdated(): Promise<void> {
|
||||||
if (this.route.path === "") {
|
if (this.route.path === "") {
|
||||||
const requestedAddon = extractSearchParam("addon");
|
const requestedAddon = extractSearchParam("addon");
|
||||||
|
const requestedAddonRepository = extractSearchParam("repository_url");
|
||||||
|
if (
|
||||||
|
requestedAddonRepository &&
|
||||||
|
!this.supervisor.supervisor.addons_repositories.find(
|
||||||
|
(repo) => repo === requestedAddonRepository
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
if (
|
||||||
|
!(await showConfirmationDialog(this, {
|
||||||
|
title: this.supervisor.localize("my.add_addon_repository_title"),
|
||||||
|
text: this.supervisor.localize(
|
||||||
|
"my.add_addon_repository_description",
|
||||||
|
{ addon: requestedAddon, repository: requestedAddonRepository }
|
||||||
|
),
|
||||||
|
confirmText: this.supervisor.localize("common.add"),
|
||||||
|
dismissText: this.supervisor.localize("common.cancel"),
|
||||||
|
}))
|
||||||
|
) {
|
||||||
|
this._error = this.supervisor.localize(
|
||||||
|
"my.error_repository_not_found"
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await setSupervisorOption(this.hass, {
|
||||||
|
addons_repositories: [
|
||||||
|
...this.supervisor.supervisor.addons_repositories,
|
||||||
|
requestedAddonRepository,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
} catch (err: any) {
|
||||||
|
this._error = extractApiErrorMessage(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (requestedAddon) {
|
if (requestedAddon) {
|
||||||
const addonsInfo = await fetchHassioAddonsInfo(this.hass);
|
const addonsInfo = await fetchHassioAddonsInfo(this.hass);
|
||||||
const validAddon = addonsInfo.addons.some(
|
const validAddon = addonsInfo.addons.some(
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ class HassioAddonInfo extends LitElement {
|
|||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
|
|
||||||
<ha-card>
|
<ha-card outlined>
|
||||||
<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 : ""}
|
||||||
@@ -649,7 +649,7 @@ class HassioAddonInfo extends LitElement {
|
|||||||
|
|
||||||
${this.addon.long_description
|
${this.addon.long_description
|
||||||
? html`
|
? html`
|
||||||
<ha-card>
|
<ha-card outlined>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<ha-markdown
|
<ha-markdown
|
||||||
.content=${this.addon.long_description}
|
.content=${this.addon.long_description}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import "@material/mwc-button";
|
|||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import "../../../../src/components/ha-alert";
|
import "../../../../src/components/ha-alert";
|
||||||
|
import "../../../../src/components/ha-ansi-to-html";
|
||||||
import "../../../../src/components/ha-card";
|
import "../../../../src/components/ha-card";
|
||||||
import {
|
import {
|
||||||
fetchHassioAddonLogs,
|
fetchHassioAddonLogs,
|
||||||
@@ -11,7 +12,6 @@ import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
|||||||
import { Supervisor } from "../../../../src/data/supervisor/supervisor";
|
import { Supervisor } from "../../../../src/data/supervisor/supervisor";
|
||||||
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-ansi-to-html";
|
|
||||||
import { hassioStyle } from "../../resources/hassio-style";
|
import { hassioStyle } from "../../resources/hassio-style";
|
||||||
|
|
||||||
@customElement("hassio-addon-logs")
|
@customElement("hassio-addon-logs")
|
||||||
@@ -34,15 +34,15 @@ class HassioAddonLogs extends LitElement {
|
|||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<h1>${this.addon.name}</h1>
|
<h1>${this.addon.name}</h1>
|
||||||
<ha-card>
|
<ha-card outlined>
|
||||||
${this._error
|
${this._error
|
||||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||||
: ""}
|
: ""}
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
${this._content
|
${this._content
|
||||||
? html`<hassio-ansi-to-html
|
? html`<ha-ansi-to-html
|
||||||
.content=${this._content}
|
.content=${this._content}
|
||||||
></hassio-ansi-to-html>`
|
></ha-ansi-to-html>`
|
||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import { ActionDetail } from "@material/mwc-list";
|
import { ActionDetail } from "@material/mwc-list";
|
||||||
import "@material/mwc-list/mwc-list-item";
|
import "@material/mwc-list/mwc-list-item";
|
||||||
import { mdiDelete, mdiDotsVertical, mdiPlus } from "@mdi/js";
|
import { mdiBackupRestore, mdiDelete, mdiDotsVertical, mdiPlus } from "@mdi/js";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
@@ -166,7 +166,15 @@ export class HassioBackups extends LitElement {
|
|||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<hass-tabs-subpage-data-table
|
<hass-tabs-subpage-data-table
|
||||||
.tabs=${supervisorTabs(this.hass)}
|
.tabs=${atLeastVersion(this.hass.config.version, 2022, 5)
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
translationKey: "panel.backups",
|
||||||
|
path: `/hassio/backups`,
|
||||||
|
iconPath: mdiBackupRestore,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: supervisorTabs(this.hass)}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.localizeFunc=${this.supervisor.localize}
|
.localizeFunc=${this.supervisor.localize}
|
||||||
.searchLabel=${this.supervisor.localize("search")}
|
.searchLabel=${this.supervisor.localize("search")}
|
||||||
@@ -182,7 +190,9 @@ export class HassioBackups extends LitElement {
|
|||||||
selectable
|
selectable
|
||||||
hasFab
|
hasFab
|
||||||
.mainPage=${!atLeastVersion(this.hass.config.version, 2021, 12)}
|
.mainPage=${!atLeastVersion(this.hass.config.version, 2021, 12)}
|
||||||
back-path="/config"
|
back-path=${atLeastVersion(this.hass.config.version, 2022, 5)
|
||||||
|
? "/config/system"
|
||||||
|
: "/config"}
|
||||||
supervisor
|
supervisor
|
||||||
>
|
>
|
||||||
<ha-button-menu
|
<ha-button-menu
|
||||||
|
|||||||
@@ -32,13 +32,6 @@ interface AddonCheckboxItem extends CheckboxItem {
|
|||||||
|
|
||||||
const _computeFolders = (folders): CheckboxItem[] => {
|
const _computeFolders = (folders): CheckboxItem[] => {
|
||||||
const list: CheckboxItem[] = [];
|
const list: CheckboxItem[] = [];
|
||||||
if (folders.includes("homeassistant")) {
|
|
||||||
list.push({
|
|
||||||
slug: "homeassistant",
|
|
||||||
name: "Home Assistant configuration",
|
|
||||||
checked: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (folders.includes("ssl")) {
|
if (folders.includes("ssl")) {
|
||||||
list.push({ slug: "ssl", name: "SSL", checked: false });
|
list.push({ slug: "ssl", name: "SSL", checked: false });
|
||||||
}
|
}
|
||||||
@@ -100,7 +93,7 @@ export class SupervisorBackupContent extends LitElement {
|
|||||||
this.folders = _computeFolders(
|
this.folders = _computeFolders(
|
||||||
this.backup
|
this.backup
|
||||||
? this.backup.folders
|
? this.backup.folders
|
||||||
: ["homeassistant", "ssl", "share", "media", "addons/local"]
|
: ["ssl", "share", "media", "addons/local"]
|
||||||
);
|
);
|
||||||
this.addons = _computeAddons(
|
this.addons = _computeAddons(
|
||||||
this.backup ? this.backup.addons : this.supervisor?.supervisor.addons
|
this.backup ? this.backup.addons : this.supervisor?.supervisor.addons
|
||||||
@@ -187,7 +180,7 @@ export class SupervisorBackupContent extends LitElement {
|
|||||||
>
|
>
|
||||||
<ha-checkbox
|
<ha-checkbox
|
||||||
.checked=${this.homeAssistant}
|
.checked=${this.homeAssistant}
|
||||||
@click=${this.toggleHomeAssistant}
|
@change=${this.toggleHomeAssistant}
|
||||||
>
|
>
|
||||||
</ha-checkbox>
|
</ha-checkbox>
|
||||||
</ha-formfield>
|
</ha-formfield>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class HassioAddons extends LitElement {
|
|||||||
<div class="card-group">
|
<div class="card-group">
|
||||||
${!this.supervisor.supervisor.addons?.length
|
${!this.supervisor.supervisor.addons?.length
|
||||||
? html`
|
? html`
|
||||||
<ha-card>
|
<ha-card outlined>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<button class="link" @click=${this._openStore}>
|
<button class="link" @click=${this._openStore}>
|
||||||
${this.supervisor.localize("dashboard.no_addons")}
|
${this.supervisor.localize("dashboard.no_addons")}
|
||||||
@@ -38,7 +38,11 @@ class HassioAddons extends LitElement {
|
|||||||
.sort((a, b) => caseInsensitiveStringCompare(a.name, b.name))
|
.sort((a, b) => caseInsensitiveStringCompare(a.name, b.name))
|
||||||
.map(
|
.map(
|
||||||
(addon) => html`
|
(addon) => html`
|
||||||
<ha-card .addon=${addon} @click=${this._addonTapped}>
|
<ha-card
|
||||||
|
outlined
|
||||||
|
.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}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { HomeAssistant, Route } from "../../../src/types";
|
|||||||
import { supervisorTabs } from "../hassio-tabs";
|
import { supervisorTabs } from "../hassio-tabs";
|
||||||
import "./hassio-addons";
|
import "./hassio-addons";
|
||||||
import "./hassio-update";
|
import "./hassio-update";
|
||||||
|
import "../../../src/layouts/hass-subpage";
|
||||||
|
|
||||||
@customElement("hassio-dashboard")
|
@customElement("hassio-dashboard")
|
||||||
class HassioDashboard extends LitElement {
|
class HassioDashboard extends LitElement {
|
||||||
@@ -22,6 +23,31 @@ class HassioDashboard extends LitElement {
|
|||||||
@property({ attribute: false }) public route!: Route;
|
@property({ attribute: false }) public route!: Route;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
|
if (atLeastVersion(this.hass.config.version, 2022, 5)) {
|
||||||
|
return html`<hass-subpage
|
||||||
|
.hass=${this.hass}
|
||||||
|
.narrow=${this.narrow}
|
||||||
|
.route=${this.route}
|
||||||
|
.header=${this.supervisor.localize("panel.addons")}
|
||||||
|
>
|
||||||
|
<hassio-addons
|
||||||
|
.hass=${this.hass}
|
||||||
|
.supervisor=${this.supervisor}
|
||||||
|
></hassio-addons>
|
||||||
|
<a href="/hassio/store">
|
||||||
|
<ha-fab
|
||||||
|
.label=${this.supervisor.localize("panel.store")}
|
||||||
|
extended
|
||||||
|
class="non-tabs"
|
||||||
|
>
|
||||||
|
<ha-svg-icon
|
||||||
|
slot="icon"
|
||||||
|
.path=${mdiStorePlus}
|
||||||
|
></ha-svg-icon> </ha-fab
|
||||||
|
></a>
|
||||||
|
</hass-subpage>`;
|
||||||
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hass-tabs-subpage
|
<hass-tabs-subpage
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -74,6 +100,12 @@ class HassioDashboard extends LitElement {
|
|||||||
.content {
|
.content {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
ha-fab.non-tabs {
|
||||||
|
position: fixed;
|
||||||
|
right: calc(16px + env(safe-area-inset-right));
|
||||||
|
bottom: calc(16px + env(safe-area-inset-bottom));
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export class HassioUpdate extends LitElement {
|
|||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<ha-card>
|
<ha-card outlined>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<ha-svg-icon .path=${mdiHomeAssistant}></ha-svg-icon>
|
<ha-svg-icon .path=${mdiHomeAssistant}></ha-svg-icon>
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { customElement, property } from "lit/decorators";
|
|||||||
import { atLeastVersion } from "../../src/common/config/version";
|
import { atLeastVersion } from "../../src/common/config/version";
|
||||||
import { applyThemesOnElement } from "../../src/common/dom/apply_themes_on_element";
|
import { applyThemesOnElement } from "../../src/common/dom/apply_themes_on_element";
|
||||||
import { fireEvent } from "../../src/common/dom/fire_event";
|
import { fireEvent } from "../../src/common/dom/fire_event";
|
||||||
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
|
|
||||||
import { mainWindow } from "../../src/common/dom/get_main_window";
|
import { mainWindow } from "../../src/common/dom/get_main_window";
|
||||||
|
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
|
||||||
import { navigate } from "../../src/common/navigate";
|
import { navigate } from "../../src/common/navigate";
|
||||||
import { HassioPanelInfo } from "../../src/data/hassio/supervisor";
|
import { HassioPanelInfo } from "../../src/data/hassio/supervisor";
|
||||||
import { Supervisor } from "../../src/data/supervisor/supervisor";
|
import { Supervisor } from "../../src/data/supervisor/supervisor";
|
||||||
@@ -73,6 +73,18 @@ export class HassioMain extends SupervisorBaseElement {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Forward keydown events to the main window for quickbar access
|
||||||
|
document.body.addEventListener("keydown", (ev: KeyboardEvent) => {
|
||||||
|
if (ev.altKey || ev.ctrlKey || ev.shiftKey || ev.metaKey) {
|
||||||
|
// Ignore if modifier keys are pressed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// @ts-ignore
|
||||||
|
fireEvent(mainWindow, "hass-quick-bar-trigger", ev, {
|
||||||
|
bubbles: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
makeDialogManager(this, this.shadowRoot!);
|
makeDialogManager(this, this.shadowRoot!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
} from "../../src/panels/my/ha-panel-my";
|
} from "../../src/panels/my/ha-panel-my";
|
||||||
import { HomeAssistant, Route } from "../../src/types";
|
import { HomeAssistant, Route } from "../../src/types";
|
||||||
|
|
||||||
const REDIRECTS: Redirects = {
|
export const REDIRECTS: Redirects = {
|
||||||
supervisor: {
|
supervisor: {
|
||||||
redirect: "/hassio/dashboard",
|
redirect: "/hassio/dashboard",
|
||||||
},
|
},
|
||||||
@@ -42,6 +42,9 @@ const REDIRECTS: Redirects = {
|
|||||||
params: {
|
params: {
|
||||||
addon: "string",
|
addon: "string",
|
||||||
},
|
},
|
||||||
|
optional_params: {
|
||||||
|
repository_url: "url",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
supervisor_ingress: {
|
supervisor_ingress: {
|
||||||
redirect: "/hassio/ingress",
|
redirect: "/hassio/ingress",
|
||||||
@@ -124,6 +127,14 @@ class HassioMyRedirect extends LitElement {
|
|||||||
}
|
}
|
||||||
resultParams[key] = params[key];
|
resultParams[key] = params[key];
|
||||||
});
|
});
|
||||||
|
Object.entries(redirect.optional_params || {}).forEach(([key, type]) => {
|
||||||
|
if (params[key]) {
|
||||||
|
if (!this._checkParamType(type, params[key])) {
|
||||||
|
throw Error();
|
||||||
|
}
|
||||||
|
resultParams[key] = params[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
return `?${createSearchParam(resultParams)}`;
|
return `?${createSearchParam(resultParams)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,24 +8,27 @@ import { atLeastVersion } from "../../src/common/config/version";
|
|||||||
import type { PageNavigation } from "../../src/layouts/hass-tabs-subpage";
|
import type { PageNavigation } from "../../src/layouts/hass-tabs-subpage";
|
||||||
import { HomeAssistant } from "../../src/types";
|
import { HomeAssistant } from "../../src/types";
|
||||||
|
|
||||||
export const supervisorTabs = (hass: HomeAssistant): PageNavigation[] => [
|
export const supervisorTabs = (hass: HomeAssistant): PageNavigation[] =>
|
||||||
{
|
atLeastVersion(hass.config.version, 2022, 5)
|
||||||
translationKey: atLeastVersion(hass.config.version, 2021, 12)
|
? []
|
||||||
? "panel.addons"
|
: [
|
||||||
: "panel.dashboard",
|
{
|
||||||
path: `/hassio/dashboard`,
|
translationKey: atLeastVersion(hass.config.version, 2021, 12)
|
||||||
iconPath: atLeastVersion(hass.config.version, 2021, 12)
|
? "panel.addons"
|
||||||
? mdiPuzzle
|
: "panel.dashboard",
|
||||||
: mdiViewDashboard,
|
path: `/hassio/dashboard`,
|
||||||
},
|
iconPath: atLeastVersion(hass.config.version, 2021, 12)
|
||||||
{
|
? mdiPuzzle
|
||||||
translationKey: "panel.backups",
|
: mdiViewDashboard,
|
||||||
path: `/hassio/backups`,
|
},
|
||||||
iconPath: mdiBackupRestore,
|
{
|
||||||
},
|
translationKey: "panel.backups",
|
||||||
{
|
path: `/hassio/backups`,
|
||||||
translationKey: "panel.system",
|
iconPath: mdiBackupRestore,
|
||||||
path: `/hassio/system`,
|
},
|
||||||
iconPath: mdiCogs,
|
{
|
||||||
},
|
translationKey: "panel.system",
|
||||||
];
|
path: `/hassio/system`,
|
||||||
|
iconPath: mdiCogs,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class HassioCoreInfo extends LitElement {
|
|||||||
];
|
];
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-card header="Core">
|
<ha-card header="Core" outlined>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div>
|
<div>
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class HassioHostInfo extends LitElement {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
return html`
|
return html`
|
||||||
<ha-card header="Host">
|
<ha-card header="Host" outlined>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div>
|
<div>
|
||||||
${this.supervisor.host.features.includes("hostname")
|
${this.supervisor.host.features.includes("hostname")
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ import {
|
|||||||
showAlertDialog,
|
showAlertDialog,
|
||||||
showConfirmationDialog,
|
showConfirmationDialog,
|
||||||
} from "../../../src/dialogs/generic/show-dialog-box";
|
} from "../../../src/dialogs/generic/show-dialog-box";
|
||||||
|
import {
|
||||||
|
UNHEALTHY_REASON_URL,
|
||||||
|
UNSUPPORTED_REASON_URL,
|
||||||
|
} from "../../../src/panels/config/system-health/ha-config-system-health";
|
||||||
import { haStyle } from "../../../src/resources/styles";
|
import { haStyle } from "../../../src/resources/styles";
|
||||||
import { HomeAssistant } from "../../../src/types";
|
import { HomeAssistant } from "../../../src/types";
|
||||||
import { bytesToString } from "../../../src/util/bytes-to-string";
|
import { bytesToString } from "../../../src/util/bytes-to-string";
|
||||||
@@ -30,11 +34,6 @@ import { documentationUrl } from "../../../src/util/documentation-url";
|
|||||||
import "../components/supervisor-metric";
|
import "../components/supervisor-metric";
|
||||||
import { hassioStyle } from "../resources/hassio-style";
|
import { hassioStyle } from "../resources/hassio-style";
|
||||||
|
|
||||||
const UNSUPPORTED_REASON_URL = {};
|
|
||||||
const UNHEALTHY_REASON_URL = {
|
|
||||||
privileged: "/more-info/unsupported/privileged",
|
|
||||||
};
|
|
||||||
|
|
||||||
@customElement("hassio-supervisor-info")
|
@customElement("hassio-supervisor-info")
|
||||||
class HassioSupervisorInfo extends LitElement {
|
class HassioSupervisorInfo extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
@@ -58,7 +57,7 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
return html`
|
return html`
|
||||||
<ha-card header="Supervisor">
|
<ha-card header="Supervisor" outlined>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div>
|
<div>
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import "../../../src/components/ha-ansi-to-html";
|
||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
@@ -11,7 +12,6 @@ import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
|||||||
import "../../../src/layouts/hass-loading-screen";
|
import "../../../src/layouts/hass-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 "../components/hassio-ansi-to-html";
|
|
||||||
import { hassioStyle } from "../resources/hassio-style";
|
import { hassioStyle } from "../resources/hassio-style";
|
||||||
|
|
||||||
interface LogProvider {
|
interface LogProvider {
|
||||||
@@ -65,7 +65,7 @@ class HassioSupervisorLog extends LitElement {
|
|||||||
|
|
||||||
protected render(): TemplateResult | void {
|
protected render(): TemplateResult | void {
|
||||||
return html`
|
return html`
|
||||||
<ha-card>
|
<ha-card outlined>
|
||||||
${this._error
|
${this._error
|
||||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||||
: ""}
|
: ""}
|
||||||
@@ -89,8 +89,8 @@ class HassioSupervisorLog extends LitElement {
|
|||||||
|
|
||||||
<div class="card-content" id="content">
|
<div class="card-content" id="content">
|
||||||
${this._content
|
${this._content
|
||||||
? html`<hassio-ansi-to-html .content=${this._content}>
|
? html`<ha-ansi-to-html .content=${this._content}>
|
||||||
</hassio-ansi-to-html>`
|
</ha-ansi-to-html>`
|
||||||
: html`<hass-loading-screen no-toolbar></hass-loading-screen>`}
|
: html`<hass-loading-screen no-toolbar></hass-loading-screen>`}
|
||||||
</div>
|
</div>
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ class UpdateAvailableCard extends LitElement {
|
|||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-card
|
<ha-card
|
||||||
|
outlined
|
||||||
.header=${this.supervisor.localize("update_available.update_name", {
|
.header=${this.supervisor.localize("update_available.update_name", {
|
||||||
name: this._name,
|
name: this._name,
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
"fuse.js": "^6.0.0",
|
"fuse.js": "^6.0.0",
|
||||||
"google-timezones-json": "^1.0.2",
|
"google-timezones-json": "^1.0.2",
|
||||||
"hls.js": "^1.1.5",
|
"hls.js": "^1.1.5",
|
||||||
"home-assistant-js-websocket": "^7.0.1",
|
"home-assistant-js-websocket": "^7.0.3",
|
||||||
"idb-keyval": "^5.1.3",
|
"idb-keyval": "^5.1.3",
|
||||||
"intl-messageformat": "^9.9.1",
|
"intl-messageformat": "^9.9.1",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ if [ -z $(which hass) ]; then
|
|||||||
echo "Installing Home Asstant core from dev."
|
echo "Installing Home Asstant core from dev."
|
||||||
python3 -m pip install --upgrade \
|
python3 -m pip install --upgrade \
|
||||||
colorlog \
|
colorlog \
|
||||||
git+git://github.com/home-assistant/home-assistant.git@dev
|
git+https://github.com/home-assistant/home-assistant.git@dev
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "${WD}/config" ]; then
|
if [ ! -d "${WD}/config" ]; then
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = home-assistant-frontend
|
name = home-assistant-frontend
|
||||||
version = 20220330.0
|
version = 20220504.0
|
||||||
author = The Home Assistant Authors
|
author = The Home Assistant Authors
|
||||||
author_email = hello@home-assistant.io
|
author_email = hello@home-assistant.io
|
||||||
license = Apache-2.0
|
license = Apache-2.0
|
||||||
|
|||||||
16
src/common/datetime/duration.ts
Normal file
16
src/common/datetime/duration.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import secondsToDuration from "./seconds_to_duration";
|
||||||
|
|
||||||
|
const DAY_IN_SECONDS = 86400;
|
||||||
|
const HOUR_IN_SECONDS = 3600;
|
||||||
|
const MINUTE_IN_SECONDS = 60;
|
||||||
|
|
||||||
|
export const UNIT_TO_SECOND_CONVERT = {
|
||||||
|
s: 1,
|
||||||
|
min: MINUTE_IN_SECONDS,
|
||||||
|
h: HOUR_IN_SECONDS,
|
||||||
|
d: DAY_IN_SECONDS,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const formatDuration = (duration: string, units: string): string =>
|
||||||
|
secondsToDuration(parseFloat(duration) * UNIT_TO_SECOND_CONVERT[units]) ||
|
||||||
|
"0";
|
||||||
@@ -12,7 +12,7 @@ export const isNavigationClick = (e: MouseEvent) => {
|
|||||||
|
|
||||||
const anchor = e
|
const anchor = e
|
||||||
.composedPath()
|
.composedPath()
|
||||||
.filter((n) => (n as HTMLElement).tagName === "A")[0] as
|
.find((n) => (n as HTMLElement).tagName === "A") as
|
||||||
| HTMLAnchorElement
|
| HTMLAnchorElement
|
||||||
| undefined;
|
| undefined;
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -29,8 +29,11 @@ import {
|
|||||||
mdiPowerPlug,
|
mdiPowerPlug,
|
||||||
mdiPowerPlugOff,
|
mdiPowerPlugOff,
|
||||||
mdiRadioboxBlank,
|
mdiRadioboxBlank,
|
||||||
mdiSmoke,
|
|
||||||
mdiSnowflake,
|
mdiSnowflake,
|
||||||
|
mdiSmokeDetector,
|
||||||
|
mdiSmokeDetectorAlert,
|
||||||
|
mdiSmokeDetectorVariant,
|
||||||
|
mdiSmokeDetectorVariantAlert,
|
||||||
mdiSquare,
|
mdiSquare,
|
||||||
mdiSquareOutline,
|
mdiSquareOutline,
|
||||||
mdiStop,
|
mdiStop,
|
||||||
@@ -52,6 +55,8 @@ export const binarySensorIcon = (state?: string, stateObj?: HassEntity) => {
|
|||||||
return is_off ? mdiBattery : mdiBatteryOutline;
|
return is_off ? mdiBattery : mdiBatteryOutline;
|
||||||
case "battery_charging":
|
case "battery_charging":
|
||||||
return is_off ? mdiBattery : mdiBatteryCharging;
|
return is_off ? mdiBattery : mdiBatteryCharging;
|
||||||
|
case "carbon_monoxide":
|
||||||
|
return is_off ? mdiSmokeDetector : mdiSmokeDetectorAlert;
|
||||||
case "cold":
|
case "cold":
|
||||||
return is_off ? mdiThermometer : mdiSnowflake;
|
return is_off ? mdiThermometer : mdiSnowflake;
|
||||||
case "connectivity":
|
case "connectivity":
|
||||||
@@ -68,7 +73,7 @@ export const binarySensorIcon = (state?: string, stateObj?: HassEntity) => {
|
|||||||
case "tamper":
|
case "tamper":
|
||||||
return is_off ? mdiCheckCircle : mdiAlertCircle;
|
return is_off ? mdiCheckCircle : mdiAlertCircle;
|
||||||
case "smoke":
|
case "smoke":
|
||||||
return is_off ? mdiCheckCircle : mdiSmoke;
|
return is_off ? mdiSmokeDetectorVariant : mdiSmokeDetectorVariantAlert;
|
||||||
case "heat":
|
case "heat":
|
||||||
return is_off ? mdiThermometer : mdiFire;
|
return is_off ? mdiThermometer : mdiFire;
|
||||||
case "light":
|
case "light":
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { formatNumber, isNumericState } from "../number/format_number";
|
|||||||
import { LocalizeFunc } from "../translations/localize";
|
import { LocalizeFunc } from "../translations/localize";
|
||||||
import { computeStateDomain } from "./compute_state_domain";
|
import { computeStateDomain } from "./compute_state_domain";
|
||||||
import { supportsFeature } from "./supports-feature";
|
import { supportsFeature } from "./supports-feature";
|
||||||
|
import { formatDuration, UNIT_TO_SECOND_CONVERT } from "../datetime/duration";
|
||||||
|
|
||||||
export const computeStateDisplay = (
|
export const computeStateDisplay = (
|
||||||
localize: LocalizeFunc,
|
localize: LocalizeFunc,
|
||||||
@@ -28,11 +29,27 @@ export const computeStateDisplay = (
|
|||||||
|
|
||||||
// Entities with a `unit_of_measurement` or `state_class` are numeric values and should use `formatNumber`
|
// Entities with a `unit_of_measurement` or `state_class` are numeric values and should use `formatNumber`
|
||||||
if (isNumericState(stateObj)) {
|
if (isNumericState(stateObj)) {
|
||||||
|
// state is duration
|
||||||
|
if (
|
||||||
|
stateObj.attributes.device_class === "duration" &&
|
||||||
|
stateObj.attributes.unit_of_measurement &&
|
||||||
|
UNIT_TO_SECOND_CONVERT[stateObj.attributes.unit_of_measurement]
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
return formatDuration(
|
||||||
|
compareState,
|
||||||
|
stateObj.attributes.unit_of_measurement
|
||||||
|
);
|
||||||
|
} catch (_err) {
|
||||||
|
// fallback to default
|
||||||
|
}
|
||||||
|
}
|
||||||
if (stateObj.attributes.device_class === "monetary") {
|
if (stateObj.attributes.device_class === "monetary") {
|
||||||
try {
|
try {
|
||||||
return formatNumber(compareState, locale, {
|
return formatNumber(compareState, locale, {
|
||||||
style: "currency",
|
style: "currency",
|
||||||
currency: stateObj.attributes.unit_of_measurement,
|
currency: stateObj.attributes.unit_of_measurement,
|
||||||
|
minimumFractionDigits: 2,
|
||||||
});
|
});
|
||||||
} catch (_err) {
|
} catch (_err) {
|
||||||
// fallback to default
|
// fallback to default
|
||||||
|
|||||||
@@ -8,26 +8,25 @@ import {
|
|||||||
mdiCalendar,
|
mdiCalendar,
|
||||||
mdiCast,
|
mdiCast,
|
||||||
mdiCastConnected,
|
mdiCastConnected,
|
||||||
|
mdiCheckCircleOutline,
|
||||||
mdiClock,
|
mdiClock,
|
||||||
|
mdiCloseCircleOutline,
|
||||||
mdiGestureTapButton,
|
mdiGestureTapButton,
|
||||||
mdiLanConnect,
|
mdiLanConnect,
|
||||||
mdiLanDisconnect,
|
mdiLanDisconnect,
|
||||||
mdiLightSwitch,
|
|
||||||
mdiLock,
|
mdiLock,
|
||||||
mdiLockAlert,
|
mdiLockAlert,
|
||||||
mdiLockClock,
|
mdiLockClock,
|
||||||
mdiLockOpen,
|
mdiLockOpen,
|
||||||
|
mdiPackage,
|
||||||
|
mdiPackageDown,
|
||||||
mdiPackageUp,
|
mdiPackageUp,
|
||||||
mdiPowerPlug,
|
mdiPowerPlug,
|
||||||
mdiPowerPlugOff,
|
mdiPowerPlugOff,
|
||||||
mdiRestart,
|
mdiRestart,
|
||||||
mdiToggleSwitch,
|
mdiToggleSwitchVariant,
|
||||||
mdiToggleSwitchOff,
|
mdiToggleSwitchVariantOff,
|
||||||
mdiCheckCircleOutline,
|
|
||||||
mdiCloseCircleOutline,
|
|
||||||
mdiWeatherNight,
|
mdiWeatherNight,
|
||||||
mdiPackage,
|
|
||||||
mdiPackageDown,
|
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { updateIsInstalling, UpdateEntity } from "../../data/update";
|
import { updateIsInstalling, UpdateEntity } from "../../data/update";
|
||||||
@@ -109,9 +108,11 @@ export const domainIcon = (
|
|||||||
case "outlet":
|
case "outlet":
|
||||||
return compareState === "on" ? mdiPowerPlug : mdiPowerPlugOff;
|
return compareState === "on" ? mdiPowerPlug : mdiPowerPlugOff;
|
||||||
case "switch":
|
case "switch":
|
||||||
return compareState === "on" ? mdiToggleSwitch : mdiToggleSwitchOff;
|
return compareState === "on"
|
||||||
|
? mdiToggleSwitchVariant
|
||||||
|
: mdiToggleSwitchVariantOff;
|
||||||
default:
|
default:
|
||||||
return mdiLightSwitch;
|
return mdiToggleSwitchVariant;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "sensor": {
|
case "sensor": {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export const promiseTimeout = (ms: number, promise: Promise<any>) => {
|
export const promiseTimeout = (ms: number, promise: Promise<any> | any) => {
|
||||||
const timeout = new Promise((_resolve, reject) => {
|
const timeout = new Promise((_resolve, reject) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
reject(`Timed out in ${ms} ms.`);
|
reject(`Timed out in ${ms} ms.`);
|
||||||
|
|||||||
18
src/common/util/subscribe-polling.ts
Normal file
18
src/common/util/subscribe-polling.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { HomeAssistant } from "../../types";
|
||||||
|
|
||||||
|
export const subscribePollingCollection = (
|
||||||
|
hass: HomeAssistant,
|
||||||
|
updateData: (hass: HomeAssistant) => void,
|
||||||
|
interval: number
|
||||||
|
) => {
|
||||||
|
let timeout;
|
||||||
|
const fetchData = async () => {
|
||||||
|
try {
|
||||||
|
await updateData(hass);
|
||||||
|
} finally {
|
||||||
|
timeout = setTimeout(() => fetchData(), interval);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchData();
|
||||||
|
return () => clearTimeout(timeout);
|
||||||
|
};
|
||||||
@@ -347,8 +347,8 @@ class StatisticsChart extends LitElement {
|
|||||||
statTypes.forEach((type) => {
|
statTypes.forEach((type) => {
|
||||||
let val: number | null;
|
let val: number | null;
|
||||||
if (type === "sum") {
|
if (type === "sum") {
|
||||||
if (!initVal) {
|
if (initVal === null) {
|
||||||
initVal = val = stat.state;
|
initVal = val = stat.state || 0;
|
||||||
prevSum = stat.sum;
|
prevSum = stat.sum;
|
||||||
} else {
|
} else {
|
||||||
val = initVal + ((stat.sum || 0) - prevSum!);
|
val = initVal + ((stat.sum || 0) - prevSum!);
|
||||||
|
|||||||
@@ -1,165 +1,167 @@
|
|||||||
|
export const currencies = [
|
||||||
|
"AED",
|
||||||
|
"AFN",
|
||||||
|
"ALL",
|
||||||
|
"AMD",
|
||||||
|
"ANG",
|
||||||
|
"AOA",
|
||||||
|
"ARS",
|
||||||
|
"AUD",
|
||||||
|
"AWG",
|
||||||
|
"AZN",
|
||||||
|
"BAM",
|
||||||
|
"BBD",
|
||||||
|
"BDT",
|
||||||
|
"BGN",
|
||||||
|
"BHD",
|
||||||
|
"BIF",
|
||||||
|
"BMD",
|
||||||
|
"BND",
|
||||||
|
"BOB",
|
||||||
|
"BRL",
|
||||||
|
"BSD",
|
||||||
|
"BTN",
|
||||||
|
"BWP",
|
||||||
|
"BYN",
|
||||||
|
"BYR",
|
||||||
|
"BZD",
|
||||||
|
"CAD",
|
||||||
|
"CDF",
|
||||||
|
"CHF",
|
||||||
|
"CLP",
|
||||||
|
"CNY",
|
||||||
|
"COP",
|
||||||
|
"CRC",
|
||||||
|
"CUP",
|
||||||
|
"CVE",
|
||||||
|
"CZK",
|
||||||
|
"DJF",
|
||||||
|
"DKK",
|
||||||
|
"DOP",
|
||||||
|
"DZD",
|
||||||
|
"EGP",
|
||||||
|
"ERN",
|
||||||
|
"ETB",
|
||||||
|
"EUR",
|
||||||
|
"FJD",
|
||||||
|
"FKP",
|
||||||
|
"GBP",
|
||||||
|
"GEL",
|
||||||
|
"GHS",
|
||||||
|
"GIP",
|
||||||
|
"GMD",
|
||||||
|
"GNF",
|
||||||
|
"GTQ",
|
||||||
|
"GYD",
|
||||||
|
"HKD",
|
||||||
|
"HNL",
|
||||||
|
"HRK",
|
||||||
|
"HTG",
|
||||||
|
"HUF",
|
||||||
|
"IDR",
|
||||||
|
"ILS",
|
||||||
|
"INR",
|
||||||
|
"IQD",
|
||||||
|
"IRR",
|
||||||
|
"ISK",
|
||||||
|
"JMD",
|
||||||
|
"JOD",
|
||||||
|
"JPY",
|
||||||
|
"KES",
|
||||||
|
"KGS",
|
||||||
|
"KHR",
|
||||||
|
"KMF",
|
||||||
|
"KPW",
|
||||||
|
"KRW",
|
||||||
|
"KWD",
|
||||||
|
"KYD",
|
||||||
|
"KZT",
|
||||||
|
"LAK",
|
||||||
|
"LBP",
|
||||||
|
"LKR",
|
||||||
|
"LRD",
|
||||||
|
"LSL",
|
||||||
|
"LTL",
|
||||||
|
"LYD",
|
||||||
|
"MAD",
|
||||||
|
"MDL",
|
||||||
|
"MGA",
|
||||||
|
"MKD",
|
||||||
|
"MMK",
|
||||||
|
"MNT",
|
||||||
|
"MOP",
|
||||||
|
"MRO",
|
||||||
|
"MUR",
|
||||||
|
"MVR",
|
||||||
|
"MWK",
|
||||||
|
"MXN",
|
||||||
|
"MYR",
|
||||||
|
"MZN",
|
||||||
|
"NAD",
|
||||||
|
"NGN",
|
||||||
|
"NIO",
|
||||||
|
"NOK",
|
||||||
|
"NPR",
|
||||||
|
"NZD",
|
||||||
|
"OMR",
|
||||||
|
"PAB",
|
||||||
|
"PEN",
|
||||||
|
"PGK",
|
||||||
|
"PHP",
|
||||||
|
"PKR",
|
||||||
|
"PLN",
|
||||||
|
"PYG",
|
||||||
|
"QAR",
|
||||||
|
"RON",
|
||||||
|
"RSD",
|
||||||
|
"RUB",
|
||||||
|
"RWF",
|
||||||
|
"SAR",
|
||||||
|
"SBD",
|
||||||
|
"SCR",
|
||||||
|
"SDG",
|
||||||
|
"SEK",
|
||||||
|
"SGD",
|
||||||
|
"SHP",
|
||||||
|
"SLL",
|
||||||
|
"SOS",
|
||||||
|
"SRD",
|
||||||
|
"SSP",
|
||||||
|
"STD",
|
||||||
|
"SYP",
|
||||||
|
"SZL",
|
||||||
|
"THB",
|
||||||
|
"TJS",
|
||||||
|
"TMT",
|
||||||
|
"TND",
|
||||||
|
"TOP",
|
||||||
|
"TRY",
|
||||||
|
"TTD",
|
||||||
|
"TWD",
|
||||||
|
"TZS",
|
||||||
|
"UAH",
|
||||||
|
"UGX",
|
||||||
|
"USD",
|
||||||
|
"UYU",
|
||||||
|
"UZS",
|
||||||
|
"VEF",
|
||||||
|
"VND",
|
||||||
|
"VUV",
|
||||||
|
"WST",
|
||||||
|
"XAF",
|
||||||
|
"XCD",
|
||||||
|
"XOF",
|
||||||
|
"XPF",
|
||||||
|
"YER",
|
||||||
|
"ZAR",
|
||||||
|
"ZMK",
|
||||||
|
"ZWL",
|
||||||
|
];
|
||||||
|
|
||||||
export const createCurrencyListEl = () => {
|
export const createCurrencyListEl = () => {
|
||||||
const list = document.createElement("datalist");
|
const list = document.createElement("datalist");
|
||||||
list.id = "currencies";
|
list.id = "currencies";
|
||||||
for (const currency of [
|
for (const currency of currencies) {
|
||||||
"AED",
|
|
||||||
"AFN",
|
|
||||||
"ALL",
|
|
||||||
"AMD",
|
|
||||||
"ANG",
|
|
||||||
"AOA",
|
|
||||||
"ARS",
|
|
||||||
"AUD",
|
|
||||||
"AWG",
|
|
||||||
"AZN",
|
|
||||||
"BAM",
|
|
||||||
"BBD",
|
|
||||||
"BDT",
|
|
||||||
"BGN",
|
|
||||||
"BHD",
|
|
||||||
"BIF",
|
|
||||||
"BMD",
|
|
||||||
"BND",
|
|
||||||
"BOB",
|
|
||||||
"BRL",
|
|
||||||
"BSD",
|
|
||||||
"BTN",
|
|
||||||
"BWP",
|
|
||||||
"BYN",
|
|
||||||
"BYR",
|
|
||||||
"BZD",
|
|
||||||
"CAD",
|
|
||||||
"CDF",
|
|
||||||
"CHF",
|
|
||||||
"CLP",
|
|
||||||
"CNY",
|
|
||||||
"COP",
|
|
||||||
"CRC",
|
|
||||||
"CUP",
|
|
||||||
"CVE",
|
|
||||||
"CZK",
|
|
||||||
"DJF",
|
|
||||||
"DKK",
|
|
||||||
"DOP",
|
|
||||||
"DZD",
|
|
||||||
"EGP",
|
|
||||||
"ERN",
|
|
||||||
"ETB",
|
|
||||||
"EUR",
|
|
||||||
"FJD",
|
|
||||||
"FKP",
|
|
||||||
"GBP",
|
|
||||||
"GEL",
|
|
||||||
"GHS",
|
|
||||||
"GIP",
|
|
||||||
"GMD",
|
|
||||||
"GNF",
|
|
||||||
"GTQ",
|
|
||||||
"GYD",
|
|
||||||
"HKD",
|
|
||||||
"HNL",
|
|
||||||
"HRK",
|
|
||||||
"HTG",
|
|
||||||
"HUF",
|
|
||||||
"IDR",
|
|
||||||
"ILS",
|
|
||||||
"INR",
|
|
||||||
"IQD",
|
|
||||||
"IRR",
|
|
||||||
"ISK",
|
|
||||||
"JMD",
|
|
||||||
"JOD",
|
|
||||||
"JPY",
|
|
||||||
"KES",
|
|
||||||
"KGS",
|
|
||||||
"KHR",
|
|
||||||
"KMF",
|
|
||||||
"KPW",
|
|
||||||
"KRW",
|
|
||||||
"KWD",
|
|
||||||
"KYD",
|
|
||||||
"KZT",
|
|
||||||
"LAK",
|
|
||||||
"LBP",
|
|
||||||
"LKR",
|
|
||||||
"LRD",
|
|
||||||
"LSL",
|
|
||||||
"LTL",
|
|
||||||
"LYD",
|
|
||||||
"MAD",
|
|
||||||
"MDL",
|
|
||||||
"MGA",
|
|
||||||
"MKD",
|
|
||||||
"MMK",
|
|
||||||
"MNT",
|
|
||||||
"MOP",
|
|
||||||
"MRO",
|
|
||||||
"MUR",
|
|
||||||
"MVR",
|
|
||||||
"MWK",
|
|
||||||
"MXN",
|
|
||||||
"MYR",
|
|
||||||
"MZN",
|
|
||||||
"NAD",
|
|
||||||
"NGN",
|
|
||||||
"NIO",
|
|
||||||
"NOK",
|
|
||||||
"NPR",
|
|
||||||
"NZD",
|
|
||||||
"OMR",
|
|
||||||
"PAB",
|
|
||||||
"PEN",
|
|
||||||
"PGK",
|
|
||||||
"PHP",
|
|
||||||
"PKR",
|
|
||||||
"PLN",
|
|
||||||
"PYG",
|
|
||||||
"QAR",
|
|
||||||
"RON",
|
|
||||||
"RSD",
|
|
||||||
"RUB",
|
|
||||||
"RWF",
|
|
||||||
"SAR",
|
|
||||||
"SBD",
|
|
||||||
"SCR",
|
|
||||||
"SDG",
|
|
||||||
"SEK",
|
|
||||||
"SGD",
|
|
||||||
"SHP",
|
|
||||||
"SLL",
|
|
||||||
"SOS",
|
|
||||||
"SRD",
|
|
||||||
"SSP",
|
|
||||||
"STD",
|
|
||||||
"SYP",
|
|
||||||
"SZL",
|
|
||||||
"THB",
|
|
||||||
"TJS",
|
|
||||||
"TMT",
|
|
||||||
"TND",
|
|
||||||
"TOP",
|
|
||||||
"TRY",
|
|
||||||
"TTD",
|
|
||||||
"TWD",
|
|
||||||
"TZS",
|
|
||||||
"UAH",
|
|
||||||
"UGX",
|
|
||||||
"USD",
|
|
||||||
"UYU",
|
|
||||||
"UZS",
|
|
||||||
"VEF",
|
|
||||||
"VND",
|
|
||||||
"VUV",
|
|
||||||
"WST",
|
|
||||||
"XAF",
|
|
||||||
"XCD",
|
|
||||||
"XOF",
|
|
||||||
"XPF",
|
|
||||||
"YER",
|
|
||||||
"ZAR",
|
|
||||||
"ZMK",
|
|
||||||
"ZWL",
|
|
||||||
]) {
|
|
||||||
const option = document.createElement("option");
|
const option = document.createElement("option");
|
||||||
option.value = currency;
|
option.value = currency;
|
||||||
option.innerHTML = currency;
|
option.innerHTML = currency;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { fireEvent } from "../../common/dom/fire_event";
|
|||||||
import {
|
import {
|
||||||
DeviceAutomation,
|
DeviceAutomation,
|
||||||
deviceAutomationsEqual,
|
deviceAutomationsEqual,
|
||||||
|
sortDeviceAutomations,
|
||||||
} from "../../data/device_automation";
|
} from "../../data/device_automation";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import "../ha-select";
|
import "../ha-select";
|
||||||
@@ -127,7 +128,9 @@ export abstract class HaDeviceAutomationPicker<
|
|||||||
|
|
||||||
private async _updateDeviceInfo() {
|
private async _updateDeviceInfo() {
|
||||||
this._automations = this.deviceId
|
this._automations = this.deviceId
|
||||||
? await this._fetchDeviceAutomations(this.hass, this.deviceId)
|
? (await this._fetchDeviceAutomations(this.hass, this.deviceId)).sort(
|
||||||
|
sortDeviceAutomations
|
||||||
|
)
|
||||||
: // No device, clear the list of automations
|
: // No device, clear the list of automations
|
||||||
[];
|
[];
|
||||||
|
|
||||||
@@ -161,8 +164,9 @@ export abstract class HaDeviceAutomationPicker<
|
|||||||
if (this.value && deviceAutomationsEqual(automation, this.value)) {
|
if (this.value && deviceAutomationsEqual(automation, this.value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fireEvent(this, "change");
|
const value = { ...automation };
|
||||||
fireEvent(this, "value-changed", { value: automation });
|
delete value.metadata;
|
||||||
|
fireEvent(this, "value-changed", { value });
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
@property() public value?: string;
|
@property() public value?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property() public devices?: DeviceRegistryEntry[];
|
@property() public devices?: DeviceRegistryEntry[];
|
||||||
|
|
||||||
@property() public areas?: AreaRegistryEntry[];
|
@property() public areas?: AreaRegistryEntry[];
|
||||||
@@ -196,9 +198,10 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
this.hass,
|
this.hass,
|
||||||
deviceEntityLookup[device.id]
|
deviceEntityLookup[device.id]
|
||||||
),
|
),
|
||||||
area: device.area_id
|
area:
|
||||||
? areaLookup[device.area_id].name
|
device.area_id && areaLookup[device.area_id]
|
||||||
: this.hass.localize("ui.components.device-picker.no_area"),
|
? areaLookup[device.area_id].name
|
||||||
|
: this.hass.localize("ui.components.device-picker.no_area"),
|
||||||
}));
|
}));
|
||||||
if (!outputDevices.length) {
|
if (!outputDevices.length) {
|
||||||
return [
|
return [
|
||||||
@@ -269,6 +272,7 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
? this.hass.localize("ui.components.device-picker.device")
|
? this.hass.localize("ui.components.device-picker.device")
|
||||||
: this.label}
|
: this.label}
|
||||||
.value=${this._value}
|
.value=${this._value}
|
||||||
|
.helper=${this.helper}
|
||||||
.renderer=${rowRenderer}
|
.renderer=${rowRenderer}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { fireEvent } from "../../common/dom/fire_event";
|
|||||||
import { PolymerChangedEvent } from "../../polymer-types";
|
import { PolymerChangedEvent } from "../../polymer-types";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import "./ha-device-picker";
|
import "./ha-device-picker";
|
||||||
|
import type { HaDevicePickerDeviceFilterFunc } from "./ha-device-picker";
|
||||||
|
|
||||||
@customElement("ha-devices-picker")
|
@customElement("ha-devices-picker")
|
||||||
class HaDevicesPicker extends LitElement {
|
class HaDevicesPicker extends LitElement {
|
||||||
@@ -11,6 +12,10 @@ class HaDevicesPicker extends LitElement {
|
|||||||
|
|
||||||
@property() public value?: string[];
|
@property() public value?: string[];
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public disabled?: boolean;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required?: boolean;
|
@property({ type: Boolean }) public required?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,6 +42,8 @@ class HaDevicesPicker extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: "pick-device-label" }) public pickDeviceLabel?: string;
|
@property({ attribute: "pick-device-label" }) public pickDeviceLabel?: string;
|
||||||
|
|
||||||
|
@property() public deviceFilter?: HaDevicePickerDeviceFilterFunc;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
if (!this.hass) {
|
if (!this.hass) {
|
||||||
return html``;
|
return html``;
|
||||||
@@ -51,11 +58,13 @@ class HaDevicesPicker extends LitElement {
|
|||||||
allow-custom-entity
|
allow-custom-entity
|
||||||
.curValue=${entityId}
|
.curValue=${entityId}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
|
.deviceFilter=${this.deviceFilter}
|
||||||
.includeDomains=${this.includeDomains}
|
.includeDomains=${this.includeDomains}
|
||||||
.excludeDomains=${this.excludeDomains}
|
.excludeDomains=${this.excludeDomains}
|
||||||
.includeDeviceClasses=${this.includeDeviceClasses}
|
.includeDeviceClasses=${this.includeDeviceClasses}
|
||||||
.value=${entityId}
|
.value=${entityId}
|
||||||
.label=${this.pickedDeviceLabel}
|
.label=${this.pickedDeviceLabel}
|
||||||
|
.disabled=${this.disabled}
|
||||||
@value-changed=${this._deviceChanged}
|
@value-changed=${this._deviceChanged}
|
||||||
></ha-device-picker>
|
></ha-device-picker>
|
||||||
</div>
|
</div>
|
||||||
@@ -63,12 +72,16 @@ class HaDevicesPicker extends LitElement {
|
|||||||
)}
|
)}
|
||||||
<div>
|
<div>
|
||||||
<ha-device-picker
|
<ha-device-picker
|
||||||
|
allow-custom-entity
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
|
.helper=${this.helper}
|
||||||
|
.deviceFilter=${this.deviceFilter}
|
||||||
.includeDomains=${this.includeDomains}
|
.includeDomains=${this.includeDomains}
|
||||||
.excludeDomains=${this.excludeDomains}
|
.excludeDomains=${this.excludeDomains}
|
||||||
.includeDeviceClasses=${this.includeDeviceClasses}
|
.includeDeviceClasses=${this.includeDeviceClasses}
|
||||||
.label=${this.pickDeviceLabel}
|
.label=${this.pickDeviceLabel}
|
||||||
.required=${this.required}
|
.disabled=${this.disabled}
|
||||||
|
.required=${this.required && !currentDevices.length}
|
||||||
@value-changed=${this._addDevice}
|
@value-changed=${this._addDevice}
|
||||||
></ha-device-picker>
|
></ha-device-picker>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,8 +14,12 @@ class HaEntitiesPickerLight extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Array }) public value?: string[];
|
@property({ type: Array }) public value?: string[];
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public disabled?: boolean;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required?: boolean;
|
@property({ type: Boolean }) public required?: boolean;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show entities from specific domains.
|
* Show entities from specific domains.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@@ -94,6 +98,7 @@ class HaEntitiesPickerLight extends LitElement {
|
|||||||
.entityFilter=${this._entityFilter}
|
.entityFilter=${this._entityFilter}
|
||||||
.value=${entityId}
|
.value=${entityId}
|
||||||
.label=${this.pickedEntityLabel}
|
.label=${this.pickedEntityLabel}
|
||||||
|
.disabled=${this.disabled}
|
||||||
@value-changed=${this._entityChanged}
|
@value-changed=${this._entityChanged}
|
||||||
></ha-entity-picker>
|
></ha-entity-picker>
|
||||||
</div>
|
</div>
|
||||||
@@ -101,6 +106,7 @@ class HaEntitiesPickerLight extends LitElement {
|
|||||||
)}
|
)}
|
||||||
<div>
|
<div>
|
||||||
<ha-entity-picker
|
<ha-entity-picker
|
||||||
|
allow-custom-entity
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.includeDomains=${this.includeDomains}
|
.includeDomains=${this.includeDomains}
|
||||||
.excludeDomains=${this.excludeDomains}
|
.excludeDomains=${this.excludeDomains}
|
||||||
@@ -110,7 +116,9 @@ class HaEntitiesPickerLight extends LitElement {
|
|||||||
.includeUnitOfMeasurement=${this.includeUnitOfMeasurement}
|
.includeUnitOfMeasurement=${this.includeUnitOfMeasurement}
|
||||||
.entityFilter=${this._entityFilter}
|
.entityFilter=${this._entityFilter}
|
||||||
.label=${this.pickEntityLabel}
|
.label=${this.pickEntityLabel}
|
||||||
.required=${this.required}
|
.helper=${this.helper}
|
||||||
|
.disabled=${this.disabled}
|
||||||
|
.required=${this.required && !currentEntities.length}
|
||||||
@value-changed=${this._addEntity}
|
@value-changed=${this._addEntity}
|
||||||
></ha-entity-picker>
|
></ha-entity-picker>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ class HaEntityAttributePicker extends LitElement {
|
|||||||
|
|
||||||
@property() public value?: string;
|
@property() public value?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean }) private _opened = false;
|
@property({ type: Boolean }) private _opened = false;
|
||||||
|
|
||||||
@query("ha-combo-box", true) private _comboBox!: HaComboBox;
|
@query("ha-combo-box", true) private _comboBox!: HaComboBox;
|
||||||
@@ -64,6 +66,7 @@ class HaEntityAttributePicker extends LitElement {
|
|||||||
)}
|
)}
|
||||||
.disabled=${this.disabled || !this.entityId}
|
.disabled=${this.disabled || !this.entityId}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
|
.helper=${this.helper}
|
||||||
.allowCustomValue=${this.allowCustomValue}
|
.allowCustomValue=${this.allowCustomValue}
|
||||||
item-value-path="value"
|
item-value-path="value"
|
||||||
item-label-path="label"
|
item-label-path="label"
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ export class HaEntityPicker extends LitElement {
|
|||||||
|
|
||||||
@property() public value?: string;
|
@property() public value?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show entities from specific domains.
|
* Show entities from specific domains.
|
||||||
* @type {Array}
|
* @type {Array}
|
||||||
@@ -304,6 +306,7 @@ export class HaEntityPicker extends LitElement {
|
|||||||
.label=${this.label === undefined
|
.label=${this.label === undefined
|
||||||
? this.hass.localize("ui.components.entity.entity-picker.entity")
|
? this.hass.localize("ui.components.entity.entity-picker.entity")
|
||||||
: this.label}
|
: this.label}
|
||||||
|
.helper=${this.helper}
|
||||||
.allowCustomValue=${this.allowCustomEntity}
|
.allowCustomValue=${this.allowCustomEntity}
|
||||||
.filteredItems=${this._states}
|
.filteredItems=${this._states}
|
||||||
.renderer=${rowRenderer}
|
.renderer=${rowRenderer}
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class HaAddonPicker extends LitElement {
|
|||||||
|
|
||||||
@property() public value = "";
|
@property() public value = "";
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@state() private _addons?: HassioAddonInfo[];
|
@state() private _addons?: HassioAddonInfo[];
|
||||||
|
|
||||||
@property({ type: Boolean }) public disabled = false;
|
@property({ type: Boolean }) public disabled = false;
|
||||||
@@ -62,6 +64,7 @@ class HaAddonPicker extends LitElement {
|
|||||||
.value=${this._value}
|
.value=${this._value}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
|
.helper=${this.helper}
|
||||||
.renderer=${rowRenderer}
|
.renderer=${rowRenderer}
|
||||||
.items=${this._addons}
|
.items=${this._addons}
|
||||||
item-value-path="slug"
|
item-value-path="slug"
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import "@polymer/paper-tooltip/paper-tooltip";
|
|||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import { Analytics, AnalyticsPreferences } from "../data/analytics";
|
import type { Analytics, AnalyticsPreferences } from "../data/analytics";
|
||||||
import { haStyle } from "../resources/styles";
|
import { haStyle } from "../resources/styles";
|
||||||
import { HomeAssistant } from "../types";
|
import type { HomeAssistant } from "../types";
|
||||||
import "./ha-checkbox";
|
|
||||||
import type { HaCheckbox } from "./ha-checkbox";
|
|
||||||
import "./ha-settings-row";
|
import "./ha-settings-row";
|
||||||
|
import "./ha-switch";
|
||||||
|
import type { HaSwitch } from "./ha-switch";
|
||||||
|
|
||||||
const ADDITIONAL_PREFERENCES = [
|
const ADDITIONAL_PREFERENCES = [
|
||||||
{
|
{
|
||||||
@@ -40,62 +40,62 @@ export class HaAnalytics extends LitElement {
|
|||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
<span slot="prefix">
|
|
||||||
<ha-checkbox
|
|
||||||
@change=${this._handleRowCheckboxClick}
|
|
||||||
.checked=${baseEnabled}
|
|
||||||
.preference=${"base"}
|
|
||||||
.disabled=${loading}
|
|
||||||
name="base"
|
|
||||||
>
|
|
||||||
</ha-checkbox>
|
|
||||||
</span>
|
|
||||||
<span slot="heading" data-for="base"> Basic analytics </span>
|
<span slot="heading" data-for="base"> Basic analytics </span>
|
||||||
<span slot="description" data-for="base">
|
<span slot="description" data-for="base">
|
||||||
This includes information about your system.
|
This includes information about your system.
|
||||||
</span>
|
</span>
|
||||||
|
<ha-switch
|
||||||
|
@change=${this._handleRowClick}
|
||||||
|
.checked=${baseEnabled}
|
||||||
|
.preference=${"base"}
|
||||||
|
.disabled=${loading}
|
||||||
|
name="base"
|
||||||
|
>
|
||||||
|
</ha-switch>
|
||||||
</ha-settings-row>
|
</ha-settings-row>
|
||||||
${ADDITIONAL_PREFERENCES.map(
|
${ADDITIONAL_PREFERENCES.map(
|
||||||
(preference) =>
|
(preference) =>
|
||||||
html`<ha-settings-row>
|
html`
|
||||||
<span slot="prefix">
|
<ha-settings-row>
|
||||||
<ha-checkbox
|
<span slot="heading" data-for=${preference.key}>
|
||||||
@change=${this._handleRowCheckboxClick}
|
${preference.title}
|
||||||
.checked=${this.analytics?.preferences[preference.key]}
|
</span>
|
||||||
.preference=${preference.key}
|
<span slot="description" data-for=${preference.key}>
|
||||||
name=${preference.key}
|
${preference.description}
|
||||||
>
|
</span>
|
||||||
</ha-checkbox>
|
<span>
|
||||||
${!baseEnabled
|
<ha-switch
|
||||||
? html`<paper-tooltip animation-delay="0" position="right">
|
@change=${this._handleRowClick}
|
||||||
You need to enable basic analytics for this option to be
|
.checked=${this.analytics?.preferences[preference.key]}
|
||||||
available
|
.preference=${preference.key}
|
||||||
</paper-tooltip>`
|
name=${preference.key}
|
||||||
: ""}
|
>
|
||||||
</span>
|
</ha-switch>
|
||||||
<span slot="heading" data-for=${preference.key}>
|
${!baseEnabled
|
||||||
${preference.title}
|
? html`
|
||||||
</span>
|
<paper-tooltip animation-delay="0" position="right">
|
||||||
<span slot="description" data-for=${preference.key}>
|
You need to enable basic analytics for this option to be
|
||||||
${preference.description}
|
available
|
||||||
</span>
|
</paper-tooltip>
|
||||||
</ha-settings-row>`
|
`
|
||||||
|
: ""}
|
||||||
|
</span>
|
||||||
|
</ha-settings-row>
|
||||||
|
`
|
||||||
)}
|
)}
|
||||||
<ha-settings-row>
|
<ha-settings-row>
|
||||||
<span slot="prefix">
|
|
||||||
<ha-checkbox
|
|
||||||
@change=${this._handleRowCheckboxClick}
|
|
||||||
.checked=${this.analytics?.preferences.diagnostics}
|
|
||||||
.preference=${"diagnostics"}
|
|
||||||
.disabled=${loading}
|
|
||||||
name="diagnostics"
|
|
||||||
>
|
|
||||||
</ha-checkbox>
|
|
||||||
</span>
|
|
||||||
<span slot="heading" data-for="diagnostics"> Diagnostics </span>
|
<span slot="heading" data-for="diagnostics"> Diagnostics </span>
|
||||||
<span slot="description" data-for="diagnostics">
|
<span slot="description" data-for="diagnostics">
|
||||||
Share crash reports when unexpected errors occur.
|
Share crash reports when unexpected errors occur.
|
||||||
</span>
|
</span>
|
||||||
|
<ha-switch
|
||||||
|
@change=${this._handleRowClick}
|
||||||
|
.checked=${this.analytics?.preferences.diagnostics}
|
||||||
|
.preference=${"diagnostics"}
|
||||||
|
.disabled=${loading}
|
||||||
|
name="diagnostics"
|
||||||
|
>
|
||||||
|
</ha-switch>
|
||||||
</ha-settings-row>
|
</ha-settings-row>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -120,23 +120,23 @@ export class HaAnalytics extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleRowCheckboxClick(ev: Event) {
|
private _handleRowClick(ev: Event) {
|
||||||
const checkbox = ev.currentTarget as HaCheckbox;
|
const target = ev.currentTarget as HaSwitch;
|
||||||
const preference = (checkbox as any).preference;
|
const preference = (target as any).preference;
|
||||||
const preferences = this.analytics ? { ...this.analytics.preferences } : {};
|
const preferences = this.analytics ? { ...this.analytics.preferences } : {};
|
||||||
|
|
||||||
if (preferences[preference] === checkbox.checked) {
|
if (preferences[preference] === target.checked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences[preference] = checkbox.checked;
|
preferences[preference] = target.checked;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
ADDITIONAL_PREFERENCES.some((entry) => entry.key === preference) &&
|
ADDITIONAL_PREFERENCES.some((entry) => entry.key === preference) &&
|
||||||
checkbox.checked
|
target.checked
|
||||||
) {
|
) {
|
||||||
preferences.base = true;
|
preferences.base = true;
|
||||||
} else if (preference === "base" && !checkbox.checked) {
|
} else if (preference === "base" && !target.checked) {
|
||||||
preferences.usage = false;
|
preferences.usage = false;
|
||||||
preferences.statistics = false;
|
preferences.statistics = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ interface State {
|
|||||||
backgroundColor: null | string;
|
backgroundColor: null | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@customElement("hassio-ansi-to-html")
|
@customElement("ha-ansi-to-html")
|
||||||
class HassioAnsiToHtml extends LitElement {
|
class HaAnsiToHtml extends LitElement {
|
||||||
@property() public content!: string;
|
@property() public content!: string;
|
||||||
|
|
||||||
protected render(): TemplateResult | void {
|
protected render(): TemplateResult | void {
|
||||||
@@ -241,6 +241,6 @@ class HassioAnsiToHtml extends LitElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"hassio-ansi-to-html": HassioAnsiToHtml;
|
"ha-ansi-to-html": HaAnsiToHtml;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,8 @@ export class HaAreaPicker extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
@property() public value?: string;
|
@property() public value?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property() public placeholder?: string;
|
@property() public placeholder?: string;
|
||||||
|
|
||||||
@property({ type: Boolean, attribute: "no-add" })
|
@property({ type: Boolean, attribute: "no-add" })
|
||||||
@@ -312,6 +314,7 @@ export class HaAreaPicker extends SubscribeMixin(LitElement) {
|
|||||||
return html`
|
return html`
|
||||||
<ha-combo-box
|
<ha-combo-box
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
|
.helper=${this.helper}
|
||||||
item-value-path="area_id"
|
item-value-path="area_id"
|
||||||
item-id-path="area_id"
|
item-id-path="area_id"
|
||||||
item-label-path="name"
|
item-label-path="name"
|
||||||
@@ -406,7 +409,7 @@ export class HaAreaPicker extends SubscribeMixin(LitElement) {
|
|||||||
name,
|
name,
|
||||||
});
|
});
|
||||||
this._areas = [...this._areas!, area];
|
this._areas = [...this._areas!, area];
|
||||||
(this.comboBox as any).items = this._getAreas(
|
(this.comboBox as any).filteredItems = this._getAreas(
|
||||||
this._areas!,
|
this._areas!,
|
||||||
this._devices!,
|
this._devices!,
|
||||||
this._entities!,
|
this._entities!,
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ export class HaAreasPicker extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
@property() public value?: string[];
|
@property() public value?: string[];
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property() public placeholder?: string;
|
@property() public placeholder?: string;
|
||||||
|
|
||||||
@property({ type: Boolean, attribute: "no-add" })
|
@property({ type: Boolean, attribute: "no-add" })
|
||||||
@@ -90,6 +92,7 @@ export class HaAreasPicker extends SubscribeMixin(LitElement) {
|
|||||||
.noAdd=${this.noAdd}
|
.noAdd=${this.noAdd}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.label=${this.pickAreaLabel}
|
.label=${this.pickAreaLabel}
|
||||||
|
.helper=${this.helper}
|
||||||
.includeDomains=${this.includeDomains}
|
.includeDomains=${this.includeDomains}
|
||||||
.excludeDomains=${this.excludeDomains}
|
.excludeDomains=${this.excludeDomains}
|
||||||
.includeDeviceClasses=${this.includeDeviceClasses}
|
.includeDeviceClasses=${this.includeDeviceClasses}
|
||||||
@@ -97,7 +100,7 @@ export class HaAreasPicker extends SubscribeMixin(LitElement) {
|
|||||||
.entityFilter=${this.entityFilter}
|
.entityFilter=${this.entityFilter}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
.placeholder=${this.placeholder}
|
.placeholder=${this.placeholder}
|
||||||
.required=${this.required}
|
.required=${this.required && !currentAreas.length}
|
||||||
@value-changed=${this._addArea}
|
@value-changed=${this._addArea}
|
||||||
></ha-area-picker>
|
></ha-area-picker>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { fireEvent } from "../common/dom/fire_event";
|
|||||||
import { stopPropagation } from "../common/dom/stop_propagation";
|
import { stopPropagation } from "../common/dom/stop_propagation";
|
||||||
import "./ha-select";
|
import "./ha-select";
|
||||||
import "./ha-textfield";
|
import "./ha-textfield";
|
||||||
|
import "./ha-input-helper-text";
|
||||||
|
|
||||||
export interface TimeChangedEvent {
|
export interface TimeChangedEvent {
|
||||||
days?: number;
|
days?: number;
|
||||||
@@ -130,7 +131,7 @@ export class HaBaseTimeInput extends LitElement {
|
|||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
${this.label
|
${this.label
|
||||||
? html`<label>${this.label}${this.required ? "*" : ""}</label>`
|
? html`<label>${this.label}${this.required ? " *" : ""}</label>`
|
||||||
: ""}
|
: ""}
|
||||||
<div class="time-input-wrap">
|
<div class="time-input-wrap">
|
||||||
${this.enableDay
|
${this.enableDay
|
||||||
@@ -253,7 +254,9 @@ export class HaBaseTimeInput extends LitElement {
|
|||||||
<mwc-list-item value="PM">PM</mwc-list-item>
|
<mwc-list-item value="PM">PM</mwc-list-item>
|
||||||
</ha-select>`}
|
</ha-select>`}
|
||||||
</div>
|
</div>
|
||||||
${this.helper ? html`<div class="helper">${this.helper}</div>` : ""}
|
${this.helper
|
||||||
|
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
||||||
|
: ""}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,6 +310,7 @@ export class HaBaseTimeInput extends LitElement {
|
|||||||
border-radius: var(--mdc-shape-small, 4px) var(--mdc-shape-small, 4px) 0 0;
|
border-radius: var(--mdc-shape-small, 4px) var(--mdc-shape-small, 4px) 0 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
direction: ltr;
|
||||||
}
|
}
|
||||||
ha-textfield {
|
ha-textfield {
|
||||||
width: 40px;
|
width: 40px;
|
||||||
@@ -350,13 +354,6 @@ export class HaBaseTimeInput extends LitElement {
|
|||||||
color: var(--mdc-theme-text-primary-on-background, rgba(0, 0, 0, 0.87));
|
color: var(--mdc-theme-text-primary-on-background, rgba(0, 0, 0, 0.87));
|
||||||
padding-left: 4px;
|
padding-left: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.helper {
|
|
||||||
color: var(--mdc-text-field-label-ink-color, rgba(0, 0, 0, 0.6));
|
|
||||||
font-size: 0.75rem;
|
|
||||||
padding-left: 16px;
|
|
||||||
padding-right: 16px;
|
|
||||||
}
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,19 @@ export class HaButtonToggleGroup extends LitElement {
|
|||||||
--mdc-shape-small: 4px;
|
--mdc-shape-small: 4px;
|
||||||
border-right-width: 1px;
|
border-right-width: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:host([dir="rtl"]) ha-icon-button:first-child,
|
||||||
|
:host([dir="rtl"]) mwc-button:first-child {
|
||||||
|
border-radius: 0 4px 4px 0;
|
||||||
|
border-right-width: 1px;
|
||||||
|
--mdc-shape-small: 0 4px 4px 0;
|
||||||
|
--mdc-button-outline-width: 1px;
|
||||||
|
}
|
||||||
|
:host([dir="rtl"]) ha-icon-button:last-child,
|
||||||
|
:host([dir="rtl"]) mwc-button:last-child {
|
||||||
|
--mdc-shape-small: 4px 0 0 4px;
|
||||||
|
border-radius: 4px 0 0 4px;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
76
src/components/ha-clickable-list-item.ts
Normal file
76
src/components/ha-clickable-list-item.ts
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import { ListItemBase } from "@material/mwc-list/mwc-list-item-base";
|
||||||
|
import { styles } from "@material/mwc-list/mwc-list-item.css";
|
||||||
|
import { css, CSSResult, html } from "lit";
|
||||||
|
import { customElement, property, query } from "lit/decorators";
|
||||||
|
|
||||||
|
@customElement("ha-clickable-list-item")
|
||||||
|
export class HaClickableListItem extends ListItemBase {
|
||||||
|
@property() public href?: string;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public disableHref = false;
|
||||||
|
|
||||||
|
// property used only in css
|
||||||
|
@property({ type: Boolean, reflect: true }) public rtl = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean, reflect: true }) public openNewTab = false;
|
||||||
|
|
||||||
|
@query("a") private _anchor!: HTMLAnchorElement;
|
||||||
|
|
||||||
|
public render() {
|
||||||
|
const r = super.render();
|
||||||
|
const href = this.href || "";
|
||||||
|
|
||||||
|
return html`${this.disableHref
|
||||||
|
? html`<a aria-role="option">${r}</a>`
|
||||||
|
: html`<a
|
||||||
|
aria-role="option"
|
||||||
|
target=${this.openNewTab ? "_blank" : ""}
|
||||||
|
href=${href}
|
||||||
|
>${r}</a
|
||||||
|
>`}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
firstUpdated() {
|
||||||
|
super.firstUpdated();
|
||||||
|
this.addEventListener("keydown", (ev) => {
|
||||||
|
if (ev.key === "Enter" || ev.key === " ") {
|
||||||
|
this._anchor.click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static get styles(): CSSResult[] {
|
||||||
|
return [
|
||||||
|
styles,
|
||||||
|
css`
|
||||||
|
:host {
|
||||||
|
padding-left: 0px;
|
||||||
|
padding-right: 0px;
|
||||||
|
}
|
||||||
|
:host([rtl]) span {
|
||||||
|
margin-left: var(--mdc-list-item-graphic-margin, 20px) !important;
|
||||||
|
margin-right: 0px !important;
|
||||||
|
}
|
||||||
|
:host([graphic="avatar"]:not([twoLine])),
|
||||||
|
:host([graphic="icon"]:not([twoLine])) {
|
||||||
|
height: 48px;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding-left: var(--mdc-list-side-padding, 20px);
|
||||||
|
padding-right: var(--mdc-list-side-padding, 20px);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"ha-clickable-list-item": HaClickableListItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,6 +64,8 @@ export class HaComboBox extends LitElement {
|
|||||||
|
|
||||||
@property() public validationMessage?: string;
|
@property() public validationMessage?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ attribute: "error-message" }) public errorMessage?: string;
|
@property({ attribute: "error-message" }) public errorMessage?: string;
|
||||||
|
|
||||||
@property({ type: Boolean }) public invalid?: boolean;
|
@property({ type: Boolean }) public invalid?: boolean;
|
||||||
@@ -147,6 +149,8 @@ export class HaComboBox extends LitElement {
|
|||||||
.suffix=${html`<div style="width: 28px;"></div>`}
|
.suffix=${html`<div style="width: 28px;"></div>`}
|
||||||
.icon=${this.icon}
|
.icon=${this.icon}
|
||||||
.invalid=${this.invalid}
|
.invalid=${this.invalid}
|
||||||
|
.helper=${this.helper}
|
||||||
|
helperPersistent
|
||||||
>
|
>
|
||||||
<slot name="icon" slot="leadingIcon"></slot>
|
<slot name="icon" slot="leadingIcon"></slot>
|
||||||
</ha-textfield>
|
</ha-textfield>
|
||||||
@@ -246,6 +250,18 @@ export class HaComboBox extends LitElement {
|
|||||||
top: -7px;
|
top: -7px;
|
||||||
right: 36px;
|
right: 36px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:host-context([style*="direction: rtl;"]) .toggle-button {
|
||||||
|
left: 12px;
|
||||||
|
right: auto;
|
||||||
|
top: -10px;
|
||||||
|
}
|
||||||
|
:host-context([style*="direction: rtl;"]) .clear-button {
|
||||||
|
--mdc-icon-size: 20px;
|
||||||
|
top: -7px;
|
||||||
|
left: 36px;
|
||||||
|
right: auto;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,11 +39,15 @@ export class HaDateInput extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return html`<ha-textfield
|
return html`<ha-textfield
|
||||||
.label=${this.label}
|
.label=${this.label}
|
||||||
|
.helper=${this.helper}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
iconTrailing
|
iconTrailing
|
||||||
|
helperPersistent
|
||||||
@click=${this._openDialog}
|
@click=${this._openDialog}
|
||||||
.value=${this.value
|
.value=${this.value
|
||||||
? formatDateNumeric(new Date(this.value), this.locale)
|
? formatDateNumeric(new Date(this.value), this.locale)
|
||||||
|
|||||||
@@ -98,6 +98,10 @@ export class HaDialog extends DialogBase {
|
|||||||
margin-left: 40px;
|
margin-left: 40px;
|
||||||
margin-right: 0px;
|
margin-right: 0px;
|
||||||
}
|
}
|
||||||
|
:host-context([style*="direction: rtl;"]) .dialog-actions {
|
||||||
|
left: 0px !important;
|
||||||
|
right: auto !important;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Fab } from "@material/mwc-fab";
|
import { Fab } from "@material/mwc-fab";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement } from "lit/decorators";
|
||||||
|
import { css } from "lit";
|
||||||
|
|
||||||
@customElement("ha-fab")
|
@customElement("ha-fab")
|
||||||
export class HaFab extends Fab {
|
export class HaFab extends Fab {
|
||||||
@@ -7,6 +8,17 @@ export class HaFab extends Fab {
|
|||||||
super.firstUpdated(changedProperties);
|
super.firstUpdated(changedProperties);
|
||||||
this.style.setProperty("--mdc-theme-secondary", "var(--primary-color)");
|
this.style.setProperty("--mdc-theme-secondary", "var(--primary-color)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static override styles = Fab.styles.concat([
|
||||||
|
css`
|
||||||
|
:host-context([style*="direction: rtl;"])
|
||||||
|
.mdc-fab--extended
|
||||||
|
.mdc-fab__icon {
|
||||||
|
margin-left: 12px !important;
|
||||||
|
margin-right: calc(12px - 20px) !important;
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
|||||||
@@ -176,10 +176,24 @@ export class HaFileUpload extends LitElement {
|
|||||||
.mdc-text-field__icon--leading {
|
.mdc-text-field__icon--leading {
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
}
|
}
|
||||||
|
:host-context([style*="direction: rtl;"])
|
||||||
|
.mdc-text-field__icon--leading {
|
||||||
|
margin-right: 0px;
|
||||||
|
}
|
||||||
.mdc-text-field--filled .mdc-floating-label--float-above {
|
.mdc-text-field--filled .mdc-floating-label--float-above {
|
||||||
transform: scale(0.75);
|
transform: scale(0.75);
|
||||||
top: 8px;
|
top: 8px;
|
||||||
}
|
}
|
||||||
|
:host-context([style*="direction: rtl;"]) .mdc-floating-label {
|
||||||
|
left: initial;
|
||||||
|
right: 16px;
|
||||||
|
}
|
||||||
|
:host-context([style*="direction: rtl;"])
|
||||||
|
.mdc-text-field--filled
|
||||||
|
.mdc-floating-label {
|
||||||
|
left: initial;
|
||||||
|
right: 48px;
|
||||||
|
}
|
||||||
.dragged:before {
|
.dragged:before {
|
||||||
position: var(--layout-fit_-_position);
|
position: var(--layout-fit_-_position);
|
||||||
top: var(--layout-fit_-_top);
|
top: var(--layout-fit_-_top);
|
||||||
|
|||||||
@@ -132,6 +132,11 @@ export class HaFormString extends LitElement implements HaFormElement {
|
|||||||
--mdc-icon-button-size: 24px;
|
--mdc-icon-button-size: 24px;
|
||||||
color: var(--secondary-text-color);
|
color: var(--secondary-text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:host-context([style*="direction: rtl;"]) ha-icon-button {
|
||||||
|
right: auto;
|
||||||
|
left: 12px;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export class HaForm extends LitElement implements HaFormElement {
|
|||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<div class="root">
|
<div class="root" part="root">
|
||||||
${this.error && this.error.base
|
${this.error && this.error.base
|
||||||
? html`
|
? html`
|
||||||
<ha-alert alert-type="error">
|
<ha-alert alert-type="error">
|
||||||
@@ -173,7 +173,6 @@ export class HaForm extends LitElement implements HaFormElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
// .root has overflow: auto to avoid margin collapse
|
|
||||||
return css`
|
return css`
|
||||||
.root {
|
.root {
|
||||||
margin-bottom: -24px;
|
margin-bottom: -24px;
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ export class HaIconPicker extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property() public placeholder?: string;
|
@property() public placeholder?: string;
|
||||||
|
|
||||||
@property() public fallbackPath?: string;
|
@property() public fallbackPath?: string;
|
||||||
@@ -57,6 +59,7 @@ export class HaIconPicker extends LitElement {
|
|||||||
allow-custom-value
|
allow-custom-value
|
||||||
.filteredItems=${iconItems}
|
.filteredItems=${iconItems}
|
||||||
.label=${this.label}
|
.label=${this.label}
|
||||||
|
.helper=${this.helper}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
.placeholder=${this.placeholder}
|
.placeholder=${this.placeholder}
|
||||||
|
|||||||
25
src/components/ha-input-helper-text.ts
Normal file
25
src/components/ha-input-helper-text.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { css, html, LitElement, TemplateResult } from "lit";
|
||||||
|
import { customElement } from "lit/decorators";
|
||||||
|
|
||||||
|
@customElement("ha-input-helper-text")
|
||||||
|
class InputHelperText extends LitElement {
|
||||||
|
protected render(): TemplateResult {
|
||||||
|
return html`<slot></slot>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static styles = css`
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
color: var(--mdc-text-field-label-ink-color, rgba(0, 0, 0, 0.6));
|
||||||
|
font-size: 0.75rem;
|
||||||
|
padding-left: 16px;
|
||||||
|
padding-right: 16px;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"ha-input-helper-text": InputHelperText;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,11 +46,14 @@ class HaLabeledSlider extends PolymerElement {
|
|||||||
value="{{value}}"
|
value="{{value}}"
|
||||||
></ha-slider>
|
></ha-slider>
|
||||||
</div>
|
</div>
|
||||||
|
<template is="dom-if" if="[[helper]]">
|
||||||
|
<ha-input-helper-text>[[helper]]</ha-input-helper-text>
|
||||||
|
</template>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
_getTitle() {
|
_getTitle() {
|
||||||
return `${this.caption}${this.required ? "*" : ""}`;
|
return `${this.caption}${this.caption && this.required ? " *" : ""}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get properties() {
|
static get properties() {
|
||||||
@@ -62,6 +65,7 @@ class HaLabeledSlider extends PolymerElement {
|
|||||||
max: Number,
|
max: Number,
|
||||||
pin: Boolean,
|
pin: Boolean,
|
||||||
step: Number,
|
step: Number,
|
||||||
|
helper: String,
|
||||||
|
|
||||||
extra: {
|
extra: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
|||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import { computeDomain } from "../common/entity/compute_domain";
|
|
||||||
import { subscribeNotifications } from "../data/persistent_notification";
|
import { subscribeNotifications } from "../data/persistent_notification";
|
||||||
import { HomeAssistant } from "../types";
|
import { HomeAssistant } from "../types";
|
||||||
import "./ha-icon-button";
|
import "./ha-icon-button";
|
||||||
@@ -43,18 +42,15 @@ class HaMenuButton extends LitElement {
|
|||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
const hasNotifications =
|
const hasNotifications =
|
||||||
(this.narrow || this.hass.dockedSidebar === "always_hidden") &&
|
this._hasNotifications &&
|
||||||
(this._hasNotifications ||
|
(this.narrow || this.hass.dockedSidebar === "always_hidden");
|
||||||
Object.keys(this.hass.states).some(
|
|
||||||
(entityId) => computeDomain(entityId) === "configurator"
|
|
||||||
));
|
|
||||||
return html`
|
return html`
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
.label=${this.hass.localize("ui.sidebar.sidebar_toggle")}
|
.label=${this.hass.localize("ui.sidebar.sidebar_toggle")}
|
||||||
.path=${mdiMenu}
|
.path=${mdiMenu}
|
||||||
@click=${this._toggleMenu}
|
@click=${this._toggleMenu}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
${hasNotifications ? html` <div class="dot"></div> ` : ""}
|
${hasNotifications ? html`<div class="dot"></div>` : ""}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
79
src/components/ha-metric.ts
Normal file
79
src/components/ha-metric.ts
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import { classMap } from "lit/directives/class-map";
|
||||||
|
import { roundWithOneDecimal } from "../util/calculate";
|
||||||
|
import "./ha-bar";
|
||||||
|
import "./ha-settings-row";
|
||||||
|
|
||||||
|
@customElement("ha-metric")
|
||||||
|
class HaMetric extends LitElement {
|
||||||
|
@property({ type: Number }) public value!: number;
|
||||||
|
|
||||||
|
@property({ type: String }) public heading!: string;
|
||||||
|
|
||||||
|
@property({ type: String }) public tooltip?: string;
|
||||||
|
|
||||||
|
protected render(): TemplateResult {
|
||||||
|
const roundedValue = roundWithOneDecimal(this.value);
|
||||||
|
return html`
|
||||||
|
<ha-settings-row>
|
||||||
|
<span slot="heading"> ${this.heading} </span>
|
||||||
|
<div slot="description" .title=${this.tooltip ?? ""}>
|
||||||
|
<span class="value"> ${roundedValue} % </span>
|
||||||
|
<ha-bar
|
||||||
|
class=${classMap({
|
||||||
|
"target-warning": roundedValue > 50,
|
||||||
|
"target-critical": roundedValue > 85,
|
||||||
|
})}
|
||||||
|
.value=${this.value}
|
||||||
|
></ha-bar>
|
||||||
|
</div>
|
||||||
|
</ha-settings-row>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get styles(): CSSResultGroup {
|
||||||
|
return css`
|
||||||
|
ha-settings-row {
|
||||||
|
padding: 0;
|
||||||
|
height: 54px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
ha-settings-row > div[slot="description"] {
|
||||||
|
white-space: normal;
|
||||||
|
color: var(--secondary-text-color);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
ha-bar {
|
||||||
|
--ha-bar-primary-color: var(
|
||||||
|
--metric-bar-ok-color,
|
||||||
|
var(--success-color)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
.target-warning {
|
||||||
|
--ha-bar-primary-color: var(
|
||||||
|
--metric-bar-warning-color,
|
||||||
|
var(--warning-color)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
.target-critical {
|
||||||
|
--ha-bar-primary-color: var(
|
||||||
|
--metric-bar-critical-color,
|
||||||
|
var(--error-color)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
.value {
|
||||||
|
width: 48px;
|
||||||
|
padding-right: 4px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"ha-metric": HaMetric;
|
||||||
|
}
|
||||||
|
}
|
||||||
90
src/components/ha-navigation-list.ts
Normal file
90
src/components/ha-navigation-list.ts
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
import "@material/mwc-list/mwc-list";
|
||||||
|
import "@material/mwc-list/mwc-list-item";
|
||||||
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import type { PageNavigation } from "../layouts/hass-tabs-subpage";
|
||||||
|
import type { HomeAssistant } from "../types";
|
||||||
|
import "./ha-clickable-list-item";
|
||||||
|
import "./ha-icon-next";
|
||||||
|
import "./ha-svg-icon";
|
||||||
|
|
||||||
|
@customElement("ha-navigation-list")
|
||||||
|
class HaNavigationList extends LitElement {
|
||||||
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public narrow!: boolean;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public pages!: PageNavigation[];
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public hasSecondary = false;
|
||||||
|
|
||||||
|
public render(): TemplateResult {
|
||||||
|
return html`
|
||||||
|
<mwc-list>
|
||||||
|
${this.pages.map(
|
||||||
|
(page) => html`
|
||||||
|
<ha-clickable-list-item
|
||||||
|
graphic="avatar"
|
||||||
|
.twoline=${this.hasSecondary}
|
||||||
|
.hasMeta=${!this.narrow}
|
||||||
|
@click=${this._entryClicked}
|
||||||
|
href=${page.path}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
slot="graphic"
|
||||||
|
class=${page.iconColor ? "icon-background" : ""}
|
||||||
|
.style="background-color: ${page.iconColor || "undefined"}"
|
||||||
|
>
|
||||||
|
<ha-svg-icon .path=${page.iconPath}></ha-svg-icon>
|
||||||
|
</div>
|
||||||
|
<span>${page.name}</span>
|
||||||
|
${this.hasSecondary
|
||||||
|
? html`<span slot="secondary">${page.description}</span>`
|
||||||
|
: ""}
|
||||||
|
${!this.narrow
|
||||||
|
? html`<ha-icon-next slot="meta"></ha-icon-next>`
|
||||||
|
: ""}
|
||||||
|
</ha-clickable-list-item>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</mwc-list>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _entryClicked(ev) {
|
||||||
|
ev.currentTarget.blur();
|
||||||
|
}
|
||||||
|
|
||||||
|
static styles: CSSResultGroup = css`
|
||||||
|
:host {
|
||||||
|
--mdc-list-vertical-padding: 0;
|
||||||
|
}
|
||||||
|
ha-svg-icon,
|
||||||
|
ha-icon-next {
|
||||||
|
color: var(--secondary-text-color);
|
||||||
|
height: 24px;
|
||||||
|
width: 24px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
ha-svg-icon {
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
.icon-background {
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
.icon-background ha-svg-icon {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
ha-clickable-list-item {
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: var(--navigation-list-item-title-font-size);
|
||||||
|
padding: var(--navigation-list-item-padding) 0;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"ha-navigation-list": HaNavigationList;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -163,6 +163,9 @@ export class HaNetwork extends LitElement {
|
|||||||
|
|
||||||
ha-settings-row {
|
ha-settings-row {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
--paper-time-input-justify-content: flex-end;
|
||||||
|
--settings-row-content-display: contents;
|
||||||
|
--settings-row-prefix-display: contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
span[slot="heading"],
|
span[slot="heading"],
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ export class HaSelect extends SelectBase {
|
|||||||
.mdc-select__anchor {
|
.mdc-select__anchor {
|
||||||
width: var(--ha-select-min-width, 200px);
|
width: var(--ha-select-min-width, 200px);
|
||||||
}
|
}
|
||||||
|
:host-context([style*="direction: rtl;"]) .mdc-floating-label {
|
||||||
|
right: 16px !important;
|
||||||
|
left: initial !important;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ export class HaAddonSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean }) public disabled = false;
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required = true;
|
@property({ type: Boolean }) public required = true;
|
||||||
@@ -23,6 +25,7 @@ export class HaAddonSelector extends LitElement {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
.label=${this.label}
|
.label=${this.label}
|
||||||
|
.helper=${this.helper}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
allow-custom-entity
|
allow-custom-entity
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ export class HaAreaSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@state() public _configEntries?: ConfigEntry[];
|
@state() public _configEntries?: ConfigEntry[];
|
||||||
|
|
||||||
@property({ type: Boolean }) public disabled = false;
|
@property({ type: Boolean }) public disabled = false;
|
||||||
@@ -47,6 +49,7 @@ export class HaAreaSelector extends LitElement {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
.label=${this.label}
|
.label=${this.label}
|
||||||
|
.helper=${this.helper}
|
||||||
no-add
|
no-add
|
||||||
.deviceFilter=${this._filterDevices}
|
.deviceFilter=${this._filterDevices}
|
||||||
.entityFilter=${this._filterEntities}
|
.entityFilter=${this._filterEntities}
|
||||||
@@ -66,6 +69,7 @@ export class HaAreaSelector extends LitElement {
|
|||||||
<ha-areas-picker
|
<ha-areas-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
|
.helper=${this.helper}
|
||||||
.pickAreaLabel=${this.label}
|
.pickAreaLabel=${this.label}
|
||||||
no-add
|
no-add
|
||||||
.deviceFilter=${this._filterDevices}
|
.deviceFilter=${this._filterDevices}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ export class HaSelectorAttribute extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean }) public disabled = false;
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required = true;
|
@property({ type: Boolean }) public required = true;
|
||||||
@@ -32,6 +34,7 @@ export class HaSelectorAttribute extends SubscribeMixin(LitElement) {
|
|||||||
this.context?.filter_entity}
|
this.context?.filter_entity}
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
.label=${this.label}
|
.label=${this.label}
|
||||||
|
.helper=${this.helper}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
allow-custom-value
|
allow-custom-value
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { fireEvent } from "../../common/dom/fire_event";
|
|||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import "../ha-formfield";
|
import "../ha-formfield";
|
||||||
import "../ha-switch";
|
import "../ha-switch";
|
||||||
|
import "../ha-input-helper-text";
|
||||||
|
|
||||||
@customElement("ha-selector-boolean")
|
@customElement("ha-selector-boolean")
|
||||||
export class HaBooleanSelector extends LitElement {
|
export class HaBooleanSelector extends LitElement {
|
||||||
@@ -13,16 +14,23 @@ export class HaBooleanSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean }) public disabled = false;
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`<ha-formfield alignEnd spaceBetween .label=${this.label}>
|
return html`
|
||||||
<ha-switch
|
<ha-formfield alignEnd spaceBetween .label=${this.label}>
|
||||||
.checked=${this.value}
|
<ha-switch
|
||||||
@change=${this._handleChange}
|
.checked=${this.value}
|
||||||
.disabled=${this.disabled}
|
@change=${this._handleChange}
|
||||||
></ha-switch>
|
.disabled=${this.disabled}
|
||||||
</ha-formfield>`;
|
></ha-switch>
|
||||||
|
</ha-formfield>
|
||||||
|
${this.helper
|
||||||
|
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
||||||
|
: ""}
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleChange(ev) {
|
private _handleChange(ev) {
|
||||||
@@ -35,12 +43,10 @@ export class HaBooleanSelector extends LitElement {
|
|||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return css`
|
return css`
|
||||||
:host {
|
|
||||||
height: 56px;
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
ha-formfield {
|
ha-formfield {
|
||||||
width: 100%;
|
display: flex;
|
||||||
|
height: 56px;
|
||||||
|
align-items: center;
|
||||||
--mdc-typography-body2-font-size: 1em;
|
--mdc-typography-body2-font-size: 1em;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ export class HaColorRGBSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true }) public disabled = false;
|
@property({ type: Boolean, reflect: true }) public disabled = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required = true;
|
@property({ type: Boolean }) public required = true;
|
||||||
@@ -24,9 +26,11 @@ export class HaColorRGBSelector extends LitElement {
|
|||||||
return html`
|
return html`
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
type="color"
|
type="color"
|
||||||
|
helperPersistent
|
||||||
.value=${this.value ? rgb2hex(this.value as any) : ""}
|
.value=${this.value ? rgb2hex(this.value as any) : ""}
|
||||||
.label=${this.label || ""}
|
.label=${this.label || ""}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
|
.helper=${this.helper}
|
||||||
.disalbled=${this.disabled}
|
.disalbled=${this.disabled}
|
||||||
@change=${this._valueChanged}
|
@change=${this._valueChanged}
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ export class HaColorTempSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true }) public disabled = false;
|
@property({ type: Boolean, reflect: true }) public disabled = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required = true;
|
@property({ type: Boolean }) public required = true;
|
||||||
@@ -24,11 +26,12 @@ export class HaColorTempSelector extends LitElement {
|
|||||||
<ha-labeled-slider
|
<ha-labeled-slider
|
||||||
pin
|
pin
|
||||||
icon="hass:thermometer"
|
icon="hass:thermometer"
|
||||||
.caption=${this.label}
|
.caption=${this.label || ""}
|
||||||
.min=${this.selector.color_temp.min_mireds ?? 153}
|
.min=${this.selector.color_temp?.min_mireds ?? 153}
|
||||||
.max=${this.selector.color_temp.max_mireds ?? 500}
|
.max=${this.selector.color_temp?.max_mireds ?? 500}
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
|
.helper=${this.helper}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
@change=${this._valueChanged}
|
@change=${this._valueChanged}
|
||||||
></ha-labeled-slider>
|
></ha-labeled-slider>
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ export class HaDateSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true }) public disabled = false;
|
@property({ type: Boolean, reflect: true }) public disabled = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required = true;
|
@property({ type: Boolean }) public required = true;
|
||||||
@@ -26,6 +28,7 @@ export class HaDateSelector extends LitElement {
|
|||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
|
.helper=${this.helper}
|
||||||
>
|
>
|
||||||
</ha-date-input>
|
</ha-date-input>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import type { HomeAssistant } from "../../types";
|
|||||||
import "../ha-date-input";
|
import "../ha-date-input";
|
||||||
import type { HaDateInput } from "../ha-date-input";
|
import type { HaDateInput } from "../ha-date-input";
|
||||||
import "../ha-time-input";
|
import "../ha-time-input";
|
||||||
|
import "../ha-input-helper-text";
|
||||||
import type { HaTimeInput } from "../ha-time-input";
|
import type { HaTimeInput } from "../ha-time-input";
|
||||||
|
|
||||||
@customElement("ha-selector-datetime")
|
@customElement("ha-selector-datetime")
|
||||||
@@ -18,6 +19,8 @@ export class HaDateTimeSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true }) public disabled = false;
|
@property({ type: Boolean, reflect: true }) public disabled = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required = true;
|
@property({ type: Boolean }) public required = true;
|
||||||
@@ -30,23 +33,28 @@ export class HaDateTimeSelector extends LitElement {
|
|||||||
const values = this.value?.split(" ");
|
const values = this.value?.split(" ");
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-date-input
|
<div class="input">
|
||||||
.label=${this.label}
|
<ha-date-input
|
||||||
.locale=${this.hass.locale}
|
.label=${this.label}
|
||||||
.disabled=${this.disabled}
|
.locale=${this.hass.locale}
|
||||||
.required=${this.required}
|
.disabled=${this.disabled}
|
||||||
.value=${values?.[0]}
|
.required=${this.required}
|
||||||
@value-changed=${this._valueChanged}
|
.value=${values?.[0]}
|
||||||
>
|
@value-changed=${this._valueChanged}
|
||||||
</ha-date-input>
|
>
|
||||||
<ha-time-input
|
</ha-date-input>
|
||||||
enable-second
|
<ha-time-input
|
||||||
.value=${values?.[1] || "0:00:00"}
|
enable-second
|
||||||
.locale=${this.hass.locale}
|
.value=${values?.[1] || "0:00:00"}
|
||||||
.disabled=${this.disabled}
|
.locale=${this.hass.locale}
|
||||||
.required=${this.required}
|
.disabled=${this.disabled}
|
||||||
@value-changed=${this._valueChanged}
|
.required=${this.required}
|
||||||
></ha-time-input>
|
@value-changed=${this._valueChanged}
|
||||||
|
></ha-time-input>
|
||||||
|
</div>
|
||||||
|
${this.helper
|
||||||
|
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
||||||
|
: ""}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +66,7 @@ export class HaDateTimeSelector extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
:host {
|
.input {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ export class HaDeviceSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@state() public _configEntries?: ConfigEntry[];
|
@state() public _configEntries?: ConfigEntry[];
|
||||||
|
|
||||||
@property({ type: Boolean }) public disabled = false;
|
@property({ type: Boolean }) public disabled = false;
|
||||||
@@ -43,6 +45,7 @@ export class HaDeviceSelector extends LitElement {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
.label=${this.label}
|
.label=${this.label}
|
||||||
|
.helper=${this.helper}
|
||||||
.deviceFilter=${this._filterDevices}
|
.deviceFilter=${this._filterDevices}
|
||||||
.includeDeviceClasses=${this.selector.device.entity?.device_class
|
.includeDeviceClasses=${this.selector.device.entity?.device_class
|
||||||
? [this.selector.device.entity.device_class]
|
? [this.selector.device.entity.device_class]
|
||||||
@@ -62,12 +65,15 @@ export class HaDeviceSelector extends LitElement {
|
|||||||
<ha-devices-picker
|
<ha-devices-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
|
.helper=${this.helper}
|
||||||
|
.deviceFilter=${this._filterDevices}
|
||||||
.includeDeviceClasses=${this.selector.device.entity?.device_class
|
.includeDeviceClasses=${this.selector.device.entity?.device_class
|
||||||
? [this.selector.device.entity.device_class]
|
? [this.selector.device.entity.device_class]
|
||||||
: undefined}
|
: undefined}
|
||||||
.includeDomains=${this.selector.device.entity?.domain
|
.includeDomains=${this.selector.device.entity?.domain
|
||||||
? [this.selector.device.entity.domain]
|
? [this.selector.device.entity.domain]
|
||||||
: undefined}
|
: undefined}
|
||||||
|
.disabled=${this.disabled}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
></ha-devices-picker>
|
></ha-devices-picker>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ export class HaEntitySelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean }) public disabled = false;
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required = true;
|
@property({ type: Boolean }) public required = true;
|
||||||
@@ -33,6 +35,7 @@ export class HaEntitySelector extends LitElement {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
.label=${this.label}
|
.label=${this.label}
|
||||||
|
.helper=${this.helper}
|
||||||
.includeEntities=${this.selector.entity.include_entities}
|
.includeEntities=${this.selector.entity.include_entities}
|
||||||
.excludeEntities=${this.selector.entity.exclude_entities}
|
.excludeEntities=${this.selector.entity.exclude_entities}
|
||||||
.entityFilter=${this._filterEntities}
|
.entityFilter=${this._filterEntities}
|
||||||
@@ -47,9 +50,11 @@ export class HaEntitySelector extends LitElement {
|
|||||||
<ha-entities-picker
|
<ha-entities-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
.entityFilter=${this._filterEntities}
|
.helper=${this.helper}
|
||||||
.includeEntities=${this.selector.entity.include_entities}
|
.includeEntities=${this.selector.entity.include_entities}
|
||||||
.excludeEntities=${this.selector.entity.exclude_entities}
|
.excludeEntities=${this.selector.entity.exclude_entities}
|
||||||
|
.entityFilter=${this._filterEntities}
|
||||||
|
.disabled=${this.disabled}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
></ha-entities-picker>
|
></ha-entities-picker>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ export class HaIconSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true }) public disabled = false;
|
@property({ type: Boolean, reflect: true }) public disabled = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required = true;
|
@property({ type: Boolean }) public required = true;
|
||||||
@@ -26,6 +28,7 @@ export class HaIconSelector extends LitElement {
|
|||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
|
.helper=${this.helper}
|
||||||
.fallbackPath=${this.selector.icon.fallbackPath}
|
.fallbackPath=${this.selector.icon.fallbackPath}
|
||||||
.placeholder=${this.selector.icon.placeholder}
|
.placeholder=${this.selector.icon.placeholder}
|
||||||
@value-changed=${this._valueChanged}
|
@value-changed=${this._valueChanged}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { html, LitElement } from "lit";
|
import { css, html, LitElement } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
@@ -20,6 +20,8 @@ export class HaLocationSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true }) public disabled = false;
|
@property({ type: Boolean, reflect: true }) public disabled = false;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
@@ -27,6 +29,7 @@ export class HaLocationSelector extends LitElement {
|
|||||||
<ha-locations-editor
|
<ha-locations-editor
|
||||||
class="flex"
|
class="flex"
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
|
.helper=${this.helper}
|
||||||
.locations=${this._location(this.selector, this.value)}
|
.locations=${this._location(this.selector, this.value)}
|
||||||
@location-updated=${this._locationChanged}
|
@location-updated=${this._locationChanged}
|
||||||
@radius-updated=${this._radiusChanged}
|
@radius-updated=${this._radiusChanged}
|
||||||
@@ -73,6 +76,13 @@ export class HaLocationSelector extends LitElement {
|
|||||||
const radius = ev.detail.radius;
|
const radius = ev.detail.radius;
|
||||||
fireEvent(this, "value-changed", { value: { ...this.value, radius } });
|
fireEvent(this, "value-changed", { value: { ...this.value, radius } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static styles = css`
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
height: 400px;
|
||||||
|
}
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ export class HaMediaSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true }) public disabled = false;
|
@property({ type: Boolean, reflect: true }) public disabled = false;
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true }) public required = true;
|
@property({ type: Boolean, reflect: true }) public required = true;
|
||||||
@@ -86,6 +88,7 @@ export class HaMediaSelector extends LitElement {
|
|||||||
.label=${this.label ||
|
.label=${this.label ||
|
||||||
this.hass.localize("ui.components.selectors.media.pick_media_player")}
|
this.hass.localize("ui.components.selectors.media.pick_media_player")}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
|
.helper=${this.helper}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
include-domains='["media_player"]'
|
include-domains='["media_player"]'
|
||||||
allow-custom-entity
|
allow-custom-entity
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { NumberSelector } from "../../data/selector";
|
|||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import "../ha-slider";
|
import "../ha-slider";
|
||||||
import "../ha-textfield";
|
import "../ha-textfield";
|
||||||
|
import "../ha-input-helper-text";
|
||||||
|
|
||||||
@customElement("ha-selector-number")
|
@customElement("ha-selector-number")
|
||||||
export class HaNumberSelector extends LitElement {
|
export class HaNumberSelector extends LitElement {
|
||||||
@@ -26,8 +27,13 @@ export class HaNumberSelector extends LitElement {
|
|||||||
@property({ type: Boolean }) public disabled = false;
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`${this.selector.number.mode !== "box"
|
const isBox = this.selector.number.mode === "box";
|
||||||
? html`${this.label}${this.required ? "*" : ""}<ha-slider
|
|
||||||
|
return html`
|
||||||
|
${this.label ? html`${this.label}${this.required ? " *" : ""}` : ""}
|
||||||
|
<div class="input">
|
||||||
|
${!isBox
|
||||||
|
? html`<ha-slider
|
||||||
.min=${this.selector.number.min}
|
.min=${this.selector.number.min}
|
||||||
.max=${this.selector.number.max}
|
.max=${this.selector.number.max}
|
||||||
.value=${this._value}
|
.value=${this._value}
|
||||||
@@ -39,28 +45,33 @@ export class HaNumberSelector extends LitElement {
|
|||||||
@change=${this._handleSliderChange}
|
@change=${this._handleSliderChange}
|
||||||
>
|
>
|
||||||
</ha-slider>`
|
</ha-slider>`
|
||||||
|
: ""}
|
||||||
|
<ha-textfield
|
||||||
|
inputMode="numeric"
|
||||||
|
pattern="[0-9]+([\\.][0-9]+)?"
|
||||||
|
.label=${this.selector.number.mode !== "box" ? undefined : this.label}
|
||||||
|
.placeholder=${this.placeholder}
|
||||||
|
class=${classMap({ single: this.selector.number.mode === "box" })}
|
||||||
|
.min=${this.selector.number.min}
|
||||||
|
.max=${this.selector.number.max}
|
||||||
|
.value=${this.value ?? ""}
|
||||||
|
.step=${this.selector.number.step ?? 1}
|
||||||
|
helperPersistent
|
||||||
|
.helper=${isBox ? this.helper : undefined}
|
||||||
|
.disabled=${this.disabled}
|
||||||
|
.required=${this.required}
|
||||||
|
.suffix=${this.selector.number.unit_of_measurement}
|
||||||
|
type="number"
|
||||||
|
autoValidate
|
||||||
|
?no-spinner=${this.selector.number.mode !== "box"}
|
||||||
|
@input=${this._handleInputChange}
|
||||||
|
>
|
||||||
|
</ha-textfield>
|
||||||
|
</div>
|
||||||
|
${!isBox && this.helper
|
||||||
|
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
||||||
: ""}
|
: ""}
|
||||||
<ha-textfield
|
`;
|
||||||
inputMode="numeric"
|
|
||||||
pattern="[0-9]+([\\.][0-9]+)?"
|
|
||||||
.label=${this.selector.number.mode !== "box" ? undefined : this.label}
|
|
||||||
.placeholder=${this.placeholder}
|
|
||||||
class=${classMap({ single: this.selector.number.mode === "box" })}
|
|
||||||
.min=${this.selector.number.min}
|
|
||||||
.max=${this.selector.number.max}
|
|
||||||
.value=${this.value ?? ""}
|
|
||||||
.step=${this.selector.number.step ?? 1}
|
|
||||||
helperPersistent
|
|
||||||
.helper=${this.helper}
|
|
||||||
.disabled=${this.disabled}
|
|
||||||
.required=${this.required}
|
|
||||||
.suffix=${this.selector.number.unit_of_measurement}
|
|
||||||
type="number"
|
|
||||||
autoValidate
|
|
||||||
?no-spinner=${this.selector.number.mode !== "box"}
|
|
||||||
@input=${this._handleInputChange}
|
|
||||||
>
|
|
||||||
</ha-textfield>`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private get _value() {
|
private get _value() {
|
||||||
@@ -92,10 +103,11 @@ export class HaNumberSelector extends LitElement {
|
|||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return css`
|
return css`
|
||||||
:host {
|
.input {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
direction: ltr;
|
||||||
}
|
}
|
||||||
ha-slider {
|
ha-slider {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { customElement, property } from "lit/decorators";
|
|||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import "../ha-yaml-editor";
|
import "../ha-yaml-editor";
|
||||||
|
import "../ha-input-helper-text";
|
||||||
|
|
||||||
@customElement("ha-selector-object")
|
@customElement("ha-selector-object")
|
||||||
export class HaObjectSelector extends LitElement {
|
export class HaObjectSelector extends LitElement {
|
||||||
@@ -12,6 +13,8 @@ export class HaObjectSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property() public placeholder?: string;
|
@property() public placeholder?: string;
|
||||||
|
|
||||||
@property({ type: Boolean }) public disabled = false;
|
@property({ type: Boolean }) public disabled = false;
|
||||||
@@ -20,13 +23,17 @@ export class HaObjectSelector extends LitElement {
|
|||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`<ha-yaml-editor
|
return html`<ha-yaml-editor
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.readonly=${this.disabled}
|
.readonly=${this.disabled}
|
||||||
.required=${this.required}
|
.label=${this.label}
|
||||||
.placeholder=${this.placeholder}
|
.required=${this.required}
|
||||||
.defaultValue=${this.value}
|
.placeholder=${this.placeholder}
|
||||||
@value-changed=${this._handleChange}
|
.defaultValue=${this.value}
|
||||||
></ha-yaml-editor>`;
|
@value-changed=${this._handleChange}
|
||||||
|
></ha-yaml-editor>
|
||||||
|
${this.helper
|
||||||
|
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
||||||
|
: ""} `;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleChange(ev) {
|
private _handleChange(ev) {
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export class HaSelectSelector extends LitElement {
|
|||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
${this._renderHelper()}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +77,7 @@ export class HaSelectSelector extends LitElement {
|
|||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
${this._renderHelper()}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,8 +109,9 @@ export class HaSelectSelector extends LitElement {
|
|||||||
item-label-path="label"
|
item-label-path="label"
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.label=${this.label}
|
.label=${this.label}
|
||||||
|
.helper=${this.helper}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
.required=${this.required}
|
.required=${this.required && !value.length}
|
||||||
.value=${this._filter}
|
.value=${this._filter}
|
||||||
.items=${options.filter((item) => !this.value?.includes(item.value))}
|
.items=${options.filter((item) => !this.value?.includes(item.value))}
|
||||||
@filter-changed=${this._filterChanged}
|
@filter-changed=${this._filterChanged}
|
||||||
@@ -131,6 +134,7 @@ export class HaSelectSelector extends LitElement {
|
|||||||
item-label-path="label"
|
item-label-path="label"
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.label=${this.label}
|
.label=${this.label}
|
||||||
|
.helper=${this.helper}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
.items=${options}
|
.items=${options}
|
||||||
@@ -161,6 +165,12 @@ export class HaSelectSelector extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _renderHelper() {
|
||||||
|
return this.helper
|
||||||
|
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
|
||||||
private get _mode(): "list" | "dropdown" {
|
private get _mode(): "list" | "dropdown" {
|
||||||
return (
|
return (
|
||||||
this.selector.select.mode ||
|
this.selector.select.mode ||
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ export class HaTargetSelector extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@state() private _entityPlaformLookup?: Record<string, string>;
|
@state() private _entityPlaformLookup?: Record<string, string>;
|
||||||
|
|
||||||
@state() private _configEntries?: ConfigEntry[];
|
@state() private _configEntries?: ConfigEntry[];
|
||||||
@@ -64,6 +66,7 @@ export class HaTargetSelector extends SubscribeMixin(LitElement) {
|
|||||||
return html`<ha-target-picker
|
return html`<ha-target-picker
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this.value}
|
.value=${this.value}
|
||||||
|
.helper=${this.helper}
|
||||||
.deviceFilter=${this._filterDevices}
|
.deviceFilter=${this._filterDevices}
|
||||||
.entityRegFilter=${this._filterRegEntities}
|
.entityRegFilter=${this._filterRegEntities}
|
||||||
.entityFilter=${this._filterEntities}
|
.entityFilter=${this._filterEntities}
|
||||||
|
|||||||
56
src/components/ha-selector/ha-selector-template.ts
Normal file
56
src/components/ha-selector/ha-selector-template.ts
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import { html, LitElement } from "lit";
|
||||||
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
|
import { HomeAssistant } from "../../types";
|
||||||
|
import "../ha-code-editor";
|
||||||
|
import "../ha-input-helper-text";
|
||||||
|
|
||||||
|
@customElement("ha-selector-template")
|
||||||
|
export class HaTemplateSelector extends LitElement {
|
||||||
|
@property() public hass!: HomeAssistant;
|
||||||
|
|
||||||
|
@property() public value?: string;
|
||||||
|
|
||||||
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
|
@property({ type: Boolean }) public required = true;
|
||||||
|
|
||||||
|
protected render() {
|
||||||
|
return html`
|
||||||
|
${this.label
|
||||||
|
? html`<p>${this.label}${this.required ? " *" : ""}</p>`
|
||||||
|
: ""}
|
||||||
|
<ha-code-editor
|
||||||
|
mode="jinja2"
|
||||||
|
.hass=${this.hass}
|
||||||
|
.value=${this.value}
|
||||||
|
.readOnly=${this.disabled}
|
||||||
|
autofocus
|
||||||
|
autocomplete-entities
|
||||||
|
@value-changed=${this._handleChange}
|
||||||
|
dir="ltr"
|
||||||
|
></ha-code-editor>
|
||||||
|
${this.helper
|
||||||
|
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
||||||
|
: ""}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _handleChange(ev) {
|
||||||
|
const value = ev.target.value;
|
||||||
|
if (this.value === value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fireEvent(this, "value-changed", { value });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"ha-selector-template": HaTemplateSelector;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,8 @@ export class HaTimeSelector extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean }) public disabled = false;
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required = false;
|
@property({ type: Boolean }) public required = false;
|
||||||
@@ -25,6 +27,7 @@ export class HaTimeSelector extends LitElement {
|
|||||||
.locale=${this.hass.locale}
|
.locale=${this.hass.locale}
|
||||||
.disabled=${this.disabled}
|
.disabled=${this.disabled}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
|
.helper=${this.helper}
|
||||||
.label=${this.label}
|
.label=${this.label}
|
||||||
enable-second
|
enable-second
|
||||||
></ha-time-input>
|
></ha-time-input>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import "./ha-selector-number";
|
|||||||
import "./ha-selector-object";
|
import "./ha-selector-object";
|
||||||
import "./ha-selector-select";
|
import "./ha-selector-select";
|
||||||
import "./ha-selector-target";
|
import "./ha-selector-target";
|
||||||
|
import "./ha-selector-template";
|
||||||
import "./ha-selector-text";
|
import "./ha-selector-text";
|
||||||
import "./ha-selector-time";
|
import "./ha-selector-time";
|
||||||
import "./ha-selector-icon";
|
import "./ha-selector-icon";
|
||||||
|
|||||||
@@ -472,6 +472,7 @@ export class HaServiceControl extends LitElement {
|
|||||||
ha-settings-row {
|
ha-settings-row {
|
||||||
--paper-time-input-justify-content: flex-end;
|
--paper-time-input-justify-content: flex-end;
|
||||||
--settings-row-content-width: 100%;
|
--settings-row-content-width: 100%;
|
||||||
|
--settings-row-prefix-display: contents;
|
||||||
border-top: var(
|
border-top: var(
|
||||||
--service-control-items-border-top,
|
--service-control-items-border-top,
|
||||||
1px solid var(--divider-color)
|
1px solid var(--divider-color)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export class HaSettingsRow extends LitElement {
|
|||||||
display: contents;
|
display: contents;
|
||||||
}
|
}
|
||||||
:host(:not([narrow])) .content {
|
:host(:not([narrow])) .content {
|
||||||
display: flex;
|
display: var(--settings-row-content-display, flex);
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 16px 0;
|
padding: 16px 0;
|
||||||
@@ -68,7 +68,7 @@ export class HaSettingsRow extends LitElement {
|
|||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
.prefix-wrap {
|
.prefix-wrap {
|
||||||
display: contents;
|
display: var(--settings-row-prefix-display);
|
||||||
}
|
}
|
||||||
:host([narrow]) .prefix-wrap {
|
:host([narrow]) .prefix-wrap {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -36,10 +36,9 @@ import memoizeOne from "memoize-one";
|
|||||||
import { LocalStorage } from "../common/decorators/local-storage";
|
import { LocalStorage } from "../common/decorators/local-storage";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import { toggleAttribute } from "../common/dom/toggle_attribute";
|
import { toggleAttribute } from "../common/dom/toggle_attribute";
|
||||||
import { computeDomain } from "../common/entity/compute_domain";
|
|
||||||
import { computeStateDomain } from "../common/entity/compute_state_domain";
|
|
||||||
import { stringCompare } from "../common/string/compare";
|
import { stringCompare } from "../common/string/compare";
|
||||||
import { computeRTL } from "../common/util/compute_rtl";
|
import { computeRTL } from "../common/util/compute_rtl";
|
||||||
|
import { throttle } from "../common/util/throttle";
|
||||||
import { ActionHandlerDetail } from "../data/lovelace";
|
import { ActionHandlerDetail } from "../data/lovelace";
|
||||||
import {
|
import {
|
||||||
PersistentNotification,
|
PersistentNotification,
|
||||||
@@ -294,11 +293,7 @@ class HaSidebar extends LitElement {
|
|||||||
toggleAttribute(this, "rtl", computeRTL(this.hass));
|
toggleAttribute(this, "rtl", computeRTL(this.hass));
|
||||||
}
|
}
|
||||||
|
|
||||||
this._updatesCount = Object.values(this.hass.states).filter(
|
this._calculateCounts();
|
||||||
(entity) =>
|
|
||||||
computeStateDomain(entity) === "update" &&
|
|
||||||
updateCanInstall(entity as UpdateEntity)
|
|
||||||
).length;
|
|
||||||
|
|
||||||
if (!SUPPORT_SCROLL_IF_NEEDED) {
|
if (!SUPPORT_SCROLL_IF_NEEDED) {
|
||||||
return;
|
return;
|
||||||
@@ -312,6 +307,21 @@ class HaSidebar extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _calculateCounts = throttle(() => {
|
||||||
|
let updateCount = 0;
|
||||||
|
|
||||||
|
for (const entityId of Object.keys(this.hass.states)) {
|
||||||
|
if (
|
||||||
|
entityId.startsWith("update.") &&
|
||||||
|
updateCanInstall(this.hass.states[entityId] as UpdateEntity)
|
||||||
|
) {
|
||||||
|
updateCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this._updatesCount = updateCount;
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
private _renderHeader() {
|
private _renderHeader() {
|
||||||
return html`<div
|
return html`<div
|
||||||
class="menu"
|
class="menu"
|
||||||
@@ -519,14 +529,9 @@ class HaSidebar extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _renderNotifications() {
|
private _renderNotifications() {
|
||||||
let notificationCount = this._notifications
|
const notificationCount = this._notifications
|
||||||
? this._notifications.length
|
? this._notifications.length
|
||||||
: 0;
|
: 0;
|
||||||
for (const entityId in this.hass.states) {
|
|
||||||
if (computeDomain(entityId) === "configurator") {
|
|
||||||
notificationCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return html`<div
|
return html`<div
|
||||||
class="notifications-container"
|
class="notifications-container"
|
||||||
@@ -1034,6 +1039,8 @@ class HaSidebar extends LitElement {
|
|||||||
|
|
||||||
.notification-badge,
|
.notification-badge,
|
||||||
.configuration-badge {
|
.configuration-badge {
|
||||||
|
left: calc(var(--app-drawer-width) - 42px);
|
||||||
|
position: absolute;
|
||||||
min-width: 20px;
|
min-width: 20px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
@@ -1044,9 +1051,6 @@ class HaSidebar extends LitElement {
|
|||||||
padding: 0px 6px;
|
padding: 0px 6px;
|
||||||
color: var(--text-accent-color, var(--text-primary-color));
|
color: var(--text-accent-color, var(--text-primary-color));
|
||||||
}
|
}
|
||||||
.configuration-badge {
|
|
||||||
background-color: var(--primary-color);
|
|
||||||
}
|
|
||||||
ha-svg-icon + .notification-badge,
|
ha-svg-icon + .notification-badge,
|
||||||
ha-svg-icon + .configuration-badge {
|
ha-svg-icon + .configuration-badge {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import type { HaEntityPickerEntityFilterFunc } from "./entity/ha-entity-picker";
|
|||||||
import "./ha-area-picker";
|
import "./ha-area-picker";
|
||||||
import "./ha-icon-button";
|
import "./ha-icon-button";
|
||||||
import "./ha-svg-icon";
|
import "./ha-svg-icon";
|
||||||
|
import "./ha-input-helper-text";
|
||||||
|
|
||||||
@customElement("ha-target-picker")
|
@customElement("ha-target-picker")
|
||||||
export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
||||||
@@ -52,6 +53,8 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show only targets with entities from specific domains.
|
* Show only targets with entities from specific domains.
|
||||||
* @type {Array}
|
* @type {Array}
|
||||||
@@ -213,7 +216,11 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>
|
||||||
|
|
||||||
|
${this.helper
|
||||||
|
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
||||||
|
: ""} `;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _showPicker(ev) {
|
private async _showPicker(ev) {
|
||||||
@@ -609,6 +616,10 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
|||||||
opacity: var(--light-disabled-opacity);
|
opacity: var(--light-disabled-opacity);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
:host-context([style*="direction: rtl;"]) .mdc-chip__icon {
|
||||||
|
margin-right: -14px !important;
|
||||||
|
margin-left: 4px !important;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,19 @@ export class HaTextField extends TextFieldBase {
|
|||||||
.mdc-text-field {
|
.mdc-text-field {
|
||||||
overflow: var(--text-field-overflow);
|
overflow: var(--text-field-overflow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:host-context([style*="direction: rtl;"]) .mdc-floating-label {
|
||||||
|
right: 10px !important;
|
||||||
|
left: initial !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host-context([style*="direction: rtl;"])
|
||||||
|
.mdc-text-field--with-leading-icon.mdc-text-field--filled
|
||||||
|
.mdc-floating-label {
|
||||||
|
max-width: calc(100% - 48px);
|
||||||
|
right: 48px !important;
|
||||||
|
left: initial !important;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ export class HaTimeInput extends LitElement {
|
|||||||
|
|
||||||
@property() public label?: string;
|
@property() public label?: string;
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean }) public disabled = false;
|
@property({ type: Boolean }) public disabled = false;
|
||||||
|
|
||||||
@property({ type: Boolean }) public required = false;
|
@property({ type: Boolean }) public required = false;
|
||||||
@@ -46,6 +48,7 @@ export class HaTimeInput extends LitElement {
|
|||||||
@value-changed=${this._timeChanged}
|
@value-changed=${this._timeChanged}
|
||||||
.enableSecond=${this.enableSecond}
|
.enableSecond=${this.enableSecond}
|
||||||
.required=${this.required}
|
.required=${this.required}
|
||||||
|
.helper=${this.helper}
|
||||||
></ha-base-time-input>
|
></ha-base-time-input>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
38
src/components/ha-tip.ts
Normal file
38
src/components/ha-tip.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { mdiLightbulbOutline } from "@mdi/js";
|
||||||
|
import { css, html, LitElement } from "lit";
|
||||||
|
import { customElement } from "lit/decorators";
|
||||||
|
|
||||||
|
import "./ha-svg-icon";
|
||||||
|
|
||||||
|
@customElement("ha-tip")
|
||||||
|
class HaTip extends LitElement {
|
||||||
|
public render() {
|
||||||
|
return html`
|
||||||
|
<ha-svg-icon .path=${mdiLightbulbOutline}></ha-svg-icon>
|
||||||
|
<span class="prefix">Tip!</span>
|
||||||
|
<span class="text"><slot></slot></span>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static styles = css`
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
margin-left: 2px;
|
||||||
|
color: var(--secondary-text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.prefix {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"ha-tip": HaTip;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -61,7 +61,9 @@ export class HaYamlEditor extends LitElement {
|
|||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
${this.label ? html`<p>${this.label}${this.required ? "*" : ""}</p>` : ""}
|
${this.label
|
||||||
|
? html`<p>${this.label}${this.required ? " *" : ""}</p>`
|
||||||
|
: ""}
|
||||||
<ha-code-editor
|
<ha-code-editor
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.value=${this._yaml}
|
.value=${this._yaml}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import memoizeOne from "memoize-one";
|
|||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import type { LeafletModuleType } from "../../common/dom/setup-leaflet-map";
|
import type { LeafletModuleType } from "../../common/dom/setup-leaflet-map";
|
||||||
import type { HomeAssistant } from "../../types";
|
import type { HomeAssistant } from "../../types";
|
||||||
|
import "../ha-input-helper-text";
|
||||||
import "./ha-map";
|
import "./ha-map";
|
||||||
import type { HaMap } from "./ha-map";
|
import type { HaMap } from "./ha-map";
|
||||||
|
|
||||||
@@ -50,6 +51,8 @@ export class HaLocationsEditor extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public locations?: MarkerLocation[];
|
@property({ attribute: false }) public locations?: MarkerLocation[];
|
||||||
|
|
||||||
|
@property() public helper?: string;
|
||||||
|
|
||||||
@property({ type: Boolean }) public autoFit = false;
|
@property({ type: Boolean }) public autoFit = false;
|
||||||
|
|
||||||
@property({ type: Number }) public zoom = 16;
|
@property({ type: Number }) public zoom = 16;
|
||||||
@@ -102,13 +105,18 @@ export class HaLocationsEditor extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`<ha-map
|
return html`
|
||||||
.hass=${this.hass}
|
<ha-map
|
||||||
.layers=${this._getLayers(this._circles, this._locationMarkers)}
|
.hass=${this.hass}
|
||||||
.zoom=${this.zoom}
|
.layers=${this._getLayers(this._circles, this._locationMarkers)}
|
||||||
.autoFit=${this.autoFit}
|
.zoom=${this.zoom}
|
||||||
.darkMode=${this.darkMode}
|
.autoFit=${this.autoFit}
|
||||||
></ha-map>`;
|
.darkMode=${this.darkMode}
|
||||||
|
></ha-map>
|
||||||
|
${this.helper
|
||||||
|
? html`<ha-input-helper-text>${this.helper}</ha-input-helper-text>`
|
||||||
|
: ""}
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getLayers = memoizeOne(
|
private _getLayers = memoizeOne(
|
||||||
@@ -287,11 +295,8 @@ export class HaLocationsEditor extends LitElement {
|
|||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
return css`
|
return css`
|
||||||
:host {
|
|
||||||
display: block;
|
|
||||||
height: 300px;
|
|
||||||
}
|
|
||||||
ha-map {
|
ha-map {
|
||||||
|
display: block;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user