mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Use ha-dialog for dialog-system-log-details, add close icon button (#7513)
This commit is contained in:
parent
7499892bc2
commit
394d552856
@ -1,6 +1,6 @@
|
|||||||
|
import "../../../components/ha-header-bar";
|
||||||
import "@material/mwc-icon-button/mwc-icon-button";
|
import "@material/mwc-icon-button/mwc-icon-button";
|
||||||
import { mdiContentCopy } from "@mdi/js";
|
import { mdiContentCopy, mdiClose } from "@mdi/js";
|
||||||
import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable";
|
|
||||||
import "@polymer/paper-tooltip/paper-tooltip";
|
import "@polymer/paper-tooltip/paper-tooltip";
|
||||||
import type { PaperTooltipElement } from "@polymer/paper-tooltip/paper-tooltip";
|
import type { PaperTooltipElement } from "@polymer/paper-tooltip/paper-tooltip";
|
||||||
import {
|
import {
|
||||||
@ -14,7 +14,7 @@ import {
|
|||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import "../../../components/dialog/ha-paper-dialog";
|
import "../../../components/ha-dialog";
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
import {
|
import {
|
||||||
domainToName,
|
domainToName,
|
||||||
@ -23,7 +23,6 @@ import {
|
|||||||
IntegrationManifest,
|
IntegrationManifest,
|
||||||
} from "../../../data/integration";
|
} from "../../../data/integration";
|
||||||
import { getLoggedErrorIntegration } from "../../../data/system_log";
|
import { getLoggedErrorIntegration } from "../../../data/system_log";
|
||||||
import type { PolymerChangedEvent } from "../../../polymer-types";
|
|
||||||
import { haStyleDialog } from "../../../resources/styles";
|
import { haStyleDialog } from "../../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import type { SystemLogDetailDialogParams } from "./show-dialog-system-log-detail";
|
import type { SystemLogDetailDialogParams } from "./show-dialog-system-log-detail";
|
||||||
@ -36,7 +35,7 @@ class DialogSystemLogDetail extends LitElement {
|
|||||||
|
|
||||||
@internalProperty() private _manifest?: IntegrationManifest;
|
@internalProperty() private _manifest?: IntegrationManifest;
|
||||||
|
|
||||||
@query("paper-tooltip", true) private _toolTip?: PaperTooltipElement;
|
@query("paper-tooltip") private _toolTip?: PaperTooltipElement;
|
||||||
|
|
||||||
public async showDialog(params: SystemLogDetailDialogParams): Promise<void> {
|
public async showDialog(params: SystemLogDetailDialogParams): Promise<void> {
|
||||||
this._params = params;
|
this._params = params;
|
||||||
@ -69,23 +68,23 @@ class DialogSystemLogDetail extends LitElement {
|
|||||||
const integration = getLoggedErrorIntegration(item);
|
const integration = getLoggedErrorIntegration(item);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-paper-dialog
|
<ha-dialog open @closed=${this.closeDialog} hideActions heading=${true}>
|
||||||
with-backdrop
|
<ha-header-bar slot="heading">
|
||||||
opened
|
<mwc-icon-button slot="navigationIcon" dialogAction="cancel">
|
||||||
@opened-changed="${this._openedChanged}"
|
<ha-svg-icon .path=${mdiClose}></ha-svg-icon>
|
||||||
>
|
</mwc-icon-button>
|
||||||
<div class="heading">
|
<span slot="title">
|
||||||
<h2>
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.logs.details",
|
"ui.panel.config.logs.details",
|
||||||
"level",
|
"level",
|
||||||
item.level
|
item.level
|
||||||
)}
|
)}
|
||||||
</h2>
|
</span>
|
||||||
<mwc-icon-button id="copy" @click=${this._copyLog}>
|
<mwc-icon-button id="copy" @click=${this._copyLog} slot="actionItems">
|
||||||
<ha-svg-icon .path=${mdiContentCopy}></ha-svg-icon>
|
<ha-svg-icon .path=${mdiContentCopy}></ha-svg-icon>
|
||||||
</mwc-icon-button>
|
</mwc-icon-button>
|
||||||
<paper-tooltip
|
<paper-tooltip
|
||||||
|
slot="actionItems"
|
||||||
manual-mode
|
manual-mode
|
||||||
for="copy"
|
for="copy"
|
||||||
position="left"
|
position="left"
|
||||||
@ -93,8 +92,8 @@ class DialogSystemLogDetail extends LitElement {
|
|||||||
offset="4"
|
offset="4"
|
||||||
>${this.hass.localize("ui.common.copied")}</paper-tooltip
|
>${this.hass.localize("ui.common.copied")}</paper-tooltip
|
||||||
>
|
>
|
||||||
</div>
|
</ha-header-bar>
|
||||||
<paper-dialog-scrollable>
|
<div class="contents">
|
||||||
<p>
|
<p>
|
||||||
Logger: ${item.name}<br />
|
Logger: ${item.name}<br />
|
||||||
Source: ${item.source.join(":")}
|
Source: ${item.source.join(":")}
|
||||||
@ -150,8 +149,8 @@ class DialogSystemLogDetail extends LitElement {
|
|||||||
`
|
`
|
||||||
: item.message[0]}
|
: item.message[0]}
|
||||||
${item.exception ? html` <pre>${item.exception}</pre> ` : html``}
|
${item.exception ? html` <pre>${item.exception}</pre> ` : html``}
|
||||||
</paper-dialog-scrollable>
|
</div>
|
||||||
</ha-paper-dialog>
|
</ha-dialog>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,15 +162,9 @@ class DialogSystemLogDetail extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _openedChanged(ev: PolymerChangedEvent<boolean>): void {
|
|
||||||
if (!(ev.detail as any).value) {
|
|
||||||
this.closeDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private _copyLog(): void {
|
private _copyLog(): void {
|
||||||
const copyElement = this.shadowRoot?.querySelector(
|
const copyElement = this.shadowRoot?.querySelector(
|
||||||
"paper-dialog-scrollable"
|
".contents"
|
||||||
) as HTMLElement;
|
) as HTMLElement;
|
||||||
|
|
||||||
const selection = window.getSelection()!;
|
const selection = window.getSelection()!;
|
||||||
@ -192,9 +185,6 @@ class DialogSystemLogDetail extends LitElement {
|
|||||||
return [
|
return [
|
||||||
haStyleDialog,
|
haStyleDialog,
|
||||||
css`
|
css`
|
||||||
ha-paper-dialog {
|
|
||||||
direction: ltr;
|
|
||||||
}
|
|
||||||
a {
|
a {
|
||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
}
|
}
|
||||||
@ -205,13 +195,19 @@ class DialogSystemLogDetail extends LitElement {
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
font-family: var(--code-font-family, monospace);
|
font-family: var(--code-font-family, monospace);
|
||||||
}
|
}
|
||||||
.heading {
|
|
||||||
display: flex;
|
ha-header-bar {
|
||||||
align-items: center;
|
--mdc-theme-on-primary: var(--primary-text-color);
|
||||||
justify-content: space-between;
|
--mdc-theme-primary: var(--mdc-theme-surface);
|
||||||
|
flex-shrink: 0;
|
||||||
|
border-bottom: 1px solid
|
||||||
|
var(--mdc-dialog-scroll-divider-color, rgba(0, 0, 0, 0.12));
|
||||||
}
|
}
|
||||||
.heading ha-svg-icon {
|
|
||||||
cursor: pointer;
|
@media all and (min-width: 451px) and (min-height: 501px) {
|
||||||
|
ha-dialog {
|
||||||
|
--mdc-dialog-max-width: 90vw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user