mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Guard more of the hardware panel (#13650)
This commit is contained in:
parent
c5428d8581
commit
5e431a07ad
@ -80,29 +80,31 @@ class HaConfigHardware extends SubscribeMixin(LitElement) {
|
|||||||
private _cpuEntries: { x: number; y: number | null }[] = [];
|
private _cpuEntries: { x: number; y: number | null }[] = [];
|
||||||
|
|
||||||
public hassSubscribe() {
|
public hassSubscribe() {
|
||||||
return [
|
return isComponentLoaded(this.hass, "hardware")
|
||||||
this.hass.connection.subscribeMessage<SystemStatusStreamMessage>(
|
? [
|
||||||
(message) => {
|
this.hass.connection.subscribeMessage<SystemStatusStreamMessage>(
|
||||||
// Only store the last 60 entries
|
(message) => {
|
||||||
this._memoryEntries.shift();
|
// Only store the last 60 entries
|
||||||
this._cpuEntries.shift();
|
this._memoryEntries.shift();
|
||||||
|
this._cpuEntries.shift();
|
||||||
|
|
||||||
this._memoryEntries.push({
|
this._memoryEntries.push({
|
||||||
x: new Date(message.timestamp).getTime(),
|
x: new Date(message.timestamp).getTime(),
|
||||||
y: message.memory_used_percent,
|
y: message.memory_used_percent,
|
||||||
});
|
});
|
||||||
this._cpuEntries.push({
|
this._cpuEntries.push({
|
||||||
x: new Date(message.timestamp).getTime(),
|
x: new Date(message.timestamp).getTime(),
|
||||||
y: message.cpu_percent,
|
y: message.cpu_percent,
|
||||||
});
|
});
|
||||||
|
|
||||||
this._systemStatusData = message;
|
this._systemStatusData = message;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "hardware/subscribe_system_status",
|
type: "hardware/subscribe_system_status",
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
];
|
]
|
||||||
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected willUpdate(): void {
|
protected willUpdate(): void {
|
||||||
@ -198,32 +200,34 @@ class HaConfigHardware extends SubscribeMixin(LitElement) {
|
|||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
.header=${this.hass.localize("ui.panel.config.hardware.caption")}
|
.header=${this.hass.localize("ui.panel.config.hardware.caption")}
|
||||||
>
|
>
|
||||||
<ha-button-menu corner="BOTTOM_START" slot="toolbar-icon">
|
${isComponentLoaded(this.hass, "hassio")
|
||||||
<ha-icon-button
|
? html`<ha-button-menu corner="BOTTOM_START" slot="toolbar-icon">
|
||||||
.label=${this.hass.localize("ui.common.menu")}
|
<ha-icon-button
|
||||||
.path=${mdiDotsVertical}
|
.label=${this.hass.localize("ui.common.menu")}
|
||||||
slot="trigger"
|
.path=${mdiDotsVertical}
|
||||||
></ha-icon-button>
|
slot="trigger"
|
||||||
<mwc-list-item @click=${this._openHardware}
|
></ha-icon-button>
|
||||||
>${this.hass.localize(
|
<mwc-list-item @click=${this._openHardware}
|
||||||
"ui.panel.config.hardware.available_hardware.title"
|
>${this.hass.localize(
|
||||||
)}</mwc-list-item
|
"ui.panel.config.hardware.available_hardware.title"
|
||||||
>
|
)}</mwc-list-item
|
||||||
${this._hostData
|
>
|
||||||
? html`
|
${this._hostData
|
||||||
<mwc-list-item class="warning" @click=${this._hostReboot}
|
? html`
|
||||||
>${this.hass.localize(
|
<mwc-list-item class="warning" @click=${this._hostReboot}
|
||||||
"ui.panel.config.hardware.reboot_host"
|
>${this.hass.localize(
|
||||||
)}</mwc-list-item
|
"ui.panel.config.hardware.reboot_host"
|
||||||
>
|
)}</mwc-list-item
|
||||||
<mwc-list-item class="warning" @click=${this._hostShutdown}
|
>
|
||||||
>${this.hass.localize(
|
<mwc-list-item class="warning" @click=${this._hostShutdown}
|
||||||
"ui.panel.config.hardware.shutdown_host"
|
>${this.hass.localize(
|
||||||
)}</mwc-list-item
|
"ui.panel.config.hardware.shutdown_host"
|
||||||
>
|
)}</mwc-list-item
|
||||||
`
|
>
|
||||||
: ""}
|
`
|
||||||
</ha-button-menu>
|
: ""}
|
||||||
|
</ha-button-menu>`
|
||||||
|
: ""}
|
||||||
${this._error
|
${this._error
|
||||||
? html`
|
? html`
|
||||||
<ha-alert alert-type="error"
|
<ha-alert alert-type="error"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user