mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-31 21:17:47 +00:00
update
This commit is contained in:
parent
4cf3aa18b1
commit
d0f799afc8
@ -2,7 +2,6 @@ import {
|
|||||||
CSSResult,
|
CSSResult,
|
||||||
customElement,
|
customElement,
|
||||||
html,
|
html,
|
||||||
internalProperty,
|
|
||||||
LitElement,
|
LitElement,
|
||||||
property,
|
property,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
@ -13,7 +12,7 @@ import { createCloseHeading } from "../../../../src/components/ha-dialog";
|
|||||||
import "../../../../src/components/ha-settings-row";
|
import "../../../../src/components/ha-settings-row";
|
||||||
import "../../../../src/components/ha-svg-icon";
|
import "../../../../src/components/ha-svg-icon";
|
||||||
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
||||||
import { setCheckOption } from "../../../../src/data/hassio/resolution";
|
import { setCheckOptions } from "../../../../src/data/hassio/resolution";
|
||||||
import { Supervisor } from "../../../../src/data/supervisor/supervisor";
|
import { Supervisor } from "../../../../src/data/supervisor/supervisor";
|
||||||
import { showAlertDialog } from "../../../../src/dialogs/generic/show-dialog-box";
|
import { showAlertDialog } from "../../../../src/dialogs/generic/show-dialog-box";
|
||||||
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
||||||
@ -24,37 +23,39 @@ import { SystemChecksParams } from "./show-dialog-system-checks";
|
|||||||
class HassioSystemChecksDialog extends LitElement {
|
class HassioSystemChecksDialog extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property({ attribute: false }) public supervisor!: Supervisor;
|
@property({ attribute: false }) public supervisor?: Supervisor;
|
||||||
|
|
||||||
@internalProperty() private _opened = false;
|
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
|
if (!this.supervisor) {
|
||||||
|
return html``;
|
||||||
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-dialog
|
<ha-dialog
|
||||||
@closing=${this.closeDialog}
|
@closing=${this.closeDialog}
|
||||||
.open=${this._opened}
|
|
||||||
.heading=${createCloseHeading(
|
.heading=${createCloseHeading(
|
||||||
this.hass,
|
this.hass,
|
||||||
this.supervisor.localize("dialog.system_check.title")
|
this.supervisor.localize("dialog.system_check.title")
|
||||||
)}
|
)}
|
||||||
hideActions
|
hideActions
|
||||||
|
open
|
||||||
>
|
>
|
||||||
<div class="form">
|
<div class="form">
|
||||||
${this.supervisor.resolution.checks.map(
|
${this.supervisor.resolution.checks.map(
|
||||||
(check) => html`
|
(check) => html`
|
||||||
<ha-settings-row three-line>
|
<ha-settings-row three-line>
|
||||||
<span slot="heading">
|
<span slot="heading">
|
||||||
${this.supervisor.localize(
|
${this.supervisor!.localize(
|
||||||
`dialog.system_check.check.${check.name}.title`
|
`dialog.system_check.check.${check.slug}.title`
|
||||||
) || check.name}
|
) || check.slug}
|
||||||
</span>
|
</span>
|
||||||
<span slot="description">
|
<span slot="description">
|
||||||
${this.supervisor.localize(
|
${this.supervisor!.localize(
|
||||||
`dialog.system_check.check.${check.name}.description`
|
`dialog.system_check.check.${check.slug}.description`
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
<ha-switch
|
<ha-switch
|
||||||
.check=${check.name}
|
.slug=${check.slug}
|
||||||
@change=${this._checkToggled}
|
@change=${this._checkToggled}
|
||||||
.checked=${check.enabled}
|
.checked=${check.enabled}
|
||||||
haptic
|
haptic
|
||||||
@ -68,14 +69,12 @@ class HassioSystemChecksDialog extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async showDialog(dialogParams: SystemChecksParams): Promise<void> {
|
public async showDialog(dialogParams: SystemChecksParams): Promise<void> {
|
||||||
this._opened = true;
|
|
||||||
this.supervisor = dialogParams.supervisor;
|
this.supervisor = dialogParams.supervisor;
|
||||||
await this.updateComplete;
|
await this.updateComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
public closeDialog(): void {
|
public closeDialog(): void {
|
||||||
this.supervisor = undefined;
|
this.supervisor = undefined;
|
||||||
this._opened = false;
|
|
||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,13 +90,13 @@ class HassioSystemChecksDialog extends LitElement {
|
|||||||
const check = ev.currentTarget as any;
|
const check = ev.currentTarget as any;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await setCheckOption(this.hass, check.check, { enabled: check.checked });
|
await setCheckOptions(this.hass, check.slug, { enabled: check.checked });
|
||||||
fireEvent(this, "supervisor-collection-refresh", {
|
fireEvent(this, "supervisor-collection-refresh", {
|
||||||
collection: "resolution",
|
collection: "resolution",
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showAlertDialog(this, {
|
showAlertDialog(this, {
|
||||||
title: this.supervisor.localize(
|
title: this.supervisor!.localize(
|
||||||
"dialog.system_check.failed_to_set_option"
|
"dialog.system_check.failed_to_set_option"
|
||||||
),
|
),
|
||||||
text: extractApiErrorMessage(err),
|
text: extractApiErrorMessage(err),
|
||||||
|
@ -7,7 +7,7 @@ export interface HassioResolution {
|
|||||||
unhealthy: string[];
|
unhealthy: string[];
|
||||||
issues: string[];
|
issues: string[];
|
||||||
suggestions: string[];
|
suggestions: string[];
|
||||||
checks: { name: string; enabled: boolean }[];
|
checks: { slug: string; enabled: boolean }[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetchHassioResolution = async (
|
export const fetchHassioResolution = async (
|
||||||
@ -29,7 +29,7 @@ export const fetchHassioResolution = async (
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setCheckOption = async (
|
export const setCheckOptions = async (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
check: string,
|
check: string,
|
||||||
data: Record<string, any>
|
data: Record<string, any>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user