mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
Add last activated column to scenes data table (#13622)
This commit is contained in:
parent
5e8c54b00f
commit
e78c875e8e
@ -42,6 +42,8 @@ import { HomeAssistant, Route } from "../../../types";
|
|||||||
import { documentationUrl } from "../../../util/documentation-url";
|
import { documentationUrl } from "../../../util/documentation-url";
|
||||||
import { showToast } from "../../../util/toast";
|
import { showToast } from "../../../util/toast";
|
||||||
import { configSections } from "../ha-panel-config";
|
import { configSections } from "../ha-panel-config";
|
||||||
|
import { formatDateTime } from "../../../common/datetime/format_date_time";
|
||||||
|
import { UNAVAILABLE_STATES } from "../../../data/entity";
|
||||||
|
|
||||||
@customElement("ha-scene-dashboard")
|
@customElement("ha-scene-dashboard")
|
||||||
class HaSceneDashboard extends LitElement {
|
class HaSceneDashboard extends LitElement {
|
||||||
@ -77,24 +79,45 @@ class HaSceneDashboard extends LitElement {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
private _columns = memoizeOne((_language): DataTableColumnContainer => {
|
private _columns = memoizeOne(
|
||||||
|
(_language, narrow): DataTableColumnContainer => {
|
||||||
const columns: DataTableColumnContainer = {
|
const columns: DataTableColumnContainer = {
|
||||||
icon: {
|
icon: {
|
||||||
title: "",
|
title: "",
|
||||||
label: this.hass.localize("ui.panel.config.scene.picker.headers.state"),
|
label: this.hass.localize(
|
||||||
|
"ui.panel.config.scene.picker.headers.state"
|
||||||
|
),
|
||||||
type: "icon",
|
type: "icon",
|
||||||
template: (_, scene) =>
|
template: (_, scene) =>
|
||||||
html` <ha-state-icon .state=${scene}></ha-state-icon> `,
|
html` <ha-state-icon .state=${scene}></ha-state-icon> `,
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
title: this.hass.localize("ui.panel.config.scene.picker.headers.name"),
|
title: this.hass.localize(
|
||||||
|
"ui.panel.config.scene.picker.headers.name"
|
||||||
|
),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
direction: "asc",
|
direction: "asc",
|
||||||
grows: true,
|
grows: true,
|
||||||
},
|
},
|
||||||
only_editable: {
|
};
|
||||||
|
if (!narrow) {
|
||||||
|
columns.state = {
|
||||||
|
title: this.hass.localize(
|
||||||
|
"ui.panel.config.scene.picker.headers.last_activated"
|
||||||
|
),
|
||||||
|
sortable: true,
|
||||||
|
width: "30%",
|
||||||
|
template: (last_activated) => html`
|
||||||
|
${last_activated && !UNAVAILABLE_STATES.includes(last_activated)
|
||||||
|
? formatDateTime(new Date(last_activated), this.hass.locale)
|
||||||
|
: this.hass.localize("ui.components.relative_time.never")}
|
||||||
|
`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
columns.only_editable = {
|
||||||
title: "",
|
title: "",
|
||||||
|
width: "56px",
|
||||||
template: (_info, scene: any) =>
|
template: (_info, scene: any) =>
|
||||||
!scene.attributes.id
|
!scene.attributes.id
|
||||||
? html`
|
? html`
|
||||||
@ -109,11 +132,10 @@ class HaSceneDashboard extends LitElement {
|
|||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
`
|
`
|
||||||
: "",
|
: "",
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
columns.actions = {
|
columns.actions = {
|
||||||
title: "",
|
title: "",
|
||||||
|
width: "72px",
|
||||||
type: "overflow-menu",
|
type: "overflow-menu",
|
||||||
template: (_: string, scene: any) =>
|
template: (_: string, scene: any) =>
|
||||||
html`
|
html`
|
||||||
@ -159,7 +181,8 @@ class HaSceneDashboard extends LitElement {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return columns;
|
return columns;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
@ -169,7 +192,7 @@ class HaSceneDashboard extends LitElement {
|
|||||||
back-path="/config"
|
back-path="/config"
|
||||||
.route=${this.route}
|
.route=${this.route}
|
||||||
.tabs=${configSections.automations}
|
.tabs=${configSections.automations}
|
||||||
.columns=${this._columns(this.hass.language)}
|
.columns=${this._columns(this.hass.locale, this.narrow)}
|
||||||
id="entity_id"
|
id="entity_id"
|
||||||
.data=${this._scenes(this.scenes, this._filteredScenes)}
|
.data=${this._scenes(this.scenes, this._filteredScenes)}
|
||||||
.activeFilters=${this._activeFilters}
|
.activeFilters=${this._activeFilters}
|
||||||
|
@ -2332,11 +2332,8 @@
|
|||||||
"duplicate_scene": "Duplicate scene",
|
"duplicate_scene": "Duplicate scene",
|
||||||
"duplicate": "[%key:ui::common::duplicate%]",
|
"duplicate": "[%key:ui::common::duplicate%]",
|
||||||
"headers": {
|
"headers": {
|
||||||
"activate": "Activate",
|
|
||||||
"state": "State",
|
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"show_info": "Show information",
|
"last_activated": "Last activated"
|
||||||
"edit": "Edit"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"editor": {
|
"editor": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user