diff --git a/src/panels/config/info/system-health-card.ts b/src/panels/config/info/system-health-card.ts index eafbf533db..b3433a0831 100644 --- a/src/panels/config/info/system-health-card.ts +++ b/src/panels/config/info/system-health-card.ts @@ -1,14 +1,18 @@ import "../../../components/ha-circular-progress"; +import { mdiContentCopy } from "@mdi/js"; import { css, CSSResult, html, + internalProperty, LitElement, property, - internalProperty, + query, TemplateResult, } from "lit-element"; import "../../../components/ha-card"; +import "@polymer/paper-tooltip/paper-tooltip"; +import type { PaperTooltipElement } from "@polymer/paper-tooltip/paper-tooltip"; import { domainToName } from "../../../data/integration"; import { fetchSystemHealthInfo, @@ -37,6 +41,8 @@ class SystemHealthCard extends LitElement { @internalProperty() private _info?: SystemHealthInfo; + @query("paper-tooltip", true) private _toolTip?: PaperTooltipElement; + protected render(): TemplateResult { if (!this.hass) { return html``; @@ -78,7 +84,24 @@ class SystemHealthCard extends LitElement { } return html` - + +

+
+ ${domainToName(this.hass.localize, "system_health")} +
+ + + + + ${this.hass.localize("ui.common.copied")} + +

${sections}
`; @@ -104,6 +127,25 @@ class SystemHealthCard extends LitElement { } } + private _copyInfo(): void { + const selection = window.getSelection()!; + selection.removeAllRanges(); + + const copyElement = this.shadowRoot?.querySelector( + "ha-card" + ) as HTMLElement; + + const range = document.createRange(); + range.selectNodeContents(copyElement); + selection.addRange(range); + + document.execCommand("copy"); + window.getSelection()!.removeAllRanges(); + + this._toolTip!.show(); + setTimeout(() => this._toolTip?.hide(), 3000); + } + static get styles(): CSSResult { return css` table { @@ -119,6 +161,11 @@ class SystemHealthCard extends LitElement { align-items: center; justify-content: center; } + + .card-header { + justify-content: space-between; + display: flex; + } `; } } diff --git a/src/panels/config/logs/dialog-system-log-detail.ts b/src/panels/config/logs/dialog-system-log-detail.ts index a1f00819db..34d0cfcd1a 100644 --- a/src/panels/config/logs/dialog-system-log-detail.ts +++ b/src/panels/config/logs/dialog-system-log-detail.ts @@ -206,7 +206,6 @@ class DialogSystemLogDetail extends LitElement { font-family: var(--code-font-family, monospace); } .heading { - display: flex; display: flex; align-items: center; justify-content: space-between;