diff --git a/src/panels/config/info/system-health-card.ts b/src/panels/config/info/system-health-card.ts index 765725b133..95947cce0d 100644 --- a/src/panels/config/info/system-health-card.ts +++ b/src/panels/config/info/system-health-card.ts @@ -1,7 +1,9 @@ import "@material/mwc-button/mwc-button"; import "@material/mwc-icon-button"; -import "../../../components/ha-circular-progress"; +import { ActionDetail } from "@material/mwc-list/mwc-list-foundation"; +import "@material/mwc-list/mwc-list-item"; import { mdiContentCopy } from "@mdi/js"; +import "@polymer/paper-tooltip/paper-tooltip"; import { css, CSSResult, @@ -9,21 +11,22 @@ import { internalProperty, LitElement, property, - query, TemplateResult, } from "lit-element"; +import { formatDateTime } from "../../../common/datetime/format_date_time"; +import { copyToClipboard } from "../../../common/util/copy-clipboard"; +import "../../../components/ha-button-menu"; import "../../../components/ha-card"; -import "@polymer/paper-tooltip/paper-tooltip"; -import type { PaperTooltipElement } from "@polymer/paper-tooltip/paper-tooltip"; +import "../../../components/ha-circular-progress"; +import "../../../components/ha-svg-icon"; import { domainToName } from "../../../data/integration"; import { subscribeSystemHealthInfo, - SystemHealthInfo, SystemCheckValueObject, + SystemHealthInfo, } from "../../../data/system_health"; import { HomeAssistant } from "../../../types"; -import { formatDateTime } from "../../../common/datetime/format_date_time"; -import { copyToClipboard } from "../../../common/util/copy-clipboard"; +import { showToast } from "../../../util/toast"; const sortKeys = (a: string, b: string) => { if (a === "homeassistant") { @@ -46,8 +49,6 @@ class SystemHealthCard extends LitElement { @internalProperty() private _info?: SystemHealthInfo; - @query("paper-tooltip", true) private _toolTip?: PaperTooltipElement; - protected render(): TemplateResult { if (!this.hass) { return html``; @@ -152,18 +153,21 @@ class SystemHealthCard extends LitElement {
${domainToName(this.hass.localize, "system_health")}
- - - - - ${this.hass.localize("ui.common.copied")} - + + + + + ${this.hass.localize("ui.panel.config.info.copy_raw")} + + + ${this.hass.localize("ui.panel.config.info.copy_github")} + +
${sections}
@@ -193,13 +197,24 @@ class SystemHealthCard extends LitElement { }); } - private _copyInfo(): void { + private _copyInfo(ev: CustomEvent): void { + const github = ev.detail.index === 1; let haContent: string | undefined; const domainParts: string[] = []; for (const domain of Object.keys(this._info!).sort(sortKeys)) { const domainInfo = this._info![domain]; - const parts = [`${domainToName(this.hass.localize, domain)}\n`]; + let first = true; + const parts = [ + `${ + github && domain !== "homeassistant" + ? `
${domainToName( + this.hass.localize, + domain + )}\n` + : "" + }`, + ]; for (const key of Object.keys(domainInfo.info)) { let value: unknown; @@ -217,23 +232,31 @@ class SystemHealthCard extends LitElement { } else { value = domainInfo.info[key]; } - - parts.push(`${key}: ${value}`); + if (github && first) { + parts.push(`${key} | ${value}\n-- | --`); + first = false; + } else { + parts.push(`${key}${github ? " | " : ": "}${value}`); + } } if (domain === "homeassistant") { haContent = parts.join("\n"); } else { domainParts.push(parts.join("\n")); + if (github && domain !== "homeassistant") { + domainParts.push("
"); + } } } copyToClipboard( - `System Health\n\n${haContent}\n\n${domainParts.join("\n\n")}` + `${github ? "## " : ""}System Health\n${haContent}\n\n${domainParts.join( + "\n\n" + )}` ); - this._toolTip!.show(); - setTimeout(() => this._toolTip?.hide(), 3000); + showToast(this, { message: this.hass.localize("ui.common.copied") }); } static get styles(): CSSResult { diff --git a/src/translations/en.json b/src/translations/en.json index c31db303c6..ff7739e88a 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -899,6 +899,8 @@ }, "info": { "caption": "Info", + "copy_raw": "Raw Text", + "copy_github": "For GitHub", "description": "View info about your Home Assistant installation", "home_assistant_logo": "Home Assistant logo", "path_configuration": "Path to configuration.yaml: {path}",