Add Board Names, Move All Hardware (#12484)

Co-authored-by: Joakim Sørensen <ludeeus@ludeeus.dev>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Zack Barett 2022-04-28 15:42:18 -05:00 committed by GitHub
parent 8c97aee1fe
commit bdfb17d957
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 56 deletions

22
src/data/hardware.ts Normal file
View File

@ -0,0 +1,22 @@
// Keep in sync with https://github.com/home-assistant/analytics.home-assistant.io/blob/dev/site/src/analytics-os-boards.ts#L6-L24
export const BOARD_NAMES: Record<string, string> = {
"odroid-n2": "Home Assistant Blue / ODROID-N2",
"odroid-xu4": "ODROID-XU4",
"odroid-c2": "ODROID-C2",
"odroid-c4": "ODROID-C4",
rpi: "Raspberry Pi",
rpi0: "Raspberry Pi Zero",
"rpi0-w": "Raspberry Pi Zero W",
rpi2: "Raspberry Pi 2",
rpi3: "Raspberry Pi 3 (32-bit)",
"rpi3-64": "Raspberry Pi 3",
rpi4: "Raspberry Pi 4 (32-bit)",
"rpi4-64": "Raspberry Pi 4",
tinker: "ASUS Tinker Board",
"khadas-vim3": "Khadas VIM3",
"generic-aarch64": "Generic AArch64",
ova: "Virtual Machine",
"generic-x86-64": "Generic x86-64",
"intel-nuc": "Intel NUC",
yellow: "Home Assistant Yellow",
};

View File

@ -8,6 +8,7 @@ import "../../../components/ha-alert";
import "../../../components/ha-button-menu"; import "../../../components/ha-button-menu";
import "../../../components/ha-card"; import "../../../components/ha-card";
import "../../../components/ha-settings-row"; import "../../../components/ha-settings-row";
import { BOARD_NAMES } from "../../../data/hardware";
import { import {
extractApiErrorMessage, extractApiErrorMessage,
ignoreSupervisorError, ignoreSupervisorError,
@ -56,6 +57,18 @@ class HaConfigHardware extends 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">
<ha-icon-button
.label=${this.hass.localize("common.menu")}
.path=${mdiDotsVertical}
slot="trigger"
></ha-icon-button>
<mwc-list-item @click=${this._openHardware}
>${this.hass.localize(
"ui.panel.config.hardware.available_hardware.title"
)}</mwc-list-item
>
</ha-button-menu>
${this._error ${this._error
? html` ? html`
<ha-alert alert-type="error" <ha-alert alert-type="error"
@ -68,59 +81,47 @@ class HaConfigHardware extends LitElement {
<div class="content"> <div class="content">
<ha-card outlined> <ha-card outlined>
<div class="card-content"> <div class="card-content">
<ha-settings-row> ${this._OSData?.board
<span slot="heading" ? html`
>${this.hass.localize( <ha-settings-row>
"ui.panel.config.hardware.board" <span slot="heading"
)}</span >${BOARD_NAMES[this._OSData.board] ||
> this.hass.localize(
<div slot="description"> "ui.panel.config.hardware.board"
<span class="value">${this._OSData.board}</span> )}</span
</div> >
</ha-settings-row> <div slot="description">
<span class="value">${this._OSData.board}</span>
</div>
</ha-settings-row>
`
: ""}
</div> </div>
<div class="card-actions"> <div class="card-actions">
<div class="buttons"> ${this._hostData.features.includes("reboot")
${this._hostData.features.includes("reboot") ? html`
? html` <ha-progress-button
<ha-progress-button class="warning"
class="warning" @click=${this._hostReboot}
@click=${this._hostReboot} >
> ${this.hass.localize(
${this.hass.localize( "ui.panel.config.hardware.reboot_host"
"ui.panel.config.hardware.reboot_host" )}
)} </ha-progress-button>
</ha-progress-button> `
` : ""}
: ""} ${this._hostData.features.includes("shutdown")
${this._hostData.features.includes("shutdown") ? html`
? html` <ha-progress-button
<ha-progress-button class="warning"
class="warning" @click=${this._hostShutdown}
@click=${this._hostShutdown} >
> ${this.hass.localize(
${this.hass.localize( "ui.panel.config.hardware.shutdown_host"
"ui.panel.config.hardware.shutdown_host" )}
)} </ha-progress-button>
</ha-progress-button> `
` : ""}
: ""}
</div>
<ha-button-menu corner="BOTTOM_START">
<ha-icon-button
.label=${this.hass.localize("common.menu")}
.path=${mdiDotsVertical}
slot="trigger"
></ha-icon-button>
<mwc-list-item
.action=${"hardware"}
@click=${this._openHardware}
>
${this.hass.localize(
"ui.panel.config.hardware.available_hardware.title"
)}
</mwc-list-item>
</ha-button-menu>
</div> </div>
</ha-card> </ha-card>
</div> </div>
@ -241,10 +242,6 @@ class HaConfigHardware extends LitElement {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
} }
.buttons {
display: flex;
align-items: center;
}
`, `,
]; ];
} }

View File

@ -1519,7 +1519,7 @@
"caption": "Hardware", "caption": "Hardware",
"available_hardware": { "available_hardware": {
"failed_to_get": "Failed to get available hardware", "failed_to_get": "Failed to get available hardware",
"title": "Available hardware", "title": "All Hardware",
"subsystem": "Subsystem", "subsystem": "Subsystem",
"device_path": "Device path", "device_path": "Device path",
"id": "ID", "id": "ID",