mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix complex attribute display in devtools (#18371)
This commit is contained in:
parent
1fdf609606
commit
191250a66a
@ -13,6 +13,7 @@ import {
|
|||||||
HassEntityAttributeBase,
|
HassEntityAttributeBase,
|
||||||
} from "home-assistant-js-websocket";
|
} from "home-assistant-js-websocket";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
|
import { dump } from "js-yaml";
|
||||||
import { formatDateTimeWithSeconds } from "../../../common/datetime/format_date_time";
|
import { formatDateTimeWithSeconds } from "../../../common/datetime/format_date_time";
|
||||||
import { computeRTL } from "../../../common/util/compute_rtl";
|
import { computeRTL } from "../../../common/util/compute_rtl";
|
||||||
import { escapeRegExp } from "../../../common/string/escape_regexp";
|
import { escapeRegExp } from "../../../common/string/escape_regexp";
|
||||||
@ -513,12 +514,23 @@ class HaPanelDevState extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _formatAttributeValue(value) {
|
||||||
|
if (
|
||||||
|
(Array.isArray(value) && value.some((val) => val instanceof Object)) ||
|
||||||
|
(!Array.isArray(value) && value instanceof Object)
|
||||||
|
) {
|
||||||
|
return `\n${dump(value)}`;
|
||||||
|
}
|
||||||
|
return Array.isArray(value) ? value.join(", ") : value;
|
||||||
|
}
|
||||||
|
|
||||||
private _attributeString(entity) {
|
private _attributeString(entity) {
|
||||||
const output = "";
|
const output = "";
|
||||||
|
|
||||||
if (entity && entity.attributes) {
|
if (entity && entity.attributes) {
|
||||||
return Object.keys(entity.attributes).map(
|
return Object.keys(entity.attributes).map(
|
||||||
(key) => `${key}: ${entity.attributes[key]}\n`
|
(key) =>
|
||||||
|
`${key}: ${this._formatAttributeValue(entity.attributes[key])}\n`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user