mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Add restart in safe mode in restart dialog (#18375)
This commit is contained in:
parent
c840f1cbb1
commit
8350d71f6e
@ -1,6 +1,12 @@
|
|||||||
import "@material/mwc-list/mwc-list";
|
import "@material/mwc-list/mwc-list";
|
||||||
import { mdiAutoFix, mdiPower, mdiPowerCycle, mdiRefresh } from "@mdi/js";
|
import {
|
||||||
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
|
mdiAutoFix,
|
||||||
|
mdiLifebuoy,
|
||||||
|
mdiPower,
|
||||||
|
mdiPowerCycle,
|
||||||
|
mdiRefresh,
|
||||||
|
} from "@mdi/js";
|
||||||
|
import { CSSResultGroup, LitElement, css, html, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
@ -14,8 +20,8 @@ import {
|
|||||||
ignoreSupervisorError,
|
ignoreSupervisorError,
|
||||||
} from "../../data/hassio/common";
|
} from "../../data/hassio/common";
|
||||||
import {
|
import {
|
||||||
fetchHassioHostInfo,
|
|
||||||
HassioHostInfo,
|
HassioHostInfo,
|
||||||
|
fetchHassioHostInfo,
|
||||||
rebootHost,
|
rebootHost,
|
||||||
shutdownHost,
|
shutdownHost,
|
||||||
} from "../../data/hassio/host";
|
} from "../../data/hassio/host";
|
||||||
@ -54,18 +60,6 @@ class DialogRestart extends LitElement {
|
|||||||
this._loadingHostInfo = false;
|
this._loadingHostInfo = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const showReload = this.hass.userData?.showAdvanced;
|
|
||||||
const showRebootShutdown = !!this._hostInfo;
|
|
||||||
|
|
||||||
// Present restart core dialog if no host actions and not advanced mode as it's the only option
|
|
||||||
if (!showReload && !showRebootShutdown) {
|
|
||||||
this._open = false;
|
|
||||||
this._showRestartDialog().then(() => this.closeDialog());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.updateComplete;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public closeDialog(): void {
|
public closeDialog(): void {
|
||||||
@ -145,15 +139,14 @@ class DialogRestart extends LitElement {
|
|||||||
</span>
|
</span>
|
||||||
</ha-list-item>
|
</ha-list-item>
|
||||||
</mwc-list>
|
</mwc-list>
|
||||||
|
<ha-expansion-panel
|
||||||
${showRebootShutdown
|
.header=${this.hass.localize(
|
||||||
? html`
|
"ui.dialogs.restart.advanced_options"
|
||||||
<ha-expansion-panel
|
)}
|
||||||
.header=${this.hass.localize(
|
>
|
||||||
"ui.dialogs.restart.advanced_options"
|
<mwc-list>
|
||||||
)}
|
${showRebootShutdown
|
||||||
>
|
? html`
|
||||||
<mwc-list>
|
|
||||||
<ha-list-item
|
<ha-list-item
|
||||||
graphic="avatar"
|
graphic="avatar"
|
||||||
twoline
|
twoline
|
||||||
@ -196,10 +189,34 @@ class DialogRestart extends LitElement {
|
|||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
</ha-list-item>
|
</ha-list-item>
|
||||||
</mwc-list>
|
`
|
||||||
</ha-expansion-panel>
|
: nothing}
|
||||||
`
|
<ha-list-item
|
||||||
: nothing}
|
graphic="avatar"
|
||||||
|
twoline
|
||||||
|
multiline-secondary
|
||||||
|
hasMeta
|
||||||
|
@request-selected=${this._restartSafeMode}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
slot="graphic"
|
||||||
|
class="icon-background restart-safe-mode"
|
||||||
|
>
|
||||||
|
<ha-svg-icon .path=${mdiLifebuoy}></ha-svg-icon>
|
||||||
|
</div>
|
||||||
|
<span>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.dialogs.restart.restart-safe-mode.title"
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<span slot="secondary">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.dialogs.restart.restart-safe-mode.description"
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</ha-list-item>
|
||||||
|
</mwc-list>
|
||||||
|
</ha-expansion-panel>
|
||||||
`}
|
`}
|
||||||
</ha-dialog>
|
</ha-dialog>
|
||||||
`;
|
`;
|
||||||
@ -262,6 +279,47 @@ class DialogRestart extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _restartSafeMode(ev) {
|
||||||
|
if (!shouldHandleRequestSelectedEvent(ev)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._showRestartSafeModeDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _showRestartSafeModeDialog() {
|
||||||
|
const confirmed = await showConfirmationDialog(this, {
|
||||||
|
title: this.hass.localize(
|
||||||
|
"ui.dialogs.restart.restart-safe-mode.confirm_title"
|
||||||
|
),
|
||||||
|
text: this.hass.localize(
|
||||||
|
"ui.dialogs.restart.restart-safe-mode.confirm_description"
|
||||||
|
),
|
||||||
|
confirmText: this.hass.localize(
|
||||||
|
"ui.dialogs.restart.restart-safe-mode.confirm_action"
|
||||||
|
),
|
||||||
|
destructive: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!confirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.closeDialog();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.hass.callService("homeassistant", "restart", {
|
||||||
|
safe_mode: true,
|
||||||
|
});
|
||||||
|
} catch (err: any) {
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: this.hass.localize(
|
||||||
|
"ui.dialogs.restart.restart-safe-mode.failed"
|
||||||
|
),
|
||||||
|
text: err.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async _hostReboot(ev): Promise<void> {
|
private async _hostReboot(ev): Promise<void> {
|
||||||
if (!shouldHandleRequestSelectedEvent(ev)) {
|
if (!shouldHandleRequestSelectedEvent(ev)) {
|
||||||
return;
|
return;
|
||||||
@ -382,6 +440,10 @@ class DialogRestart extends LitElement {
|
|||||||
background-color: #0b1d29;
|
background-color: #0b1d29;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
.restart-safe-mode {
|
||||||
|
background-color: #e48629;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
.divider {
|
.divider {
|
||||||
height: 1px;
|
height: 1px;
|
||||||
background-color: var(--divider-color);
|
background-color: var(--divider-color);
|
||||||
|
@ -1233,6 +1233,14 @@
|
|||||||
"confirm_action": "Shut down",
|
"confirm_action": "Shut down",
|
||||||
"shutting_down": "Shutting down system",
|
"shutting_down": "Shutting down system",
|
||||||
"failed": "Failed to shut down system"
|
"failed": "Failed to shut down system"
|
||||||
|
},
|
||||||
|
"restart-safe-mode": {
|
||||||
|
"title": "Restart Home Assistant in safe mode",
|
||||||
|
"description": "Restart Home Assistant without loading any custom integrations and modules.",
|
||||||
|
"confirm_title": "Restart Home Assistant in safe mode?",
|
||||||
|
"confirm_description": "This will restart Home Assistant without loading any custom integrations and modules.",
|
||||||
|
"confirm_action": "Restart",
|
||||||
|
"failed": "Failed to restart Home Assistant"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"aliases": {
|
"aliases": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user