mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-31 21:17:47 +00:00
change
This commit is contained in:
parent
36831d26e4
commit
09f4922ad3
@ -220,10 +220,29 @@ export class HassioUpdate extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _updateCore(): Promise<void> {
|
private async _updateCore(): Promise<void> {
|
||||||
|
try {
|
||||||
await updateCore(this.hass);
|
await updateCore(this.hass);
|
||||||
|
} catch (err) {
|
||||||
|
if (this.hass.connection.connected && !ignoreSupervisorError(err)) {
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: this.supervisor.localize(
|
||||||
|
"common.failed_to_update_name",
|
||||||
|
"name",
|
||||||
|
"Home Assistant Core"
|
||||||
|
),
|
||||||
|
text: extractApiErrorMessage(err),
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fireEvent(this, "supervisor-collection-refresh", {
|
fireEvent(this, "supervisor-collection-refresh", {
|
||||||
collection: "core",
|
collection: "core",
|
||||||
});
|
});
|
||||||
|
fireEvent(this, "supervisor-applying-update", {
|
||||||
|
name: "Home Assistant Core",
|
||||||
|
version: this.supervisor.core.version_latest,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
|
@ -7,17 +7,12 @@ import "../../../../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 "../../../../src/components/ha-switch";
|
import "../../../../src/components/ha-switch";
|
||||||
import {
|
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
|
||||||
extractApiErrorMessage,
|
|
||||||
ignoreSupervisorError,
|
|
||||||
} from "../../../../src/data/hassio/common";
|
|
||||||
import { createHassioPartialSnapshot } from "../../../../src/data/hassio/snapshot";
|
import { createHassioPartialSnapshot } from "../../../../src/data/hassio/snapshot";
|
||||||
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
|
||||||
import type { HomeAssistant } from "../../../../src/types";
|
import type { HomeAssistant } from "../../../../src/types";
|
||||||
import { SupervisorDialogSupervisorUpdateParams } from "./show-dialog-update";
|
import { SupervisorDialogSupervisorUpdateParams } from "./show-dialog-update";
|
||||||
|
|
||||||
const BLOCKING_UPDATES: string[] = ["Home Assistant Core"];
|
|
||||||
|
|
||||||
@customElement("dialog-supervisor-update")
|
@customElement("dialog-supervisor-update")
|
||||||
class DialogSupervisorUpdate extends LitElement {
|
class DialogSupervisorUpdate extends LitElement {
|
||||||
public hass!: HomeAssistant;
|
public hass!: HomeAssistant;
|
||||||
@ -38,13 +33,6 @@ class DialogSupervisorUpdate extends LitElement {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
this._opened = true;
|
this._opened = true;
|
||||||
this._dialogParams = params;
|
this._dialogParams = params;
|
||||||
this.addEventListener("supervisor-applying-update", (ev) => {
|
|
||||||
fireEvent(
|
|
||||||
this._dialogParams!.element,
|
|
||||||
"supervisor-applying-update",
|
|
||||||
ev.detail
|
|
||||||
);
|
|
||||||
});
|
|
||||||
await this.updateComplete;
|
await this.updateComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,21 +150,7 @@ class DialogSupervisorUpdate extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._action = "update";
|
this._action = "update";
|
||||||
try {
|
|
||||||
await this._dialogParams!.updateHandler!();
|
await this._dialogParams!.updateHandler!();
|
||||||
} catch (err) {
|
|
||||||
if (this.hass.connection.connected && !ignoreSupervisorError(err)) {
|
|
||||||
this._error = extractApiErrorMessage(err);
|
|
||||||
this._action = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (BLOCKING_UPDATES.includes(this._dialogParams!.name)) {
|
|
||||||
fireEvent(this, "supervisor-applying-update", {
|
|
||||||
name: this._dialogParams!.name,
|
|
||||||
version: this._dialogParams!.version,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.closeDialog();
|
this.closeDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../../src/common/dom/fire_event";
|
||||||
|
import { HassioPartialSnapshotCreateParams } from "../../../../src/data/hassio/snapshot";
|
||||||
import { Supervisor } from "../../../../src/data/supervisor/supervisor";
|
import { Supervisor } from "../../../../src/data/supervisor/supervisor";
|
||||||
|
|
||||||
export interface SupervisorDialogSupervisorUpdateParams {
|
export interface SupervisorDialogSupervisorUpdateParams {
|
||||||
supervisor: Supervisor;
|
supervisor: Supervisor;
|
||||||
name: string;
|
name: string;
|
||||||
version: string;
|
version: string;
|
||||||
snapshotParams: any;
|
snapshotParams: HassioPartialSnapshotCreateParams;
|
||||||
element: HTMLElement;
|
|
||||||
updateHandler: () => Promise<void>;
|
updateHandler: () => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,7 +14,6 @@ export const showDialogSupervisorUpdate = (
|
|||||||
element: HTMLElement,
|
element: HTMLElement,
|
||||||
dialogParams: Partial<SupervisorDialogSupervisorUpdateParams>
|
dialogParams: Partial<SupervisorDialogSupervisorUpdateParams>
|
||||||
): void => {
|
): void => {
|
||||||
dialogParams.element = element;
|
|
||||||
fireEvent(element, "show-dialog", {
|
fireEvent(element, "show-dialog", {
|
||||||
dialogTag: "dialog-supervisor-update",
|
dialogTag: "dialog-supervisor-update",
|
||||||
dialogImport: () => import("./dialog-supervisor-update"),
|
dialogImport: () => import("./dialog-supervisor-update"),
|
||||||
|
@ -56,7 +56,7 @@ class HassioPanel extends LitElement {
|
|||||||
|
|
||||||
if (this._applyingUpdate !== undefined) {
|
if (this._applyingUpdate !== undefined) {
|
||||||
return html`<hass-loading-screen no-toolbar>
|
return html`<hass-loading-screen no-toolbar>
|
||||||
${this.supervisor.localize("common.applying_update", {
|
${this.supervisor.localize("dialog.update.updating", {
|
||||||
name: this._applyingUpdate.name,
|
name: this._applyingUpdate.name,
|
||||||
version: this._applyingUpdate.version,
|
version: this._applyingUpdate.version,
|
||||||
})}
|
})}
|
||||||
|
@ -11,6 +11,7 @@ import {
|
|||||||
extractApiErrorMessage,
|
extractApiErrorMessage,
|
||||||
fetchHassioStats,
|
fetchHassioStats,
|
||||||
HassioStats,
|
HassioStats,
|
||||||
|
ignoreSupervisorError,
|
||||||
} from "../../../src/data/hassio/common";
|
} from "../../../src/data/hassio/common";
|
||||||
import { restartCore, updateCore } from "../../../src/data/supervisor/core";
|
import { restartCore, updateCore } from "../../../src/data/supervisor/core";
|
||||||
import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
||||||
@ -150,7 +151,7 @@ class HassioCoreInfo extends LitElement {
|
|||||||
title: this.supervisor.localize(
|
title: this.supervisor.localize(
|
||||||
"common.failed_to_restart_name",
|
"common.failed_to_restart_name",
|
||||||
"name",
|
"name",
|
||||||
"Home AssistantCore"
|
"Home Assistant Core"
|
||||||
),
|
),
|
||||||
text: extractApiErrorMessage(err),
|
text: extractApiErrorMessage(err),
|
||||||
});
|
});
|
||||||
@ -175,10 +176,29 @@ class HassioCoreInfo extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _updateCore(): Promise<void> {
|
private async _updateCore(): Promise<void> {
|
||||||
|
try {
|
||||||
await updateCore(this.hass);
|
await updateCore(this.hass);
|
||||||
|
} catch (err) {
|
||||||
|
if (this.hass.connection.connected && !ignoreSupervisorError(err)) {
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: this.supervisor.localize(
|
||||||
|
"common.failed_to_update_name",
|
||||||
|
"name",
|
||||||
|
"Home Assistant Core"
|
||||||
|
),
|
||||||
|
text: extractApiErrorMessage(err),
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fireEvent(this, "supervisor-collection-refresh", {
|
fireEvent(this, "supervisor-collection-refresh", {
|
||||||
collection: "core",
|
collection: "core",
|
||||||
});
|
});
|
||||||
|
fireEvent(this, "supervisor-applying-update", {
|
||||||
|
name: "Home Assistant Core",
|
||||||
|
version: this.supervisor.core.version_latest,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
|
@ -3779,7 +3779,6 @@
|
|||||||
"update_available": "{count, plural,\n one {Update}\n other {{count} updates}\n} pending",
|
"update_available": "{count, plural,\n one {Update}\n other {{count} updates}\n} pending",
|
||||||
"update": "Update",
|
"update": "Update",
|
||||||
"version": "Version",
|
"version": "Version",
|
||||||
"applying_update": "Applying update to {version} for {name}",
|
|
||||||
"error": {
|
"error": {
|
||||||
"unknown": "Unknown error",
|
"unknown": "Unknown error",
|
||||||
"update_failed": "Update failed"
|
"update_failed": "Update failed"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user