mirror of
https://github.com/home-assistant/frontend.git
synced 2026-02-09 09:48:20 +00:00
Compare commits
1 Commits
migrate-di
...
migrate-di
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19e16693ef |
@@ -30,7 +30,6 @@ import type {
|
||||
import { showDataTableSettingsDialog } from "../../../../components/data-table/show-dialog-data-table-settings";
|
||||
import "@home-assistant/webawesome/dist/components/divider/divider";
|
||||
import "../../../../components/ha-button";
|
||||
import "../../../../components/ha-dialog";
|
||||
import "../../../../components/ha-dropdown";
|
||||
import "../../../../components/ha-dropdown-item";
|
||||
import type { HaMdMenu } from "../../../../components/ha-md-menu";
|
||||
|
||||
@@ -6,7 +6,8 @@ import memoizeOne from "memoize-one";
|
||||
import { formatDateTime } from "../../../../common/datetime/format_date_time";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import "../../../../components/ha-spinner";
|
||||
import "../../../../components/ha-dialog";
|
||||
import "../../../../components/ha-dialog-footer";
|
||||
import "../../../../components/ha-wa-dialog";
|
||||
import "../../../../components/ha-button";
|
||||
import "../../../../components/ha-form/ha-form";
|
||||
import "../../../../components/ha-icon-next";
|
||||
@@ -41,6 +42,8 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
|
||||
@state() private _params?: DialogStatisticsAdjustSumParams;
|
||||
|
||||
@state() private _open = false;
|
||||
|
||||
@state() private _busy = false;
|
||||
|
||||
@state() private _moment?: string;
|
||||
@@ -71,6 +74,7 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
|
||||
public showDialog(params: DialogStatisticsAdjustSumParams): void {
|
||||
this._params = params;
|
||||
this._open = true;
|
||||
// moment is in format YYYY-MM-DD HH:mm:ss because of selector
|
||||
// Here we create a date with minutes set to %5
|
||||
const now = new Date();
|
||||
@@ -80,6 +84,11 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
}
|
||||
|
||||
public closeDialog(): void {
|
||||
this._open = false;
|
||||
}
|
||||
|
||||
private _dialogClosed(): void {
|
||||
this._open = false;
|
||||
this._params = undefined;
|
||||
this._moment = undefined;
|
||||
this._stats5min = undefined;
|
||||
@@ -97,25 +106,59 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
}
|
||||
|
||||
let content: TemplateResult;
|
||||
let footer: TemplateResult;
|
||||
|
||||
if (!this._chosenStat) {
|
||||
content = this._renderPickStatistic();
|
||||
footer = html`
|
||||
<ha-button
|
||||
slot="secondaryAction"
|
||||
appearance="plain"
|
||||
@click=${this._fetchOutliers}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.outliers"
|
||||
)}
|
||||
</ha-button>
|
||||
<ha-button slot="primaryAction" data-dialog="close">
|
||||
${this.hass.localize("ui.common.close")}
|
||||
</ha-button>
|
||||
`;
|
||||
} else {
|
||||
content = this._renderAdjustStat();
|
||||
footer = html`
|
||||
<ha-button
|
||||
slot="secondaryAction"
|
||||
.disabled=${this._busy}
|
||||
@click=${this._clearChosenStatistic}
|
||||
appearance="plain"
|
||||
>
|
||||
${this.hass.localize("ui.common.back")}</ha-button
|
||||
>
|
||||
<ha-button
|
||||
slot="primaryAction"
|
||||
.disabled=${this._busy}
|
||||
@click=${this._fixIssue}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.adjust"
|
||||
)}</ha-button
|
||||
>
|
||||
`;
|
||||
}
|
||||
|
||||
return html`
|
||||
<ha-dialog
|
||||
open
|
||||
scrimClickAction
|
||||
escapeKeyAction
|
||||
@closed=${this.closeDialog}
|
||||
.heading=${this.hass.localize(
|
||||
<ha-wa-dialog
|
||||
.hass=${this.hass}
|
||||
.open=${this._open}
|
||||
header-title=${this.hass.localize(
|
||||
"ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.title"
|
||||
)}
|
||||
@closed=${this._dialogClosed}
|
||||
>
|
||||
${content}
|
||||
</ha-dialog>
|
||||
<ha-dialog-footer slot="footer">${footer}</ha-dialog-footer>
|
||||
</ha-wa-dialog>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -196,18 +239,6 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
@value-changed=${this._dateTimeSelectorChanged}
|
||||
></ha-selector-datetime>
|
||||
<div class="stat-list">${stats}</div>
|
||||
<ha-button
|
||||
appearance="plain"
|
||||
slot="secondaryAction"
|
||||
@click=${this._fetchOutliers}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.outliers"
|
||||
)}
|
||||
</ha-button>
|
||||
<ha-button slot="primaryAction" dialogAction="cancel">
|
||||
${this.hass.localize("ui.common.close")}
|
||||
</ha-button>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -285,24 +316,6 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
.disabled=${this._busy}
|
||||
@value-changed=${this._amountChanged}
|
||||
></ha-selector-number>
|
||||
|
||||
<ha-button
|
||||
slot="secondaryAction"
|
||||
.disabled=${this._busy}
|
||||
@click=${this._clearChosenStatistic}
|
||||
appearance="plain"
|
||||
>
|
||||
${this.hass.localize("ui.common.back")}</ha-button
|
||||
>
|
||||
<ha-button
|
||||
slot="primaryAction"
|
||||
.disabled=${this._busy}
|
||||
@click=${this._fixIssue}
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.adjust"
|
||||
)}</ha-button
|
||||
>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -492,27 +505,6 @@ export class DialogStatisticsFixUnsupportedUnitMetadata extends LitElement {
|
||||
haStyle,
|
||||
haStyleDialog,
|
||||
css`
|
||||
@media all and (max-width: 450px), all and (max-height: 500px) {
|
||||
/* overrule the ha-style-dialog max-height on small screens */
|
||||
ha-dialog {
|
||||
--mdc-dialog-max-height: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media all and (min-width: 850px) {
|
||||
ha-dialog {
|
||||
--mdc-dialog-max-height: 80%;
|
||||
--mdc-dialog-max-height: 80%;
|
||||
}
|
||||
}
|
||||
|
||||
@media all and (min-width: 451px) and (min-height: 501px) {
|
||||
ha-dialog {
|
||||
--mdc-dialog-max-width: 480px;
|
||||
}
|
||||
}
|
||||
|
||||
.text-content,
|
||||
ha-selector-datetime,
|
||||
ha-selector-number {
|
||||
|
||||
@@ -2,7 +2,8 @@ import type { CSSResultGroup } from "lit";
|
||||
import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import "../../../../components/ha-dialog";
|
||||
import "../../../../components/ha-dialog-footer";
|
||||
import "../../../../components/ha-wa-dialog";
|
||||
import "../../../../components/ha-button";
|
||||
import "../../../../components/ha-formfield";
|
||||
import "../../../../components/ha-radio";
|
||||
@@ -21,20 +22,24 @@ export class DialogStatisticsFixUnitsChanged extends LitElement {
|
||||
|
||||
@state() private _params?: DialogStatisticsUnitsChangedParams;
|
||||
|
||||
@state() private _open = false;
|
||||
|
||||
@state() private _action?: "update" | "clear" | "change";
|
||||
|
||||
public showDialog(params: DialogStatisticsUnitsChangedParams): void {
|
||||
this._params = params;
|
||||
this._action = "update";
|
||||
this._open = true;
|
||||
}
|
||||
|
||||
public closeDialog(): void {
|
||||
this._cancel();
|
||||
this._open = false;
|
||||
}
|
||||
|
||||
private _closeDialog(): void {
|
||||
private _dialogClosed(): void {
|
||||
this._params = undefined;
|
||||
this._action = undefined;
|
||||
this._open = false;
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
@@ -44,14 +49,13 @@ export class DialogStatisticsFixUnitsChanged extends LitElement {
|
||||
}
|
||||
|
||||
return html`
|
||||
<ha-dialog
|
||||
open
|
||||
scrimClickAction
|
||||
escapeKeyAction
|
||||
@closed=${this._closeDialog}
|
||||
.heading=${this.hass.localize(
|
||||
<ha-wa-dialog
|
||||
.hass=${this.hass}
|
||||
.open=${this._open}
|
||||
header-title=${this.hass.localize(
|
||||
"ui.panel.config.developer-tools.tabs.statistics.fix_issue.units_changed.title"
|
||||
)}
|
||||
@closed=${this._dialogClosed}
|
||||
>
|
||||
<p>
|
||||
${this.hass.localize(
|
||||
@@ -91,7 +95,7 @@ export class DialogStatisticsFixUnitsChanged extends LitElement {
|
||||
name="action"
|
||||
.checked=${this._action === "update"}
|
||||
@change=${this._handleActionChanged}
|
||||
dialogInitialFocus
|
||||
autofocus
|
||||
></ha-radio>
|
||||
</ha-formfield>
|
||||
<ha-formfield
|
||||
@@ -107,19 +111,21 @@ export class DialogStatisticsFixUnitsChanged extends LitElement {
|
||||
></ha-radio>
|
||||
</ha-formfield>
|
||||
|
||||
<ha-button
|
||||
appearance="plain"
|
||||
slot="primaryAction"
|
||||
@click=${this._cancel}
|
||||
>
|
||||
${this.hass.localize("ui.common.close")}
|
||||
</ha-button>
|
||||
<ha-button slot="primaryAction" @click=${this._fixIssue}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.developer-tools.tabs.statistics.fix_issue.fix"
|
||||
)}
|
||||
</ha-button>
|
||||
</ha-dialog>
|
||||
<ha-dialog-footer slot="footer">
|
||||
<ha-button
|
||||
appearance="plain"
|
||||
slot="secondaryAction"
|
||||
@click=${this._cancel}
|
||||
>
|
||||
${this.hass.localize("ui.common.close")}
|
||||
</ha-button>
|
||||
<ha-button slot="primaryAction" @click=${this._fixIssue}>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.developer-tools.tabs.statistics.fix_issue.fix"
|
||||
)}
|
||||
</ha-button>
|
||||
</ha-dialog-footer>
|
||||
</ha-wa-dialog>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -129,7 +135,7 @@ export class DialogStatisticsFixUnitsChanged extends LitElement {
|
||||
|
||||
private _cancel(): void {
|
||||
this._params?.cancelCallback!();
|
||||
this._closeDialog();
|
||||
this.closeDialog();
|
||||
}
|
||||
|
||||
private async _fixIssue(): Promise<void> {
|
||||
@@ -144,7 +150,7 @@ export class DialogStatisticsFixUnitsChanged extends LitElement {
|
||||
);
|
||||
}
|
||||
this._params?.fixedCallback!();
|
||||
this._closeDialog();
|
||||
this.closeDialog();
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
|
||||
@@ -3,7 +3,8 @@ import { html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import "../../../../components/ha-button";
|
||||
import "../../../../components/ha-dialog";
|
||||
import "../../../../components/ha-dialog-footer";
|
||||
import "../../../../components/ha-wa-dialog";
|
||||
import "../../../../components/ha-spinner";
|
||||
import { clearStatistics, getStatisticLabel } from "../../../../data/recorder";
|
||||
import { haStyle, haStyleDialog } from "../../../../resources/styles";
|
||||
@@ -18,19 +19,23 @@ export class DialogStatisticsFix extends LitElement {
|
||||
|
||||
@state() private _params?: DialogStatisticsFixParams;
|
||||
|
||||
@state() private _open = false;
|
||||
|
||||
@state() private _clearing = false;
|
||||
|
||||
public showDialog(params: DialogStatisticsFixParams): void {
|
||||
this._params = params;
|
||||
this._open = true;
|
||||
}
|
||||
|
||||
public closeDialog(): void {
|
||||
this._cancel();
|
||||
this._open = false;
|
||||
}
|
||||
|
||||
private _closeDialog(): void {
|
||||
private _dialogClosed(): void {
|
||||
this._params = undefined;
|
||||
this._clearing = false;
|
||||
this._open = false;
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
}
|
||||
|
||||
@@ -42,14 +47,13 @@ export class DialogStatisticsFix extends LitElement {
|
||||
const issue = this._params.issue;
|
||||
|
||||
return html`
|
||||
<ha-dialog
|
||||
open
|
||||
scrimClickAction
|
||||
escapeKeyAction
|
||||
@closed=${this._closeDialog}
|
||||
.heading=${this.hass.localize(
|
||||
<ha-wa-dialog
|
||||
.hass=${this.hass}
|
||||
.open=${this._open}
|
||||
header-title=${this.hass.localize(
|
||||
`ui.panel.config.developer-tools.tabs.statistics.fix_issue.${issue.type}.title`
|
||||
)}
|
||||
@closed=${this._dialogClosed}
|
||||
>
|
||||
<p>
|
||||
${this.hass.localize(
|
||||
@@ -147,33 +151,36 @@ export class DialogStatisticsFix extends LitElement {
|
||||
: nothing}
|
||||
</p>
|
||||
|
||||
${issue.type !== "entity_not_recorded"
|
||||
? html`<ha-button
|
||||
appearance="plain"
|
||||
slot="primaryAction"
|
||||
@click=${this._cancel}
|
||||
>
|
||||
${this.hass.localize("ui.common.close")}
|
||||
</ha-button>
|
||||
<ha-button
|
||||
slot="primaryAction"
|
||||
@click=${this._clearStatistics}
|
||||
variants="danger"
|
||||
.disabled=${this._clearing}
|
||||
.loading=${this._clearing}
|
||||
>
|
||||
${this.hass.localize("ui.common.delete")}
|
||||
</ha-button>`
|
||||
: html`<ha-button slot="primaryAction" @click=${this._cancel}>
|
||||
${this.hass.localize("ui.common.ok")}
|
||||
</ha-button>`}
|
||||
</ha-dialog>
|
||||
<ha-dialog-footer slot="footer">
|
||||
${issue.type !== "entity_not_recorded"
|
||||
? html`<ha-button
|
||||
appearance="plain"
|
||||
slot="secondaryAction"
|
||||
@click=${this._cancel}
|
||||
>
|
||||
${this.hass.localize("ui.common.close")}
|
||||
</ha-button>
|
||||
<ha-button
|
||||
slot="primaryAction"
|
||||
appearance="filled"
|
||||
@click=${this._clearStatistics}
|
||||
variants="danger"
|
||||
.disabled=${this._clearing}
|
||||
.loading=${this._clearing}
|
||||
>
|
||||
${this.hass.localize("ui.common.delete")}
|
||||
</ha-button>`
|
||||
: html`<ha-button slot="primaryAction" @click=${this._cancel}>
|
||||
${this.hass.localize("ui.common.ok")}
|
||||
</ha-button>`}
|
||||
</ha-dialog-footer>
|
||||
</ha-wa-dialog>
|
||||
`;
|
||||
}
|
||||
|
||||
private _cancel(): void {
|
||||
this._params?.cancelCallback!();
|
||||
this._closeDialog();
|
||||
this.closeDialog();
|
||||
}
|
||||
|
||||
private async _clearStatistics(): Promise<void> {
|
||||
@@ -200,7 +207,7 @@ export class DialogStatisticsFix extends LitElement {
|
||||
} finally {
|
||||
this._clearing = false;
|
||||
this._params?.fixedCallback!();
|
||||
this._closeDialog();
|
||||
this.closeDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { mdiClose } from "@mdi/js";
|
||||
import { dump } from "js-yaml";
|
||||
import type { CSSResultGroup } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
@@ -5,9 +6,9 @@ import { customElement, property, state } from "lit/decorators";
|
||||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import { stringCompare } from "../../../common/string/compare";
|
||||
import "../../../components/ha-dialog";
|
||||
import "../../../components/ha-expansion-panel";
|
||||
import "../../../components/ha-icon-next";
|
||||
import "../../../components/ha-wa-dialog";
|
||||
import "../../../components/search-input";
|
||||
import { extractApiErrorMessage } from "../../../data/hassio/common";
|
||||
import type { HassioHardwareInfo } from "../../../data/hassio/hardware";
|
||||
@@ -47,12 +48,9 @@ class DialogHardwareAvailable extends LitElement implements HassDialog {
|
||||
|
||||
@state() private _filter?: string;
|
||||
|
||||
@state() private _open = false;
|
||||
|
||||
public async showDialog(): Promise<Promise<void>> {
|
||||
try {
|
||||
this._hardware = await fetchHassioHardwareInfo(this.hass);
|
||||
this._open = true;
|
||||
} catch (err: any) {
|
||||
await showAlertDialog(this, {
|
||||
title: this.hass.localize(
|
||||
@@ -63,15 +61,10 @@ class DialogHardwareAvailable extends LitElement implements HassDialog {
|
||||
}
|
||||
}
|
||||
|
||||
public closeDialog(): boolean {
|
||||
this._open = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private _dialogClosed() {
|
||||
this._open = false;
|
||||
public closeDialog() {
|
||||
this._hardware = undefined;
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
return true;
|
||||
}
|
||||
|
||||
protected render() {
|
||||
@@ -87,24 +80,35 @@ class DialogHardwareAvailable extends LitElement implements HassDialog {
|
||||
);
|
||||
|
||||
return html`
|
||||
<ha-wa-dialog
|
||||
.hass=${this.hass}
|
||||
.open=${this._open}
|
||||
header-title=${this.hass.localize(
|
||||
<ha-dialog
|
||||
open
|
||||
hideActions
|
||||
@closed=${this.closeDialog}
|
||||
.heading=${this.hass.localize(
|
||||
"ui.panel.config.hardware.available_hardware.title"
|
||||
)}
|
||||
@closed=${this._dialogClosed}
|
||||
>
|
||||
<search-input
|
||||
autofocus
|
||||
.hass=${this.hass}
|
||||
.filter=${this._filter}
|
||||
@value-changed=${this._handleSearchChange}
|
||||
.label=${this.hass.localize(
|
||||
"ui.panel.config.hardware.available_hardware.search"
|
||||
)}
|
||||
>
|
||||
</search-input>
|
||||
<div class="header" slot="heading">
|
||||
<h2>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.hardware.available_hardware.title"
|
||||
)}
|
||||
</h2>
|
||||
<ha-icon-button
|
||||
.label=${this.hass.localize("ui.common.close")}
|
||||
.path=${mdiClose}
|
||||
dialogAction="close"
|
||||
></ha-icon-button>
|
||||
<search-input
|
||||
.hass=${this.hass}
|
||||
.filter=${this._filter}
|
||||
@value-changed=${this._handleSearchChange}
|
||||
.label=${this.hass.localize(
|
||||
"ui.panel.config.hardware.available_hardware.search"
|
||||
)}
|
||||
>
|
||||
</search-input>
|
||||
</div>
|
||||
${devices.map(
|
||||
(device) => html`
|
||||
<ha-expansion-panel
|
||||
@@ -151,7 +155,7 @@ class DialogHardwareAvailable extends LitElement implements HassDialog {
|
||||
</ha-expansion-panel>
|
||||
`
|
||||
)}
|
||||
</ha-wa-dialog>
|
||||
</ha-dialog>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -164,6 +168,23 @@ class DialogHardwareAvailable extends LitElement implements HassDialog {
|
||||
haStyle,
|
||||
haStyleDialog,
|
||||
css`
|
||||
ha-icon-button {
|
||||
position: absolute;
|
||||
right: 16px;
|
||||
inset-inline-end: 16px;
|
||||
inset-inline-start: initial;
|
||||
top: 10px;
|
||||
inset-inline-end: 16px;
|
||||
inset-inline-start: initial;
|
||||
text-decoration: none;
|
||||
color: var(--primary-text-color);
|
||||
}
|
||||
h2 {
|
||||
margin: 18px 42px 0 18px;
|
||||
margin-inline-start: 18px;
|
||||
margin-inline-end: 42px;
|
||||
color: var(--primary-text-color);
|
||||
}
|
||||
ha-expansion-panel {
|
||||
margin: 4px 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user