mirror of
https://github.com/home-assistant/frontend.git
synced 2026-07-05 14:44:12 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d1605ba196 | |||
| 2240d019f5 | |||
| cb11c6b3ea | |||
| 5893559951 | |||
| 8408d25cef |
@@ -1,5 +1,4 @@
|
||||
import "@material/mwc-button";
|
||||
import { ActionDetail } from "@material/mwc-list/mwc-list-foundation";
|
||||
import "@material/mwc-list/mwc-list-item";
|
||||
import { mdiDotsVertical } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
@@ -19,6 +18,7 @@ import { fetchHassioHardwareInfo } from "../../../src/data/hassio/hardware";
|
||||
import {
|
||||
changeHostOptions,
|
||||
configSyncOS,
|
||||
dataDiskMove,
|
||||
rebootHost,
|
||||
shutdownHost,
|
||||
updateOS,
|
||||
@@ -180,21 +180,27 @@ class HassioHostInfo extends LitElement {
|
||||
`
|
||||
: ""}
|
||||
|
||||
<ha-button-menu
|
||||
corner="BOTTOM_START"
|
||||
@action=${this._handleMenuAction}
|
||||
>
|
||||
<ha-button-menu corner="BOTTOM_START">
|
||||
<mwc-icon-button slot="trigger">
|
||||
<ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
|
||||
</mwc-icon-button>
|
||||
<mwc-list-item>
|
||||
<mwc-list-item @click=${() => this._handleMenuAction("hardware")}>
|
||||
${this.supervisor.localize("system.host.hardware")}
|
||||
</mwc-list-item>
|
||||
${this.supervisor.host.features.includes("haos")
|
||||
? html`<mwc-list-item>
|
||||
? html`<mwc-list-item
|
||||
@click=${() => this._handleMenuAction("import_from_usb")}
|
||||
>
|
||||
${this.supervisor.localize("system.host.import_from_usb")}
|
||||
</mwc-list-item>`
|
||||
: ""}
|
||||
${this.supervisor.host.features.includes("agent")
|
||||
? html`<mwc-list-item
|
||||
@click=${() => this._handleMenuAction("data_disk_move")}
|
||||
>
|
||||
${this.supervisor.localize("system.host.data_disk_move")}
|
||||
</mwc-list-item>`
|
||||
: ""}
|
||||
</ha-button-menu>
|
||||
</div>
|
||||
</ha-card>
|
||||
@@ -216,14 +222,17 @@ class HassioHostInfo extends LitElement {
|
||||
return network_info.interfaces.find((a) => a.primary)?.ipv4?.address![0];
|
||||
});
|
||||
|
||||
private async _handleMenuAction(ev: CustomEvent<ActionDetail>) {
|
||||
switch (ev.detail.index) {
|
||||
case 0:
|
||||
private async _handleMenuAction(action: string) {
|
||||
switch (action) {
|
||||
case "hardware":
|
||||
await this._showHardware();
|
||||
break;
|
||||
case 1:
|
||||
case "import_from_usb":
|
||||
await this._importFromUSB();
|
||||
break;
|
||||
case "data_disk_move":
|
||||
await this._dataDiskMove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,6 +404,34 @@ class HassioHostInfo extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private async _dataDiskMove(): Promise<void> {
|
||||
const confirmed = await showConfirmationDialog(this, {
|
||||
title: this.supervisor.localize("system.host.data_disk_move"),
|
||||
text: html`${this.supervisor.localize(
|
||||
"dialog.data_disk_move.description",
|
||||
{ current_path: this.supervisor.os.data_disk }
|
||||
)} <br /><br />${this.supervisor.localize(
|
||||
"dialog.data_disk_move.confirm_text"
|
||||
)}`,
|
||||
confirmText: this.supervisor.localize("dialog.data_disk_move.move"),
|
||||
dismissText: this.supervisor.localize("dialog.data_disk_move.cancel"),
|
||||
});
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await dataDiskMove(this.hass);
|
||||
} catch (err) {
|
||||
if (this.hass.connection.connected && !ignoreSupervisorError(err)) {
|
||||
showAlertDialog(this, {
|
||||
title: this.supervisor.localize("system.host.failed_to_move"),
|
||||
text: extractApiErrorMessage(err),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async _loadData(): Promise<void> {
|
||||
if (atLeastVersion(this.hass.config.version, 2021, 2, 4)) {
|
||||
fireEvent(this, "supervisor-collection-refresh", {
|
||||
|
||||
@@ -22,8 +22,9 @@ export const binarySensorIcon = (state?: string, stateObj?: HassEntity) => {
|
||||
case "gas":
|
||||
case "problem":
|
||||
case "safety":
|
||||
case "smoke":
|
||||
return is_off ? "hass:check-circle" : "hass:alert-circle";
|
||||
case "smoke":
|
||||
return is_off ? "hass:check-circle" : "hass:smoke";
|
||||
case "heat":
|
||||
return is_off ? "hass:thermometer" : "hass:fire";
|
||||
case "light":
|
||||
|
||||
@@ -106,19 +106,24 @@ export class HaStateLabelBadge extends LitElement {
|
||||
|
||||
private _computeValue(domain: string, entityState: HassEntity) {
|
||||
switch (domain) {
|
||||
case "alarm_control_panel":
|
||||
case "binary_sensor":
|
||||
case "device_tracker":
|
||||
case "person":
|
||||
case "updater":
|
||||
case "scene":
|
||||
case "sun":
|
||||
case "alarm_control_panel":
|
||||
case "timer":
|
||||
case "updater":
|
||||
return null;
|
||||
// @ts-expect-error we don't break and go to default
|
||||
case "sensor":
|
||||
if (entityState.attributes.device_class === "moon__phase") {
|
||||
return null;
|
||||
}
|
||||
// eslint-disable-next-line: disable=no-fallthrough
|
||||
default:
|
||||
return entityState.attributes.device_class === "moon__phase"
|
||||
? null
|
||||
: entityState.state === UNKNOWN
|
||||
return entityState.state === UNKNOWN ||
|
||||
entityState.state === UNAVAILABLE
|
||||
? "-"
|
||||
: entityState.attributes.unit_of_measurement
|
||||
? formatNumber(entityState.state, this.hass!.locale)
|
||||
@@ -160,16 +165,19 @@ export class HaStateLabelBadge extends LitElement {
|
||||
case "device_tracker":
|
||||
case "updater":
|
||||
case "person":
|
||||
case "scene":
|
||||
case "sun":
|
||||
return stateIcon(entityState);
|
||||
case "timer":
|
||||
return entityState.state === "active"
|
||||
? "hass:timer-outline"
|
||||
: "hass:timer-off-outline";
|
||||
default:
|
||||
return entityState?.attributes.device_class === "moon__phase"
|
||||
case "sensor":
|
||||
return entityState.attributes.device_class === "moon__phase"
|
||||
? stateIcon(entityState)
|
||||
: null;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,21 +173,25 @@ export class HatScriptGraph extends LitElement {
|
||||
?track=${track_this}
|
||||
?active=${this.selected === branch_path}
|
||||
></hat-graph-node>
|
||||
${ensureArray(branch.sequence).map((action, j) =>
|
||||
this.render_action_node(
|
||||
action,
|
||||
`${branch_path}/sequence/${j}`
|
||||
)
|
||||
)}
|
||||
${branch.sequence !== null
|
||||
? ensureArray(branch.sequence).map((action, j) =>
|
||||
this.render_action_node(
|
||||
action,
|
||||
`${branch_path}/sequence/${j}`
|
||||
)
|
||||
)
|
||||
: ""}
|
||||
</div>
|
||||
`;
|
||||
})
|
||||
: ""}
|
||||
<div ?track=${track_default}>
|
||||
<hat-graph-spacer ?track=${track_default}></hat-graph-spacer>
|
||||
${ensureArray(config.default)?.map((action, i) =>
|
||||
this.render_action_node(action, `${path}/default/${i}`)
|
||||
)}
|
||||
${config.default !== null
|
||||
? ensureArray(config.default)?.map((action, i) =>
|
||||
this.render_action_node(action, `${path}/default/${i}`)
|
||||
)
|
||||
: ""}
|
||||
</div>
|
||||
</hat-graph-branch>
|
||||
`;
|
||||
|
||||
@@ -22,6 +22,7 @@ export interface HassioHassOSInfo {
|
||||
update_available: boolean;
|
||||
version_latest: string | null;
|
||||
version: string | null;
|
||||
data_disk: string;
|
||||
}
|
||||
|
||||
export const fetchHassioHostInfo = async (
|
||||
@@ -113,6 +114,19 @@ export const configSyncOS = async (hass: HomeAssistant) => {
|
||||
return hass.callApi<HassioResponse<void>>("POST", "hassio/os/config/sync");
|
||||
};
|
||||
|
||||
export const dataDiskMove = async (hass: HomeAssistant) => {
|
||||
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
|
||||
return hass.callWS({
|
||||
type: "supervisor/api",
|
||||
endpoint: "/os/datadisk/move",
|
||||
method: "post",
|
||||
timeout: null,
|
||||
});
|
||||
}
|
||||
|
||||
return hass.callApi<HassioResponse<void>>("POST", "hassio/os/datadisk/move");
|
||||
};
|
||||
|
||||
export const changeHostOptions = async (hass: HomeAssistant, options: any) => {
|
||||
if (atLeastVersion(hass.config.version, 2021, 2, 4)) {
|
||||
return hass.callWS({
|
||||
|
||||
+3
-1
@@ -294,13 +294,15 @@ export const fetchStatistics = (
|
||||
hass: HomeAssistant,
|
||||
startTime: Date,
|
||||
endTime?: Date,
|
||||
statistic_ids?: string[]
|
||||
statistic_ids?: string[],
|
||||
period: "hour" | "5minute" = "hour"
|
||||
) =>
|
||||
hass.callWS<Statistics>({
|
||||
type: "history/statistics_during_period",
|
||||
start_time: startTime.toISOString(),
|
||||
end_time: endTime?.toISOString(),
|
||||
statistic_ids,
|
||||
period,
|
||||
});
|
||||
|
||||
export const calculateStatisticSumGrowth = (
|
||||
|
||||
@@ -4099,6 +4099,7 @@
|
||||
"failed_to_shutdown": "Failed to shutdown the host",
|
||||
"failed_to_set_hostname": "Setting hostname failed",
|
||||
"failed_to_import_from_usb": "Failed to import from USB",
|
||||
"failed_to_move": "Failed to move data disk",
|
||||
"used_space": "Used space",
|
||||
"hostname": "Hostname",
|
||||
"change_hostname": "Change Hostname",
|
||||
@@ -4114,7 +4115,8 @@
|
||||
"confirm_shutdown": "Are you sure you want to shutdown the host?",
|
||||
"shutdown_host": "Shutdown host",
|
||||
"hardware": "Hardware",
|
||||
"import_from_usb": "Import from USB"
|
||||
"import_from_usb": "Import from USB",
|
||||
"data_disk_move": "Move to data disk"
|
||||
},
|
||||
"core": {
|
||||
"cpu_usage": "Core CPU Usage",
|
||||
@@ -4201,6 +4203,12 @@
|
||||
"id": "ID",
|
||||
"attributes": "Attributes",
|
||||
"device_path": "Device path"
|
||||
},
|
||||
"data_disk_move": {
|
||||
"description": "The current path to the data disk is ''{current_path}'', moving the disk will require a reboot of the host which will be done automatically.",
|
||||
"confirm_text": "Do you want to move now?",
|
||||
"cancel": "[%key:ui::common::cancel%]",
|
||||
"move": "Move"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user