Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions src/panels/config/info/system-health-card.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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``;
Expand Down Expand Up @@ -78,7 +84,24 @@ class SystemHealthCard extends LitElement {
}

return html`
<ha-card .header=${domainToName(this.hass.localize, "system_health")}>
<ha-card>
<h1 class="card-header">
<div class="card-header-text">
${domainToName(this.hass.localize, "system_health")}
</div>
<mwc-icon-button id="copy" @click=${this._copyInfo}>
<ha-svg-icon .path=${mdiContentCopy}></ha-svg-icon>
</mwc-icon-button>
<paper-tooltip
manual-mode
for="copy"
position="left"
animation-delay="0"
offset="4"
>
${this.hass.localize("ui.common.copied")}
</paper-tooltip>
</h1>
<div class="card-content">${sections}</div>
</ha-card>
`;
Expand All @@ -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 {
Expand All @@ -119,6 +161,11 @@ class SystemHealthCard extends LitElement {
align-items: center;
justify-content: center;
}

.card-header {
justify-content: space-between;
display: flex;
}
`;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/panels/config/logs/dialog-system-log-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down