Skip to content

Commit c05054e

Browse files
committed
Merge branch 'rc'
2 parents e7d9032 + f416b1b commit c05054e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+374
-248
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"type": "module",
2828
"dependencies": {
2929
"@babel/runtime": "7.26.0",
30-
"@braintree/sanitize-url": "7.1.0",
30+
"@braintree/sanitize-url": "7.1.1",
3131
"@codemirror/autocomplete": "6.18.4",
3232
"@codemirror/commands": "6.7.1",
3333
"@codemirror/language": "6.10.7",
@@ -139,7 +139,7 @@
139139
"tinykeys": "3.0.0",
140140
"tsparticles-engine": "2.12.0",
141141
"tsparticles-preset-links": "2.12.0",
142-
"ua-parser-js": "1.0.39",
142+
"ua-parser-js": "1.0.40",
143143
"vis-data": "7.1.9",
144144
"vis-network": "9.1.9",
145145
"vue": "2.7.16",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "home-assistant-frontend"
7-
version = "20241223.1"
7+
version = "20241224.0"
88
license = {text = "Apache-2.0"}
99
description = "The Home Assistant frontend"
1010
readme = "README.md"

src/components/chart/ha-chart-base.ts

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export class HaChartBase extends LitElement {
6161

6262
@state() private _chartHeight?: number;
6363

64+
@state() private _legendHeight?: number;
65+
6466
@state() private _tooltip?: Tooltip;
6567

6668
@state() private _hiddenDatasets: Set<number> = new Set();
@@ -214,10 +216,22 @@ export class HaChartBase extends LitElement {
214216
this.chart.update("none");
215217
}
216218

219+
protected updated(changedProperties: PropertyValues): void {
220+
super.updated(changedProperties);
221+
if (changedProperties.has("data") || changedProperties.has("options")) {
222+
if (this.options?.plugins?.legend?.display) {
223+
this._legendHeight =
224+
this.renderRoot.querySelector(".chart-legend")?.clientHeight;
225+
} else {
226+
this._legendHeight = 0;
227+
}
228+
}
229+
}
230+
217231
protected render() {
218232
return html`
219233
${this.options?.plugins?.legend?.display === true
220-
? html`<div class="chartLegend">
234+
? html`<div class="chart-legend">
221235
<ul>
222236
${this._datasetOrder.map((index) => {
223237
const dataset = this.data.datasets[index];
@@ -249,7 +263,7 @@ export class HaChartBase extends LitElement {
249263
</div>`
250264
: ""}
251265
<div
252-
class="animationContainer"
266+
class="animation-container"
253267
style=${styleMap({
254268
height: `${this.height || this._chartHeight || 0}px`,
255269
overflow: this._chartHeight ? "initial" : "hidden",
@@ -288,7 +302,7 @@ export class HaChartBase extends LitElement {
288302
</div>
289303
${this._tooltip
290304
? html`<div
291-
class="chartTooltip ${classMap({
305+
class="chart-tooltip ${classMap({
292306
[this._tooltip.yAlign]: true,
293307
})}"
294308
style=${styleMap({
@@ -298,7 +312,7 @@ export class HaChartBase extends LitElement {
298312
>
299313
<div class="title">${this._tooltip.title}</div>
300314
${this._tooltip.beforeBody
301-
? html`<div class="beforeBody">
315+
? html`<div class="before-body">
302316
${this._tooltip.beforeBody}
303317
</div>`
304318
: ""}
@@ -456,6 +470,7 @@ export class HaChartBase extends LitElement {
456470

457471
private _handleChartScroll(ev: MouseEvent) {
458472
const modifier = isMac ? "metaKey" : "ctrlKey";
473+
this._tooltip = undefined;
459474
if (!ev[modifier] && !this._showZoomHint) {
460475
this._showZoomHint = true;
461476
setTimeout(() => {
@@ -498,15 +513,20 @@ export class HaChartBase extends LitElement {
498513
this._tooltip = undefined;
499514
return;
500515
}
516+
const boundingBox = this.getBoundingClientRect();
501517
this._tooltip = {
502518
...context.tooltip,
503-
top: this.chart!.canvas.offsetTop + context.tooltip.caretY + 12 + "px",
519+
top:
520+
boundingBox.y +
521+
(this._legendHeight || 0) +
522+
context.tooltip.caretY +
523+
12 +
524+
"px",
504525
left:
505-
this.chart!.canvas.offsetLeft +
506526
clamp(
507-
context.tooltip.caretX,
508-
100,
509-
this.clientWidth - 100 - this._paddingYAxisInternal
527+
boundingBox.x + context.tooltip.caretX,
528+
boundingBox.x + 100,
529+
boundingBox.x + boundingBox.width - 100
510530
) -
511531
100 +
512532
"px",
@@ -525,27 +545,24 @@ export class HaChartBase extends LitElement {
525545
return css`
526546
:host {
527547
display: block;
528-
position: var(--chart-base-position, relative);
548+
position: relative;
529549
}
530-
.animationContainer {
550+
.animation-container {
531551
overflow: hidden;
532552
height: 0;
533553
transition: height 300ms cubic-bezier(0.4, 0, 0.2, 1);
534554
}
535-
.chart-container {
536-
position: relative;
537-
}
538555
canvas {
539556
max-height: var(--chart-max-height, 400px);
540557
}
541558
canvas.not-zoomed {
542559
/* allow scrolling if the chart is not zoomed */
543560
touch-action: pan-y !important;
544561
}
545-
.chartLegend {
562+
.chart-legend {
546563
text-align: center;
547564
}
548-
.chartLegend li {
565+
.chart-legend li {
549566
cursor: pointer;
550567
display: inline-grid;
551568
grid-auto-flow: column;
@@ -554,16 +571,16 @@ export class HaChartBase extends LitElement {
554571
align-items: center;
555572
color: var(--secondary-text-color);
556573
}
557-
.chartLegend .hidden {
574+
.chart-legend .hidden {
558575
text-decoration: line-through;
559576
}
560-
.chartLegend .label {
577+
.chart-legend .label {
561578
text-overflow: ellipsis;
562579
white-space: nowrap;
563580
overflow: hidden;
564581
}
565-
.chartLegend .bullet,
566-
.chartTooltip .bullet {
582+
.chart-legend .bullet,
583+
.chart-tooltip .bullet {
567584
border-width: 1px;
568585
border-style: solid;
569586
border-radius: 50%;
@@ -577,13 +594,13 @@ export class HaChartBase extends LitElement {
577594
margin-inline-start: initial;
578595
direction: var(--direction);
579596
}
580-
.chartTooltip .bullet {
597+
.chart-tooltip .bullet {
581598
align-self: baseline;
582599
}
583-
.chartTooltip {
600+
.chart-tooltip {
584601
padding: 8px;
585602
font-size: 90%;
586-
position: absolute;
603+
position: fixed;
587604
background: rgba(80, 80, 80, 0.9);
588605
color: white;
589606
border-radius: 4px;
@@ -596,34 +613,34 @@ export class HaChartBase extends LitElement {
596613
box-sizing: border-box;
597614
direction: var(--direction);
598615
}
599-
.chartLegend ul,
600-
.chartTooltip ul {
616+
.chart-legend ul,
617+
.chart-tooltip ul {
601618
display: inline-block;
602619
padding: 0 0px;
603620
margin: 8px 0 0 0;
604621
width: 100%;
605622
}
606-
.chartTooltip ul {
623+
.chart-tooltip ul {
607624
margin: 0 4px;
608625
}
609-
.chartTooltip li {
626+
.chart-tooltip li {
610627
display: flex;
611628
white-space: pre-line;
612629
word-break: break-word;
613630
align-items: center;
614631
line-height: 16px;
615632
padding: 4px 0;
616633
}
617-
.chartTooltip .title {
634+
.chart-tooltip .title {
618635
text-align: center;
619636
font-weight: 500;
620637
word-break: break-word;
621638
direction: ltr;
622639
}
623-
.chartTooltip .footer {
640+
.chart-tooltip .footer {
624641
font-weight: 500;
625642
}
626-
.chartTooltip .beforeBody {
643+
.chart-tooltip .before-body {
627644
text-align: center;
628645
font-weight: 300;
629646
word-break: break-all;

src/components/media-player/dialog-media-manage.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,9 @@ class DialogMediaManage extends LitElement {
210210
href="/config/storage"
211211
@click=${this.closeDialog}
212212
>
213-
${this.hass
214-
.localize(
215-
"ui.components.media-browser.file_management.tip_storage_panel"
216-
)
217-
.toLowerCase()}
213+
${this.hass.localize(
214+
"ui.components.media-browser.file_management.tip_storage_panel"
215+
)}
218216
</a>`,
219217
}
220218
)}

src/data/backup.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
import { setHours, setMinutes } from "date-fns";
2+
import type { HassConfig } from "home-assistant-js-websocket";
3+
import memoizeOne from "memoize-one";
4+
import { formatTime } from "../common/datetime/format_time";
15
import type { LocalizeFunc } from "../common/translations/localize";
26
import type { HomeAssistant } from "../types";
37
import { domainToName } from "./integration";
8+
import type { FrontendLocaleData } from "./translation";
9+
import {
10+
formatDateTime,
11+
formatDateTimeNumeric,
12+
} from "../common/datetime/format_date_time";
13+
import { fileDownload } from "../util/file_download";
414

515
export const enum BackupScheduleState {
616
NEVER = "never",
@@ -282,3 +292,49 @@ export const generateEncryptionKey = () => {
282292
});
283293
return result;
284294
};
295+
296+
export const generateEmergencyKit = (
297+
hass: HomeAssistant,
298+
encryptionKey: string
299+
) =>
300+
"data:text/plain;charset=utf-8," +
301+
encodeURIComponent(`Home Assistant Backup Emergency Kit
302+
303+
This emergency kit contains your backup encryption key. You need this key
304+
to be able to restore your Home Assistant backups.
305+
306+
Date: ${formatDateTime(new Date(), hass.locale, hass.config)}
307+
308+
Instance:
309+
${hass.config.location_name}
310+
311+
URL:
312+
${hass.auth.data.hassUrl}
313+
314+
Encryption key:
315+
${encryptionKey}
316+
317+
For more information visit: https://www.home-assistant.io/more-info/backup-emergency-kit`);
318+
319+
export const geneateEmergencyKitFileName = (
320+
hass: HomeAssistant,
321+
append?: string
322+
) =>
323+
`home_assistant_backup_emergency_kit_${append ? `${append}_` : ""}${formatDateTimeNumeric(new Date(), hass.locale, hass.config).replace(",", "").replace(" ", "_")}.txt`;
324+
325+
export const downloadEmergencyKit = (
326+
hass: HomeAssistant,
327+
key: string,
328+
appendFileName?: string
329+
) =>
330+
fileDownload(
331+
generateEmergencyKit(hass, key),
332+
geneateEmergencyKitFileName(hass, appendFileName)
333+
);
334+
335+
export const getFormattedBackupTime = memoizeOne(
336+
(locale: FrontendLocaleData, config: HassConfig) => {
337+
const date = setMinutes(setHours(new Date(), 4), 45);
338+
return formatTime(date, locale, config);
339+
}
340+
);

src/dialogs/config-flow/show-dialog-config-flow.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const showConfigFlowDialog = (
5050

5151
return description
5252
? html`
53-
<ha-markdown allowsvg breaks .content=${description}></ha-markdown>
53+
<ha-markdown allow-svg breaks .content=${description}></ha-markdown>
5454
`
5555
: step.reason;
5656
},
@@ -71,7 +71,7 @@ export const showConfigFlowDialog = (
7171
);
7272
return description
7373
? html`
74-
<ha-markdown allowsvg breaks .content=${description}></ha-markdown>
74+
<ha-markdown allow-svg breaks .content=${description}></ha-markdown>
7575
`
7676
: "";
7777
},
@@ -163,7 +163,7 @@ export const showConfigFlowDialog = (
163163
${description
164164
? html`
165165
<ha-markdown
166-
allowsvg
166+
allow-svg
167167
breaks
168168
.content=${description}
169169
></ha-markdown>
@@ -184,7 +184,7 @@ export const showConfigFlowDialog = (
184184
${description
185185
? html`
186186
<ha-markdown
187-
allowsvg
187+
allow-svg
188188
breaks
189189
.content=${description}
190190
></ha-markdown>
@@ -214,7 +214,7 @@ export const showConfigFlowDialog = (
214214
);
215215
return description
216216
? html`
217-
<ha-markdown allowsvg breaks .content=${description}></ha-markdown>
217+
<ha-markdown allow-svg breaks .content=${description}></ha-markdown>
218218
`
219219
: "";
220220
},
@@ -234,7 +234,7 @@ export const showConfigFlowDialog = (
234234
);
235235
return description
236236
? html`
237-
<ha-markdown allowsvg breaks .content=${description}></ha-markdown>
237+
<ha-markdown allow-svg breaks .content=${description}></ha-markdown>
238238
`
239239
: "";
240240
},

0 commit comments

Comments
 (0)