mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Add unhealthy dialog and SU restart button (#7781)
This commit is contained in:
parent
d7d1121f7d
commit
0ef8881660
@ -19,6 +19,7 @@ import {
|
|||||||
fetchHassioSupervisorInfo,
|
fetchHassioSupervisorInfo,
|
||||||
HassioSupervisorInfo as HassioSupervisorInfoType,
|
HassioSupervisorInfo as HassioSupervisorInfoType,
|
||||||
reloadSupervisor,
|
reloadSupervisor,
|
||||||
|
restartSupervisor,
|
||||||
setSupervisorOption,
|
setSupervisorOption,
|
||||||
SupervisorOptions,
|
SupervisorOptions,
|
||||||
updateSupervisor,
|
updateSupervisor,
|
||||||
@ -32,7 +33,7 @@ import { HomeAssistant } from "../../../src/types";
|
|||||||
import { documentationUrl } from "../../../src/util/documentation-url";
|
import { documentationUrl } from "../../../src/util/documentation-url";
|
||||||
import { hassioStyle } from "../resources/hassio-style";
|
import { hassioStyle } from "../resources/hassio-style";
|
||||||
|
|
||||||
const ISSUES = {
|
const UNSUPPORTED_REASON = {
|
||||||
container: {
|
container: {
|
||||||
title: "Containers known to cause issues",
|
title: "Containers known to cause issues",
|
||||||
url: "/more-info/unsupported/container",
|
url: "/more-info/unsupported/container",
|
||||||
@ -59,6 +60,25 @@ const ISSUES = {
|
|||||||
systemd: { title: "Systemd", url: "/more-info/unsupported/systemd" },
|
systemd: { title: "Systemd", url: "/more-info/unsupported/systemd" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const UNHEALTHY_REASON = {
|
||||||
|
privileged: {
|
||||||
|
title: "Supervisor is not privileged",
|
||||||
|
url: "/more-info/unsupported/privileged",
|
||||||
|
},
|
||||||
|
supervisor: {
|
||||||
|
title: "Supervisor was not able to update",
|
||||||
|
url: "/more-info/unhealthy/supervisor",
|
||||||
|
},
|
||||||
|
setup: {
|
||||||
|
title: "Setup of the Supervisor failed",
|
||||||
|
url: "/more-info/unhealthy/setup",
|
||||||
|
},
|
||||||
|
docker: {
|
||||||
|
title: "The Docker environment is not working properly",
|
||||||
|
url: "/more-info/unhealthy/docker",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
@customElement("hassio-supervisor-info")
|
@customElement("hassio-supervisor-info")
|
||||||
class HassioSupervisorInfo extends LitElement {
|
class HassioSupervisorInfo extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
@ -66,9 +86,12 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
public supervisorInfo!: HassioSupervisorInfoType;
|
public supervisorInfo!: HassioSupervisorInfoType;
|
||||||
|
|
||||||
@property() public hostInfo!: HassioHostInfoType;
|
@property({ attribute: false }) public hostInfo!: HassioHostInfoType;
|
||||||
|
|
||||||
protected render(): TemplateResult | void {
|
protected render(): TemplateResult | void {
|
||||||
|
if (!this.hass || !this.supervisorInfo || !this.hostInfo) {
|
||||||
|
return html``;
|
||||||
|
}
|
||||||
return html`
|
return html`
|
||||||
<ha-card header="Supervisor">
|
<ha-card header="Supervisor">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
@ -126,7 +149,7 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
: ""}
|
: ""}
|
||||||
</ha-settings-row>
|
</ha-settings-row>
|
||||||
|
|
||||||
${this.supervisorInfo?.supported
|
${this.supervisorInfo.supported
|
||||||
? html` <ha-settings-row three-line>
|
? html` <ha-settings-row three-line>
|
||||||
<span slot="heading">
|
<span slot="heading">
|
||||||
Share Diagnostics
|
Share Diagnostics
|
||||||
@ -157,14 +180,33 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
Learn more
|
Learn more
|
||||||
</button>
|
</button>
|
||||||
</div>`}
|
</div>`}
|
||||||
|
${!this.supervisorInfo.healthy
|
||||||
|
? html`<div class="error">
|
||||||
|
Your installtion is running in an unhealthy state.
|
||||||
|
<button
|
||||||
|
class="link"
|
||||||
|
title="Learn more about why your system is marked as unhealthy"
|
||||||
|
@click=${this._unhealthyDialog}
|
||||||
|
>
|
||||||
|
Learn more
|
||||||
|
</button>
|
||||||
|
</div>`
|
||||||
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<ha-progress-button
|
<ha-progress-button
|
||||||
@click=${this._supervisorReload}
|
@click=${this._supervisorReload}
|
||||||
title="Reload parts of the supervisor"
|
title="Reload parts of the Supervisor"
|
||||||
>
|
>
|
||||||
Reload
|
Reload
|
||||||
</ha-progress-button>
|
</ha-progress-button>
|
||||||
|
<ha-progress-button
|
||||||
|
class="warning"
|
||||||
|
@click=${this._supervisorRestart}
|
||||||
|
title="Restart the Supervisor"
|
||||||
|
>
|
||||||
|
Restart
|
||||||
|
</ha-progress-button>
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
`;
|
`;
|
||||||
@ -213,8 +255,9 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
title: "Failed to set supervisor option",
|
title: "Failed to set supervisor option",
|
||||||
text: extractApiErrorMessage(err),
|
text: extractApiErrorMessage(err),
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
button.progress = false;
|
||||||
}
|
}
|
||||||
button.progress = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _supervisorReload(ev: CustomEvent): Promise<void> {
|
private async _supervisorReload(ev: CustomEvent): Promise<void> {
|
||||||
@ -229,8 +272,25 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
title: "Failed to reload the supervisor",
|
title: "Failed to reload the supervisor",
|
||||||
text: extractApiErrorMessage(err),
|
text: extractApiErrorMessage(err),
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
button.progress = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _supervisorRestart(ev: CustomEvent): Promise<void> {
|
||||||
|
const button = ev.currentTarget as any;
|
||||||
|
button.progress = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await restartSupervisor(this.hass);
|
||||||
|
} catch (err) {
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: "Failed to restart the supervisor",
|
||||||
|
text: extractApiErrorMessage(err),
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
button.progress = false;
|
||||||
}
|
}
|
||||||
button.progress = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _supervisorUpdate(ev: CustomEvent): Promise<void> {
|
private async _supervisorUpdate(ev: CustomEvent): Promise<void> {
|
||||||
@ -256,8 +316,9 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
title: "Failed to update the supervisor",
|
title: "Failed to update the supervisor",
|
||||||
text: extractApiErrorMessage(err),
|
text: extractApiErrorMessage(err),
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
button.progress = false;
|
||||||
}
|
}
|
||||||
button.progress = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _diagnosticsInformationDialog(): Promise<void> {
|
private async _diagnosticsInformationDialog(): Promise<void> {
|
||||||
@ -285,13 +346,46 @@ class HassioSupervisorInfo extends LitElement {
|
|||||||
${resolution.unsupported.map(
|
${resolution.unsupported.map(
|
||||||
(issue) => html`
|
(issue) => html`
|
||||||
<li>
|
<li>
|
||||||
${ISSUES[issue]
|
${UNSUPPORTED_REASON[issue]
|
||||||
? html`<a
|
? html`<a
|
||||||
href="${documentationUrl(this.hass, ISSUES[issue].url)}"
|
href="${documentationUrl(
|
||||||
|
this.hass,
|
||||||
|
UNSUPPORTED_REASON[issue].url
|
||||||
|
)}"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
>
|
>
|
||||||
${ISSUES[issue].title}
|
${UNSUPPORTED_REASON[issue].title}
|
||||||
|
</a>`
|
||||||
|
: issue}
|
||||||
|
</li>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</ul>`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _unhealthyDialog(): Promise<void> {
|
||||||
|
const resolution = await fetchHassioResolution(this.hass);
|
||||||
|
await showAlertDialog(this, {
|
||||||
|
title: "Your installation is unhealthy",
|
||||||
|
text: html`Running an unhealthy installation will cause issues. Below is a
|
||||||
|
list of issues found with your installation, click on the links to learn
|
||||||
|
how you can resolve the issues. <br /><br />
|
||||||
|
<ul>
|
||||||
|
${resolution.unhealthy.map(
|
||||||
|
(issue) => html`
|
||||||
|
<li>
|
||||||
|
${UNHEALTHY_REASON[issue]
|
||||||
|
? html`<a
|
||||||
|
href="${documentationUrl(
|
||||||
|
this.hass,
|
||||||
|
UNHEALTHY_REASON[issue].url
|
||||||
|
)}"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
${UNHEALTHY_REASON[issue].title}
|
||||||
</a>`
|
</a>`
|
||||||
: issue}
|
: issue}
|
||||||
</li>
|
</li>
|
||||||
|
@ -3,6 +3,9 @@ import { hassioApiResultExtractor, HassioResponse } from "./common";
|
|||||||
|
|
||||||
export interface HassioResolution {
|
export interface HassioResolution {
|
||||||
unsupported: string[];
|
unsupported: string[];
|
||||||
|
unhealthy: string[];
|
||||||
|
issues: string[];
|
||||||
|
suggestions: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetchHassioResolution = async (hass: HomeAssistant) => {
|
export const fetchHassioResolution = async (hass: HomeAssistant) => {
|
||||||
|
@ -76,6 +76,10 @@ export const reloadSupervisor = async (hass: HomeAssistant) => {
|
|||||||
await hass.callApi<HassioResponse<void>>("POST", `hassio/supervisor/reload`);
|
await hass.callApi<HassioResponse<void>>("POST", `hassio/supervisor/reload`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const restartSupervisor = async (hass: HomeAssistant) => {
|
||||||
|
await hass.callApi<HassioResponse<void>>("POST", `hassio/supervisor/restart`);
|
||||||
|
};
|
||||||
|
|
||||||
export const updateSupervisor = async (hass: HomeAssistant) => {
|
export const updateSupervisor = async (hass: HomeAssistant) => {
|
||||||
await hass.callApi<HassioResponse<void>>("POST", `hassio/supervisor/update`);
|
await hass.callApi<HassioResponse<void>>("POST", `hassio/supervisor/update`);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user