From 31aed6e6fcc0876a7227c4eb72c20570581d5e7a Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Tue, 5 Sep 2023 15:30:55 +0200 Subject: [PATCH] Fix backup and gallery --- gallery/src/pages/misc/entity-state.ts | 8 ++++---- hassio/src/backups/hassio-backups.ts | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/gallery/src/pages/misc/entity-state.ts b/gallery/src/pages/misc/entity-state.ts index 58c639e6fd93..9e62a6ae91d0 100644 --- a/gallery/src/pages/misc/entity-state.ts +++ b/gallery/src/pages/misc/entity-state.ts @@ -343,7 +343,7 @@ export class DemoEntityState extends LitElement { const columns: DataTableColumnContainer = { icon: { title: "Icon", - template: (_, entry) => html` + template: (entry) => html` + template: (entry) => html`${computeStateDisplay( hass.localize, entry.stateObj, @@ -371,14 +371,14 @@ export class DemoEntityState extends LitElement { }, device_class: { title: "Device class", - template: (dc) => html`${dc ?? "-"}`, + template: (entry) => html`${entry.device_class ?? "-"}`, width: "20%", filterable: true, sortable: true, }, domain: { title: "Domain", - template: (_, entry) => html`${computeDomain(entry.entity_id)}`, + template: (entry) => html`${computeDomain(entry.entity_id)}`, width: "20%", filterable: true, sortable: true, diff --git a/hassio/src/backups/hassio-backups.ts b/hassio/src/backups/hassio-backups.ts index 7dc5c949727e..80282aa7d6ad 100644 --- a/hassio/src/backups/hassio-backups.ts +++ b/hassio/src/backups/hassio-backups.ts @@ -49,6 +49,10 @@ import { showHassioCreateBackupDialog } from "../dialogs/backup/show-dialog-hass import { supervisorTabs } from "../hassio-tabs"; import { hassioStyle } from "../resources/hassio-style"; +type BackupItem = HassioBackup & { + secondary: string; +}; + @customElement("hassio-backups") export class HassioBackups extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; @@ -117,15 +121,15 @@ export class HassioBackups extends LitElement { } private _columns = memoizeOne( - (narrow: boolean): DataTableColumnContainer => ({ + (narrow: boolean): DataTableColumnContainer => ({ name: { title: this.supervisor.localize("backup.name"), main: true, sortable: true, filterable: true, grows: true, - template: (entry: string, backup: any) => - html`${entry || backup.slug} + template: (backup) => + html`${backup.name || backup.slug}
${backup.secondary}
`, }, size: { @@ -134,7 +138,7 @@ export class HassioBackups extends LitElement { hidden: narrow, filterable: true, sortable: true, - template: (entry: number) => Math.ceil(entry * 10) / 10 + " MB", + template: (backup) => Math.ceil(backup.size * 10) / 10 + " MB", }, location: { title: this.supervisor.localize("backup.location"), @@ -142,8 +146,8 @@ export class HassioBackups extends LitElement { hidden: narrow, filterable: true, sortable: true, - template: (entry: string | null) => - entry || this.supervisor.localize("backup.data_disk"), + template: (backup) => + backup.location || this.supervisor.localize("backup.data_disk"), }, date: { title: this.supervisor.localize("backup.created"), @@ -152,8 +156,8 @@ export class HassioBackups extends LitElement { hidden: narrow, filterable: true, sortable: true, - template: (entry: string) => - relativeTime(new Date(entry), this.hass.locale), + template: (backup) => + relativeTime(new Date(backup.date), this.hass.locale), }, secondary: { title: "", @@ -163,7 +167,7 @@ export class HassioBackups extends LitElement { }) ); - private _backupData = memoizeOne((backups: HassioBackup[]) => + private _backupData = memoizeOne((backups: HassioBackup[]): BackupItem[] => backups.map((backup) => ({ ...backup, secondary: this._computeBackupContent(backup),