mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 08:16:36 +00:00
Fix sort/filter on statistics issues (#17545)
This commit is contained in:
parent
baba02f563
commit
54a9f4592c
@ -5,6 +5,7 @@ import { css, CSSResultGroup, html, LitElement } from "lit";
|
|||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
|
import { LocalizeFunc } from "../../../common/translations/localize";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||||
import "../../../components/data-table/ha-data-table";
|
import "../../../components/data-table/ha-data-table";
|
||||||
import type { DataTableColumnContainer } from "../../../components/data-table/ha-data-table";
|
import type { DataTableColumnContainer } from "../../../components/data-table/ha-data-table";
|
||||||
@ -42,6 +43,7 @@ type StatisticData = StatisticsMetaData & {
|
|||||||
|
|
||||||
type DisplayedStatisticData = StatisticData & {
|
type DisplayedStatisticData = StatisticData & {
|
||||||
displayName: string;
|
displayName: string;
|
||||||
|
issues_string?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement("developer-tools-statistics")
|
@customElement("developer-tools-statistics")
|
||||||
@ -59,17 +61,26 @@ class HaPanelDevStatistics extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _displayData = memoizeOne(
|
private _displayData = memoizeOne(
|
||||||
(data: StatisticData[]): DisplayedStatisticData[] =>
|
(data: StatisticData[], localize: LocalizeFunc): DisplayedStatisticData[] =>
|
||||||
data.map((item) => ({
|
data.map((item) => ({
|
||||||
...item,
|
...item,
|
||||||
displayName: item.state
|
displayName: item.state
|
||||||
? computeStateName(item.state)
|
? computeStateName(item.state)
|
||||||
: item.name || item.statistic_id,
|
: item.name || item.statistic_id,
|
||||||
|
issues_string: item.issues
|
||||||
|
?.map(
|
||||||
|
(issue) =>
|
||||||
|
localize(
|
||||||
|
`ui.panel.developer-tools.tabs.statistics.issues.${issue.type}`,
|
||||||
|
issue.data
|
||||||
|
) || issue.type
|
||||||
|
)
|
||||||
|
.join(" "),
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|
||||||
private _columns = memoizeOne(
|
private _columns = memoizeOne(
|
||||||
(localize): DataTableColumnContainer => ({
|
(localize: LocalizeFunc): DataTableColumnContainer => ({
|
||||||
displayName: {
|
displayName: {
|
||||||
title: localize(
|
title: localize(
|
||||||
"ui.panel.developer-tools.tabs.statistics.data_table.name"
|
"ui.panel.developer-tools.tabs.statistics.data_table.name"
|
||||||
@ -104,7 +115,7 @@ class HaPanelDevStatistics extends SubscribeMixin(LitElement) {
|
|||||||
filterable: true,
|
filterable: true,
|
||||||
width: "10%",
|
width: "10%",
|
||||||
},
|
},
|
||||||
issues: {
|
issues_string: {
|
||||||
title: localize(
|
title: localize(
|
||||||
"ui.panel.developer-tools.tabs.statistics.data_table.issue"
|
"ui.panel.developer-tools.tabs.statistics.data_table.issue"
|
||||||
),
|
),
|
||||||
@ -112,16 +123,9 @@ class HaPanelDevStatistics extends SubscribeMixin(LitElement) {
|
|||||||
filterable: true,
|
filterable: true,
|
||||||
direction: "asc",
|
direction: "asc",
|
||||||
width: "30%",
|
width: "30%",
|
||||||
template: (issues) =>
|
template: (issues_string) =>
|
||||||
html`${issues
|
html`${issues_string ??
|
||||||
? issues.map(
|
localize("ui.panel.developer-tools.tabs.statistics.no_issue")}`,
|
||||||
(issue) =>
|
|
||||||
localize(
|
|
||||||
`ui.panel.developer-tools.tabs.statistics.issues.${issue.type}`,
|
|
||||||
issue.data
|
|
||||||
) || issue.type
|
|
||||||
)
|
|
||||||
: localize("ui.panel.developer-tools.tabs.statistics.no_issue")}`,
|
|
||||||
},
|
},
|
||||||
fix: {
|
fix: {
|
||||||
title: "",
|
title: "",
|
||||||
@ -164,7 +168,7 @@ class HaPanelDevStatistics extends SubscribeMixin(LitElement) {
|
|||||||
<ha-data-table
|
<ha-data-table
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.columns=${this._columns(this.hass.localize)}
|
.columns=${this._columns(this.hass.localize)}
|
||||||
.data=${this._displayData(this._data)}
|
.data=${this._displayData(this._data, this.hass.localize)}
|
||||||
noDataText="No statistics"
|
noDataText="No statistics"
|
||||||
id="statistic_id"
|
id="statistic_id"
|
||||||
clickable
|
clickable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user